From: swarsmatt AT aol DOT com (SWars Matt) Newsgroups: comp.os.msdos.djgpp Subject: Windows protection error in graphics program?? Lines: 29 Message-ID: <1998062801190800.VAA10894@ladder03.news.aol.com> NNTP-Posting-Host: ladder03.news.aol.com Date: 28 Jun 1998 01:19:08 GMT Organization: AOL http://www.aol.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I've started designing a C++ class library for graphics routines with DJGPP. I have a base class, grafix, which performs clipping and has routines for drawing lines, circles, etc., all of which call the function putpixel, a pure virtual function. My plan was to have derived classes define the putpixel function and use base class functions for the rest. I have a derived class, mode 13h, which sets mode 13h in the constructor, and mode 3h in the destructor. This is done using a __dpmi_regs structure r with r.x.ax set to 0x13 (or 0x03 for text mode) and calling __dpmi_int(0x10, &r). The mode13h class defines a putpixel function using _farpokeb calls. I wrote a test program which creates a mode 13h object, randomly draws pixels, lines, rectangles, circles, etc., then, when a key is pressed, exits. All of the graphics look fine (I'm running this full-screen from a Windows95 DOS box), but when the program exits, I get a "Windows protection error" and the computer restarts. I'm not sure what's causing the problem. It appears to be at the very end of the program. Also, it doesn't happen on all Windows 95 machines. I wrote another test program, not object-oriented, which just calls a function setgfxmode to set mode 13h, then, in a for loop, calls putpixel(i,j,i&j&255) for all points (i,j) on the screen. The program then waits for a keypress and sets text mode (3h). This program does not generate Windows protection errors. What's the difference? The only thing I could think of was that no destructor is being called. The destructor for my base class, grafix, was virtual because I plan on doing memory allocation in derived classes. I tried making it not virtual, but that didn't fix anything. Also, when I commented out the line __dpmi_int(0x10, &r) in the destructor of the mode13h class, I still got the protection error message, so the problem isn't in the mode being set upon exit. I have no idea what's going wrong. Can anyone help? Thanks. ____________________________________________ Matt Reece (swarsmatt AT aol DOT com) ____________________________________________