Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie graphics question 2

Status
Not open for further replies.

MikeCox

Programmer
Jun 4, 2001
340
US
Hi!

I would like to start working on some sort of simple game in VC++, but every graphics tutorial I found on the net talks about #include "graphics.h", which only works with Borland. What is the equivelant in VC++, and how do I use it? Do I have to use MFC to draw on an object, or can I just draw a line from a console app? I'd like to be able to draw in the DOS window if possible, since I have a long way to go before MFC. Just simple stuff like lines, circles, and different colors. Also, is there an easy way to adjust the size of the DOS window when the program launches?

Thanks alot!

-Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
try using DirectX or OpenGL. Ion Filipski
1c.bmp


filipski@excite.com
 
The easiest way is to use MFC. At first try a SDI MFC AppWizard. You will find in your project a class named C...View. In this class is a method like

void C...View::OnDraw(CDC *pDC)

The CDC class is embedding almost all functions regarding graphical operations. For more details please check the MSDN documentation.

For updating the image (animation, etc.) you will use the

Invalidate();

function (called from a timer function, or whenever a new repaint is necessary).

Ofcourse, for a better performance you will need to use threads for your game's entities, and a graphical engine like DirectX or OpenGL would help to increase the speed and the graphical quality, but this means a good knowledge of Windows API (and/or MFC).

By the way, I don't think that it's possible to create a console application with graphical support.

regards,
Mawsh Krah'tchoon
 
Good stuff, Mawsh! Is *pDC a pointer to the View's DeviceContext? If so, then I think I know what I can do from there. I'll certainly check MSDN for more info, but atleast now I know where to start, and what's available (and not available). Do you recommend subclassing C...View and overloading the OnDraw method, or should I typically use the C...View the AppWizard creates?

Thanks!

-Mike Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
*pDC is a pointer to an MFC CDC object which encapsulates the device context. The m_hDC member is the handle for the device context.

The wizard creates a class derived from CView and creates an overloaded OnDraw() method. :) Hope that this helped! :)
 
Thanks, guys, I believe this is exactly what I was needing. I was pouring over MFC last nite, and wow it's big (at first anyway). Sometimes I wonder what is more to learn, syntax and tecniques, or implementing what has been made available for convenience. I suppose eventually one will catch up with the other. Meanwhile the info above clears alot of things up, and even answers a couple questions I didn't have before. Thanks again.

-Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top