glPushMatrix Deprecated, GL30-GL43 Solution? Basic Box example

隐身守侯 提交于 2019-12-25 07:36:11

问题


I'm working on a Program to Render a basic box, but through googling, I have not found a solution for Drawing a face(or group of faces) on screen.

Currently every tutorial I've found uses glPushMatrix/glBegin/glEnd/glPopMatrix like this

GL11.glPushMatrix();

GL11.glRotatef(pit, 1, 0, 0);
GL11.glRotatef(yaw, 0, 1, 0);
GL11.glRotatef(rol, 0, 0, 1);
GL11.glTranslatef(pos.x, pos.y, pos.z);

GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex3f(-1.0f, -1.0f,  1.0f);   // Bottom Left Of The Quad
GL11.glVertex3f( 1.0f, -1.0f,  1.0f);   // Bottom Right Of The Quad
GL11.glVertex3f( 1.0f,  1.0f,  1.0f);   // Top Right Of The Quad
GL11.glVertex3f(-1.0f,  1.0f,  1.0f);   // Top Left Of The Quad
//insert similar code here for all 6 faces
GL11.glEnd();

GL11.glPopMatrix();

I have read that in OGL 3.0 they Deprecated glPushMatrix/glBegin/glEnd/glPopMatrix but I cant seem to find what the "proper" way to render a Object. Is there a method I should be using?


回答1:


You need to forget about the idea of OpenGL managing matrices for you. You will need to implement this stuff yourself using a vector math library. The java 3D Api does a great job of providing a robust set of Matrix and Vector classes and methods. Sorry to be the one to tell you that there is more work for you to do on your end of things, but this is the direction that graphics programming is going.



来源:https://stackoverflow.com/questions/15305879/glpushmatrix-deprecated-gl30-gl43-solution-basic-box-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!