30 using namespace MaliSDK;
39 LOGE(
"Resource Directory has not been set\n");
53 float color[] = {red, green, blue, alpha};
57 if (colorLocation != -1)
59 GL_CHECK(glUniform4fv(colorLocation, 1, color));
63 LOGE(
"Could not locate \"color\" uniform in program [%d]",
programID);
69 GLint projectionMatrixLocation =
GL_CHECK(glGetUniformLocation(
programID,
"projectionMatrix"));
72 GL_CHECK(glUniformMatrix4fv(projectionMatrixLocation, 1, GL_FALSE, projectionMatrix->
getAsArray()));
85 GL_CHECK(glAttachShader(programID, vertexShaderID));
86 GL_CHECK(glAttachShader(programID, fragmentShaderID));
91 float cameraTranslation = -2.5f;
96 GLint scaleMatrixLocation =
GL_CHECK(glGetUniformLocation(programID,
"scaleMatrix"));
97 GLint cameraMatrixLocation =
GL_CHECK(glGetUniformLocation(programID,
"cameraMatrix"));
101 GL_CHECK(glUniformMatrix4fv(scaleMatrixLocation, 1, GL_FALSE, scaleMatrix.
getAsArray()));
102 GL_CHECK(glUniformMatrix4fv(cameraMatrixLocation, 1, GL_FALSE, cameraMatrix.
getAsArray()));
virtual ~Torus(void)
Frees allocated memory.
float projectionMatrix[16]
void setProjectionMatrix(MaliSDK::Matrix *projectionMatrix)
Pass the correctly defined projection matrix to the program related to the torus model.
Functions for manipulating matrices.
static Matrix createTranslation(float x, float y, float z)
Create and return a translation matrix.
static Matrix createScaling(float x, float y, float z)
Create and return a scaling matrix.
float * getAsArray(void)
Get the matrix elements as a column major order array.
Torus(void)
Protected constructor used to do intialization general to all torus objects.
void setColor(float red, float green, float blue, float alpha)
Sets the uniform color of the drawn torus.
static void setResourceDirectory(std::string requiredResourceDirectory)
Set the resource directory for all tori.
static void processShader(GLuint *shader, const char *filename, GLint shaderType)
Create shader, load in source, compile, and dump debug as necessary.
void setupGraphics(const std::string vertexShaderPath, const std::string fragmentShaderPath)
Initialize constant OpenGL components such as program, shaders and constant matrices.
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
static std::string resourceDirectory