The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL 2.0 OpenGL ES 1.1, NDK, home bt losing the draw screen
Jared Maddox
Guest

Quote:
Date: Wed, 08 May 2013 19:20:14 -0700
From: "Timodor"
To:
Subject: [SDL] SDL 2.0 OpenGL ES 1.1, NDK, home bt losing the draw
screen
Message-ID:
Content-Type: text/plain; charset="iso-8859-1"

Hey Dudes,

I've now decided to move onto SDL 2.0 and scrapping SDL 1.2 because of
On-pause Issues and Asset-Management issues.
Since I'm doing everything in OpenGL, all I need to do is get and set the
resolution and do the events, which shouldn't be much work.
I'm hoping at the end of this assets are working fine and onPause works
perfectly. Which would mean I would have 100% working base to develop.

I just got my first OPENGL window to draw on SDL 2.0!

Seems like you need this for it to draw:

// TO CREATE SCREEN
SDL_Window *win;
win = SDL_CreateWindow("Hello World!", 100, 100, 480, 800,
SDL_WINDOW_OPENGL);

// NEEDED TO DRAW OPENGL
SDL_GLContext glcontext = SDL_GL_CreateContext(win);

//LIKE THE OLD SWAP BUUFERS FUNCTION
SDL_GL_SwapWindow(win);

It's drawing! Which is good.
But when I press the home button on the phone Android 4.0 and then go back
to it, the screen is lost. It's all BLACK. It's like it has no
SDL_GLContext;

I need to figure this out, then move onto events to make sure they also
don't get lost. Anyone have any idea why it's going back?

Code is below.


Some platforms destroy the OpenGL context (or it's textures, or...)
when the current window loses focus. I don't know that Android is one
of these, but I think it might be, and I know that this specifically
happens on some of the smart-phone OSes. The solution is to keep an
eye out for certain events, and when they happen, set a flag so that
the program will know to reinitialize part or all of it's OpenGL
configuration the next time that it makes a render pass. As a result,
I'd suggest starting on events, and just stick a note somewhere in the
event loop to remind yourself of this later on.
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
onpause
Timodor


Joined: 14 Apr 2013
Posts: 72
Location: Australia
I was trying that last night with the event, but how does one know the application is on-pause? How does the event determine that?

I also think I'm using an old version base version SDL 1.2 and SDL 2.0, maybe that's why on pause is also not working.

I'm not sure what is supposed recreated, which parts of OpenGL need to be reloaded.
SDL 2.0 OpenGL ES 1.1, NDK, home bt losing the draw screen
Jared Maddox
Guest

Quote:
Date: Thu, 09 May 2013 15:54:33 -0700
From: "Timodor"
To:
Subject: Re: [SDL] SDL 2.0 OpenGL ES 1.1, NDK, home bt losing the draw
screen
Message-ID:
Content-Type: text/plain; charset="iso-8859-1"

I was trying that last night with the event, but how does one know the
application is on-pause? How does the event determine that?

I also think I'm using an old version base version SDL 1.2 and SDL 2.0,
maybe that's why on pause is also not working.

I'm not sure what is supposed recreated, which parts of OpenGL need to be
reloaded.


I believe this is all buried in the mailing list archives. I'll try to
look it up later, but I don't have time at the moment.
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL 2.0 OpenGL ES 1.1, NDK, home bt losing the draw screen
Jared Maddox
Guest

Quote:
Date: Fri, 10 May 2013 13:04:53 -0500
From: Jared Maddox
To:
Subject: Re: [SDL] SDL 2.0 OpenGL ES 1.1, NDK, home bt losing the draw
screen
Message-ID:
<CABXS6_m_5nfLeaRX2=
Content-Type: text/plain; charset=ISO-8859-1

Quote:
Date: Thu, 09 May 2013 15:54:33 -0700
From: "Timodor"
To:
Subject: Re: [SDL] SDL 2.0 OpenGL ES 1.1, NDK, home bt losing the draw
screen
Message-ID:
Content-Type: text/plain; charset="iso-8859-1"

I was trying that last night with the event, but how does one know the
application is on-pause? How does the event determine that?

I also think I'm using an old version base version SDL 1.2 and SDL 2.0,
maybe that's why on pause is also not working.

I'm not sure what is supposed recreated, which parts of OpenGL need to be
reloaded.


I believe this is all buried in the mailing list archives. I'll try to
look it up later, but I don't have time at the moment.


Not certain that I've found the right stuff, but I didn't want to
leave this TOO long. It's mostly my hope that this will give you the
references that you need to find the info you actually want.

Firstly, make certain that you understand the "Pause / Resume
behaviour" portion of README.android ... unfortunately, I don't know
whether it's fully up to date. Why isn't anyone that currently
compiles for Android chiming in on the events/needed actions?

Next, a set of mailing list archive messages. Note that some iOS
support is relevant here. I've basically tried to just grab all of the
relevant conversations, instead of specific posts, so you'll want to
browse a little.
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2012-April/084358.html
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2012-April/084369.html
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2012-April/084445.html
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2012-May/084743.html
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2012-June/084935.html
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2012-July/084998.html
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2012-August/085378.html
http://lists.libsdl.org/pipermail/sdl-libsdl.org/2012-August/085380.html

Finally, two forum posts:
http://forums.libsdl.org/viewtopic.php?t=7926
http://forums.libsdl.org/viewtopic.php?t=7990&sid=85572573f88be2948c3f1b55be16e519

In all of that, I noticed that SDL2 is supposed to deal with this
stuff itself, but that on some versions of Android that apparently
doesn't actually work. Did you mention your Android version? Have you
checked inside the Android files for SDL2 to see what Android-specific
events and window messages are specified? What events are you actually
getting leading up to, and following, an application pause? The more
information you can provide, the more likely we are to figure out the
problem.
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Hello
Timodor


Joined: 14 Apr 2013
Posts: 72
Location: Australia
Hey Jared

Thanks for taking the time to look up that information for me.

But you know what I finally fixed it all. I suspect I was using an old version of SDL 2.0 which id downloaded from internet (which was android eclipse project) before the on pause was fixed.
Not only that assets now load from APK!!!, on pause works totally fine now. goes in and out.
The game is still running, but still there must be some type of event issue to pause the game, if no events with in 5 seconds pause game or something.
I downloaded latest SDL 2.0 Source today and complied them. I've come to the conclusion SDL 2.0 is the way to go for android. I literally jumped from SDL 1.2 to SDL 2.0 with like 5 lines of code, which was all the setting of the screen and OpenGL context. Everything else, events, mouse still using the old 1.2 commands :)

If your using OpenGL moving from SDL 1.2 and SDL 2.0 is like 5 lines of code. Which is pretty amazing.

I've had a good day today.

I guess now I need to figure out how to dodual touch. I suspect maybe it's the right mouse button instead of the left?
SDL 2.0 OpenGL ES 1.1, NDK, home bt losing the draw screen
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
Quote:
Not certain that I've found the right stuff, but I didn't want to
leave this TOO long. It's mostly my hope that this will give you the
references that you need to find the info you actually want.

Firstly, make certain that you understand the "Pause / Resume
behaviour" portion of README.android ... unfortunately, I don't know
whether it's fully up to date. Why isn't anyone that currently
compiles for Android chiming in on the events/needed actions?



I haven't because most of this stuff has already been discussed and is readily available via the forum search or Google.


 
Quote:
In all of that, I noticed that SDL2 is supposed to deal with this
stuff itself, but that on some versions of Android that apparently
doesn't actually work.


It does work AFAIK. If it doesn't, that's a bug worth reporting! Wink
 



--
Gabriel.