FAQ Database Discussion Community


How to draw different tiles using an IBO?

opengl,indexing,textures,mesh,vbo
My aim is to draw a bunch of "blocks" using a mesh in OpenGL. I can draw a mesh with a VBO and an IBO. But I don't know how to handle texture coordinates because in my "concept" not each adjacent block shares the same texture coordinates. But by using...

Should I use the same VBO for passing different vertex attributes? Or should I use 2?

c++,opengl,attributes,shared,vbo
I know the glVertexAttribPointer will use the values from the VBO that was bound when it was called. But can you buffer twice onto the same object? Would it replace what was in? Or can you clear a buffer? I don't know if this approach is correct: glBindVertexArray(VAO); glBindBuffer(GL_ARRAY_BUFFER, VBO);...

Fade Out OpenGL VBO with Colors but without Texture

opengl-es,fade,alpha,vbo,blend
I would like to fade out a VBO object in OpenGL ES. The VBO is drawn using RGBA format GL_UNSIGNED_BYTE like this: glEnableClientState(GL_COLOR_ARRAY); glColorPointer( 4, GL_UNSIGNED_BYTE, .... I am fairly certain I should set up blending like this: glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glColor4f( 1, 1, 1, alpha...

OpenGL: try to draw lines using VBO(vertex buffer object), it doesn't display

c,opengl,vbo,vertex-buffer-objects
I try to switch my openGL code from using display list to using VBO. In the code, I tried to draw a green-grid floor, which is composed by green lines in parallel with x-axis and green lines in parallel with z-axis. But when the program runs, floor doesn't display. And...

How to add textures to vertex buffer objects in OpenGL (2.1)

c++,opengl,vbo,texture-mapping,texture2d
What is the correct way to texture map an object in OpenGL 2.1? At the moment I am performing the following steps but am unable to get the texture to appear correctly on the object. Generate a buffer and store the ID Bind the buffer Upload the data to the...

glsl layout with glvertexattribpointer issues

layout,glsl,vbo
So I have a working program that displays a terrain mesh generated from a height map. I want to use the layout qualifier to declare the vertex attributes now, but I am having issues. When I just use the built in gl_Normal for my normals, everything works fine. When I...

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...

Meaning of “index” parameter in glEnableVertexAttribArray and (possibly) a bug in the OS X OpenGL implementation

c++,osx,opengl,vbo
1) Do I understand correctly that to draw using vertex arrays or VBOs I need for all my attributes to either call glBindAttribLocation before the shader program linkage or call glGetAttribLocation after the shader program was successfully linked and then use the bound/obtained index in the glVertexAttribPointer and glEnableVertexAttribArray calls?...

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,...

WebGL VBO error in Firefox

javascript,firefox,webgl,vbo
I am using Firefox to render a 3D object in a canvas using WebGL. My code was working previously, whereby a textured object was being displayed within the canvas. However upon revisiting my code, without making any changes, the object will not render and the browser console displays the following...