Sign in to follow this  
chibitotoro0_0

Simple VBO Rendering problem

Recommended Posts

chibitotoro0_0    122
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
TheBuzzSaw    143
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
karwosts    840
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this