Support Forum       G3D Web Page     
Classes | Public Member Functions | List of all members
G3D::SlowMesh Class Reference

Used to convert old immediate mode OpenGL code to OpenGL 3+ core. More...

Public Member Functions

 SlowMesh (PrimitiveType p, const shared_ptr< Texture > &t=shared_ptr< Texture >())
 
void makeVertex (const Vector2 &vertex)
 Construct a Vertex given the current texCoord, color, and normal state. More...
 
void makeVertex (const Vector3 &vertex)
 
void makeVertex (const Vector4 &vertex)
 
void render (RenderDevice *rd, int coverageSamples=1) const
 Constructs a VertexBuffer from the vertex array, and renders it using a simple shader that mimics the old fixed-function pipeline. More...
 
void reserveSpace (int numVertices)
 Call to reserve space in the CPU array for. More...
 
void setColor (const Color3 &color)
 Change the currently set color state, defaulted to black. More...
 
void setColor (const Color4 &color)
 
void setNormal (const Vector3 &normal)
 Change the currently set color state, defaulted to (0,0,1) More...
 
void setPointSize (const float size)
 
void setPrimitveType (const PrimitiveType &p)
 Overrides the current PrimitiveType, all of the create vertices will be of said type, whether made before or after this call. More...
 
void setTexCoord (const Vector2 &texCoord)
 Change the currently set texCoord state, defaulted to (0,0) More...
 
void setTexture (const shared_ptr< Texture > t)
 Sets the texture to use for rendering. More...
 

Detailed Description

Used to convert old immediate mode OpenGL code to OpenGL 3+ core.

Named as such to discourage use by end-users of G3D.

Old immediate mode: rd->setTexture(0, t); glBegin(PrimitiveType::TRIANGLES); { glColor(...); glMultiTexCoord(0, ...); glVertex(...); glMultiTexCoord(0, ...); glVertex(...); glMultiTexCoord(0, ...); glVertex(...); } glEnd();

New Code: SlowMesh m(PrimitiveType::TRIANGLES); { m.setTexture(t); m.setColor(...); m.setTexCoord(...); m.makeVertex(...); m.setTexCoord(...); m.makeVertex(...); m.setTexCoord(...); m.makeVertex(...); } m.render(rd);

Alternatively, if you already have a CPUVertexArray:

SlowMesh m(PrimitiveType::TRIANGLES, cpuVertexArray, texture); m.render(rd);

Constructor & Destructor Documentation

◆ SlowMesh()

G3D::SlowMesh::SlowMesh ( PrimitiveType  p,
const shared_ptr< Texture > &  t = shared_ptr<Texture>() 
)
inline

Member Function Documentation

◆ makeVertex() [1/3]

void G3D::SlowMesh::makeVertex ( const Vector2 vertex)

Construct a Vertex given the current texCoord, color, and normal state.

◆ makeVertex() [2/3]

void G3D::SlowMesh::makeVertex ( const Vector3 vertex)

◆ makeVertex() [3/3]

void G3D::SlowMesh::makeVertex ( const Vector4 vertex)

◆ render()

void G3D::SlowMesh::render ( RenderDevice rd,
int  coverageSamples = 1 
) const

Constructs a VertexBuffer from the vertex array, and renders it using a simple shader that mimics the old fixed-function pipeline.

Parameters
coverageAntialiasingModeIf greater than 1, use multisampling for coverage. This only works with depth and stencil disabled.

◆ reserveSpace()

void G3D::SlowMesh::reserveSpace ( int  numVertices)

Call to reserve space in the CPU array for.

Parameters
numVerticesVertices, to avoid continous reallocation. This is to make use of SlowMesh slightly faster for large vertex counts, but custom code bypassing SlowMesh should be used for optimal performance.

◆ setColor() [1/2]

void G3D::SlowMesh::setColor ( const Color3 color)

Change the currently set color state, defaulted to black.

◆ setColor() [2/2]

void G3D::SlowMesh::setColor ( const Color4 color)

◆ setNormal()

void G3D::SlowMesh::setNormal ( const Vector3 normal)

Change the currently set color state, defaulted to (0,0,1)

◆ setPointSize()

void G3D::SlowMesh::setPointSize ( const float  size)

◆ setPrimitveType()

void G3D::SlowMesh::setPrimitveType ( const PrimitiveType p)

Overrides the current PrimitiveType, all of the create vertices will be of said type, whether made before or after this call.

◆ setTexCoord()

void G3D::SlowMesh::setTexCoord ( const Vector2 texCoord)

Change the currently set texCoord state, defaulted to (0,0)

◆ setTexture()

void G3D::SlowMesh::setTexture ( const shared_ptr< Texture t)

Sets the texture to use for rendering.


documentation generated on Wed Nov 24 2021 08:02:00 using doxygen 1.8.15