PDA

View Full Version : how to get started with header files



seun
08-21-2002, 01:29 PM
i have been trying my program but it has been given me wrong header file in my C++ program pls try to tell me or send me a code that can do a 2D and 3D graphics of drawing a box using windows ME operating system.

omega arts
08-25-2002, 06:32 PM
would like to help with you question but i need more information on your question like what are you asking. Like do you not know how to set up the OpenGl headers or do you need to use it with Windows if thats the case you use wglfunctions are is this a higher lvl question

fabianspring
08-25-2002, 08:05 PM
hi suen!
Do you mean that you create your own headerfiles, right? In which you write the constructions for a cube.. and then include this in your mainpart to call the classes and functions from that header right?

I am no expert about that at all, but in MSVC++6.0 it's working like this:
1. you have written the main CPP part in your workspace already (i guess you know how that works).
2. you go to insert -> files -> new -> headerfile
and give the headerfile a name... example.h
3. you open this file now and include some important headers from openGL and windows.. such as: #include <windows.h> #include <gl/opengl.h> or something like that
4. create a class, for example a class cube.
class cube:
{
private:
// private variables or functions
global:
// global stuff.. for example
void drawCube();
};
5. Now you need to "fill" the function:
cube::drawCube(void)
{
glBegin .... //your code

return 0;
}:
6. Now go back to your mainpart and include the headerfile there as well which would look like #include "example.h"
7. Make a handle (i hope thats not the wrong word)
cube CUBE;
8. call the function:
CUBE.drawcube();

So.. that's it.. sure you might make some more improvements.. like return variabled and so on. But thats the basic idea. SORRY if i made some mistakes!!
Fabian