Skip to content

Commit

Permalink
Start implementing InitFramebuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
kivutar committed Dec 30, 2018
1 parent d861e3d commit 7e79469
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package core
import (
"archive/zip"
"errors"
"fmt"
"io"
"log"
"os"
Expand Down Expand Up @@ -154,6 +155,9 @@ func LoadGame(filename string) error {
state.Global.MenuActive = false
state.Global.GamePath = filename

fmt.Println(vid.Geom.BaseWidth)
vid.InitFramebuffer(vid.Geom.BaseWidth, vid.Geom.BaseHeight)

log.Println("[Core]: Game loaded: " + filename)
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions core/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func environment(cmd uint32, data unsafe.Pointer) bool {
state.Global.AudioCb = libretro.SetAudioCallback(data)
case libretro.EnvironmentSetHWRenderer:
state.Global.HWRenderCb = libretro.SetHWRenderCallback(data)
state.Global.HWRenderCb.GetCurrentFramebuffer = vid.CurrentFramebuffer
state.Global.HWRenderCb.GetProcAddress = vid.ProcAddress
fmt.Println(state.Global.HWRenderCb)
return true
case libretro.EnvironmentGetCanDupe:
Expand Down
2 changes: 1 addition & 1 deletion libretro/libretro.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ type HWRenderCallback struct {
HWContextType uint
ContextReset func()
GetCurrentFramebuffer func() uintptr
GetProcAddress func()
GetProcAddress func() uintptr
Depth bool
Stencil bool
BottomLeftOrigin bool
Expand Down
16 changes: 16 additions & 0 deletions video/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Video struct {
pixFmt uint32
pixType uint32
bpp int32
fboID uint32
}

// Init instanciates the video package
Expand Down Expand Up @@ -124,6 +125,12 @@ func (video *Video) configureContext() uint {
return GLSLVersion
}

func (video *Video) InitFramebuffer(width, height int) {
gl.GenFramebuffers(1, &video.fboID)
gl.BindFramebuffer(gl.FRAMEBUFFER, video.fboID)
gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, video.texID, 0)
}

// Configure instanciates the video package
func (video *Video) Configure(fullscreen bool) {
var width, height int
Expand Down Expand Up @@ -348,6 +355,15 @@ func (video *Video) Refresh(data unsafe.Pointer, width int32, height int32, pitc
}
}

// CurrentFramebuffer returns the current FBO ID
func (video *Video) CurrentFramebuffer() uintptr {
return uintptr(video.fboID)
}

func (video *Video) ProcAddress() uintptr {
return 0
}

var vertices = []float32{
// X, Y, U, V
-1.0, -1.0, 0.0, 1.0, // left-bottom
Expand Down

0 comments on commit 7e79469

Please sign in to comment.