Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

OpenGL rendering context

Posted on 2000-04-01
9
Medium Priority
?
514 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 400 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

773 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