blackberry / SDL

Simple DirectMedia Layer is an open-source, cross-platform multimedia library designed to provide a low level API.
GNU Lesser General Public License v2.1
86 stars 46 forks source link

Running SDL_SetVideoMode with SDL_OPENGL crashes #15

Closed jgranick closed 12 years ago

jgranick commented 12 years ago

Hi!

So far things are running well. I can initialize software through SDL just fine, but when I use the SDL_OPENGL flag, with any combination of SDL_GL_SetAttribute calls (or none at all), I always receive a crash:

eglGetDisplay: Memory fault (core dump)

I am using the "next" branch. Using the "master" branch reported an unresolved symbol ("pps_encoder_initialize") and I didn't try the "emulate" branch, because I had a feeling that was designed only for the emulator?

I tried a wide variety of calls, both complicated and simple. Here's an example of a simpler call:

screen = SDL_SetVideoMode(0, 0, 32, SDL_OPENGL);

Without SDL_OPENGL it runs just fine, but with it I receive this eglGetDisplay crash error. I'm not sure if I need to configure something differently in order to use OpenGL with this port of SDL, or not. Ideally, if the display mode is not valid, the screen will return NULL rather than crashing the application.

Thank you again! Having a full working port feels close. Thank you for creating this port of SDL... it has been hugely valuable.

asimonov-im commented 12 years ago

In general, you should be using the emulate branch since it is the primary branch of the SDL repository. The next branch is used for merging pull requests. Currently the two branches are almost identical, but nevertheless I would recommend switching to the emulate branch.

I will investigate the crash and see what I can uncover.

asimonov-im commented 12 years ago

Are your SDL and TouchControlOverlay repositories up to date?

Could you check out the following test app I put together, then build and run it from the NDK? For me it runs without a problem and outputs a yellow screen. https://github.com/asimonov-rim/SDL_GL

jgranick commented 12 years ago

It does.

Now that I've tried your application, I think the main issue is that I've been running the application from the terminal over SSH, in order to receive output from the application. After testing yours, I see that it works from the launcher but fails to initialize the display when running on the terminal.

Is there a way to receive console log output from native applications, while still running in the launcher? Is there some sort of "blackberry-log" command or something else I can use to get output?

Thank you!

asimonov-im commented 12 years ago

I am not aware of any other way for you to receive console log output. As far as I know, the only two ways are: 1) build and launch the application through the NDK, or 2) launch the application from navigator and read the log file on the device yourself

jgranick commented 12 years ago

I've been digging into this further.

I found that even your code from SDL_GL will fail and cause the same crash, when I put it into my application. I think it may be caused by the fact that the framework I am porting does not initialize SDL immediately.

When it calls SDL_SetVideoMode, eglGetDisplay returns EGL_NO_DISPLAY, instead of returning a valid handle. This occurs with both your code and with mine when either is used at the time SDL is initialized.

I commented out the error call in "SDL_playbookvideo_gl.c", which enables the application to realize it was not able to initialize OpenGL, and switch to software mode instead. I think something about calling egl_perror is causing the application to stop instead of allowing a NULL value to return.

It seems pretty straightforward... do you know of any reason why the device should not return a display when you call eglGetDisplay(EGL_DEFAULT_DISPLAY)?

jgranick commented 12 years ago

Wait... I might be close to solving it. I just changed the libraries I'm linking to (like -lGLESv1_CM instead of -lGLES_CM) and now its giving me different feedback

jgranick commented 12 years ago

http://www.joshuagranick.com/blog/2012/03/08/introducing-the-blackberry-target-for-nme/