Tag: opengl

OpenGL:用于加载资源的辅助线程?

使用C和Win32,我想知道如何实现用于加载资源(纹理和VBO)的辅助OpenGL线程。 从我发现的,这应该用wglShareLists()完成,但我不确定如何设置辅助线程: 我是否需要新的设备上下文或仅需要新的渲染上下文? 我需要调用哪些wgl函数?

glGenBuffers没有定义?

我正在使用Windows,我注意到很多function都是灰色的,因为我猜#ifdef GL_GLEXT_PROTOTYPES没有定义。 其中之一是VBO扩展。 我应该只定义GL_GLEXT_PROTOTYPES吗? 否则我怎么能使用VBO,因为我使用OpenGL32.dll(我希望我的应用程序没有默认情况下不包含在Windows中的dll依赖项。)谢谢

如何使用GLEW与MinGW

我试图在我的项目中使用glew32.lib文件链接,而不是自己编译Glew源来获取glew.a文件。 现在,我的项目中存在以下链接错误: g++ -o Chapter10(OpenCLTest).exe src\Chapter10(OpenCLTest).o -lopengl32 -lglew -lglut32 -lglu32 -lopencl src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x167): undefined reference to `_imp____glewBindBuffer’ src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x39a): undefined reference to `_imp__glewInit’ src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x3a7): undefined reference to `_imp__glewIsSupported’ src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x48a): undefined reference to `_imp____glewGenBuffers’ src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x495): undefined reference to `_imp____glewBindBuffer’ src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x4dd): undefined reference to `_imp____glewBufferData’ src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x50b): undefined reference to `_imp____glewGetBufferParameteriv’ src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x1d67): undefined reference to `_imp____glewBindBuffer’ src\Chapter10(OpenCLTest).o:Chapter10(OpenCLTest).cpp:(.text+0x1d7f): undefined reference to […]

Opengl在3d场景问题上绘制2d覆盖图

我有一个移动的3D场景设置,我想制作一个永远在顶部的固定2d GUI覆盖,当我尝试制作2d形状时,我什么也看不到。 当我调用:glMatrixMode(GL_PROJECTION); 我的3D场景消失了,我留下了一个空白的窗口…… 这是我用于叠加层的代码 编辑:更新的代码 glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-100, 100, -100, 100); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glColor3f(1, 1, 1); glPushMatrix(); glBegin(GL_QUADS); glVertex3f(-5.0f, 5.0f, 0.0f); glVertex3f(-5.0f, -5.0f, 0.0f); glVertex3f(5.0f, -5.0f, 0.0f); glVertex3f(5.0f, 5.0f, 0.0f); glEnd(); glPopMatrix(); glEnable(GL_DEPTH_TEST); glutSwapBuffers();

多边形轮廓上的边缘并不总是正确的

我正在使用下面的算法来生成四边形,然后渲染这些四边形来制作这样的轮廓 http://img810.imageshack.us/img810/8530/uhohz.png 在图像上看到的问题是,当线条总是应该具有相同的宽度时,线条太细。 我的算法找到第一个的4个顶点,然后是下一个的前2个顶点是前一个的底部2 。 这会创建连接线,但似乎并不总是有效。 我怎么能解决这个问题? 这是我的算法: void OGLENGINEFUNCTIONS::GenerateLinePoly(const std::vector<std::vector> &input, std::vector &output, int width) { output.clear(); if(input.size() < 2) { return; } int temp; float dirlen; float perplen; POINTFLOAT start; POINTFLOAT end; POINTFLOAT dir; POINTFLOAT ndir; POINTFLOAT perp; POINTFLOAT nperp; POINTFLOAT perpoffset; POINTFLOAT diroffset; POINTFLOAT p0, p1, p2, p3; for(unsigned int i = […]

什么时候OpenGL完成函数指针?

OpenGL有许多直接指针的函数 。 其中一些从这些指针中读取数据 ,另一些则将数据 写入这些指针 。 但是,OpenGL函数通常不会立即执行。 通常,当您绘制某些内容时,绘图需要一段时间才能完成。 那么我怎么知道OpenGL何时完成了我给它的指针呢?

如何在C中最好地编写体素引擎并考虑到性能

我是OpenGl中的一个电枢,因此我只想学习现代OpenGl 4.x的东西。 一旦我完成了基本教程(例如旋转立方体),我决定尝试创建一个基于体素的程序,仅处理立方体。 这个程序的目标是快速,使用有限的CPU功率和内存,并且是动态的,因此地图大小可以改变,只有在数组中它表示块被填充时才会绘制块。 我有一个VBO,其中包含由三角形构成的立方体的顶点和索引。 一开始,如果渲染函数我告诉OpenGl要使用的着色器,然后在完成后绑定VBO我执行此循环 绘制立方体循环: //The letter_max are the dimensions of the matrix created to store the voxel status in // The method I use for getting and setting entries in the map are very efficient so I have not included it in this example for(int z = -(z_max / 2); z < […]

通过OpenGL进行图像缩放(KeepAspectRatioByExpanding)

我正在尝试仅使用glTexCoord2f()和glVertex2f()在OpenGL中实现图像缩放 。 让我解释一下:在加载QImage并使用glTexImage2D()将其发送到gpu之后,我必须根据Qt的规范执行图像缩放操作 。 Qt定义了这3个操作(见下图): 我认为这是唯一的方法,因为我的应用程序是一个Qt插件,这个任务需要在类的paint()方法中完成。 IgnoreAspectRatio操作非常简单,现在正在运行。 KeepAspectRatio最初给了我一些麻烦,但现在它也在工作。 不幸的是, KeepAspectRatioByExpanding令我头疼 。 我正在分享我到目前为止所做的工作,感谢您对此问题的帮助: main.cpp中: #include “oglWindow.h” #include int main(int argc, char *argv[]) { QApplication a(argc, argv); oglWindow w; w.show(); return a.exec(); } oglWindow.cpp: #include “oglWindow.h” #include “glwidget.h” #include oglWindow::oglWindow(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { ui.setupUi(this); GLWidget *openGL = new GLWidget(this); QGridLayout *layout = new […]