Solved

OpenGL rendering context

Posted on 2000-04-01
9
504 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
Comment Utility
just listening ..
 hi mike ;-)
0
 
LVL 10

Expert Comment

by:Lischke
Comment Utility
:-) 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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:programmerX
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I honestly hope so :-) How else can it work?

Ciao, Mike
0
 

Author Comment

by:programmerX
Comment Utility
thanx for idea...it works fine
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

12 Experts available now in Live!

Get 1:1 Help Now