• Advertisement

Archived

This topic is now archived and is closed to further replies.

ATI Object Buffer question

This topic is 5528 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

I have the following code: my object: (I am aware the normals are a little funny, but they render fine with nvidia VAR and normal vertex arrays).

	box_vertex[0] = -1.0f; // x 
	box_vertex[1] = -1.0f; // y
	box_vertex[2] =  1.0f; // z

	box_vertex[3] = -1.0f;
	box_vertex[4] =  1.0f;
	box_vertex[5] =  1.0f;

	box_vertex[6] =  1.0f;
	box_vertex[7] =  1.0f;
	box_vertex[8] =  1.0f;

	box_vertex[9] =   1.0f;
	box_vertex[10] = -1.0f;
	box_vertex[11] =  1.0f;

	box_vertex[12] =  1.0f;
	box_vertex[13] = -1.0f;
	box_vertex[14] = -1.0f;

	box_vertex[15] =  1.0f;
	box_vertex[16] =  1.0f;
	box_vertex[17] = -1.0f;

	box_vertex[18] = -1.0f;
	box_vertex[19] =  1.0f;
	box_vertex[20] = -1.0f;

	box_vertex[21] = -1.0f;
	box_vertex[22] = -1.0f;
	box_vertex[23] = -1.0f;



	box_normal[0] = -0.71f;
	box_normal[1] =     0;
	box_normal[2] =  0.71f;

	box_normal[3] = -0.71f;
	box_normal[4] =     0;
	box_normal[5] =  0.71f;

	box_normal[6] =  0.71f;
	box_normal[7] =     0;
	box_normal[8] =  0.71f;

	box_normal[9] =  0.71f;
	box_normal[10] =    0;
	box_normal[11] = 0.71f;

	box_normal[12] =  0.71f;
	box_normal[13] =     0;
	box_normal[14] = -0.71f;

	box_normal[15] =  0.71f;
	box_normal[16] =     0;
	box_normal[17] = -0.71f;

	box_normal[18] = -0.71f;
	box_normal[19] =     0;
	box_normal[20] = -0.71f;

	box_normal[21] = -0.71f;
	box_normal[22] =     0;
	box_normal[23] = -0.71f;

	box_tex[0] = 0.0f;
	box_tex[1] = 1.0f;

	box_tex[2] = 0.0f;
	box_tex[3] = 0.0f;

	box_tex[4] = 1.0f;
	box_tex[5] = 0.0f;

	box_tex[6] = 1.0f;
	box_tex[7] = 1.0f;

	box_tex[8] = 0.0f;
	box_tex[9] = 1.0f;

	box_tex[10] = 0.0f;
	box_tex[11] = 0.0f;

	box_tex[12] = 1.0f;
	box_tex[13] = 0.0f;

	box_tex[14] = 1.0f;
	box_tex[15] = 1.0f;

	box_indices[0] = 4;
	box_indices[1] = 7;
	box_indices[2] = 3;
	box_indices[3] = 0;
	box_indices[4] = 0;
	box_indices[5] = 1;
	box_indices[6] = 7;
	box_indices[7] = 6;
	box_indices[8] = 4;
	box_indices[9] = 5;
	box_indices[10] = 3;
	box_indices[11] = 2;
	box_indices[12] = 0;
	box_indices[13] = 1;
	box_indices[14] = 1;
	box_indices[15] = 6;
	box_indices[16] = 2;
	box_indices[17] = 5;

 
initializing the object buffers:
	vertexObject = glNewObjectBufferATI(sizeof(box_vertex), box_vertex, GL_STATIC_ATI);
	textureObject = glNewObjectBufferATI(sizeof(box_tex), box_tex, GL_STATIC_ATI);
	normalObject = glNewObjectBufferATI(sizeof(box_normal), box_normal, GL_STATIC_ATI);

 
drawing it:
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);

	glBindTexture(GL_TEXTURE_2D, texture[filter]);

		glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, sizeof(box_tex), textureObject, 0);
		glArrayObjectATI(GL_NORMAL_ARRAY, 3, GL_FLOAT, sizeof(box_normal), normalObject, 0);
		glArrayObjectATI(GL_VERTEX_ARRAY, 3, GL_FLOAT, sizeof(box_vertex), vertexObject, 0);

		glDrawElements(GL_TRIANGLE_STRIP, 18, GL_UNSIGNED_INT, box_indices);

	glDisableClientState(GL_NORMAL_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);

 
for some reaso I only see 1 texture triangle instead of a texture cube. What am I doing wrong ? Thanks! Nitzan ------------------------- www.geocities.com/nitzanw www.scorchedearth3d.net -------------------------

Share this post


Link to post
Share on other sites
Advertisement
Ok,
I re-read the various tutorials and changed my code to the following calls, but someone it seems like my vertex info is getting corrupted and random triangles are being drawn:



vertexObject = glNewObjectBufferATI(24*4, box_vertex, GL_STATIC_ATI);
normalObject = glNewObjectBufferATI(24*4, box_normal, GL_STATIC_ATI);
textureObject = glNewObjectBufferATI(16*4, box_tex, GL_STATIC_ATI);

glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, 16, textureObject, 0);
glArrayObjectATI(GL_NORMAL_ARRAY, 3, GL_FLOAT, 24, normalObject, 0);
glArrayObjectATI(GL_VERTEX_ARRAY, 3, GL_FLOAT, 24, vertexObject, 0);

glDrawElements(GL_TRIANGLE_STRIP, 18, GL_UNSIGNED_INT, box_indices);



Does anyone have any ideas ?

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------

Share this post


Link to post
Share on other sites

  • Advertisement