PDA

View Full Version : two short questions



Vexator
07-31-2005, 10:10 AM
1) I recently rewrote my code to use vertex arrays and vertex buffer objects for my models data instead of using immediate mode. it works fine so far. but, now i realized that if i use glDrawArrayElements instead of glDrawElements and specify values for start end end, still everything is rendered:


glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER, Indices->Id );
glDrawArrayElements( GL_TRIANGLES, 8, 24, Indices->Size, GL_UNSIGNED_INT, 0 );shouldn't this actually only render indices 8 to 24? or are these values ignored as the data is stored in vbo's?

2) i'd need a replacement for gluScaleImage(), it's the only function that still makes me link to the glu lib. i searched google but didn't find anything useful.

thanks in advance :)

Humus
07-31-2005, 01:38 PM
You mean glDrawRangeElements? Then the additional parameters specify the min and max value for the indices that you draw. This is used to tell the driver how much of the vertex array needs to be copied to the GPU for this draw call. It's not a way to specify a subset of the index array.

Zulfiqar Malik
07-31-2005, 09:29 PM
Originally posted by Vexator

2) i'd need a replacement for gluScaleImage(), it's the only function that still makes me link to the glu lib. i searched google but didn't find anything useful.

gluScaleImage(...) uses a box filter, if the image is being scaled down, and lerps the values if the image is scaled up. It won't be too hard to do such a thing yourself. You might even find a simple implementation online somewhere.

Vexator
08-01-2005, 01:10 AM
You mean glDrawRangeElements? Then the additional parameters specify the min and max value for the indices that you draw. This is used to tell the driver how much of the vertex array needs to be copied to the GPU for this draw call. It's not a way to specify a subset of the index array.argh yes just a typo. so i got it wrong. but what's the difference between specifying the min and max value for the indices that i draw and specifying a subset of the index array?

@zm: thx i'll search for these topics :)

CrazyButcher
08-01-2005, 02:12 AM
its not the indices but the vertices

to allow better optimisation when rendering you can tell the driver how many vertices you will use

let say your indices are 2 triangles

5 6 7
6 7 8

now when the driver knows your minimum vertex is 5 (start) and maximum is 8 (end), it nows which chunk of memory to pull

it really just to help the driver, some sort of manual preprocessing. knowing your limits of vertices you will refer to

Vexator
08-01-2005, 08:09 AM
ah now i see, thx :)

al_bob
08-01-2005, 11:29 AM
Also note that a conformant implementation can (but need not to) implement glDrawRangeElements() as just glDrawElements() (with additional parameter checking, of course). glDrawRangeElements() doesn't provide any new functionality. It's an optimization.