Advertisement

OpenGL ES 2.0 Raspberry Pi 3b+ glCopyTexSubImage2d GL_INVALID_VALUE

Started by April 13, 2020 05:52 PM
4 comments, last by _WeirdCat_ 4 years, 9 months ago

So basically i am retrieving pixel data from usb camera and i want to display them on the screen,

so i first init texture

int px_width, px_height;
void InitTex(int iw, int ih, int ibpp)
{
pdata = new unsigned char[iw*ih*ibpp];
for (int i=0; i < iw*ih*ibpp; i++) pdata[i] = 255;
px_width = iw;
px_height = ih;
}
void Loadas24()
{
	  glGenTextures(1, &texture);
	  glBindTexture(GL_TEXTURE_2D, texture);
	  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, px_width, px_height, 0, GL_RGB, GL_UNSIGNED_BYTE, pdata);

}

void SubLoadAs24()
{
 glBindTexture(GL_TEXTURE_2D, texture);
 glTexSubImage2D(	GL_TEXTURE_2D,0,0,0 px_width, px_height, GL_RGB, GL_UNSIGNED_BYTE, pdata);
}
void main()
{
InitTex(352, 288, 3);
LoadAs24();
while (true) { getimgandshow(); }
}
void getimgandshow()
{
pdata = getPixelsFromCAM();
SubLoadAs24();
}

I just wrote that it aint the exact code but the order of commands and actual gl calls are the exactly the same

Now when this works on notebook, it does not on rpi - i had similar problem years before and i cant remember what was that)

Tried to create power of two texture and upload with subteximage2d a region, but that didint work either (black screen and GLINVALID_VALUE returned by gltexsubiage2d)

maybe i shoukd use GLsizei instead of int? ill try that tommorow but i think thats not the case since

when i change

void getimgandshow()
{
pdata = getPixelsFromCAM();
Loadas24(); //use glTexImage2d not glTexSubImage2d
}

I see the image from camera but the performance is slow and i am generating the texture over and over causing out of memory after some time….

Any ideas what is going on?

Try using the internal format e.g. GL_RGB8 for a 3 channel unsigned byte texture as the 3rd parameter to glTexImage2D(). https://khronos.org/registry/OpenGL-Refpages/gl4/

Advertisement

Theres no definition of GL_RGB8 at all for es 2.0

Aww …

It happens now it is GLINVALIDOPERATION

Anyway it happens i was calling glTexImage2D before initializing opengl itself….

:D

This topic is closed to new replies.

Advertisement