PBuffer render-to-texture problem...

Using the win32 headers/binaries in OGLES-1.1_WINDOWS_PCEMULATION_2.04.24.0811.msi, on a Radeon X1300:





I’m trying to figure out render-to-texture using pbuffers and ran into a problem.





With the code below pbw = pbh = 128 results in expected behavior:








Anything larger than the main window (pbw = pbh = 256 and up for a 320x240 window) seems to clip/clamp the texture to the main window dimensions:








Is there a problem with the code or is the SDK doing something odd? Or can pbuffers only be smaller than your main window/surface?







#include <iostream>

#include <SDL/SDL.h>

#include <SDL/SDL_syswm.h>



#include <GLES/egl.h>

#include <GLES/gl.h>



using namespace std;



int main(int argc, char* argv[])

{

SDL_Init(SDL_INIT_EVERYTHING);

const int winw = 320;

const int winh = 240;

SDL_SetVideoMode(winw, winh, 32, 0);



// grab the window’s HWND

static SDL_SysWMinfo wmInfo;

SDL_VERSION( &wmInfo.version );

SDL_GetWMInfo( &wmInfo );



NativeDisplayType nativeDisplay = (NativeDisplayType)GetDC(wmInfo.window);

NativeWindowType nativeWindow = (NativeWindowType)wmInfo.window;



const int pbw = 512;

const int pbh = 512;



EGLDisplay eglDisplay;

EGLConfig eglConfig;

EGLSurface eglSurface;

EGLContext eglContext;



eglDisplay = eglGetDisplay( nativeDisplay );

eglInitialize(eglDisplay, NULL, NULL);

EGLint attribs[] = {

    EGL_RED_SIZE,               5,

    EGL_GREEN_SIZE,             5,

    EGL_BLUE_SIZE,              5,

    EGL_ALPHA_SIZE,             0,

    EGL_DEPTH_SIZE,             16,

    EGL_MAX_PBUFFER_WIDTH,      pbw,

    EGL_MAX_PBUFFER_HEIGHT,     pbh,

    EGL_BIND_TO_TEXTURE_RGBA,   EGL_TRUE,

    EGL_SURFACE_TYPE,           EGL_WINDOW_BIT | EGL_PBUFFER_BIT,

    EGL_NONE,

};

int iConfigs = 0;

eglChooseConfig(eglDisplay, attribs, &eglConfig, 1, &iConfigs);

eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, nativeWindow, NULL);

eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, NULL);



eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);



EGLint pbuffer_attribs[] = {

     EGL_WIDTH,                  pbw,

     EGL_HEIGHT,                 pbh,

     EGL_TEXTURE_TARGET,        EGL_TEXTURE_2D,

     EGL_TEXTURE_FORMAT,        EGL_TEXTURE_RGBA,

     EGL_NONE

};

EGLSurface pbuffer = eglCreatePbufferSurface(eglDisplay, eglConfig, pbuffer_attribs);



GLuint pbuffer_texobj;

glEnable(GL_TEXTURE_2D);

glGenTextures(1, &pbuffer_texobj);

glBindTexture(GL_TEXTURE_2D, pbuffer_texobj);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);





// ES1.1 only allows 4-component colors

GLfloat verts[] = {

    0.0f, 0.0f, 0.0f,           // pos

    1.0f, 0.0f, 0.0f, 1.0f,     // color

    1.0f, 0.0f, 0.0f,           // pos

    0.0f, 1.0f, 0.0f, 1.0f,     // color

    1.0f, 1.0f, 0.0f,           // pos

    0.0f, 0.0f, 1.0f, 1.0f,     // color

    };

GLubyte index[] = {0, 1, 2};



// textured quad

GLfloat verts2[] = {

    0, 0, 0,

    0, 0,

    1, 0, 0,

    1, 0,

    1, 1, 0,

    1, 1,

    0, 1, 0,

    0, 1,

    };

