Hy,
As the title suggests I wanted to draw individual pixels to the screen. I've come a long way, but this is the essential code I've got now:
int main() {
glewExperimental=GL_TRUE;
glewInit();
GLuint BUFFER;
glGenBuffers(1,&BUFFER);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,BUFFER);
glBufferData(GL_PIXEL_UNPACK_BUFFER,WIDTH*HEIGHT,NULL,GL_DYNAMIC_DRAW);
unsigned char* buffer_map = (unsigned char*) glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
fill_buffer(buffer_map, WIDTH, HEIGHT,objects);
}
void fill_buffer(unsigned char* buffer, unsigned int width, unsigned int height) {
for (unsigned int pixelX = 0; pixelX < width; ++pixelX) {
for (unsigned int pixelY = 0; pixelY < height; ++pixelY) {
buffer[pixelX*height+pixelY] = 255;
}
}
glDrawPixels(width,height,GL_RED,GL_UNSIGNED_BYTE,buffer);
}
It seems to work right. The buffer is intitialised correctly, plus it is loaded with the right values (as an test I just wanted to fill my screen with red). However though, the screen stays black, instead of being red.
Anyone a suggestion why this would be?