Sign in to follow this  
Dragon_Lance

Two Source File help?

Recommended Posts

Hi, heres my problem. I want to make things clean and tidy in my code by putting code that, lets say, makes the window maximize and other window functions. In my other source file I have stuff that, lets say, adds stuff to the screen. Well the Source file that adds stuff to the screen is the only one that works. The other one doesn't. I am using Dark GDK. Heres an example Of what I'm talking about: Source File - Windows.cpp ======================================== #include "Windows.h" void Windows ( void ) { dbMaximizeWindow (); // Self Explanitory dbSetWindowTitle ( "FPS" ); // Sets Window Title dbSetWindowLayout ( 0, 0, 1 ); // Removes the window bar up at the top of the window } ========================================== Source File - Main.cpp ======================================== #include "Include.h" #include "Globals.h" bool GameStart = false; void DarkGDK ( void ) { ///////////////////////////// ///////// Settings ///////// ///////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////// /* /// Variable Settings /// */ int ScreenHeightHalf = dbScreenHeight() /2; // Height of Screen Halved int ScreenWidthHalf = dbScreenWidth() /2; // Width of Screen Halved /* /// Terrain Settings /// */ dbMakeMatrix ( 1000, 1000, 1000, 1, 1); // Makes a 3D world /* /// Model Settings /// */ dbMakeObjectBox ( 1, 50, 50, 50 ); // Self Explanitory /* /// Mouse Settings /// */ dbHideMouse (); // Self Explanitory //////////////////////////////////////////////////////////////////////////////////////////////////////////// dbSyncOn ( ); dbSyncRate ( 60 ); /* /// Main Loop /// */ while ( LoopGDK ( ) ) { if (GameStart == true) { dbPositionMouse ( ScreenWidthHalf , ScreenHeightHalf ); } /* /// Mouse Detections Temp /// */ if (dbMouseClick () == 1 ) { GameStart = true; } if (dbMouseClick () == 2 ) { GameStart = false; } /* /// Control Via Arrow Keys /// */ dbControlCameraUsingArrowKeys(0,2.0f,2.0f); /* /// Sync-To-Screen /// */ dbSync ( ); } return; } ======================================== (Ignore how the code looks atm. I'm still playing around with Dark GDK and separating out my code) Can anyone tell me why my Windows.cpp code inst working while my Main.cpp is? P.S. void Windows (void) is actually my mains initializer just changed. It compiles fine it just doesn't do anything. If you need any more info please let me know My guess is it is a linking problem but I don't know [Edited by - Dragon_Lance on August 15, 2009 7:49:51 PM]

Share this post


Link to post
Share on other sites
The problem is that you're never calling that Windows() function. DarkGDK() is the programs entry point, right? Then call Windows() from within that function. For main.cpp to know about it, it also need to include Windows.h (assuming that that's the header that contains a definition of your Windows() function).

On a sidenote, you may want to change that filename. windows.h is related to Windows, the operating system, so it's better to avoid confusion and possible include problems.


Bytheway, for source code, you should use the [source] [/source] tags. They preserve formatting and make posts easier to read. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this