Jump to content
  • Advertisement
Sign in to follow this  
chibitotoro0_0

Simple VBO Rendering problem

This topic is 3014 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, I looked up some examples using VBOs but I can't get it to render with the current setup:
init(){

	GLuint vboIDs[4];
	glGenBuffers(4 ,vboIDs);		//create 4 vbos

	//vertices
	glBindBuffer(GL_ARRAY_BUFFER, vboIDs[0]);
	glBufferData(GL_ARRAY_BUFFER, blotCount*8, blotVertex, GL_STATIC_DRAW);
	
	//textures
	glBindBuffer(GL_ARRAY_BUFFER, vboIDs[1]);
	glBufferData(GL_ARRAY_BUFFER, blotCount*8, blotVertex, GL_STATIC_DRAW);
	
	//colors
	glBindBuffer(GL_ARRAY_BUFFER, vboIDs[2]);
	glBufferData(GL_ARRAY_BUFFER, blotCount*16, blotColor, GL_STATIC_DRAW);

	//indexes
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIDs[3]);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6*blotCount, blotTriangle, GL_STATIC_DRAW);

	//reset so other's can draw first
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}

draw(){
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

	//vertices
	glBindBuffer(GL_ARRAY_BUFFER, vboIDs[0]);
	glVertexPointer(2, GL_FLOAT, 0, 0);
	
	//textures
	glBindBuffer(GL_ARRAY_BUFFER, vboIDs[1]);
	glTexCoordPointer(2, GL_FLOAT, 0, 0);
	
	//colors
	glBindBuffer(GL_ARRAY_BUFFER, vboIDs[2]);
	glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
	
	//textures
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIDs[3]);
	glDrawElements(GL_TRIANGLES, 6*blotCount, GL_UNSIGNED_SHORT, 0);
	
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}



Where: vertex:137.000000,113.000000,157.000000,113.000000,137.000000,133.000000,157.000000,133.000000 uv:0.000000,0.000000,0.500000,0.000000,0.000000,0.500000,0.500000,0.500000 color:214,50,20,60,214,50,20,60,214,50,20,60,214,50,20,60 index:0,1,2,1,2,3

Share this post


Link to post
Share on other sites
Advertisement
I really hope your GLuint vboIDs[4]; is declared somewhere OUTSIDE of your init() function. From the looks of it, it has local scope to your init() function, which means it cannot be seen in your draw() function. If that were the case, it either would not compile or contain garbage data anyway.

Share this post


Link to post
Share on other sites
I'm not sure if this is your problem, but I don't know what your texture settings are like:


//vertices
glBindBuffer(GL_ARRAY_BUFFER, vboIDs[0]);
glBufferData(GL_ARRAY_BUFFER, blotCount*8, blotVertex, GL_STATIC_DRAW);

//textures
glBindBuffer(GL_ARRAY_BUFFER, vboIDs[1]);
glBufferData(GL_ARRAY_BUFFER, blotCount*8, blotVertex, GL_STATIC_DRAW);



Your using your vertices as your texcoords, which I'm pretty sure you don't want.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!