Small fixes and some comments.
This commit is contained in:
parent
74292f7a62
commit
1dcec5bd3b
@ -9,30 +9,34 @@ OpenGLColour convertMaterialIDToColour(PolyVox::uint8 materialID)
|
||||
switch(materialID)
|
||||
{
|
||||
case 1:
|
||||
colour.red = 1.0;
|
||||
colour.green = 0.0;
|
||||
colour.blue = 0.0;
|
||||
colour.red = 1.0f;
|
||||
colour.green = 0.0f;
|
||||
colour.blue = 0.0f;
|
||||
break;
|
||||
case 2:
|
||||
colour.red = 0.0;
|
||||
colour.green = 1.0;
|
||||
colour.blue = 0.0;
|
||||
colour.red = 0.0f;
|
||||
colour.green = 1.0f;
|
||||
colour.blue = 0.0f;
|
||||
break;
|
||||
case 3:
|
||||
colour.red = 0.0;
|
||||
colour.green = 0.0;
|
||||
colour.blue = 1.0;
|
||||
colour.red = 0.0f;
|
||||
colour.green = 0.0f;
|
||||
colour.blue = 1.0f;
|
||||
break;
|
||||
case 4:
|
||||
colour.red = 1.0;
|
||||
colour.green = 1.0;
|
||||
colour.blue = 0.0;
|
||||
colour.red = 1.0f;
|
||||
colour.green = 1.0f;
|
||||
colour.blue = 0.0f;
|
||||
break;
|
||||
case 5:
|
||||
colour.red = 1.0;
|
||||
colour.green = 0.0;
|
||||
colour.blue = 1.0;
|
||||
colour.red = 1.0f;
|
||||
colour.green = 0.0f;
|
||||
colour.blue = 1.0f;
|
||||
break;
|
||||
default:
|
||||
colour.red = 1.0f;
|
||||
colour.green = 1.0f;
|
||||
colour.blue = 1.0f;
|
||||
}
|
||||
|
||||
return colour;
|
||||
|
@ -6,20 +6,27 @@
|
||||
using namespace PolyVox;
|
||||
using namespace std;
|
||||
|
||||
OpenGLSurfacePatch BuildOpenGLSurfacePatch(IndexedSurfacePatch& isp)
|
||||
OpenGLSurfacePatch BuildOpenGLSurfacePatch(const IndexedSurfacePatch& isp)
|
||||
{
|
||||
//Represents our filled in OpenGL vertex and index buffer objects.
|
||||
OpenGLSurfacePatch result;
|
||||
|
||||
//Convienient access to the vertices and indices
|
||||
const vector<SurfaceVertex>& vecVertices = isp.getVertices();
|
||||
const vector<uint32>& vecIndices = isp.getIndices();
|
||||
|
||||
glGenBuffers(1, &result.indexBuffer);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.indexBuffer);
|
||||
int s = vecIndices.size() * sizeof(GLint);
|
||||
if(s != 0)
|
||||
//If we have any indices...
|
||||
if(!vecIndices.empty())
|
||||
{
|
||||
GLvoid* blah = (GLvoid*)(&(vecIndices[0]));
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, s, blah, GL_STATIC_DRAW);
|
||||
//Create an OpenGL index buffer
|
||||
glGenBuffers(1, &result.indexBuffer);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.indexBuffer);
|
||||
|
||||
//Get a pointer to the first index
|
||||
GLvoid* pIndices = (GLvoid*)(&(vecIndices[0]));
|
||||
|
||||
//Fill the OpenGL index buffer with our data.
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, vecIndices.size() * sizeof(uint32), pIndices, GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
result.noOfIndices = vecIndices.size();
|
||||
|
@ -12,7 +12,7 @@ struct OpenGLSurfacePatch
|
||||
GLuint vertexBuffer;
|
||||
};
|
||||
|
||||
OpenGLSurfacePatch BuildOpenGLSurfacePatch(PolyVox::IndexedSurfacePatch& isp);
|
||||
OpenGLSurfacePatch BuildOpenGLSurfacePatch(const PolyVox::IndexedSurfacePatch& isp);
|
||||
void renderRegionVertexBufferObject(const OpenGLSurfacePatch& openGLSurfacePatch);
|
||||
|
||||
#endif //__OpenGLExample_OpenGLVertexBufferObjectSupport_H__
|
||||
|
Loading…
x
Reference in New Issue
Block a user