1

I am trying to "software render" a pixel array to the screen in Android 12, using C and OpenGLES.

Relevant code - where I am expecting a 0xff0000ff (red) or 0xff00ffff (violet) rectangle:

GLbitfield *rectangle;
GLbitfield *picture;

void Renderer::render() {
for (int i = 0; i<1024*768; i++)
*(picture + i) = 0xff00ffff;

glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 1024, 768, GL_RGB_INTEGER, GL_UNSIGNED_INT, picture);
// necessary IDK
glBlitFramebuffer( 0, 0, 1024, 768,0, 0, 1024, 768, GL_COLOR_BUFFER_BIT, GL_LINEAR);

eglSwapBuffers( display_, surface_ );
}

GLuint texid;
void Renderer::initRenderer() {

rectangle = (GLbitfield*)malloc(1024 * 768 * sizeof(GLbitfield));
picture = (GLbitfield*)malloc(1024 * 768 * sizeof(GLbitfield));

for( int i=0; i<1024*768; i++ )
*(rectangle + i ) = 0xff0000ff;

glGenTextures(1, &texid);
glBindTexture( GL_TEXTURE_2D, texid);
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 1024, 768, 0, GL_RGBA, GL_UNSIGNED_INT, rectangle);
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texid, 0 );

[...]
}

so yeah this compiles and runs with a black screen. I just want GL to "let me through" with my red/purple pixels so that I can change the array *picture later in my render-loop to sth cool.

Or is it kinda totally wrong or even unfeasible? Performance-wise that ARM in the phone should be more than capable to do some software trickery, IMHO..

btw, I really thank Khronos for removing glWritePixels() from GLES as this would have seemed to be the ideal solution to me. No need for some stupid texture workaround!

Thanks in advance for your expertise.

Irchel
  • 11
  • 2
  • I don't think glFramebufferTexture2D does anything unless you create a framebuffer and bind it. Framebuffers are how you render *to* textures, not from them. – user253751 Sep 27 '22 at 16:51

0 Answers0