Hi All,
I’m using opengl for in my application for rendering RGB24 4K data. I’m using glTexImage2D for creating/preparing image array with below paramters
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, camera->width, camera->height, 0, GL_BGR, GL_UNSIGNED_BYTE, buffer);
Above function takes 20 milliseconds, because of this I can not render @60FPS. Below is snap shot the code for RGB24
/******* Init part **********/
initializeOpenGLFunctions();
glEnable(GL_DEPTH_TEST);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
/******* Render part **********/
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, camera->width, camera->height, 0, GL_BGR, GL_UNSIGNED_BYTE, g_buffer); //RGB24 working
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0, 1);
glVertex2f(-1, -1);
glTexCoord2f(1, 1);
glVertex2f(1, -1);glTexCoord2f(0, 0);
glVertex2f(-1, 1);
glTexCoord2f(1, 0);
glVertex2f(1, 1);
glEnd();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
Question:
- How to modify the above code to support RGB24 with Fragment and vertex shader to reduce 20milli seconds to ~5 milliseconds.
- I want use the shader to convert RGB24 to RGB32 and then use below function to render RGB24.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, camera->width, camera->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer);