I am building a simple 3D application in Go. I have this nuisance problem when I first load the app. Here is a sample that should work fine:
func main() {
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err)
}
window, err := sdl.CreateWindow("go3d", sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, 800, 600, sdl.WINDOW_OPENGL)
if err != nil {
panic(err)
}
context, err := window.GLCreateContext()
if err != nil {
panic(err)
}
defer sdl.GLDeleteContext(context)
if err := gl.Init(); err != nil {
panic(err)
}
gl.ClearColor(1, 0, 1, 1)
gl.Viewport(0, 0, 800, 600)
for true {
handleEvents()
gl.Clear(gl.COLOR_BUFFER_BIT)
window.GLSwap()
}
}
When I build a run this I am greeted with a nice black screen. It should be purple?
When I move the window slightly (I have to move it, clicking on it or trying to interact won't do anything) it starts working... but why? I've tried this with GLFW and SDL and got the same result. I checked my loop and it does run fine, anyone know whats up?