• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Lode

Knowing whether or not SDL_SetVideoMode destroyed the OpenGL context

4 posts in this topic

For SDL 1.2: On Windows, SDL_SetVideoMode destroys the OpenGL context, on Linux it does not. So in Windows, all textures have to be updated to the video card again, on Linux not. I even think doing that would give a memory leak in the video RAM on Linux because of not deleting the textures first (when the context is destroyed they get deleted automatically). Currently, I use an "#if defined(_WIN32)" to detect the difference. But is there a more portable way to detect with SDL whether or not it destroyed the OpenGL context? Is there a way to get a pointer or something to "the OpenGL context" and see whether or not it's different? Or an SDL function equivalent to "SDL_DeletesOpenGLContextOnVideoResizeOnCurrentPlatform" (didn't find any). The SDL_Surface* pointer returned by SDL_SetVideoMode turns out to remain the same, so that pointer doesn't represent the opengl context.
0

Share this post


Link to post
Share on other sites
I don't know the answer, but I know this has been discussed fairly recently on the SDL forums (with respect to 1.3, I believe), so you might try doing a search over there, if you haven't already.
0

Share this post


Link to post
Share on other sites
What version of SDL 1.2 do you have? I recall this being an issue a few months ago, and there was a patch to prevent context loss where possible (I think it still occurs when switching to and from fullscreen).

The latest 1.2 build *should* have this fix, you can probably just drop in SDL.dll and see if it happens as often.

As jyk alluded to, there is some discussion on the mailing list (Brian = me) about adding an event or other notification mechanism when the context is lost. AFAIK there is no implementation work done on this yet.
0

Share this post


Link to post
Share on other sites
I'm using the latest version of SDL 1.2 on Linux at least (sdl-1.2.14), on Windows probably not but I can try that if I'm booted in it some next time. But that only makes it worse! If different versions of SDL 1.2 do or do not delete the OpenGL context on Windows, how can I ever know what it's going to be and whether or not the textures need to be recreated? I was just thinking I could rely on the predictable "win32 = they get deleted, linux = they don't".

Future features of SDL are great, but this program is supposed to be running right now!

I'm not using SDL 1.3 yet simply because it's not finished yet (and will be excited - but also have some work - when it is).

A related question: what would happen if the GL context is destroyed, a new one is created instead, and I'd do "glDeleteTextures" on some textures that were created on that previous context? I mean, to prevent memory leak in case that the context was NOT destroyed I'd have to use glDeleteTextures. But to be honest, I'm not entirely sure how exactly the relationship between these contexts, the SDL surface, the graphics card and OpenGL works, so please excuse me if the question makes no sense...

Might there be some "gl" function calls to get the info I need? (whether or not the current context is the same as earlier).
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Lode
A related question: what would happen if the GL context is destroyed, a new one is created instead, and I'd do "glDeleteTextures" on some textures that were created on that previous context?


Use glIsTexture on a texture ID to find out whether or not the current state machine is holding a texture object bound to the ID. If the context is destroyed, though, the state machine shouldn't be holding any old texture IDs. I'm not sure what calling glDeleteTextures on an ID that doesn't exist in the state machine would do, but if you plan on going that route, at least check it with glIsTexture before trying it.

(Although, it might be that in the case of Windows losing the context, the texture is "corrupted" but still maintained with an ID. I haven't tested it personally so I can't say.)

Also, in response to the original post... couldn't you just play it safe and add some code to delete and reload all your textures just in case? Or do you really want to take advantage of that extra little bit of efficiency on Linux?

I mean, I know it's a bit of a pain, but unless you're planning on sticking it out til a 1.3 polished release, it's probably best to follow the advice given in this article.

[Edited by - cmc5788 on January 3, 2010 5:00:11 PM]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0