Gles1/2 trouble ( sdl2 ubuntu 13.04 GT 440 )

Hi. I try to use gles1/2 within sdl2, but something is going wrong.

#include <SDL2/SDL.h>
#include <SDL2/SDL_opengles2.h>

Code:
int main(int argc, char **argv) {
SDL_Init(SDL_INIT_VIDEO);

SDL_Window* w=SDL_CreateWindow(
    "Hello SDL2!",
     100,
     100,
     400,
     200,
     SDL_WINDOW_OPENGL);

SDL_GLContext c=SDL_GL_CreateContext(w);

glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(w);

SDL_Delay(2000);

SDL_GL_DeleteContext(c);
SDL_DestroyWindow(w);

return 0;

}

Code:
gcc ./main2.c -o main2 -lSDL2 -lGLESv2

I expect to get a window with white background, but it seems not initialized.
Where could be a problem?

p.s. app linked with libgl works fine (window with white backgound)

Code:
gcc ./main2.c -o main2 -lSDL2 -lGL

Did you build libSDL2 with support for both GLX and EGL? If you did, then
it’s defaulting to use GLX for the context operations, and calls to the
GLES libraries will do nothing.

You can force SDL to use EGL with GLES2 by setting the following GL
attributes before creating a window:

SDL_GL_SetAttribute( SDL_GL_CONTEXT_EGL, 1 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 2
);SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 0 );On 19 June 2013 02:32, sdl2devel <ilja.ryndin at gmail.com> wrote:

**
Hi. I try to use gles1/2 within sdl2, but something is going wrong.

#include **
#include **

Code:

int main(int argc, char **argv) {
SDL_Init(SDL_INIT_VIDEO);

SDL_Window* w=SDL_CreateWindow(
    "Hello SDL2!",
     100,
     100,
     400,
     200,
     SDL_WINDOW_OPENGL);

SDL_GLContext c=SDL_GL_CreateContext(w);

glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(w);

SDL_Delay(2000);

SDL_GL_DeleteContext(c);
SDL_DestroyWindow(w);

return 0;

}

Code:

gcc ./main2.c -o main2 -lSDL2 -lGLESv2

I expect to get a window with white background, but it seems not
initialized.
Where could be a problem?

p.s. app linked with libgl works fine (window with white backgound)

Code:

gcc ./main2.c -o main2 -lSDL2 -lGL


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Scott Percival wrote:

Did you build libSDL2 with support for both GLX and EGL? If you did, then it’s defaulting to use GLX for the context operations, and calls to the GLES libraries will do nothing.

Thank you, Scott! :slight_smile: I built libSDL2 with --disable-video-opengl and now everything works.