Tag: opengl

opengl + glut glutPostRedisplay在哪里?

我用C语言编写GLUT和OPENGL,我希望我的窗口一次又一次地重绘自己。 我知道我可以用glutPostRedisplay()渲染,如果我把它放在Glut的闲置函数中我的电脑滞后。 我的代码是关注atm void on_idle() { glutPostRedisplay(); } void on_draw() { … glClearColor(1.f, 1.f, 1.f, 1.f); glClear(GL_COLOR_BUFFER_BIT); … glFlush(); } int main(int argc, char** argv) { … glutDisplayFunc(&on_draw); glutIdleFunc(&on_idle); … }

来自Mesa的gluPickMatrix代码

我正在研究一些OpenGL代码,我找到了gluPickMatrix函数的Mesa代码: void gluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height, GLint viewport[4]) { GLfloat m[16]; GLfloat sx, sy; GLfloat tx, ty; sx = viewport[2] / width; sy = viewport[3] / height; tx = (viewport[2] + 2.0 * (viewport[0] – x)) / width; ty = (viewport[3] + 2.0 * (viewport[1] – y)) / height; #define M(row, […]

在OpenGL中围绕自身旋转对象

我在绕自己旋转房间时遇到了麻烦。 它的中心位于(5,5,0)所以我想如果我用glTranslatef(5,5,5)然后glRotatef(rotateroom,0,0,1)翻译房间和房间里的物品然后画出物品并使用glTranslate(-5,-5,0)它将旋转房间及其中的所有内容大约5,5,0但它似乎仍在旋转(0,0,0)并且我不确定是什么我做错了。 我在这里先向您的帮助表示感谢。 void drawside(){ int i,j; /*for (j = 0; j <= 8; j++) { glBegin(GL_LINE_STRIP); for (i = 0; i <= 30; i++) glEvalCoord2f((GLfloat)i/30.0, (GLfloat)j/8.0); glEnd(); glBegin(GL_LINE_STRIP); for (i = 0; i <= 30; i++) glEvalCoord2f((GLfloat)j/8.0, (GLfloat)i/30.0); glEnd(); }*/ glEvalMesh2(GL_FILL, 0, 20, 0, 20); } void drawRoom(){ //floor glBegin(GL_POLYGON); glColor3f(1,1,1); glNormal3f(0,0,0); glVertex3f(0,0,0); glNormal3f(0,10,0); […]

为什么GlutPostRedisplay和sleep函数在这段代码中不起作用?

我试图在这个项目中实现usb和cpu之间的数据传输。 数据传输显示为从计算机的一个组件移动到另一个组件的小矩形。 在下面的代码中,GlutPostRedisplay不起作用。 另外,有人可以告诉我使用的sleep()是否正确,因为显示中调用的函数不能同步工作。 从不执行casing()。 在fisrtscreen()之后,它直接跳转到opened()并且operation()不起作用。 这段代码的错误是什么? void operate() { URLTEXTX = 200; URLTEXTY = 950; displayString(READUSB,1); //southbrigde to northbrigde bottom(488.0,425.0,380.0); back(488.0,188.0,380.0); top(188.0,380.0,550.0); //northbridge to cpu front(230.0,350.0,595.0); top(345.0,600.0,650.0); //read from usb back(700.0,625.0,465.0); bottom(625.0,460.0,385.0); back(620.0,525.0,390.0); sleep(1); URLTEXTX = 200; URLTEXTY = 950; displayString(WRITEUSB,1); //cpu to northbridge bottom(350.0,650.0,595.0); back(350.0,230.0,600.0); //northbridge to southbridge bottom(188.0,550.0,380.0); front(188.0,488.0,380.0); top(483.0,380.0,425.0); //write to […]

opengl白色窗口 – Visual Studio 2010

我是opengl初学者。 我设置了DLL,Library,Header但是发生了错误。 我的开发环境是win7(64位)。 供参考 – DLLs:C:\ Windows \ System32,C:\ Windows \ SysWOW64 // glu32.dll,glut.dll,glut32.dll,opengl32.dll Libs:C:\ Program Files(x86)\ Microsoft SDKs \ Windows \ v7.0A \ Lib,C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ lib // glut.lib,glut32.lib 标题:C:\ Program Files(x86)\ Microsoft SDKs \ Windows \ v7.0A \ Include \ gl,C:\ Program Files(x86)\ Microsoft Visual Studio […]

尝试使用OpenGL时出错

我有一个非常简单的C代码,我试图使用OpenGl。 当我包含以下文件时 #include #include #include #include 我得到以下错误(还有更多,但它们相似):C:\ Program Files \ Microsoft Visual Studio 8 \ VC \ PlatformSDK \ include \ GL / gl.h(1152):错误C2144:语法错误:’void’应该以’;’开头 但当我包括 #include #include #include #include #include 我得到以下错误\ mainfile.cpp(4):致命错误C1083:无法打开包含文件:’GL / glut.h’:没有这样的文件或目录 知道发生了什么事吗? 我正在使用XP,VS2005

如何从矩阵中获取角度

我有一个像这样的旋转矩阵: 1.0 0.0 0.0 2.07814 0.0 -0.809017 0.587785 0.0 0.0 -0.587785 -0.809017 0.0 0.0 0.0 0.0 1.0 我怎样才能从中获得角度? 如果我应用逆,我得到这个 cos exp -1 (-0.809017) = 144.0 sin exp -1 (-0.587785) = -36.0 sin exp -1 ( 0.587785) = 36.0 cos exp -1 (-0.809017) = 144.0 但我的问题是我知道角度是216.0度,我该如何回到那个角度?

设置3D OpenGL透视投影的最简单方法

有很多教程,其中每个建议使用gluPerspective或glFrustum与其他东西的组合,但我在设置正确的矩阵时遇到了困难。 我需要用什么代码来设置俯视+ z轴的45˚透视图? 到目前为止我有: glShadeModel(GL_SMOOTH); glClearColor(0,0,0,0); glClearDepth(1); glDepthFunc(GL_LEQUAL); glViewport(0,0,width,height); glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45,1,0.1,100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); 但这似乎不起作用。 当我试图绘制东西时,我得到的只是黑屏。 编辑:这是最小的绘图代码: glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glColor3ub(255,255,255); glBegin(GL_TRIANGLE_STRIP); glVertex3f(20,20,20); glVertex3f(20,30,20); glVertex3f(30,20,20); glVertex3f(30,30,20); glEnd();

OpenGL – GLUT – 显示不同的弹出菜单

在我的项目中,我想根据用户按下鼠标右键的位置显示两个不同的菜单。 我实施了采摘。 这里没有问题。 我想在用户右键单击对象时显示菜单,在右键单击任何对象(屏幕中的空白区域)时显示不同的菜单。 这可能与GLUT有关吗?

纹理映射NGon?

我不知道如何确定如何为2D NGon(N边多边形)绘制纹理坐标图如何做到这一点? 我想要实现的效果是使纹理适合多边形并相应地伸展,以便整个纹理适合它。 谢谢