View Full Version : wglMakeCurrent: problem with ati graphic card
10-14-2009, 12:14 AM
I'm an intern and my task is to find a bug in an opengl program, which saves a screenshot of an opengl object in a .bmp format.
On a computer with a nvidia graphic card it is no problem, but on a laptop with an ati graphic card, there is a little problem.
Whenever it calls the wglMakeCurrent(m_hdc, m_hGLrc); function, it gives me an exception.
"0xC0000005:Zugriffsverletzung beim Lesen an Position x00000120" Translation: :-)
"00xC0000005:Access Violation while reading position 0x00000120"
(The graphic card is an ati mobility radeon x300)
But as mentioned on the nvidia computer everything works. :(
Does anyone know this problem, or even has a solution for it?
I am thankful for any kind of help.
10-14-2009, 02:20 AM
Probably it's a driver bug. Can you send us some source code listing?
10-14-2009, 04:55 AM
view->get_viewport( x, y, width, height );
int WindowWidth = 4096;
int WindowHeight = 4096;
int MaxTextureSize = 0;
int MaxFrameSize = 0;
if ( MaxTextureSize < WindowWidth ) WindowWidth = MaxTextureSize;
if ( MaxTextureSize < WindowHeight ) WindowHeight = MaxTextureSize;
if ( MaxFrameSize < WindowWidth ) WindowWidth = MaxFrameSize;
if ( MaxFrameSize < WindowHeight ) WindowHeight = MaxFrameSize;
// allocate final image buffer
GLubyte* image = reinterpret_cast<GLubyte*>( malloc( WindowWidth * WindowHeight * 3 ) );
GLubyte* cimage = reinterpret_cast<GLubyte*>( malloc( WindowWidth * WindowHeight * 3 ) );
clGLFrameBuffer* FrameBuffer = new clGLFrameBuffer( WindowWidth, WindowHeight, 8, true );
glGenFramebuffersEXT( 1, &FFrameBuffer );
void clGLFrameBuffer::BindRenderTarget(int TargetIndex) const
After this call my program calls this “make_current”-function and delivers me my "00xC0000005:Access Violation while reading position 0x00000120"-error.
void gl_context_data::make_current( view3d *view )
I hope that this little extract can illustrate the problem a little bit.
10-14-2009, 05:29 AM
OK. I'm interested in the code which gets the DC of the window and creates the RC.
10-14-2009, 06:41 AM
Ok. I hope this is the right thing
if( m_hdc == NULL)
m_hdc = CreateCompatibleDC( NULL);
if( m_hdc == NULL)
m_hGLrc = wglCreateContext(m_hdc);
10-14-2009, 08:28 AM
Seems that you use a NULL as the parameter to CreateCompatibleDC. You know that it won't create a DC for your window, but rather it will create a memory device context?
Are you sure that you want to do here?
If think the created rendering context then maybe can be invalid, that's why the exception. Btw it's still a driver bug that it not gracefully returns an error code instead of crashing, but I suppose there is some problem also in your code.
10-15-2009, 02:46 AM
Ok, first of all: Thanks for your help!
So if that is the problem, how can I create a DC for my window, rather than a memory device context?
I have tried to understand it, but I don't get it :-)
10-15-2009, 06:38 AM
Use the WinAPI function GetDC which has as parameter the handle for the window. For an on-screen context (actually for the context of the window), this should be used. After that request a rendering context in the same way as before just use the device context got from GetDC.
For a thorough and much more advanced context creation tutorial, check this:
10-16-2009, 05:27 AM
Ok. I am now pretty sure, that there is a problem with the drivers. They don't seem to support fbo.
My question is now, is there a possibility to solve this problem, without installing new drivers? Because the problem is, you can't tell the customers, that they have to install new drivers. Has somebody an idea of a solution? Thx
10-16-2009, 05:53 AM
There is no other possibility. If a driver does not support FBO then you cannot use it.
Usually softwares have in their documentation that latest drivers are required to run the software.
On the other hand you can create some limited fallback of FBOs using pbuffers but I don't advice that, since that functionality is quite deprecated and limited.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.