I coded myself in circles trying to get some render to texture code working in an eight bit environment. And I’d like some sanity checking.
I’m trying to slot in to an existing project that has an 8-bit blitter. So I want to render to the same surface that the current blitter does - looks like a simple RTT using a GL_RED and UNIT8 pixelformat with Nearest Neighbour filtering. I think I can do this with a fixed function pipeline.
Because this is SDL 1.2.15 I need to use the frame buffer EXT methods.
Before posting up a long description of the problem and two pages of code, I’m doing this to generate a colour buffer to render to. The SDL surface object, “image” has an allocated buffer of (width*height) size.
glGenTextures(1, &_colourBuffer); glBindTexture(GL_TEXTURE_2D, _colourBuffer); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, image->w, image->h, 0, GL_RED, GL_UNSIGNED_BYTE, image->pixels);
Then this is attached to GL_COLOR_ATTACHMENT0_EXT and I’m relying on the fixed function and GL_NEAREST to do all of the work.
Is this a terrible plan?
Am I going to face a world of hurt trying to draw to an eight bit surface?
I didn’t want to post up a longer description and pages of code until I was sure that GL_RED, GL_UNSIGNED_BYTE was legal and the problem was with my implementation not my thought process.