Switched to integer naming conventions from C++0x (e.g. uint16_t)

This commit is contained in:
David Williams
2009-03-30 21:44:23 +00:00
parent 47e0e66228
commit 5acbd012cf
44 changed files with 711 additions and 711 deletions

View File

@ -9,10 +9,10 @@ using namespace std;
void renderRegionImmediateMode(PolyVox::IndexedSurfacePatch& isp)
{
const vector<SurfaceVertex>& vecVertices = isp.getVertices();
const vector<uint32>& vecIndices = isp.getIndices();
const vector<uint32_t>& vecIndices = isp.getIndices();
glBegin(GL_TRIANGLES);
for(vector<uint32>::const_iterator iterIndex = vecIndices.begin(); iterIndex != vecIndices.end(); ++iterIndex)
for(vector<uint32_t>::const_iterator iterIndex = vecIndices.begin(); iterIndex != vecIndices.end(); ++iterIndex)
{
const SurfaceVertex& vertex = vecVertices[*iterIndex];
const Vector3DFloat& v3dVertexPos = vertex.getPosition();
@ -22,7 +22,7 @@ void renderRegionImmediateMode(PolyVox::IndexedSurfacePatch& isp)
uint8 material = vertex.getMaterial() + 0.5;
uint8_t material = vertex.getMaterial() + 0.5;
OpenGLColour colour = convertMaterialIDToColour(material);

View File

@ -2,7 +2,7 @@
using namespace PolyVox;
OpenGLColour convertMaterialIDToColour(PolyVox::uint8 materialID)
OpenGLColour convertMaterialIDToColour(PolyVox::uint8_t materialID)
{
OpenGLColour colour;

View File

@ -12,6 +12,6 @@ struct OpenGLColour
GLfloat blue;
};
OpenGLColour convertMaterialIDToColour(PolyVox::uint8 materialID);
OpenGLColour convertMaterialIDToColour(PolyVox::uint8_t materialID);
#endif //__OpenGLExample_OpenGLSupport_H__

View File

@ -13,7 +13,7 @@ OpenGLSurfacePatch BuildOpenGLSurfacePatch(const IndexedSurfacePatch& isp)
//Convienient access to the vertices and indices
const vector<SurfaceVertex>& vecVertices = isp.getVertices();
const vector<uint32>& vecIndices = isp.getIndices();
const vector<uint32_t>& vecIndices = isp.getIndices();
//If we have any indices...
if(!vecIndices.empty())
@ -26,7 +26,7 @@ OpenGLSurfacePatch BuildOpenGLSurfacePatch(const IndexedSurfacePatch& isp)
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);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, vecIndices.size() * sizeof(uint32_t), pIndices, GL_STATIC_DRAW);
}
result.noOfIndices = vecIndices.size();
@ -57,7 +57,7 @@ OpenGLSurfacePatch BuildOpenGLSurfacePatch(const IndexedSurfacePatch& isp)
*ptr = vertex.getNormal().getZ();
ptr++;
uint8 material = vertex.getMaterial() + 0.5;
uint8_t material = vertex.getMaterial() + 0.5;
OpenGLColour colour = convertMaterialIDToColour(material);

View File

