Opengl Es Segmantation Fault When Calling


Jan-Nik

Active Member
Joined
Jan 5, 2009
Messages
539
Location
Germany
I'm trying to use OpenGL ES, but I'm getting a segmentation fault when calling eglGetDisplay. I also described it here: http://www.gp32x.de/board/index.php?showtopic=47879 , but I think it's better to open a new thread.

This is my code so far:

CODE
#include <GL/egl.h>
#include <GL/libogl.h>
#include <cstdio>
#include <unistd.h>
#include <iostream>

EGLDisplay glDisplay;
EGLConfig glConfig;
EGLContext glContext;
EGLSurface glSurface;

NativeWindowType hNativeWnd = 0;

const char *gl_vendor;
const char *gl_renderer;
const char *gl_version;
const char *gl_extensions;

EGLint attrib_list[] =
{
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BUFFER_SIZE, 0,
EGL_DEPTH_SIZE, 16,
EGL_NONE
};

void Check(bool c)
{
if(c)
{
std::cout << "OK" << std::endl;
}
else
{
std::cout << "FAIL" << std::endl;
exit(1);
}
}

int main()
{
std::cout << "VID_Init: Creating the window ... " << std::flush;
hNativeWnd = OS_CreateWindow();
Check(hNativeWnd);

std::cout << "eglGetDisplay ... " << std::flush;
glDisplay = eglGetDisplay( (NativeDisplayType)0 );
Check(glDisplay != EGL_NO_DISPLAY);

std::cout << "eglInitialize ... " << std::flush;
EGLint majorVersion;
EGLint minorVersion;
Check(eglInitialize( glDisplay, &majorVersion, &minorVersion));

std::cout << "eglChooseConfig" << std::flush;
EGLint numConfigs;
Check(eglChooseConfig( glDisplay, attrib_list, &glConfig, 1, &numConfigs));

glContext = eglCreateContext( glDisplay, glConfig, NULL, NULL );
if( glContext==0 )
{
std::cout << "GL Context failed" << std::endl;
}
glSurface = eglCreateWindowSurface( glDisplay, glConfig, hNativeWnd, NULL );
if( glSurface==0 )
{
std::cout << "GL Surface failed" << std::endl;
}
std::cout << "EGL Init Completed" << std::endl;

eglMakeCurrent( glDisplay, glSurface, glSurface, glContext );

gl_vendor = (const char*)glGetString (GL_VENDOR);
printf("GL_VENDOR: %s\n", gl_vendor);
gl_renderer = (const char*)glGetString (GL_RENDERER);
printf("GL_RENDERER: %s\n", gl_renderer);

gl_version = (const char*)glGetString (GL_VERSION);
printf("GL_VERSION: %s\n", gl_version);
gl_extensions = (const char*)glGetString (GL_EXTENSIONS);
printf("GL_EXTENSIONS: %s\n", gl_extensions);

eglSwapBuffers(glDisplay,glSurface);
}


The output is this:

CODE
VID_Init: Creating the window ... OK
eglGetDisplay ... Segmentation fault


I compilied it using this command:

CODE
arm-openwiz-linux-gnu-g++ -I. -lwizGLES -L. main.cpp -lnanoGL -ldl -o opengl_test.gpe


These are the libraries I've used:

CODE
70905b27234e99827d0e5cd662726131 libnanoGL.so
beaee2c7fa509fff1624dff684de154b libwizGLES.so
ab217998d5da3eef0e824ad0ef2de645 libopengles_lite.so


Can someone help me?
 
Last edited by a moderator:
Are you sure passing 0 to eglGetDisplay is okay? I don't know what EGL_DEFAULT_DISPLAY is, but if it's not zero maybe you should try that instead.
 
Yes, this line is in egltypes.h:

CODE
#define EGL_DEFAULT_DISPLAY ((NativeDisplayType)0)
 
get gdb from the gp2x archive and run your binary, copy the gdb next to your binary

./gdb myapp

run
<if you get any exceptions from pthreads just hit c to continue, the app will still run>
<hopefully by this time the program will seg fault>
where

using where should tell us exactly where the problem occurs.

(on a side note, I found last night a rotating cube example that was leaked from GPH, I will take a look at it and see if I can get it running again.)


Edit: Jan-Nik!!! If you insist on using nanoGL, you have to use it right. You need to call the init function before you do anything with egl or es. Make sure you call the destroy function at the end too.
 
Pickle posted on May 27 2009 at 09:20 PM said:
get gdb from the gp2x archive and run your binary, copy the gdb next to your binary

./gdb myapp

run
<if you get any exceptions from pthreads just hit c to continue, the app will still run>
<hopefully by this time the program will seg fault>
where

using where should tell us exactly where the problem occurs.
How can I do that? I mean, I don't have a terminal or a keyboard on the Wiz.

QUOTE
Edit: Jan-Nik!!! If you insist on using nanoGL, you have to use it right. You need to call the init function before you do anything with egl or es. Make sure you call the destroy function at the end too.

Ah thank you!! Now it works :). Well, I don't really need nanoGL, but when linking against libopengles_lite.so I'm getting the VFP error mentioned in the other thread.
 
Last edited by a moderator:
Jan-Nik posted on May 27 2009 at 05:45 PM said:
QUOTE
Edit: Jan-Nik!!! If you insist on using nanoGL, you have to use it right. You need to call the init function before you do anything with egl or es. Make sure you call the destroy function at the end too.
Ah thank you!! Now it works :) . Well, I don't really need nanoGL, but when linking against libopengles_lite.so I'm getting the VFP error mentioned in the other thread.

Finally we are getting somewhere :)
 
Last edited by a moderator:
Back
Top