Skip to content

Commit

Permalink
Added basic doxygen documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrzej Szymczak committed May 20, 2014
1 parent 0d04aa1 commit 79ae00b
Show file tree
Hide file tree
Showing 27 changed files with 3,129 additions and 363 deletions.
2,303 changes: 2,303 additions & 0 deletions Doxyfile

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion Makefile
Expand Up @@ -2,7 +2,7 @@
CC = g++
OPT = -Wall -I/usr/include/glm -I. -O2
LIBOPT = -L/usr/lib/nvidia-331/ -lglut -lGL -lGLEW
SOURCES = buffer.cpp framebuffer.cpp glutwrapper.cpp handlerbase.cpp menucreator.cpp mesh.cpp program.cpp shader.cpp texture.cpp tfprogram.cpp trackball.cpp trackballhandler.cpp vertexarray.cpp
SOURCES = buffer.cpp framebuffer.cpp glutwrapper.cpp handlerbase.cpp menucreator.cpp mesh.cpp program.cpp shader.cpp texture.cpp tfprogram.cpp trackballhandler.cpp vertexarray.cpp
OBJECTS = $(subst .cpp,.o,$(SOURCES))

all : $(SOURCES) demo1 demo2 demo3 demo4
Expand All @@ -23,6 +23,10 @@ demo4 : $(OBJECTS) demo4.o Makefile
%.o: %.cpp *.h Makefile
$(CC) $(OPT) -c -o $@ $<

doc :
doxygen

clean :
rm *.o demo1 demo2 demo3 demo4
rm -rf html latex

