Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Alusair

GDI Failure error from Borland C++ 5

This topic is 6030 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I''m somewhat new to game programming, having next to no experience with Windows programming. for the last few weeks, I''ve been reading Tricks of the Windows Game Programming Gurus and recently finished the chapters on GDI. All of these programs compile fine on my computer. However, when I tried to do some of my own work I would get an error whenever I tried to move the window or close it. When I do either I get a message box with "Object Windows Exception", "GDI Failure." I click OK and I then get several dozen page faults and Borland closes. For code, I''m basically using the base file from the end of Chapter 4. The error appears if all I do is create one brush and pen and try to draw a rectangle. Basically, I am wondering what this error is and if its my compiler or if this could happen on some other compiler, be it VC++ or some other one.

Share this post


Link to post
Share on other sites
Advertisement
Are you checking the return values of the function calls that create the brush and pen? They may be failing and then you might be trying to use invalid values in later function calls.

Steve ''Sly'' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers

Share this post


Link to post
Share on other sites
The chapter deals with mainly drawing pixels, lines, polygons, ellipses, and rectangles using GDI from Windows.
Below are the main lines that I''m using to do the drawing, taken pretty much word for word from the book. I simply changed some of the values.

hdc = GetDC(hwnd);

red_pen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
black_brush = CreateSolidBrush(RGB(255, 255, 255));
SelectObject(hdc, red_pen);
SelectObject(hdc, black_brush);

Rectangle(hdc, 0, 0, 133, 133);

ReleaseDC(hwnd, hdc);

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!