Why Black Screen on native Android

66 Views Asked by At

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.

0

There are 0 best solutions below