CMake outputs this:
CMake compiler = [/usr/bin/c++]
CMake compiler ID = [Clang]
As for the OpenGL code... I tried what you said (although I'm not sure where to put these calls) but I still get a white square instead of my texture:
glClearColor(1, 0, 0, 1);
unsigned width = 128;
unsigned heigth = 128;
unsigned char *data = malloc(width * heigth * 4);
assert(data != NULL);
for (unsigned x = 0; x < width;x++)
{
for (unsigned y = 0; y < heigth;y++)
{
if ((y * width + x) % 2 == 0)
{
data[(x * heigth + y) * 4 + 0] = 0;
data[(x * heigth + y) * 4 + 1] = 0;
data[(x * heigth + y) * 4 + 2] = 255;
data[(x * heigth + y) * 4 + 3] = 255;
}
else
{
data[(x * heigth + y) * 4 + 0] = 255;
data[(x * heigth + y) * 4 + 1] = 0;
data[(x * heigth + y) * 4 + 2] = 0;
data[(x * heigth + y) * 4 + 3] = 255;
}
}
}
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, heigth, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glBindTexture(GL_TEXTURE_2D, textureId);
glRotatef(1, 0, 0, 5);
glPushMatrix();
glTranslatef(0.1, 0.1, 0);
glScalef(0.8, 0.8, 0.8);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, -1.0f); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex2f( 1.0f, -1.0f); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex2f( 1.0f, 1.0f); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f, 1.0f); // Top Left Of The Texture and Quad
glEnd();
glPopMatrix();
[[self.glView openGLContext] flushBuffer];
After checking the OpenGL errors I noticed it says "GL_INVALID_OPERATION, the specified operation is not allowed in the current state" (ok I copied SFML glCheck function
) on the glEnd(); call but I don't know why...