Solved

OpenGL rendering context

Posted on 2000-04-01
9
511 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

617 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