GLubyte index2[] = {0, 1, 3, 3, 1, 2};



float size;



bool running = true;

SDL_Event event;

while( running )

    {

    // handle all pending events

    while( SDL_PollEvent(&event) ) {

        switch (event.type) {

              case SDL_KEYDOWN: switch(event.key.keysym.sym) {

                   case SDLK_ESCAPE: running = false; break;

                   default: break;

             } break;

              case SDL_QUIT: running = false; break;

              default: break;

        }

    }



    // render to texture bound to our pbuffer

    eglMakeCurrent(eglDisplay, pbuffer, pbuffer, eglContext);

    glViewport(0, 0, pbw, pbh);

    glClearColor(1,0,1,1);

    glClear(GL_COLOR_BUFFER_BIT);



    glMatrixMode(GL_PROJECTION); glLoadIdentity();

    size = 0.6f;

    glOrthof(-size, size, -size, size, -1.0f, 1.0f);

    glMatrixMode(GL_MODELVIEW); glLoadIdentity();



    glEnableClientState(GL_VERTEX_ARRAY);

    glEnableClientState(GL_COLOR_ARRAY);

    glVertexPointer(3, GL_FLOAT, sizeof(GLfloat)*7, &verts[0]);

    glColorPointer(4, GL_FLOAT, sizeof(GLfloat)*7, &verts[3]);



    glDisable(GL_TEXTURE_2D);

    glPushMatrix();

    glRotatef(SDL_GetTicks() / 10.0f, 0, 0, 1);

    glTranslatef(-0.5f, -0.5f, 0);

    glDrawArrays(GL_TRIANGLES, 0, 3);

    glPopMatrix();





    // render textured quad using pbuffer texture

    eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);



    glBindTexture(GL_TEXTURE_2D, pbuffer_texobj);

    eglBindTexImage(eglDisplay, pbuffer, EGL_BACK_BUFFER);



    glViewport(0, 0, winw, winh);

    glClearColor(0,0,0,1);

    glClear(GL_COLOR_BUFFER_BIT);



    glMatrixMode(GL_PROJECTION); glLoadIdentity();

    size = 0.8f;

    glOrthof(-size, size, -size, size, -1.0f, 1.0f);

    glMatrixMode(GL_MODELVIEW); glLoadIdentity();



    glDisableClientState(GL_COLOR_ARRAY);

    glEnableClientState(GL_VERTEX_ARRAY);

    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    glVertexPointer(3, GL_FLOAT, sizeof(GLfloat)*5, &verts2[0]);

    glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat)*5, &verts2[3]);



    glEnable(GL_TEXTURE_2D);

    glColor4f(1,1,1,1);

    glBindTexture(GL_TEXTURE_2D, pbuffer_texobj);

    glPushMatrix();

    //glRotatef(-(float)SDL_GetTicks() / 100.0f, 0, 0, 1);

    glTranslatef(-0.5f, -0.5f, 0);

    glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, index2);

    glPopMatrix();



    eglReleaseTexImage(eglDisplay, pbuffer, EGL_BACK_BUFFER);





    glFlush();

    eglSwapBuffers(eglDisplay, eglSurface);

    SDL_Delay(1);

    }



eglReleaseTexImage(eglDisplay, pbuffer, EGL_BACK_BUFFER);

eglDestroySurface(eglDisplay, pbuffer);

glDeleteTextures(1, &pbuffer_texobj);



eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);

eglTerminate(eglDisplay);



SDL_Quit();

return 0;

}

