opengl-3

OpenGL: What's the deal with deprecation?

白昼怎懂夜的黑 提交于 2019-12-01 06:01:49
OpenGL 3.0 and 3.1 have deprecated quite a few features I find essential. In particular, the use of fixed function in shaders. Can anyone explain what's really the deal with that? Why do they find the need to deprecate such useful feature that its obvious everybody uses and that no sane hardware company is going to remove support for? As you said, no hardware company will remove support for fixed-function shaders, because there are so many existing applications that use them. What they don't want to do, though, is figure out how to specify the interactions between FF shaders and every future

Combining vertex arrays with textures in OpenGL

戏子无情 提交于 2019-12-01 04:41:30
I'm trying to use vertex arrays to draw a reasonably large mesh, containing a large number of vertices. The textures have been determined from these and it's easy enough to draw in immediate mode along the lines of: glBegin(GL_TRIANGLES) { for ( int faceIdx = 0; faceIdx < nFaces; ++faceIdx ) glVertex3fv(&vertexArray[vIdx]); glTexCoord2fv(&texCoord[vIdx++]); glVertex3fv(&vertexArray[vIdx]); glTexCoord2fv(&texCoord[vIdx++]); glVertex3fv(&vertexArray[vIdx]); glTexCoord2fv(&texCoord[vIdx++]); } } glEnd(); However for readability, speed and the rest I want to use vertex arrays (with a view to

How to get flat normals on a cube

天大地大妈咪最大 提交于 2019-12-01 03:39:26
问题 I am using OpenGL without the deprecated features and my light calculation is done on fragment shader. So, I am doing smooth shading. My problem, is that when I am drawing a cube, I need flat normals. By flat normals I mean that every fragment generated in a face has the same normal. My solution to this so far is to generate different vertices for each face. So, instead of having 8 vertices, now I have 24(6*4) vertices. But this seems wrong to me, replicating the vertexes. Is there a better

glDrawElements and flat shading

拥有回忆 提交于 2019-12-01 03:36:20
Is it possible to achieve flat shading in OpenGL when using glDrawElements to draw objects, and if so how? The ideal way would be to calculate a normal for each triangle only once, if possible. The solution must only use the programmable pipeline (core profile). There are indeed ways around this without duplicating vertices, with some limitations for each one (at least those I can think of with my limited OpenGL experience). I can see two solutions that would give you a constant value for the normal over each triangle : declare the input as flat in your shader and pick which vertex gives its

Combining vertex arrays with textures in OpenGL

*爱你&永不变心* 提交于 2019-12-01 03:08:45
问题 I'm trying to use vertex arrays to draw a reasonably large mesh, containing a large number of vertices. The textures have been determined from these and it's easy enough to draw in immediate mode along the lines of: glBegin(GL_TRIANGLES) { for ( int faceIdx = 0; faceIdx < nFaces; ++faceIdx ) glVertex3fv(&vertexArray[vIdx]); glTexCoord2fv(&texCoord[vIdx++]); glVertex3fv(&vertexArray[vIdx]); glTexCoord2fv(&texCoord[vIdx++]); glVertex3fv(&vertexArray[vIdx]); glTexCoord2fv(&texCoord[vIdx++]); } }

OpenGL: What's the deal with deprecation?

好久不见. 提交于 2019-12-01 03:03:18
问题 OpenGL 3.0 and 3.1 have deprecated quite a few features I find essential. In particular, the use of fixed function in shaders. Can anyone explain what's really the deal with that? Why do they find the need to deprecate such useful feature that its obvious everybody uses and that no sane hardware company is going to remove support for? 回答1: As you said, no hardware company will remove support for fixed-function shaders, because there are so many existing applications that use them. What they

Multiple context with different version

限于喜欢 提交于 2019-12-01 00:37:42
I'm experimenting on list sharing among multiple OpenGL contextes. It is a great feature, since it allow me to execute parallel rendering threads. But since I'm using CreateContextAttribs, I offer the possibility to request a specific OpenGL implementation. So, it can happen the some context is implementing version 3.2+ while the other is implementing version 2.1. Actually works quite fine, but I suspect that this modus operandi hides some side effect. What would be a list of problems which can occour while using contextes having different versions? Beyond this, I query the implemented

Multiple context with different version

非 Y 不嫁゛ 提交于 2019-11-30 19:58:30
问题 I'm experimenting on list sharing among multiple OpenGL contextes. It is a great feature, since it allow me to execute parallel rendering threads. But since I'm using CreateContextAttribs, I offer the possibility to request a specific OpenGL implementation. So, it can happen the some context is implementing version 3.2+ while the other is implementing version 2.1. Actually works quite fine, but I suspect that this modus operandi hides some side effect. What would be a list of problems which

(OpenGL 3.1 - 4.2) Dynamic Uniform Arrays?

拈花ヽ惹草 提交于 2019-11-30 13:25:38
问题 Lets say I have 2 species such as humans and ponies. They have different skeletal systems so the uniform bone array will have to be different for each species. Do I have to implement two separate shader programs able to render each bone array properly or is there a way to dynamically declare uniform arrays and iterate through that dynamic array instead? Keeping in mind performance (There's all of the shaders suck at decision branching going around). 回答1: Until OpenGL 4.3, arrays in GLSL had

VAO and element array buffer state

こ雲淡風輕ζ 提交于 2019-11-30 11:24:27
问题 I was recently writing some OpenGL 3.3 code with Vertex Array Objects (VAO) and tested it later on Intel graphics adapter where I found, to my disappointment, that element array buffer binding is evidently not part of VAO state, as calling: glBindVertexArray(my_vao); glDrawElements(GL_TRIANGLE_STRIP, count, GL_UNSIGNED_INTEGER, 0); had no effect, while: glBindVertexArray(my_vao); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, my_index_buffer); // ? glDrawElements(GL_TRIANGLE_STRIP, count, GL_UNSIGNED