Advertisement

Minimum of 66 verts?

Started by November 12, 2019 11:15 PM
56 comments, last by Bozemoto 5 years, 2 months ago

glBindBuffer(GL_ARRAY_BUFFER, 0);
...

if (mesh.indices)
...
else
{
	glDrawArrays(GL_TRIANGLES, 0, (GLsizei)mesh.num_verts);
	CheckForErrors();
}

This looks like it will be dangerous if mesh.indices is false, no array buffer bound and drawarrays called ... ?

Doesn't this bit of code set it up so that the shader has vertices to use?


glEnableVertexAttribArray(positionLocation);
glBindBuffer(GL_ARRAY_BUFFER, mesh.vbo);
glVertexAttribPointer(positionLocation, 3, GL_FLOAT, GL_FALSE, 0, NULL);

I mean it is drawing 99% of the time so it won't be something that breaks 100% of the time.
I can draw 2000 spheres with that code, which is why it's confusing.

Video Game Programmer.
5 years in industry.

Advertisement

I cannot see stride definition in, do you have positions packed in a sepparate gl buffer?


glVertexAttribPointer(positionLocation, 3, GL_FLOAT, GL_FALSE, 0, NULL);

That's cause all the buffers are contiguous. I've got one buffer for vertices, one for normals etc.

Video Game Programmer.
5 years in industry.

Do you forget to bind them up sometime? Having attributes in sepparate buffers is a no go, keep in mind you do not have even POV4 aligned verticies sizes as for elements in buffers. That is a serious issue.

They're always bound, having attributes in separate buffers seems to work fine and can't find any source that says that it's not supported.
Are you saying I should add badding to my vec3s to make them 4*sizeof(GLFloat)?

Video Game Programmer.
5 years in industry.

Advertisement

It is a long time since i last did the basics. Meanwhile i have my framework and don't care about the minutious buffer handling any more ? You were right, the buffer with the data does not need to be bound, the vertex array suffices.

In principle, you can divide your vertex data among buffers howver you like, interleaved, in separate buffers, or sequential. Thus says the Red Book. I allways use interleaved just because it is simpler imo, and i would expect acces to be faster when data for one vertex can be read as a block of memory, but that is speculating.

Padding is equally unnessary.

You'll probably have to do classic debugging. Isolate functionality, check portions, and all that ...

 

Thanks for all the help Green_Baron. I'll probably have to strip it out into the smallest breaking example I can get and go from there.
It's hard to isolate with all the other logic in there.

Long term plan is to clean all this up and do it properly but I'm still very much in the getting familiar stage.
Interleaving does sound more cache performant but I think I've read somewhere that it's not always so.
Guess it can vary between vert counts, graphics cards and even driver versions.

Video Game Programmer.
5 years in industry.

Suggesting just like @JohnnyCode, and to make your life easier, to use a single buffer for a vertex array, either interleaved or sequential. I personally would probably get confused with different buffer objects ...

Now I'm even more confused, works fine if I comment these lines out
 


SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);

 

Video Game Programmer.
5 years in industry.

This topic is closed to new replies.

Advertisement