[/CODE]<br /> <br />#include &lt;iostream&gt;<br /> <br />#include &lt;SDL/SDL.h&gt;<br /> <br />#include &lt;SDL/SDL_syswm.h&gt;<br /> <br /><br /> <br />#include &lt;GLES/egl.h&gt;<br /> <br />#include &lt;GLES/gl.h&gt;<br /> <br /><br /> <br />using namespace std;<br /> <br /><br /> <br />int main(int argc, char* argv[])<br /> <br />{<br /> <br />SDL_Init(SDL_INIT_EVERYTHING);<br /> <br />const int winw = 320;<br /> <br />const int winh = 240;<br /> <br />SDL_SetVideoMode(winw, winh, 32, 0);<br /> <br /><br /> <br />// grab the window's HWND<br /> <br />static SDL_SysWMinfo wmInfo;<br /> <br />SDL_VERSION( &wmInfo.version );<br /> <br />SDL_GetWMInfo( &wmInfo );<br /> <br /><br /> <br />NativeDisplayType nativeDisplay = (NativeDisplayType)GetDC(wmInfo.window);<br /> <br />NativeWindowType nativeWindow = (NativeWindowType)wmInfo.window;<br /> <br /><br /> <br />const int pbw = 512;<br /> <br />const int pbh = 512;<br /> <br /><br /> <br />EGLDisplay eglDisplay;<br /> <br />EGLConfig eglConfig;<br /> <br />EGLSurface eglSurface;<br /> <br />EGLContext eglContext;<br /> <br /><br /> <br />eglDisplay = eglGetDisplay( nativeDisplay );<br /> <br />eglInitialize(eglDisplay, NULL, NULL);<br /> <br />EGLint attribs[] = {<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;EGL_RED_SIZE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;EGL_GREEN_SIZE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;EGL_BLUE_SIZE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;EGL_ALPHA_SIZE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;EGL_DEPTH_SIZE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;16,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;EGL_MAX_PBUFFER_WIDTH,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pbw,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;EGL_MAX_PBUFFER_HEIGHT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pbh,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;EGL_BIND_TO_TEXTURE_RGBA,&nbsp;&nbsp;&nbsp;EGL_TRUE,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;EGL_SURFACE_TYPE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EGL_WINDOW_BIT | EGL_PBUFFER_BIT,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;EGL_NONE,<br /> <br />};<br /> <br />int iConfigs = 0;<br /> <br />eglChooseConfig(eglDisplay, attribs, &eglConfig, 1, &iConfigs);<br /> <br />eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, nativeWindow, NULL);<br /> <br />eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, NULL);<br /> <br /><br /> <br />eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);<br /> <br /><br /> <br />EGLint pbuffer_attribs[] = {<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EGL_WIDTH,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pbw,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EGL_HEIGHT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pbh,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EGL_TEXTURE_TARGET,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EGL_TEXTURE_2D,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EGL_TEXTURE_FORMAT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EGL_TEXTURE_RGBA,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EGL_NONE<br /> <br />};<br /> <br />EGLSurface pbuffer = eglCreatePbufferSurface(eglDisplay, eglConfig, pbuffer_attribs);<br /> <br /><br /> <br />GLuint pbuffer_texobj;<br /> <br />glEnable(GL_TEXTURE_2D);<br /> <br />glGenTextures(1, &pbuffer_texobj);<br /> <br />glBindTexture(GL_TEXTURE_2D, pbuffer_texobj);<br /> <br />glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);<br /> <br />glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);<br /> <br />glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);<br /> <br />glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);<br /> <br /><br /> <br /><br /> <br />// ES1.1 only allows 4-component colors<br /> <br />GLfloat verts[] = {<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;0.0f, 0.0f, 0.0f,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// pos<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;1.0f, 0.0f, 0.0f, 1.0f,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// color<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;1.0f, 0.0f, 0.0f,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// pos<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;0.0f, 1.0f, 0.0f, 1.0f,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// color<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;1.0f, 1.0f, 0.0f,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// pos<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;0.0f, 0.0f, 1.0f, 1.0f,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// color<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;};<br /> <br />GLubyte index[] = {0, 1, 2};<br /> <br /><br /> <br />// textured quad<br /> <br />GLfloat verts2[] = {<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;0, 0, 0,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;0, 0,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;1, 0, 0,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;1, 0,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;1, 1, 0,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;1, 1,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;0, 1, 0,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;0, 1,<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;};<br /> <br />GLubyte index2[] = {0, 1, 3, 3, 1, 2};<br /> <br /><br /> <br />float size;<br /> <br /><br /> <br />bool running = true;<br /> <br />SDL_Event event;<br /> <br />while( running )<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;{<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;// handle all pending events<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;while( SDL_PollEvent(&event) ) {<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch (event.type) {<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case SDL_KEYDOWN: switch(event.key.keysym.sym) {<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case SDLK_ESCAPE: running = false; break;<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default: break;<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} break;<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case SDL_QUIT: running = false; break;<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default: break;<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;// render to texture bound to our pbuffer<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;eglMakeCurrent(eglDisplay, pbuffer, pbuffer, eglContext);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glViewport(0, 0, pbw, pbh);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glClearColor(1,0,1,1);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glClear(GL_COLOR_BUFFER_BIT);<br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glMatrixMode(GL_PROJECTION); glLoadIdentity();<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;size = 0.6f;<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glOrthof(-size, size, -size, size, -1.0f, 1.0f);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glMatrixMode(GL_MODELVIEW); glLoadIdentity();<br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glEnableClientState(GL_VERTEX_ARRAY);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glEnableClientState(GL_COLOR_ARRAY);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glVertexPointer(3, GL_FLOAT, sizeof(GLfloat)*7, &verts[0]);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glColorPointer(4, GL_FLOAT, sizeof(GLfloat)*7, &verts[3]);<br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glDisable(GL_TEXTURE_2D);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glPushMatrix();<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glRotatef(SDL_GetTicks() / 10.0f, 0, 0, 1);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glTranslatef(-0.5f, -0.5f, 0);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glDrawArrays(GL_TRIANGLES, 0, 3);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glPopMatrix();<br /> <br /><br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;// render textured quad using pbuffer texture<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);<br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glBindTexture(GL_TEXTURE_2D, pbuffer_texobj);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;eglBindTexImage(eglDisplay, pbuffer, EGL_BACK_BUFFER);<br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glViewport(0, 0, winw, winh);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glClearColor(0,0,0,1);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glClear(GL_COLOR_BUFFER_BIT);<br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glMatrixMode(GL_PROJECTION); glLoadIdentity();<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;size = 0.8f;<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glOrthof(-size, size, -size, size, -1.0f, 1.0f);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glMatrixMode(GL_MODELVIEW); glLoadIdentity();<br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glDisableClientState(GL_COLOR_ARRAY);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glEnableClientState(GL_VERTEX_ARRAY);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glEnableClientState(GL_TEXTURE_COORD_ARRAY);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glVertexPointer(3, GL_FLOAT, sizeof(GLfloat)*5, &verts2[0]);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat)*5, &verts2[3]);<br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glEnable(GL_TEXTURE_2D);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glColor4f(1,1,1,1);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glBindTexture(GL_TEXTURE_2D, pbuffer_texobj);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glPushMatrix();<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;//glRotatef(-(float)SDL_GetTicks() / 100.0f, 0, 0, 1);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glTranslatef(-0.5f, -0.5f, 0);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, index2);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glPopMatrix();<br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;eglReleaseTexImage(eglDisplay, pbuffer, EGL_BACK_BUFFER);<br /> <br /><br /> <br /><br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;glFlush();<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;eglSwapBuffers(eglDisplay, eglSurface);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;SDL_Delay(1);<br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /> <br /><br /> <br />eglReleaseTexImage(eglDisplay, pbuffer, EGL_BACK_BUFFER);<br /> <br />eglDestroySurface(eglDisplay, pbuffer);<br /> <br />glDeleteTextures(1, &pbuffer_texobj);<br /> <br /><br /> <br />eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);<br /> <br />eglTerminate(eglDisplay);<br /> <br /><br /> <br />SDL_Quit();<br /> <br />return 0;<br /> <br />}<br /> <br />