InitView(){
glClearColor(0, 0, 0, 255);
// Enables texturing
glEnable(GL_TEXTURE_2D);
// Loads the textures.
if(!PVRTLoadTextureFromPointer((void*)tex_base, texName))
{
PVRShellSet(prefExitMessage, "ERROR: Cannot load the texture
");
return false;
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE);
}
RenderScene(){
glClear(GL_COLOR_BUFFER_BIT);
VERTTYPE afVertices[] = {0.25f,0.0f,0.0f,
0.75f,0.0f,0.0f,
0.75f,0.5f,0.0f,
0.25f,0.5f,0.0f};
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,0,afVertices);
VERTTYPE afColors[] = { 1.0f, 0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f };
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4,GL_FLOAT,0,afColors);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
CreateCircle(0.5f, -0.5f, 0.0f, texName);
}
//create filled circle
void CreateCircle(GLfloat radius, GLfloat xpos, GLfloat ypos, GLuint texName){
glBindTexture(GL_TEXTURE_2D, texName);
GLfloat afVertices[FAN_VERTICES*3];
GLfloat angle = 0.0f;
afVertices[0] = xpos;
afVertices[1] = ypos;
afVertices[2] = 0.0f;
for(int i = 3; i<(FAN_VERTICES*3); i++){
afVertices[i++] = (radius*cos(angle) + xpos)*RATIO;
afVertices[i++] = radius*sin(angle) + ypos;
//afVertices[i++] = radius*sin(angle) + ypos;
afVertices[i] = 0.0f;
angle+=(PI/180);
}
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,0,afVertices);
//pass the texture coordinates
GLfloat pfTexCoord[2*FAN_VERTICES];
angle = 0.0f;
pfTexCoord[0] = 0.5f;
pfTexCoord[1] = 0.5f;
for(int i=2; i<(2*FAN_VERTICES); i++){
pfTexCoord[i++] = 0.5f * cos(angle) + 0.5f;
pfTexCoord[i] = 0.5f * sin(angle) + 0.5f;
angle += (PI/180.0f);
}
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2,GL_FLOAT,0,pfTexCoord);
glDrawArrays(GL_TRIANGLE_FAN, 0, FAN_VERTICES);
}
okay,
like i said earlier, the texture mapping works. the cirlce is created with the texture i want. then i create a square in RenderScene(). now the square is suppose to be red, however, it seems like it somewhat looks like the texture that is read into the cirlce (earlier I said it was initially white, its not).