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