190 changes: 176 additions & 14 deletions buffer.h
Expand Up @@ -8,20 +8,28 @@ namespace EZGraphics {

/* ------------------------------------------- */

/** supported buffer types: Array is a standard array buffer and ElemArray is an element array (index buffer) */
typedef enum { Array, ElemArray } BufType;

/* ------------------------------------------- */

/** wrapper class for OpenGL Buffer objects */
class Buffer {

private:
GLuint handle;
BufType tp;
GLenum type;
int components;

GLuint handle; /** OpenGL name of the buffer object */
BufType tp; /** type of the buffer (array or element) */
GLenum type; /** type of entries - this is an OpenGL constant such as GL_INT */
int components; /** components per entry - can be 1,2,3 or 4, e.g. 3 if entries are 3D vectors */

public:
Buffer ( const Buffer &a );
void on();
void off();

GLenum getType() const { return type; }
GLuint getHandle() const { return handle; }

protected:
Buffer ( const int cs, const int size, const GLubyte * const data = NULL, const BufType t = Array );
Buffer ( const int cs, const int size, const GLbyte * const data = NULL, const BufType t = Array );
Buffer ( const int cs, const int size, const GLuint * const data = NULL, const BufType t = Array );
Expand All @@ -30,51 +38,205 @@ namespace EZGraphics {
Buffer ( const int cs, const int size, const GLushort * const data = NULL, const BufType t = Array );
Buffer ( const int cs, const int size, const GLfloat * const data = NULL, const BufType t = Array );

public:

/**
Generates an error - use only pointers to Buffer objects for best results
*/
Buffer ( const Buffer &a );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const GLubyte * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const GLbyte * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const GLshort * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const GLushort * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const GLint * const data, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const glm::ivec2 * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const glm::ivec3 * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const glm::ivec4 * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const GLuint * const data, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const glm::uvec2 * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const glm::uvec3 * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const glm::uvec4 * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const GLfloat * const data, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const glm::vec2 * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const glm::vec3 * const data = NULL, const BufType t = Array );

/**
Constructs a buffer object; sends data to it if non-NULL pointer is provided as the data parameter
\param size is the number of entries (typically, vertices in the model)
\param data is the pointer to data to be sent to the buffer; if data==NULL (default), no data is sent
\param t is the buffer type; default value is Array (meaning array buffer)
*/
Buffer ( const int size, const glm::vec4 * const data = NULL, const BufType t = Array );

/** deletes the buffer */
~Buffer();

/** will generate an error */
Buffer & operator= ( const Buffer & rhs );

/**
sets the vertex attribute index for data stored in the buffer
\param aix is the index of the attribute; has to match the location qualifier in the vertex shader
*/
void setIndex ( int aix ) const;
void on();
void off();

GLenum getType() const { return type; }
GLuint getHandle() const { return handle; }


/**
Use buffer as shader storage
\param index is the index of the shader storage buffer; has to match the binding qualifier of the buffer in the shaders
*/
void useAsShaderStorage ( GLuint index );

friend class VertexArray;
friend class TFProgram;
};

/* ------------------------------------------- */

/** a wrapper for index buffers (or element array buffers) */
class IndexBuffer : public Buffer {
public:

/** constructs the index buffer; sends data to it if non-NULL pointer is provided as the second argument
\param size is the number of entries in the buffer
\param data is the pointer to data to be sent to it
*/
IndexBuffer ( const int size, const GLubyte * const data = NULL );

/** constructs the index buffer; sends data to it if non-NULL pointer is provided as the second argument
\param size is the number of entries in the buffer
\param data is the pointer to data to be sent to it
*/
IndexBuffer ( const int size, const GLuint * const data = NULL );

/** constructs the index buffer; sends data to it if non-NULL pointer is provided as the second argument
\param size is the number of entries in the buffer
\param data is the pointer to data to be sent to it
*/
IndexBuffer ( const int size, const GLushort * const data = NULL );


/** constructs the index buffer; sends data to it if non-NULL pointer is provided as the second argument
\param size is the number of entries in the buffer
\param data is the pointer to data to be sent to it
The resulting buffer has 2*size scalar entries
*/
IndexBuffer ( const int size, const glm::uvec2 * const data = NULL );

/** constructs the index buffer; sends data to it if non-NULL pointer is provided as the second argument
\param size is the number of entries in the buffer
\param data is the pointer to data to be sent to it
Note that the resulting buffer has 3*size scalar entries for this variant of the constructor
*/
IndexBuffer ( const int size, const glm::uvec3 * const data = NULL );


/** will generate an error - use only pointers to IndexBuffer objects for best results */
IndexBuffer ( const IndexBuffer & );

/** will generate an error - use only pointers to IndexBuffer objects for best results */
IndexBuffer & operator= ( const IndexBuffer & );
};

Expand Down
4 changes: 2 additions & 2 deletions demo1.cpp
Expand Up @@ -88,12 +88,12 @@ class ViewerEventHandlers : public TrackballHandler, public MenuCreator {
// For NVIDIA GPUs, you may not see anything printed if all went well.

cout << "Creating Gouraud program..." << endl;
pgmGouraud = createProgram(
pgmGouraud = Program::createProgram(
ShaderFile(Vert,"demo1-shaders/vtxGouraud.glsl"),
ShaderFile(Frag,"demo1-shaders/frgGouraud.glsl")
);
cout << "Creating Phong program..." << endl;
pgmPhong = createProgram(
pgmPhong = Program::createProgram(
ShaderFile(Vert,"demo1-shaders/vtxPhong.glsl"),
ShaderFile(Frag,"demo1-shaders/frgPhong.glsl")
);
Expand Down
10 changes: 5 additions & 5 deletions demo2.cpp
Expand Up @@ -98,29 +98,29 @@ class ViewerEventHandlers : public TrackballHandler, public MenuCreator {
// Compile and link GLSL programs. The last three include geometry shader

cout << "Creating Gouraud program..." << endl;
pgmGouraud = createProgram(
pgmGouraud = Program::createProgram(
ShaderFile(Vert,"demo2-shaders/Gouraud/vtxGouraud.glsl"),
ShaderFile(Frag,"demo2-shaders/Gouraud/frgGouraud.glsl")
);
cout << "Creating Phong program..." << endl;
pgmPhong = createProgram(
pgmPhong = Program::createProgram(
ShaderFile(Vert,"demo2-shaders/Phong/vtxPhong.glsl"),
ShaderFile(Frag,"demo2-shaders/Phong/frgPhong.glsl")
);
cout << "Creating Flat program..." << endl;
pgmFlat = createProgram(
pgmFlat = Program::createProgram(
ShaderFile(Vert,"demo2-shaders/Flat/vtxFlat.glsl"),
ShaderFile(Geom,"demo2-shaders/Flat/geoFlat.glsl"),
ShaderFile(Frag,"demo2-shaders/Flat/frgFlat.glsl")
);
cout << "Creating WFlat program..." << endl;
pgmWFlat = createProgram(
pgmWFlat = Program::createProgram(
ShaderFile(Vert,"demo2-shaders/Wire/vtxWire.glsl"),
ShaderFile(Geom,"demo2-shaders/Wire/geoWire.glsl"),
ShaderFile(Frag,"demo2-shaders/Wire/frgWire.glsl")
);
cout << "Creating Double program..." << endl;
pgmDouble = createProgram(
pgmDouble = Program::createProgram(
ShaderFile(Vert,"demo2-shaders/Double/vtxDouble.glsl"),
ShaderFile(Geom,"demo2-shaders/Double/geoDouble.glsl"),
ShaderFile(Frag,"demo2-shaders/Double/frgDouble.glsl")
Expand Down
4 changes: 2 additions & 2 deletions demo3.cpp
Expand Up @@ -191,9 +191,9 @@ class ViewerEventHandlers : public TrackballHandler, public MenuCreator {

// we'll use the familiar Phong program and a program to apply texture to the square

pgmPhong = createProgram(ShaderFile(Vert,"demo3-shaders/vtxPhong.glsl"),
pgmPhong = Program::createProgram(ShaderFile(Vert,"demo3-shaders/vtxPhong.glsl"),
ShaderFile(Frag,"demo3-shaders/frgPhong.glsl"));
pgmSquare = createProgram(ShaderFile(Vert,"demo3-shaders/vtxSquare.glsl"),
pgmSquare = Program::createProgram(ShaderFile(Vert,"demo3-shaders/vtxSquare.glsl"),
ShaderFile(Frag,"demo3-shaders/frgSquare.glsl"));

// this should look familiar: use the Mesh class to read mesh and get
Expand Down
2 changes: 1 addition & 1 deletion demo4.cpp
Expand Up @@ -119,7 +119,7 @@ class ViewerEventHandlers : public TrackballHandler, public MenuCreator {

/* TessE = tesselation evaluation, TessC = tesselation control */

p = createProgram(ShaderFile(Vert,"demo4-shaders/vtx.glsl"),
p = Program::createProgram(ShaderFile(Vert,"demo4-shaders/vtx.glsl"),
ShaderFile(TessC,"demo4-shaders/ctrl.glsl"),
ShaderFile(TessE,"demo4-shaders/eval.glsl"),
ShaderFile(Geom,"demo4-shaders/geom.glsl"),
Expand Down
12 changes: 12 additions & 0 deletions framebuffer.cpp
Expand Up @@ -9,6 +9,18 @@ using namespace std;

namespace EZGraphics {

Framebuffer::Framebuffer ( const Framebuffer &f )
{
cerr << "Attempting to use copy constructor for a Buffer object" << endl;
exit(1);
}

Framebuffer & Framebuffer::operator= ( const Framebuffer &f )
{
cerr << "Attempting to use assignment operator for a Buffer object" << endl;
exit(1);
}

Framebuffer::Framebuffer()
{
glGenFramebuffers(1,&handle);
Expand Down

0 comments on commit 79ae00b

Please sign in to comment.