PDA

View Full Version : How to draw a texture using glDrawTexiOES?



loki5100
09-12-2017, 06:34 AM
I try the following code, but without any success :

I create my texture like this :


glActiveTexture(GL_TEXTURE0);
glGenTextures(1, @Tex);
glBindTexture(GL_TEXTURE_2D, Tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
TJGLUtils.JavaClass.texImage2D(GL_TEXTURE_2D, // target: Integer;
0, // level: Integer;
aBitmap, // bitmap: JBitmap;
0); // border: Integer =>
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 100, 100, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
glBindTexture(GL_TEXTURE_2D, 0);


then later in my main render loop i try to draw the texture with glDrawTexiOES like this :



eglMakeCurrent(eglGetCurrentDisplay, SharedSurface, SharedSurface,
SharedContext);

glViewport(Round(FContentRect.Left * FScale), Round(FContentRect.Top * FScale), Round(FContentRect.Width * FScale),
Round(FContentRect.Height * FScale));

glDepthMask(1);
glClearDepthf(1);
glClearStencil(0);
glClearColor(0, 0, 0, 0);
glClear(GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT or GL_COLOR_BUFFER_BIT);

glBindTexture(GL_TEXTURE_2D, Tex);

aParams[0] := 0;
aParams[1] := 0;
aParams[2] := 100;
aParams[3] := 100;
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, @aParams[0]);

glDrawTexiOES(0, 0, 0, 100, 100);

eglSwapBuffers(SharedDisplay, SharedSurface);



but it's not work :( what did i miss ?

NOTE: i have an glerror (1280) here :


glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, @aParams[0]);

loki5100
09-12-2017, 02:21 PM
it's seam that glDrawTexiOES is not available under opengl 2.0 ? or i m wrong ?