Game Development Reference
In-Depth Information
sUniform
is a
struct
holding a single active uniform:
struct sUniform
{
public:
explicit sUniform( const std::string& Name )
: FName( Name ), FLocation( -1 ) {}
sUniform( int Location, const std::string& Name )
: FName( Name ), FLocation( Location ) {}
std::string FName;
int FLocation;
};
It is used in numerous
SetUniformName()
functions to set the values of uniforms by name
at runtime without touching OpenGL API to resolve the names.
See also
F
Manipulating geometry
F
Unifying vertex arrays
F
Creating a canvas for immediate rendering
Manipulating geometry
In
Chapter 4
,
Organizing a Virtual Filesystem
, we created the
Bitmap
class to load and store
bitmaps in an API-independent way. Now we will create a similar abstraction for geometry data
representation that we will later use to submit vertices and their attributes to OpenGL.
Getting ready
Before we proceed with the abstraction, let's take a look at how the vertex speciication in
OpenGL works. Submitting vertex data to OpenGL requires you to create different vertex
streams, and specify ways of their interpretation. Refer to the tutorial if you are unfamiliar
with this concept at
http://www.opengl.org/wiki/Vertex_Specification
.
How to do it…
We have to decide which vertex attributes, or vertex streams, we will store in our mesh. Let's
assume that for a given vertex we need a position, texture coordinates, a normal, and a color.