Problems with Opengl ES 2.0

Hi,

I’ve been googling for a couple of days now but cannot find the reason why my code is not working. I’m trying to create a very basic application with SDL 2.0 and Opengl ES 2.0 that will run in a Windows 7 machine.
Since Windows 7 doesn’t support OpenGL ES 2.0 natively, I’ve downloaded and compiled Angle project to be able to use OpenGL ES 2.0 calls.
I’m sure that the Angle binaries work because i used a plain old Windows forms application to test it and could render a texture.
I was not happy with the windows forms executable since I am aiming to port my app to Android, IOS and Linux.
I’m using mingw to link and compile (not a big fan of visual studio, at all).

I’ve been testing a lot of variations from what I’ve been seen while googling but so far no success :frowning:
The problem is this:
My application compiles and links, and display the strings:
GL_VERSION: OpenGL ES 2.0 (ANGLE 1.2.0.2450)
GL_SHADING_LANGUAGE_VERSION: OpenGL ES GLSL ES 1.00 (ANGLE 1.2.0.2450)
when it runs, but then it doesn’t draw any color afterwards. Just displays a window with a black background.
I have not found any simple example of an SDL 2.0 + Opengl ES 2.0 application yet, neither.
Any clues will be appreciated

Here’s the code:----------------------------

Code:

#include <stdio.h>
#include <assert.h>

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

int main(int _nArg, char *_aArg[])
{
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

assert(SDL_Init(SDL_INIT_EVERYTHING) == 0); 

SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

SDL_Window * oWindow = SDL_CreateWindow("Default", 100, 100, 320, 480, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
assert(oWindow);
SDL_GLContext oGlContext = SDL_GL_CreateContext(oWindow);
assert(oGlContext);
SDL_GL_MakeCurrent(oWindow, oGlContext);

printf("GL_VERSION: %s\n", reinterpret_cast<const char *>(glGetString(GL_VERSION)));
printf("GL_SHADING_LANGUAGE_VERSION: %s\n", reinterpret_cast<const char *>(glGetString(GL_SHADING_LANGUAGE_VERSION)));

/* Clear our buffer with a red background */
glViewport(0, 0, 320, 480);
glClearColor(1, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(oWindow);
SDL_Delay(3000);
SDL_GL_DeleteContext(oGlContext);
SDL_DestroyWindow(oWindow);

SDL_Quit();
return 0;

}

Thanks beforehand!


When you run on the earth and run with the earth, you can run forever.

Have you tried running testgles2? Does that work?

Also, try setting SDL_GL_CONTEXT_MINOR_VERSION to 0. Any other errors in
the console?

2013/12/19 hiramegl > Hi,

I’ve been googling for a couple of days now but cannot find the reason why
my code is not working. I’m trying to create a very basic application with
SDL 2.0 and Opengl ES 2.0 that will run in a Windows 7 machine.
Since Windows 7 doesn’t support OpenGL ES 2.0 natively, I’ve downloaded
and compiled Angle project to be able to use OpenGL ES 2.0 calls.
I’m sure that the Angle binaries work because i used a plain old Windows
forms application to test it and could render a texture.
I was not happy with the windows forms executable since I am aiming to
port my app to Android, IOS and Linux.
I’m using mingw to link and compile (not a big fan of visual studio, at
all).

I’ve been testing a lot of variations from what I’ve been seen while
googling but so far no success [image: Sad]
The problem is this:
My application compiles and links, and display the strings:
GL_VERSION: OpenGL ES 2.0 (ANGLE 1.2.0.2450)
GL_SHADING_LANGUAGE_VERSION: OpenGL ES GLSL ES 1.00 (ANGLE 1.2.0.2450)
when it runs, but then it doesn’t draw any color afterwards. Just displays
a window with a black background.
I have not found any simple example of an SDL 2.0 + Opengl ES 2.0
application yet, neither.
Any clues will be appreciated

Here’s the code:

Code:

#include
#include

#include
#include

int main(int _nArg, char *_aArg[])
{
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

assert(SDL_Init(SDL_INIT_EVERYTHING) == 0);

SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

SDL_Window * oWindow = SDL_CreateWindow("Default", 100, 100, 320, 480,

SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
assert(oWindow);
SDL_GLContext oGlContext = SDL_GL_CreateContext(oWindow);
assert(oGlContext);
SDL_GL_MakeCurrent(oWindow, oGlContext);

printf("GL_VERSION: %s\n", reinterpret_cast(glGetString(GL_VERSION)));
printf("GL_SHADING_LANGUAGE_VERSION: %s\n", reinterpret_cast

(glGetString(GL_SHADING_LANGUAGE_VERSION)));

/* Clear our buffer with a red background */
glViewport(0, 0, 320, 480);
glClearColor(1, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(oWindow);
SDL_Delay(3000);
SDL_GL_DeleteContext(oGlContext);
SDL_DestroyWindow(oWindow);

SDL_Quit();
return 0;

}

Thanks beforehand!


When you run on the earth and run with the earth, you can run forever.


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


Gabriel.