Hello,
I'm trying to edit the pixels of a texture in order to create a program like Paint (windows). The idea is that the user can use the mouse to draw in a screen.
This is my code, I create an array of pixels and set it with white and red pixels. But when I try to render the texture I can only see a red quad. (It's only rendering one color)
I'm using OpenGL 2.0
for(int y = 0; y < SCREEN_WIDTH; ++y)
for(int x = 0; x < SCREEN_HEIGHT; ++x)
{
if(x % 2 == 0)
{
screenData[y][x][0] = 179;
screenData[y][x][1] = 53;
screenData[y][x][2] = 53;
}
else
{
screenData[y][x][0] = 255;
screenData[y][x][1] = 255;
screenData[y][x][2] = 255;
}
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
//Generate a texture and holds the ID in blackboard
glGenTextures(1, &blackboard);
//Set the current texture in order to modify it
glBindTexture(GL_TEXTURE_2D, blackboard);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1280, 720, 0, GL_RGB, GL_UNSIGNED_BYTE, &screenData);