V
V
Vladimir Grabko2016-07-13 08:06:37
go
Vladimir Grabko, 2016-07-13 08:06:37

Why doesn't the square "render"?

My code just opens a window. And I also expect a square.

func init() {
  runtime.LockOSThread()
}

func main() {
  if err := glfw.Init(); err != nil {
    log.Fatal(err)
  }
  defer glfw.Terminate()

  window, err := glfw.CreateWindow(640, 480, "Testing", nil, nil)
  if err != nil {
    log.Fatal(err)
  }

  window.MakeContextCurrent()
  if err := gl.Init(); err != nil {
    log.Fatal(err)
  }

  for !window.ShouldClose() {
    // Do OpenGL stuff.
    window.SwapBuffers()
    glfw.PollEvents()
    //делаем квадрат
    gl.Clear(gl.COLOR_BUFFER_BIT)
    gl.Begin(gl.QUADS)

    gl.Color3f(1.0, 1.0, 1.0)
    gl.Vertex2i(250, 450)
    gl.Color3f(0.0, 0.0, 1.0)
    gl.Vertex2i(250, 150)
    gl.Color3f(0.0, 1.0, 0.0)
    gl.Vertex2i(550, 150)
    gl.Color3f(1.0, 0.0, 0.0)
    gl.Vertex2i(550, 450)
    gl.End()

  }

}

What did you do wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Silin, 2016-07-13
@VGrabko

I don't see setting world, view and projection matrices. Campaign it is really rendered, but the camera just does not look there. Plus, you need to explicitly specify a color for clearing the screen, to be sure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question