Skip to content

Commit 7e79469

Browse files
committed
Start implementing InitFramebuffer
1 parent d861e3d commit 7e79469

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

core/core.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package core
55
import (
66
"archive/zip"
77
"errors"
8+
"fmt"
89
"io"
910
"log"
1011
"os"
@@ -154,6 +155,9 @@ func LoadGame(filename string) error {
154155
state.Global.MenuActive = false
155156
state.Global.GamePath = filename
156157

158+
fmt.Println(vid.Geom.BaseWidth)
159+
vid.InitFramebuffer(vid.Geom.BaseWidth, vid.Geom.BaseHeight)
160+
157161
log.Println("[Core]: Game loaded: " + filename)
158162
return nil
159163
}

core/environment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ func environment(cmd uint32, data unsafe.Pointer) bool {
4848
state.Global.AudioCb = libretro.SetAudioCallback(data)
4949
case libretro.EnvironmentSetHWRenderer:
5050
state.Global.HWRenderCb = libretro.SetHWRenderCallback(data)
51+
state.Global.HWRenderCb.GetCurrentFramebuffer = vid.CurrentFramebuffer
52+
state.Global.HWRenderCb.GetProcAddress = vid.ProcAddress
5153
fmt.Println(state.Global.HWRenderCb)
5254
return true
5355
case libretro.EnvironmentGetCanDupe:

libretro/libretro.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ type HWRenderCallback struct {
130130
HWContextType uint
131131
ContextReset func()
132132
GetCurrentFramebuffer func() uintptr
133-
GetProcAddress func()
133+
GetProcAddress func() uintptr
134134
Depth bool
135135
Stencil bool
136136
BottomLeftOrigin bool

video/video.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type Video struct {
5151
pixFmt uint32
5252
pixType uint32
5353
bpp int32
54+
fboID uint32
5455
}
5556

5657
// Init instanciates the video package
@@ -124,6 +125,12 @@ func (video *Video) configureContext() uint {
124125
return GLSLVersion
125126
}
126127

128+
func (video *Video) InitFramebuffer(width, height int) {
129+
gl.GenFramebuffers(1, &video.fboID)
130+
gl.BindFramebuffer(gl.FRAMEBUFFER, video.fboID)
131+
gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, video.texID, 0)
132+
}
133+
127134
// Configure instanciates the video package
128135
func (video *Video) Configure(fullscreen bool) {
129136
var width, height int
@@ -348,6 +355,15 @@ func (video *Video) Refresh(data unsafe.Pointer, width int32, height int32, pitc
348355
}
349356
}
350357

358+
// CurrentFramebuffer returns the current FBO ID
359+
func (video *Video) CurrentFramebuffer() uintptr {
360+
return uintptr(video.fboID)
361+
}
362+
363+
func (video *Video) ProcAddress() uintptr {
364+
return 0
365+
}
366+
351367
var vertices = []float32{
352368
// X, Y, U, V
353369
-1.0, -1.0, 0.0, 1.0, // left-bottom

0 commit comments

Comments
 (0)