Forum > OpenGL

Vertex arrays aren't compatible with vertex buffer object?

(1/1)

Mr.Madguy:
I'm trying to revive my old project, that is retro game engine with maximum backwards compatibility. My current problem - vertex arrays refuse to work with vertex buffer object, even if I extract data from it via glGetBufferSubData instead of using glMapBuffer. I checked buffer data and it looks correctly, but all of sudden I get blank screen instead of picture. Disabling one of two feature helps.

May be I'm missing something? Docs say, that I should use glVertexAttribPointer with glDrawArrays, but it's OpenGL 2.0 feature or part of GL_ARB_vertex_program extension, that is related to shaders. And glDrawArrays is part of OpenGL 1.1, so therefore there should be way to make it work using 1.1 features only.

May be I need to create 1.5 compatibility context or something like that?

marcov:
I don't understand your problem exactly, but I had bad experiences reviving old opengl code.

It turned out that the old code left textures enabled while trying to draw lines etc. Make sure your enabling/disabling is nicely balanced.

Afaik all Windows 7-10 drivers will also support newer opengl, and other OSes are legacy. (and even windows 7 is, strictly)

That said, I don't use the Lazarus opengl headers, but dglopengl.

Mr.Madguy:

--- Quote from: marcov on August 21, 2020, 01:03:24 pm ---I don't understand your problem exactly, but I had bad experiences reviving old opengl code.

It turned out that the old code left textures enabled while trying to draw lines etc. Make sure your enabling/disabling is nicely balanced.

Afaik all Windows 7-10 drivers will also support newer opengl, and other OSes are legacy. (and even windows 7 is, strictly)

That said, I don't use the Lazarus opengl headers, but dglopengl.

--- End quote ---
Problem is following:
glVertex/glColor on plain memory arrays - work
glDrawArrays on plain memory arrays - work
glVertex/glColor on glBufferData/glMapBuffer - work
glDrawArray on glBufferData/glMapBuffer - doesn't work, just blank screen

And I can't find reason for this, because even glGetBufferSubData doesn't help. I tried to exclude all possible problems:
glMapBuffer memory doesn't suit for glDrawArrays
glDrawArrays has some delayed processing, so I shouldn't unmap or free memory till some later moment

Nothing helps.

marcov:
glGetBufferSubData is for reading vextexbuffers?

My vertex (modification) code looks like:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---lBindVertexArray(vao);   glBindBuffer(GL_ARRAY_BUFFER, vbo);  glBufferSubData(GL_ARRAY_BUFFER, 0,length(vertices)*sizeof(vertices[0]), @vertices[0]);{  err:=glGetError;  if err<>GL_NO_ERROR then    onlog(5,'reload :'+inttostr(err),4);}  if length(indexdata)>0 then    begin     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);     glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0,length(indices)*sizeof(indices[0]), @indices[0]);    end;   glBindVertexArray(0);

Mr.Madguy:
Solved this problem! Verifying data has shown, that there is no data corruption happens. So there is just one thing left, that could cause problem. glBindBuffer. Looks like some sort of interference with newer extensions, that expect additional parameters via glVertexAttribPointer, if buffer is bound. So unbinding buffer before calling glDrawArrays helped.

Navigation

[0] Message Index

Go to full version