dongzi0850 2011-01-18 23:39
浏览 56
已采纳

GO-OpenGL LoadMatrixd和GetDoublev问题

gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()

m := new([16]float64)
setIdentity(m)

gl.LoadMatrixd((*gl.GLdouble)(&m[0]))
gl.Rotated(90, 0, 1, 0)
gl.GetDoublev(gl.MODELVIEW_MATRIX, (*gl.GLdouble)(&m[0]))
gl.PopMatrix()

fmt.Printf("%f", m[0])
// m[0] == forward.x

The contents of m doesn't not change after the GetDoublev. I am trying to port some C code (which works and it basically this). What am I doing wrong?

The C code as requested:

//m is float[16] set to identity
glMatrixMode(GL_MODELVIEW);
glPushMatrix();

glLoadMatrixf(m);
glRotatef(90, 0,1,0);
glGetFloatv(GL_MODELVIEW_MATRIX, m);
glPopMatrix();
  • 写回答

1条回答 默认 最新

  • doujianmin6527 2011-01-19 20:00
    关注

    You must call sdl.SetVideoMode() before you can use Matrix functions.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?