@ -14,7 +14,7 @@ OpenGLWidget::OpenGLWidget(QWidget *parent)
}
void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8>* volData)
void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8_t>* volData)
{
//First we free anything from the previous volume (if there was one).
m_mapOpenGLSurfacePatches.clear();
@ -26,11 +26,11 @@ void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8>* volData)
{
//Our volume is broken down into cuboid regions, and we create one mesh for each region.
//This three-level for loop iterates over each region.
for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ)
for(uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ)
{
for(uint16 uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY)
for(uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY)
{
for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX)
for(uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX)
{
//Create a new surface patch (which is basiaclly the PolyVox term for a mesh).
IndexedSurfacePatch* ispCurrent = new IndexedSurfacePatch();
@ -38,13 +38,13 @@ void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8>* volData)
//Compute the extents of the current region
//FIXME - This is a little complex? PolyVox could
//provide more functions for dealing with regions?
uint16 regionStartX = uRegionX * g_uRegionSideLength;
uint16 regionStartY = uRegionY * g_uRegionSideLength;
uint16 regionStartZ = uRegionZ * g_uRegionSideLength;
uint16_t regionStartX = uRegionX * g_uRegionSideLength;
uint16_t regionStartY = uRegionY * g_uRegionSideLength;
uint16_t regionStartZ = uRegionZ * g_uRegionSideLength;
uint16 regionEndX = regionStartX + g_uRegionSideLength + 1; //Why do we need the '+1' here?
uint16 regionEndY = regionStartY + g_uRegionSideLength + 1; //Why do we need the '+1' here?
uint16 regionEndZ = regionStartZ + g_uRegionSideLength + 1; //Why do we need the '+1' here?
uint16_t regionEndX = regionStartX + g_uRegionSideLength + 1; //Why do we need the '+1' here?
uint16_t regionEndY = regionStartY + g_uRegionSideLength + 1; //Why do we need the '+1' here?
uint16_t regionEndZ = regionStartZ + g_uRegionSideLength + 1; //Why do we need the '+1' here?
Vector3DInt32 regLowerCorner(regionStartX, regionStartY, regionStartZ);
Vector3DInt32 regUpperCorner(regionEndX, regionEndY, regionEndZ);
@ -131,11 +131,11 @@ void OpenGLWidget::paintGL()
//Centre the volume on the origin
glTranslatef(-g_uVolumeSideLength/2,-g_uVolumeSideLength/2,-g_uVolumeSideLength/2);
for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ)
for(uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ)
{
for(uint16 uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY)
for(uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY)
{
for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX)
for(uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX)
{
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
if(m_bUseOpenGLVertexBufferObjects)

View File

@ -14,9 +14,9 @@
#include "OpenGLVertexBufferObjectSupport.h"
#include "Shapes.h"
const PolyVox::uint16 g_uVolumeSideLength = 128;
const PolyVox::uint16 g_uRegionSideLength = 16;
const PolyVox::uint16 g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength;
const PolyVox::uint16_t g_uVolumeSideLength = 128;
const PolyVox::uint16_t g_uRegionSideLength = 16;
const PolyVox::uint16_t g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength;
class OpenGLWidget : public QGLWidget
{
@ -24,7 +24,7 @@ class OpenGLWidget : public QGLWidget
public:
OpenGLWidget(QWidget *parent);
void setVolume(PolyVox::Volume<PolyVox::uint8>* volData);
void setVolume(PolyVox::Volume<PolyVox::uint8_t>* volData);
protected:
void initializeGL();
@ -36,7 +36,7 @@ class OpenGLWidget : public QGLWidget
bool m_bUseOpenGLVertexBufferObjects;
//Creates a volume 128x128x128
PolyVox::Volume<PolyVox::uint8>* m_volData;
PolyVox::Volume<PolyVox::uint8_t>* m_volData;
//Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region
std::map<PolyVox::Vector3DUint8, OpenGLSurfacePatch> m_mapOpenGLSurfacePatches;

View File

@ -2,7 +2,7 @@
using namespace PolyVox;
void createSphereInVolume(Volume<uint8>& volData, float fRadius, uint8 uValue)
void createSphereInVolume(Volume<uint8_t>& volData, float fRadius, uint8_t uValue)
{
//This vector hold the position of the center of the volume
Vector3DFloat v3dVolCenter(volData.getSideLength() / 2, volData.getSideLength() / 2, volData.getSideLength() / 2);
@ -30,7 +30,7 @@ void createSphereInVolume(Volume<uint8>& volData, float fRadius, uint8 uValue)
}
}
void createCubeInVolume(Volume<uint8>& volData, Vector3DUint16 lowerCorner, Vector3DUint16 upperCorner, uint8 uValue)
void createCubeInVolume(Volume<uint8_t>& volData, Vector3DUint16 lowerCorner, Vector3DUint16 upperCorner, uint8_t uValue)
{
//This three-level for loop iterates over every voxel between the specified corners
for (int z = lowerCorner.getZ(); z <= upperCorner.getZ(); z++)

View File

@ -3,7 +3,7 @@
#include "PolyVoxCore/Volume.h"
void createSphereInVolume(PolyVox::Volume<PolyVox::uint8>& volData, float fRadius, PolyVox::uint8 uValue);
void createCubeInVolume(PolyVox::Volume<PolyVox::uint8>& volData, PolyVox::Vector3DUint16 lowerCorner, PolyVox::Vector3DUint16 upperCorner, PolyVox::uint8 uValue);
void createSphereInVolume(PolyVox::Volume<PolyVox::uint8_t>& volData, float fRadius, PolyVox::uint8_t uValue);
void createCubeInVolume(PolyVox::Volume<PolyVox::uint8_t>& volData, PolyVox::Vector3DUint16 lowerCorner, PolyVox::Vector3DUint16 upperCorner, PolyVox::uint8_t uValue);
#endif //__OpenGLExample_Shapes_H__

View File

@ -22,12 +22,12 @@ using namespace std;
int main(int argc, char *argv[])
{
Volume<uint8> volData(g_uVolumeSideLength);
Volume<uint8_t> volData(g_uVolumeSideLength);
//Make our volume contain a sphere in the center.
uint16 minPos = 0;
uint16 midPos = volData.getSideLength() / 2;
uint16 maxPos = volData.getSideLength() - 1;
uint16_t minPos = 0;
uint16_t midPos = volData.getSideLength() / 2;
uint16_t maxPos = volData.getSideLength() - 1;
createCubeInVolume(volData, Vector3DUint16(minPos, minPos, minPos), Vector3DUint16(maxPos, maxPos, maxPos), 0);
createSphereInVolume(volData, 50.0f, 5);
@ -72,9 +72,9 @@ using namespace std;
//Global variables are easier for demonstration purposes, especially
//as I'm not sure how/if I can pass variables to the GLUT functions.
//Global variables are denoted by the 'g_' prefix
const uint16 g_uVolumeSideLength = 256;
const uint16 g_uRegionSideLength = 16;
const uint16 g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength;
const uint16_t g_uVolumeSideLength = 256;
const uint16_t g_uRegionSideLength = 16;
const uint16_t g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength;
int g_xRotation = 0.0f;
int g_yRotation = 0.0f;
@ -86,7 +86,7 @@ int g_frameCounter = 0;
bool g_bUseOpenGLVertexBufferObjects;
//Creates a volume 128x128x128
Volume<uint8> g_volData(g_uVolumeSideLength);
Volume<uint8_t> g_volData(g_uVolumeSideLength);
//Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region
OpenGLSurfacePatch g_openGLSurfacePatches[g_uVolumeSideLengthInRegions][g_uVolumeSideLengthInRegions][g_uVolumeSideLengthInRegions];
@ -133,11 +133,11 @@ void display ( void ) // Create The Display Function
//Centre the volume on the origin
glTranslatef(-g_uVolumeSideLength/2,-g_uVolumeSideLength/2,-g_uVolumeSideLength/2);
for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ)
for(uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ)
{
for(uint16 uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY)
for(uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY)
{
for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX)
for(uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX)
{
if(g_bUseOpenGLVertexBufferObjects)
{
@ -254,9 +254,9 @@ void main ( int argc, char** argv ) // Create Main Function For Bringing It Al
}
//Make our volume contain a sphere in the center.
uint16 minPos = 0;
uint16 midPos = g_volData.getSideLength() / 2;
uint16 maxPos = g_volData.getSideLength() - 1;
uint16_t minPos = 0;
uint16_t midPos = g_volData.getSideLength() / 2;
uint16_t maxPos = g_volData.getSideLength() - 1;
createCubeInVolume(g_volData, Vector3DUint16(minPos, minPos, minPos), Vector3DUint16(maxPos, maxPos, maxPos), 0);
createSphereInVolume(g_volData, 50.0f, 5);
@ -272,11 +272,11 @@ void main ( int argc, char** argv ) // Create Main Function For Bringing It Al
//Our volume is broken down into cuboid regions, and we create one mesh for each region.
//This three-level for loop iterates over each region.
for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ)
for(uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ)
{
for(uint16 uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY)
for(uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY)
{
for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX)
for(uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX)
{
//Create a new surface patch (which is basiaclly the PolyVox term for a mesh).
IndexedSurfacePatch* ispCurrent = new IndexedSurfacePatch();
@ -284,13 +284,13 @@ void main ( int argc, char** argv ) // Create Main Function For Bringing It Al
//Compute the extents of the current region
//FIXME - This is a little complex? PolyVox could
//provide more functions for dealing with regions?
uint16 regionStartX = uRegionX * g_uRegionSideLength;
uint16 regionStartY = uRegionY * g_uRegionSideLength;
uint16 regionStartZ = uRegionZ * g_uRegionSideLength;
uint16_t regionStartX = uRegionX * g_uRegionSideLength;
uint16_t regionStartY = uRegionY * g_uRegionSideLength;
uint16_t regionStartZ = uRegionZ * g_uRegionSideLength;
uint16 regionEndX = regionStartX + g_uRegionSideLength + 1; //Why do we need the '+1' here?
uint16 regionEndY = regionStartY + g_uRegionSideLength + 1; //Why do we need the '+1' here?
uint16 regionEndZ = regionStartZ + g_uRegionSideLength + 1; //Why do we need the '+1' here?
uint16_t regionEndX = regionStartX + g_uRegionSideLength + 1; //Why do we need the '+1' here?
uint16_t regionEndY = regionStartY + g_uRegionSideLength + 1; //Why do we need the '+1' here?
uint16_t regionEndZ = regionStartZ + g_uRegionSideLength + 1; //Why do we need the '+1' here?
Vector3DInt32 regLowerCorner(regionStartX, regionStartY, regionStartZ);
Vector3DInt32 regUpperCorner(regionEndX, regionEndY, regionEndZ);