glPushMatrix已弃用,GL30-GL43解决方案?基本包装箱示例 [英] glPushMatrix Deprecated, GL30-GL43 Solution? Basic Box example

查看:84
本文介绍了glPushMatrix已弃用,GL30-GL43解决方案?基本包装箱示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个渲染基本框的程序,但是通过谷歌搜索,我还没有找到在屏幕上绘制一张脸(或一组脸)的解决方案.

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.

目前我发现的每个教程都使用glPushMatrix/glBegin/glEnd/glPopMatrix这样的

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();

我已经阅读到在OGL 3.0中,它们已弃用glPushMatrix/glBegin/glEnd/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?

推荐答案

您需要忘记OpenGL为您管理矩阵的想法.您将需要使用矢量数学库自己实现这些东西. Java 3D Api在提供一组强大的Matrix和Vector类和方法方面做得很好.不好意思告诉您,您的工作要做更多的工作,但这就是图形编程的发展方向.

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.

这篇关于glPushMatrix已弃用,GL30-GL43解决方案?基本包装箱示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