问题
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