Problems with rendering using an indexed VBO

Started by blainicus, August 09, 2011, 11:08:20

Previous topic - Next topic

blainicus

I've been fiddling with this for days and just can't get my indexed VBO to work. The program should render a large matrix of blocks, like minecraft. The vertex buffer itself is created via an external class which I have already confirmed working. Why is this not rendering/how to fix?

SOLVED: My data was at the wrong points, and my indexes were not accurate (you need an index for every single vertex, not just a list of offsets. IE: 0, 1, 3, 4, 6 as a list of 24 is not enough, you need a VERY long list containing the location of each vertex within the vertex array IE: 23, 767, 12).

Fool Running

I assume when you say it's not rendering, you are just getting a blue view (the color of your clear color).
The first thing that jumped out to me was your call to GLU.gluLookAt(). Passing all zeros seems like it would produce unpredictable results.

Also, have you tried to render the blocks in immediate mode just to make sure that the camera is looking at the right place? From the look of the code, there is no way to move the camera  around, so what you are rendering may be behind/above/below where the camera is looking.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

blainicus

My GLULookAt is just a placeholder to move the camera between debugs. It doesn't show anything no matter what I set it to (yes I understand how it works). I don't have any culling enabled, and even with no camera shifts from the origin I see nothing.

I was rendering from a very poorly optimized function with this same VBO structure before, so the VBO data isn't the issue. It is most likely that I didn't set the indexes right to access the VBO vertexes and draw the quads. The VBO is structured like this: for each block, add 8 vertexes to the VBO, (bottom left front, bottom left back, bottom right back, bottom right front, top left front, top left back, top right back, top right front). Top is +y, front is +z, and right is +x. I THOUGHT I did the indexes right for that data.

I'm at the level of frustration now that I am willing to take the performance hit of just not using indexes and adding redundant vertexes to my array. If someone could tell me how to recode this snippet for that (just in case) it would be massively appreciated.  I'm not sure which function call to use if I change to redundant arrays, drawArrays gave me some trouble, as well as drawArray in a for-loop. I have a custom rendering function I can use, but it's extremely inefficient (renders from regular ram). In the future I will be using an interleaved array with vertexes and texture coordinates, so whatever is more portable to that will be best.