Solved

OpenGL rendering context

Posted on 2000-04-01
9
505 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now