glDrawRangeElements Issues

BlitzMax Forums/OpenGL Module/glDrawRangeElements Issues

Drey(Posted 2006) [#1]
the whole range concept doesn't seem to be working for me here.

The program is suppose to render either the full object, or either half. Key 1 and 2 work ( if key 2 really works..i'm not sure because..) . Key 3 doesn't seem to work..i've tried a varity of range input as well. I know changing the pointer will work but i shouldn't have too if range does what it says.
GLGraphics 800,600
glewInit()

	
Local	fltVertex#[] =[ -1.0 , 1.0 , 0.0 ,    1.0 , 1.0,  0.0 ,    -1.0, -1.0, 0.0 ,    1.0, -1.0, 0.0 ]
Local	fltColor#[] = [ 1.0 ,  0.0 , 0.0 ,    0.0 , 1.0,  0.0 ,     0.0,  0.0, 1.0 ,    1.0,  1.0, 0.0 ]
		'              Red                      Green              Blue                  Yellow
Local	shtElements:Short[] = [ 0:Short,  1:Short, 2:Short, 1:Short, 3:Short , 2:Short ]	



	glMatrixMode(GL_PROJECTION);				'		// Select The Projection Matrix
	glLoadIdentity();							'// Reset The Projection Matrix

	'// Calculate The Aspect Ratio Of The Window
	gluPerspective(45.0 ,Float(GraphicsWidth())/GraphicsHeight(),0.1 ,100.0 );

	glMatrixMode(GL_MODELVIEW);						'// Select The Modelview Matrix
	glLoadIdentity();	
	
	glShadeMOdel(GL_SMOOTH);
	glClearColor( 0.0, 0.0 , 0.0 , 0.0 )
	
		
	
	glEnable(GL_DEPTH_TEST);					'	// Enables Depth Testing	
	
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);		
	
			
glEnableClientState(GL_VERTEX_ARRAY)
glEnableCLientState(GL_Color_Array)
glVertexPointer(3, GL_FLOAT , 0 , Varptr(fltVertex[0]) )
glColorPointer(3,  GL_FLOAT , 0 , Varptr(fltColor[0]) )

Local KeyInput = KEY_1
While Not KeyHit(KEY_A)

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);			'// Clear The Screen And The Depth Buffer
	glLoadIdentity();							'// Reset The Current Modelview Matrix
	
	glTranslatef( 0.0 , 0.0, -5.0 )

	
	If KeyHit(KEY_1)
		Keyinput = KEY_1
	ElseIf KeyHit(Key_2)
		keyinput = KEY_2
	ElseIf KeyHit(Key_3)
		keyinput = KEY_3
	EndIf
	
	Select KeyInput
	
		Case KEY_1
			glDrawRangeElements(GL_TRIANGLES, 0,5,6, GL_UNSIGNED_SHORT , Varptr(shtElements[0]) )
		Case Key_2
			glDrawRangeElements(GL_TRIANGLES, 0,2,3, GL_UNSIGNED_SHORT , Varptr(shtElements[0]) ) 
		Case Key_3
			glDrawRangeElements(GL_TRIANGLES, 3,5,3, GL_UNSIGNED_SHORT , Varptr(shtElements[0]) )
					
	End Select
	
		
	Flip()
	
Wend 

gldisableClientState(GL_VERTEX_ARRAY)
gldisableCLientState(GL_Color_Array)



Drey(Posted 2006) [#2]
The issue has been resolved. Range just pertains to Max and Min values in the array. Basically i have to change the pointer. However when it comes to VBO..if want to have the render be broken. I can't have the elements be bufferbound. That's not too much overhead.

So i made a slight change to the system. The system is now dynamic. A VBO token is passed which uses bitwise compliments to determine what array should be VBO or not.


Drey(Posted 2006) [#3]
actually that's not the case either. In VBO you just had to set the byte offset and pass it as a pointer

glDrawElements(GL_TRIANGLES, Last-First , <GL_TYPE>, int ptr(First * SizeOfMemoryType)) lets you control how the indices array flows on the VBO