Work on new OpenGL example - Splitting into several files.
This commit is contained in:
parent
877396af31
commit
74292f7a62
@ -1,4 +1,5 @@
|
|||||||
#include "OpenGLImmediateModeSupport.h"
|
#include "OpenGLImmediateModeSupport.h"
|
||||||
|
#include "OpenGLSupport.h"
|
||||||
|
|
||||||
#include "PolyVoxCore/IndexedSurfacePatch.h"
|
#include "PolyVoxCore/IndexedSurfacePatch.h"
|
||||||
|
|
||||||
@ -21,42 +22,11 @@ void renderRegionImmediateMode(PolyVox::IndexedSurfacePatch& isp)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
GLfloat red = 0.0f;
|
|
||||||
GLfloat green = 0.0f;
|
|
||||||
GLfloat blue = 0.0f;
|
|
||||||
|
|
||||||
uint8 material = vertex.getMaterial() + 0.5;
|
uint8 material = vertex.getMaterial() + 0.5;
|
||||||
|
|
||||||
switch(material)
|
OpenGLColour colour = convertMaterialIDToColour(material);
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
red = 1.0;
|
|
||||||
green = 0.0;
|
|
||||||
blue = 0.0;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
red = 0.0;
|
|
||||||
green = 1.0;
|
|
||||||
blue = 0.0;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
red = 0.0;
|
|
||||||
green = 0.0;
|
|
||||||
blue = 1.0;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
red = 1.0;
|
|
||||||
green = 1.0;
|
|
||||||
blue = 0.0;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
red = 1.0;
|
|
||||||
green = 0.0;
|
|
||||||
blue = 1.0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
glColor3f(red, green, blue);
|
glColor3f(colour.red, colour.green, colour.blue);
|
||||||
glNormal3f(vertex.getNormal().getX(), vertex.getNormal().getY(), vertex.getNormal().getZ());
|
glNormal3f(vertex.getNormal().getX(), vertex.getNormal().getY(), vertex.getNormal().getZ());
|
||||||
glVertex3f(v3dFinalVertexPos.getX(), v3dFinalVertexPos.getY(), v3dFinalVertexPos.getZ());
|
glVertex3f(v3dFinalVertexPos.getX(), v3dFinalVertexPos.getY(), v3dFinalVertexPos.getZ());
|
||||||
|
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
#include "OpenGLSupport.h"
|
||||||
|
|
||||||
|
using namespace PolyVox;
|
||||||
|
|
||||||
|
OpenGLColour convertMaterialIDToColour(PolyVox::uint8 materialID)
|
||||||
|
{
|
||||||
|
OpenGLColour colour;
|
||||||
|
|
||||||
|
switch(materialID)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
colour.red = 1.0;
|
||||||
|
colour.green = 0.0;
|
||||||
|
colour.blue = 0.0;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
colour.red = 0.0;
|
||||||
|
colour.green = 1.0;
|
||||||
|
colour.blue = 0.0;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
colour.red = 0.0;
|
||||||
|
colour.green = 0.0;
|
||||||
|
colour.blue = 1.0;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
colour.red = 1.0;
|
||||||
|
colour.green = 1.0;
|
||||||
|
colour.blue = 0.0;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
colour.red = 1.0;
|
||||||
|
colour.green = 0.0;
|
||||||
|
colour.blue = 1.0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return colour;
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef __OpenGLExample_OpenGLSupport_H__
|
||||||
|
#define __OpenGLExample_OpenGLSupport_H__
|
||||||
|
|
||||||
|
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||||
|
|
||||||
|
#include "glew/glew.h"
|
||||||
|
|
||||||
|
struct OpenGLColour
|
||||||
|
{
|
||||||
|
GLfloat red;
|
||||||
|
GLfloat green;
|
||||||
|
GLfloat blue;
|
||||||
|
};
|
||||||
|
|
||||||
|
OpenGLColour convertMaterialIDToColour(PolyVox::uint8 materialID);
|
||||||
|
|
||||||
|
#endif //__OpenGLExample_OpenGLSupport_H__
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "OpenGLSupport.h"
|
||||||
#include "OpenGLVertexBufferObjectSupport.h"
|
#include "OpenGLVertexBufferObjectSupport.h"
|
||||||
|
|
||||||
#include "PolyVoxCore/IndexedSurfacePatch.h"
|
#include "PolyVoxCore/IndexedSurfacePatch.h"
|
||||||
@ -49,46 +50,15 @@ OpenGLSurfacePatch BuildOpenGLSurfacePatch(IndexedSurfacePatch& isp)
|
|||||||
*ptr = vertex.getNormal().getZ();
|
*ptr = vertex.getNormal().getZ();
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
GLfloat red = 0.0f;
|
|
||||||
GLfloat green = 0.0f;
|
|
||||||
GLfloat blue = 0.0f;
|
|
||||||
|
|
||||||
uint8 material = vertex.getMaterial() + 0.5;
|
uint8 material = vertex.getMaterial() + 0.5;
|
||||||
|
|
||||||
switch(material)
|
OpenGLColour colour = convertMaterialIDToColour(material);
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
red = 1.0;
|
|
||||||
green = 0.0;
|
|
||||||
blue = 0.0;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
red = 0.0;
|
|
||||||
green = 1.0;
|
|
||||||
blue = 0.0;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
red = 0.0;
|
|
||||||
green = 0.0;
|
|
||||||
blue = 1.0;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
red = 1.0;
|
|
||||||
green = 1.0;
|
|
||||||
blue = 0.0;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
red = 1.0;
|
|
||||||
green = 0.0;
|
|
||||||
blue = 1.0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ptr = red;
|
*ptr = colour.red;
|
||||||
ptr++;
|
ptr++;
|
||||||
*ptr = green;
|
*ptr = colour.green;
|
||||||
ptr++;
|
ptr++;
|
||||||
*ptr = blue;
|
*ptr = colour.blue;
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ default:
|
|||||||
|
|
||||||
void main ( int argc, char** argv ) // Create Main Function For Bringing It All Together
|
void main ( int argc, char** argv ) // Create Main Function For Bringing It All Together
|
||||||
{
|
{
|
||||||
g_bUseOpenGLVertexBufferObjects = false;
|
g_bUseOpenGLVertexBufferObjects = true;
|
||||||
glutInit ( &argc, argv ); // Erm Just Write It =)
|
glutInit ( &argc, argv ); // Erm Just Write It =)
|
||||||
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE ); // Display Mode
|
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE ); // Display Mode
|
||||||
glutInitWindowSize ( 500, 500 ); // If glutFullScreen wasn't called this is the window size
|
glutInitWindowSize ( 500, 500 ); // If glutFullScreen wasn't called this is the window size
|
||||||
|
Loading…
x
Reference in New Issue
Block a user