• 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
ecco_the_dolphin

wglMakeCurrent fails

11 posts in this topic

The problem is that sometimes (very-very-very rare) wglMakeCurrent(...) fails. GetLastError returns 2004 (ERROR_TRANSFORM_NOT_SUPPORTED - I dont know what this means). In the case if wglMakeCurrent fails during frame render pass, I just do nothing. The funny thing is that during next frame wglMakeCurrent succeeds and application runs fine. Could someone explain to me what the hell is going on? By the way, i use NVIDIA drivers 190.62; operating system is Windows XP.
0

Share this post


Link to post
Share on other sites
Interesting. I only call it once at start-up/on change display size.

Do you actually need to call it every frame?
0

Share this post


Link to post
Share on other sites
Yes, I call it every frame. I do this because there are several windows in my app, and I use one OpenGL context for all of them, so I need wglMakeCurrent(...) for every window I want to draw in.
0

Share this post


Link to post
Share on other sites
Is the application single-threaded?
(Update to the latest drivers too, from nvidia.com, they are at 195.x now. Shouldn't matter ofcourse but you never know, always test on latest drivers, bugs get fixed all the time).
0

Share this post


Link to post
Share on other sites
No, application is actually multithreaded (actually it is multithreaded ActiveX component). I use two OpenGL contexts: first is used for drawing into windows and second context is used by the second thread for rendering to texture (using FBO, by the way, I render not to an active texture. I mean that I actually have 2 textures, one is used by the first context and another by the second) which is used by the first context.

[Edited by - ecco_the_dolphin on December 4, 2009 5:42:26 PM]
0

Share this post


Link to post
Share on other sites
Sounds strange.. just a few ideas to check out:
Have you properly set the contexts up for sharing, through wglShareLists?
Is everything synced properly, so that you only try to use a context on one thread at once?
Read the remarks in the documentation for wglMakeCurrent.
Do you always use the same HDC to set the contexts?
I don't see what that error message means.. it says The requested transformation operation is not supported... but that doesn't really make much sense. Perhaps setting a matrix that isn't invertible or something? (If that is the type of transformation it's referring to at all). Or perhaps that error just happens to be the last one set because of a previous failure.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Erik Rufelt
Do you always use the same HDC to set the contexts?
I don't see what that error message means.. it says The requested transformation operation is not supported... but that doesn't really make much sense. Perhaps setting a matrix that isn't invertible or something? (If that is the type of transformation it's referring to at all). Or perhaps that error just happens to be the last one set because of a previous failure.


Everything is synced properly, but I dont use the same HDC to set contexts, however I use HDCs with the equal pixel formats. Moreover in Debug build i have glGetError() call after almost every OpenGL function, so everything seems fine. I dont understand how wglMakeCurrent can fail and can succeed during next frame. I mean, application can run for a week, then for one frame wglMakeCurrent fails, and then application runs as usual. I use first context ONLY by the primary thread and second context ONLY by the second thread (except of initialization procedure). I dont render to an active texture, I synchronize texture names via SendMessageCall.
0

Share this post


Link to post
Share on other sites
And before doing SendMessage to change texture names, i call glFinish() and wglMakeCurrent(0,0) by the second thread and also detach texture from FBO. Moreover whem I draw frame by the primary thread I call glBindTexture(GL_TEXUTRE_2D,0) at the end of a frame to make shure that texture is not current for the primary thread.
0

Share this post


Link to post
Share on other sites
Does it fail only on the primary thread, only on the texture rendering thread, or on both?
Can you solve it for example by a while(failed) { Sleep(10); wglMakeCurrent(...); }?
I'm mostly guessing, and I don't know how your application or ActiveX works behind the scenes, but perhaps for some reason something is changing in the background at regular (or irregular) intervals, like DC changes or something. If you call wglMakeCurrent at exactly a time in the duration of such a change, perhaps it is not able to set a current context right then.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Erik Rufelt
Does it fail only on the primary thread, only on the texture rendering thread, or on both?


It happens only on primary thread, e.g on thread that renders to ActiveX controls. I have found the following words in remarks section at wglMakeCurrent. : "GDI transformation and clipping in hdc are not supported by the rendering context." Could these be related to ERROR_TRANSFORM_NOT_SUPPORTED code? If that so, then your quess could be true. Thanks for you reply, may be I should ask microsoft about this code...However, i get my HDC only once during window creation, I set pixel format and dont release this HDC untill window is destroyed. Is it true, that if application will get ANOTHER HDC of my window, and change its settings, these changes will affect my own HDC?

Quote:
Original post by Erik Rufelt
Can you solve it for example by a while(failed) { Sleep(10); wglMakeCurrent(...); }?


I will try that, but if your quess is true, it will not help, because if application behind the scenes changes my hdc settings and than changes it back, then it happens in application message loop. During Sleep aplication does not respond to window messages.

[Edited by - ecco_the_dolphin on December 5, 2009 9:36:56 AM]
0

Share this post


Link to post
Share on other sites
Hi ecco_the_dolp[color="#284b72"]h[/color]in,
How did you solve the wglMakeCurrent fail issure in the end? I've experienced the same problem.
0

Share this post


Link to post
Share on other sites

I'd like to share a possible solution.

 

In my heavily concurrent application, I had the similar problems, though I had two possible error codes: ERROR_TRANSFORM_NOT_SUPPORTED or ERROR_INVALID_HANDLE, both appearing in an apparent in-deterministic manner, indicating a multithreading issue. I figured out that wglMakeCurrent ist *not* reentrant (at least when called on the same device context HDC, i didn't test the scenario when both, HDC and HGLRC, point to a different handle). By creating a spin-lock around wglMakeCurrent the problem disappeared for me.

Edited by gravitino
1

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