FAQ Database Discussion Community


Rendering object causes heightmap not to calculate

c++,opengl-3,vertex-array-object,index-buffer
I have a heightmap and a model rendered in my seen. When I render the heightmap by itself without loading the model, The heightmap works perfectly displaying itself as a mountainous terrain. But when I load in a model along with it and rebuild the program, the heightmap doesn't move...

Porting OpenGL ES Framebuffer to OpenGL

opengl,opengl-es-2.0,opengl-3
I got the following code working perfectly fine on iOS and Android: unsigned int depth_texture = 0, framebuffer = 0; glGenTextures( 1, &depth_texture ); glBindTexture( GL_TEXTURE_2D, depth_texture ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,...

How to use VBOs without VAOs with OpenGL core profile?

c++,opengl,opengl-3,opengl-4
I'm having trouble using vertex buffer objects without using a vertex array object. My understanding was that VAOs are just encapsulating the state around VBOs. But shouldn't the VBOs be usable without a VAO? Here's a mini-example. With use_vao=true this works correctly (renders orange rect). With use_vao=false this renders nothing...

How to draw TRIANGLE_FAN with geometry shader created coordinates? (GLSL 3.3)

opengl,opengl-3,geometry-shader
I want to draw multiple fans with a GS. Each fan should billboard to the camera at each time, which makes it necessary that each vertex is multiplied with MVP matrix. Since each fan is movable by the user, I came up with the idea to feed the GS with...

OpenGL: Strange bahaviour of VBO deletion?

c++,opengl,vbo,opengl-3,vao
I am getting a strange issue in Vertex Buffer Object (VBO). I created a class that includes VBO creation and deletion. I delete all the VBOs (with glDeleteBuffers()) in the destructor of the class. Now I created 2 OpenGL context windows each running with VBO class. Now when I close...

Mesa + Linux : gl.h does not contain modern OpenGL

c++,linux,opengl,opengl-3
This is the environment I currently use: Eclipse-Luna, C++11 on Linux Mint -Rebecca. When I try to use modern OpenGL like with VAOs or VBOs I get Compiler Errors such that methods could not be resolved. For Example: GLuint VaoID; //GLuint is working glGenVertexArrays(1, &VaoID); or: GLuint VboID; glGenBuffers(1, &VboID);...

Objects placed inside classes to be rendered with OpenGL

c++,class,opengl,c++11,opengl-3
I began to learn OpenGL about a week ago and I now want to create a mesh class. The code I'm about to show gives me a black screen (that's the color I fill it with). I basically stripped the code from my main function and placed it inside a...

Problems passing OpenGL 3.0 uniforms through multiple classes

c++,opengl,shader,opengl-3,light
I'm loosely following the tutorial on www.learnopengl.com, I'm currently passing multiple lights into my fragmentshader. For that I've got multiple lightclasses and one class that acts as a container to be able to pass my lights uniforms into the shader. The shader is set up correctly. However when I call...

How to draw polygon with 3D points in modern openGL?

opengl,opengl-3
I know in 2.0- openGL we can draw a line simply like this. glBegin(GL_LINES); glVertex3f(20.0f,150.0f,0.0f); glVertex3f(220.0f,150.0f,0.0f); glVertex3f(200.0f,160.0f,0.0f); glVertex3f(200.0f,160.0f,0.0f); glEnd(); but how to do similar thing in modern openGL(3.0+) I have read Drawing round points using modern OpenGL but the answer is not about certain point,since I want to draw polygon...

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) vs. glDraw*(GL_LINE_STRIP…)

opengl,deprecated,glfw,opengl-3
I made an interesting, if confusing discovery today. Thus far I've gotten by fine using glDraw*(GL_LINE_STRIP...) (or related GL_LINE* draw modes). Of course, this always requires some re-ordering of vertices in order to make the same vertex data work seamlessly between GL_TRIANGLES and GL_LINE_STRIP, but okay, all good there. Then...

Are OpenGL indices and locations the same thing for uniforms and vertex attributes?

opengl,opengl-es,opengl-es-2.0,opengl-3,opengl-4
In the OpenGL Reference Pages, some functions are marked as using uniform locations, while other functions are marked as using uniform indices. Are these the same thing? Similarly for vertex attributes, some functions are marked as using vertex attribute indices, while other functions are marked as using vertex attribute locations....

Modern GLSL ( opengl 3+ ) : Implementing phong effect correctly;

glsl,opengl-3
I am implementing a basic phong lighting GLSL shader; I have looked up some things on the internet, and found that the phong effect was created by adding an ambient, diffuse, and specular layer on the object (see image below, from tom dalling's site); problem is I have seen a...

illegal vector field selection length

vector,glsl,opengl-3,variable-length
I am receiving this error on a pc where I cannot have access. The error is on the Vertex Shader of the init program of the depth peeling technique. ERROR: 0:42: error(#222) Illegal vector field selection length ERROR: 0:42: error(#222) Illegal vector field selection length ERROR: error(#273) 2 compilation errors....

OpenGL drawing several objects

c++,opengl,vbo,opengl-3
How usually people draw several objects in OpenGL 3.3+? I have 2 objects: a terrain and a sphere. For each object i have 2 arrays(of vertices and indices). I tried to set different VBO and IBO(like this): glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE,...

segmentation fault when using glUniformMatrix in combination with an array

c++,opengl-3
I get a segmentation fault when I use glUniformMatrix4fv to pass a matrix to a mat4 uniform. My shader looks like this: #version 330 core layout(location = 0) in vec3 pos; layout(std140) uniform ModelMatrixBuffer { mat4 ModelMatrix[2]; }; out vec3 color; uniform mat4 ViewProj; void main() { gl_Position = ViewProj...