Hello all,
Please forgive the basic question :)
I am a 2nd year Software Engineering Student at a local college starting to learn OpenGL. I have recently been using c and made the switch to c++ a few months ago but this is my first run into making windows proggries from scratch.
After making a few test apps I have decided to seperate my code to different files but am wondering if I am going too far. My Original thought was to have a main.cpp with only winmain, have the event handler off in its own .h/.cpp pair, a setup.cpp/.h pair that would register the class, pixelformat, etc and create the window and finally a displayFrame pair that would have all the rendering stuff.
My question is should I be seperating windows functions out to their own files or for implementation, standards, speed, etc, would it be best to keep them all in the same file?
(then I have to figure out why my handle isn't passing from one file to the next :) )
Thx all,
Nep
Proper C++ Implementation
Started by neptune3d, Apr 11 2006 12:33 PM
4 replies to this topic
#1
Posted 11 April 2006 - 12:33 PM
#2
Posted 11 April 2006 - 03:08 PM
It doesn't really matter with regards to the end result, so do what you're most comfortable with. Keep in mind that compilation times of larger files are longer of course, so a small change in a single file takes less project rebuild time than that very same change in a much larger file.
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.
-
Currently working on: the 3D engine for Tomb Raider.
#3
Posted 11 April 2006 - 05:20 PM
neptune3d said:
Hello all,
My Original thought was to have a main.cpp with only winmain, have the event handler off in its own .h/.cpp pair, a setup.cpp/.h pair that would register the class, pixelformat, etc and create the window and finally a displayFrame pair that would have all the rendering stuff.
My Original thought was to have a main.cpp with only winmain, have the event handler off in its own .h/.cpp pair, a setup.cpp/.h pair that would register the class, pixelformat, etc and create the window and finally a displayFrame pair that would have all the rendering stuff.
hi
i'm not sure i would go that far.
why dont break your problem in logical entities, and put them in separate files, something like: window.cpp, menu.cpp, scene.cpp, object3d.cpp etc.
#4
Posted 11 April 2006 - 05:25 PM
Thx folks,
The more I thought about it the more it made sense to create the window in area with all that good windows stuff with it, then create seperate functions in other files to use as reusable code for later.
Thx again.
Nep
The more I thought about it the more it made sense to create the window in area with all that good windows stuff with it, then create seperate functions in other files to use as reusable code for later.
Thx again.
Nep
#5
Posted 11 April 2006 - 07:24 PM
You may want to research object oriented design (OOD) and organize your code into a hierarchy of classes. OOD (classes) and generic programming (templates) are the major additions from vanilla C. Well, having the STL and type-safe I/O (i.e., iostreams versus sprintf et al) are nice too, but they involve templates and classes!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












