Solved

OpenGL rendering context

Posted on 2000-04-01
9
509 Views
Last Modified: 2010-04-04
why i can create opengl rendering context only once (without closing my program).
When i start it 1st time, all is ok, but if i try to close opengl window (of course, i deactivate context, delete rendering context and release device context) and run it 2nd time without restarting whole application , i have error (zero result on wglCreateContext).
This error appear on new 3d-cards (all nvidia riva series)
0
Comment
Question by:programmerX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2676263
just listening ..
 hi mike ;-)
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2676423
:-) Hi Barry,
hi programmerX,

now that I managed after days of delay to log into E-E again, I can finally answer questions again. Quite happy about that :-) (non-cookie login does not work yet and I hate cookies :-().

Now to the question. What I need is a bit more information. You should be aware that MS explicitly states that you cannot set a pixel format twice for any DC. Hence, if you need to recreate a RC then do it without setting the pixel format again.

Ciao, Mike
0
 

Author Comment

by:programmerX
ID: 2677105
hi Mike,
it's sounds nice, but what i can do if user choose another pixel format for second start? (for example, he can choose new color depth).
My code looks like this:
    VideoHandle:={some window}.Handle;
    DC:=GetDeviceContext(VideoHandle);
    SetDCPixelFormat;
    RC := wglCreateContext(DC);
    wglMakeCurrent(DC, RC);
    ...
    {drawing here}
    ...
    wglMakeCurrent(DC, RC);
    wglDeleteContext(RC);
    ReleaseDC(VideoHandle, DC);
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:programmerX
ID: 2677107
hi Mike,
it's sounds nice, but what i can do if user choose another pixel format for second start? (for example, he can choose new color depth).
My code looks like this:
    VideoHandle:={some window}.Handle;
    DC:=GetDeviceContext(VideoHandle);
    SetDCPixelFormat;
    RC := wglCreateContext(DC);
    wglMakeCurrent(DC, RC);
    ...
    {drawing here}
    ...
    wglMakeCurrent(DC, RC);
    wglDeleteContext(RC);
    ReleaseDC(VideoHandle, DC);
0
 

Author Comment

by:programmerX
ID: 2677111
i forgot to add:
  my program can run in windowed and fullscreen mode. To change video-mode (fullscreen) I choose it with ChangeDisplaySettings function
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2677289
Well, that's the sad thing about OpenGL under Windows. The fact that you cannot reset the pixel format has caused many problems in the past. Somehow it must be possible, though, to reset a device context such that it appears to be like newly allocated, because you can restart your program, it will allocate a DC and for this a valid rendering context can be created. Perhaps playing around with the class styles for the window carrying the RC and GetDCEx will expose a workaround?

Ciao, Mike
0
 

Author Comment

by:programmerX
ID: 2677452
i'll try to add this code in opengl finalization:
 {somewindow}.Free;
 {somewindow}:={somewindow}.Create;
Can this code reset DC?
0
 
LVL 10

Accepted Solution

by:
Lischke earned 100 total points
ID: 2678103
I honestly hope so :-) How else can it work?

Ciao, Mike
0
 

Author Comment

by:programmerX
ID: 2688623
thanx for idea...it works fine
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question