Brett Baisley said:
I don't really understand what you meant by:
but thats ok.
This looks weird to my eyes:
#include <stdio.h>
#include <stdlib.h>
#include "glut.h"
#define WINDOW_HEIGHT 256
#define WINDOW_WIDTH 256
#include "init.cpp"
#include "myMouse.cpp"
#include "myDisplay.cpp"
#include "main.cpp"
The way I see it, the source files init, myMouse, myDisplay and main are
each modules in their own right. They should be compiled separately. The way
the example is written, a change to anything requires a recompilation of
everything. No sane person who uses a compiler for much of the day would
adopt such a ridiculous style. In the real world modules and projects get
big in a hurry. The last thing you want to be doing is to be recompilng the
entire project to fix every bug or to make every change. That's why I called
your prof a bonehead.
Take the main module:
main(int argc, char **argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE |
GLUT_RGB);
glutInitWindowSize(WINDOW_WIDTH,
WINDOW_HEIGHT);
glutInitWindowPosition(100,150);
glutCreateWindow("OpenGL window");
glutDisplayFunc(myDisplay);
glutMouseFunc(myMouse);
myInit();
coordInit();
glutMainLoop();
}
It looks weird roo. That's because it references external functions, e.g.
glutInit(), and constants, e.g. GLUT_SINGLE, yet there is no way these names
can be declared. No C or C++ compiler could successfully compile this
module. However, if it were rewritten like so
#include <stdio.h>
#include <stdlib.h>
#include "glut.h"
#define WINDOW_HEIGHT 256
#define WINDOW_WIDTH 256
main(int argc, char **argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE |
GLUT_RGB);
glutInitWindowSize(WINDOW_WIDTH,
WINDOW_HEIGHT);
glutInitWindowPosition(100,150);
glutCreateWindow("OpenGL window");
glutDisplayFunc(myDisplay);
glutMouseFunc(myMouse);
myInit();
coordInit();
glutMainLoop();
}
then those names would be declared before they are referenced and the module
could compile separately. If you change the source files of the sample in
this way then they each could be added to the project individually. The IDE
would know to compile modules needing recompilation and not compile the
others.
This is a OpenGL program, it doesn't use any Microsoft code for windows.
Ah, to be young.
Whatever it is, GLUT is a layer _on top of_ the native
windowing system. On Windows, you code to GLUT, GLUT codes to the Graphics
Device Interface (GDI).
The click is actually there on purpose to demonstrate how
input from a mouse in OpenGL works. If you look at the points example, you
would see that it actually makes a 20x20 pixel rectangle using the point on
the window of the mouse click as its starting point. Its kinda cool.
OK, I'll accept that it is just a teaching device. But in my view, there is
no use in porting code if to do so is to scream out loud that the author
(not you!!! - I mean your prof or the author of GLUT ) doesn't know or care
about the native behaviors of the platform. If you obsure the OpenGL window
by dragging another window over it and then uncover the OpenGL window it
does not know enough to repaint itself. Instead it contains the remnants of
other windows. That looks ugly and unprofessional.
That's what I was referring to when I mentioned the structure of windowed
programs and the work left to do to complete a proper port.
I was just sick of the lab computers, they never work right, so I wanted to
get this working at home, so I can work on my homework here instead of the
lab.
Yup. That's exactly like the perspective of my niece.
I am still not sure how to get it working so that F5 will build and run the
program, but now at least I can manage. To me, all files included in the
solution should be compiled as one big thing, so as long as they are all
listed in the solution, they should be able to find/reference each other.
But that might not be how it works.
No, this is definitely not how it works, not with MS VS.Net, not with
Borland's C++ Builder. Each source file gets compiled independently.
Nevertheless, there should be no problem with a one file project
(rectangle.cpp) as long as the other files are in the same directory. It
works here.
Regards,
Will