render default preset

This commit is contained in:
filifa 2024-08-22 20:08:28 -05:00
parent a67aa7a4ae
commit a9a6211521
1 changed files with 9 additions and 13 deletions

22
main.go
View File

@ -9,6 +9,10 @@ import "github.com/veandco/go-sdl2/sdl"
*/ */
import "C" import "C"
import (
"time"
)
func main() { func main() {
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil { if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err) panic(err)
@ -29,25 +33,13 @@ func main() {
defer sdl.GLDeleteContext(context) defer sdl.GLDeleteContext(context)
handle := C.projectm_create() handle := C.projectm_create()
if (handle == nil) { if handle == nil {
panic("nil") panic("nil")
} }
defer C.projectm_destroy(handle) defer C.projectm_destroy(handle)
C.projectm_set_window_size(handle, 800, 600) C.projectm_set_window_size(handle, 800, 600)
surface, err := window.GetSurface()
if err != nil {
panic(err)
}
surface.FillRect(nil, 0)
rect := sdl.Rect{0, 0, 200, 200}
colour := sdl.Color{R: 255, G: 0, B: 255, A: 255} // purple
pixel := sdl.MapRGBA(surface.Format, colour.R, colour.G, colour.B, colour.A)
surface.FillRect(&rect, pixel)
window.UpdateSurface()
running := true running := true
for running { for running {
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() { for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
@ -58,5 +50,9 @@ func main() {
break break
} }
} }
C.projectm_opengl_render_frame(handle)
window.GLSwap()
time.Sleep(1 / 60 * time.Second)
} }
} }