網頁

2014年3月21日 星期五

OpenGL - Render Points with glDrawArray

Last Update: 2014/03/21 16:48+08
Type: Note



std::vector vertices = std::vector(8);

PxVec3 geometry = PxVec3(1.0f,1.0f,1.0f);

vertices[0] = PxVec3(-geometry.x, geometry.y, geometry.z);//left-up-front
vertices[1] = PxVec3(geometry.x, geometry.y, geometry.z);//right-up-front
vertices[2] = PxVec3(-geometry.x, -geometry.y, geometry.z);//left-bottom-front
vertices[3] = PxVec3(geometry.x, -geometry.y, geometry.z);//right-bottom-front

vertices[4] = PxVec3(-geometry.x, geometry.y, -geometry.z);//left-up-back
vertices[5] = PxVec3(geometry.x, geometry.y, -geometry.z);//right-up-back
vertices[6] = PxVec3(-geometry.x, -geometry.y, -geometry.z);//left-bottom-back
vertices[7] = PxVec3(geometry.x, -geometry.y, -geometry.z);//right-bottom-back


{/*Render*/
 glPointSize(5);
 glColor3f(1.0f,1.0f,1.0f);


 glEnableClientState(GL_VERTEX_ARRAY);

 glVertexPointer(3, GL_FLOAT, 0, &vertices[0].x);
 glDrawArrays(GL_POINTS, 0, vertices.size());

 glDisableClientState(GL_VERTEX_ARRAY);
 
 glPointSize(1.0f);
}

沒有留言:

張貼留言