Hmmm, ok... I'll admit that I'm new to GDK, and haven't too much experience with C++, but I have played with DBP for a number of years. I have been attempting to redo a game I was working on in DBP, which involved using 360 Controllers (2 of them for co-op play to be more precise) and i was getting frames of about 50 or so with both running simultaneously. Now, with GDK, and only running a simple program which has nothing more than some text i'm getting frames of about 30... I haven't even gotten a chance to code any of the controller stuff. Why does it seem slow (or more precise, what am I doing that's MAKING it run slow)
here is the full program:
/ Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple 3D project that uses Dark GDK
// it can be used as a starting point in making your own 3D games
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include "XB360 Controller.h"
#include "Globals.h"
//XB360 Control Globals
#define VK_PAD_A 0x5800
#define VK_PAD_B 0x5801
#define VK_PAD_X 0x5802
#define VK_PAD_Y 0x5803
#define VK_PAD_RSHOULDER 0x5804
#define VK_PAD_LSHOULDER 0x5805
#define VK_PAD_LTRIGGER 0x5806
#define VK_PAD_RTRIGGER 0x5807
#define VK_PAD_DPAD_UP 0x5810
#define VK_PAD_DPAD_DOWN 0x5811
#define VK_PAD_DPAD_LEFT 0x5812
#define VK_PAD_DPAD_RIGHT 0x5813
#define VK_PAD_START 0x5814
#define VK_PAD_BACK 0x5815
#define VK_PAD_LTHUMB_PRESS 0x5816
#define VK_PAD_RTHUMB_PRESS 0x5817
#define VK_PAD_LTHUMB_UP 0x5820
#define VK_PAD_LTHUMB_DOWN 0x5821
#define VK_PAD_LTHUMB_RIGHT 0x5822
#define VK_PAD_LTHUMB_LEFT 0x5823
#define VK_PAD_LTHUMB_UPLEFT 0x5824
#define VK_PAD_LTHUMB_UPRIGHT 0x5825
#define VK_PAD_LTHUMB_DOWNRIGHT 0x5826
#define VK_PAD_LTHUMB_DOWNLEFT 0x5827
#define VK_PAD_RTHUMB_UP 0x5830
#define VK_PAD_RTHUMB_DOWN 0x5831
#define VK_PAD_RTHUMB_RIGHT 0x5832
#define VK_PAD_RTHUMB_LEFT 0x5833
#define VK_PAD_RTHUMB_UPLEFT 0x5834
#define VK_PAD_RTHUMB_UPRIGHT 0x5835
#define VK_PAD_RTHUMB_DOWNRIGHT 0x5836
#define VK_PAD_RTHUMB_DOWNLEFT 0x5837
int Control;
//Array for Texts
char txt[100];
enum eMode { eGameSetup , eControlSetup, eGameTitle, eGameEnd };
eMode g_eGameMode = eGameSetup;
// the main entry point for the application is this function
void DarkGDK ( void )
{
while ( LoopGDK ( ) )
{
dbCLS( );
Game( );
//Display FPS Other Stats
sprintf_s( txt,100,"FPS:%d",dbScreenFPS ( ) );
dbText( 10,100,txt );
// here we make a call to update the contents of the screen
dbSync( );
}
// before quitting delete our objects
// and now everything is ready to return back to Windows
return;
}
void Game( void )
{
// lets find out which game mode we are in and call the appropiate routine
// from here we can easily see the different parts that make up the game
switch ( g_eGameMode )
{
// initial setting up of the game
case eGameSetup:
GameSetup( ); break;
case eControlSetup:
ControlSetup( ); break;
case eGameTitle:
GameTitle( ); break;
}
}
void GameSetup ( void )
{
dbSetDisplayMode ( 1024 , 768 , 32 );
dbSyncOn();
dbSyncRate(100);
dbMaximiseWindow();
XB360Init( );
// turn global dead zone on
int deadzone=1;
// Set Dead Zone Percent to 25% (Note: 25% is default anyways if this command is not called )
int thumbpercent=25;
int triggerpercent=25;
XB360ThumbDeadZonePercent( 0,thumbpercent );
XB360ThumbDeadZonePercent( 1,thumbpercent );
XB360ThumbDeadZonePercent( 2,thumbpercent );
XB360ThumbDeadZonePercent( 3,thumbpercent );
XB360TriggerDeadZonePercent( 0,triggerpercent );
XB360TriggerDeadZonePercent( 1,triggerpercent );
XB360TriggerDeadZonePercent( 2,triggerpercent );
XB360TriggerDeadZonePercent( 3,triggerpercent );
// now we come to our main loop, we call LoopGDK so some internal
// work can be carried out by the GDK
XB360Poll( 1 );
// switch to game title mode
g_eGameMode = eControlSetup;
}
void ControlSetup ( void )
{
if ( XB360ControllerConnected( 0 )==0 )
Control=0;
sprintf_s( txt,256,"Controller[%d]=%d",0,XB360ControllerConnected( 0 ) );
dbText( 10, 150, txt );
if ( XB360ControllerConnected( 1 )==1 )
Control=1;
sprintf_s( txt,256,"Controller[%d]=%d",1,XB360ControllerConnected( 1 ) );
dbText( 10, 200, txt );
g_eGameMode = eGameTitle;
}
void GameTitle ( void )
{
dbSetTextFont ( "Papyrus" );
dbSetTextSize ( 96 );
dbInk(dbRGB(235,90,40),dbRGB(0,0,0));
dbText ( 510,55,"Of Nine Worlds" );
//if XB360CheckControllerConnections( == 0);
//dbText ( 400,350,"NO CONTROLLERS" );
}
void GameControls ( void )
{
// move the camera forwards
if ( dbUpKey ( ) )
dbMoveCamera ( 1 );
// move the camera backwards
if ( dbDownKey ( ) )
dbMoveCamera( -1 );
}
Are there things I should avoid using. I know someone has mentioned the switch method is not good... but I didn't understand the other method he/she described. Other than that... any thing that I could/should be doing differently?
Thanks to anyone who has taken the time to respond... P.S. I am not sure if it's the controller dll which is making it so slow, but without it... it still runs slow, and in DBP the controller addition runs fast!
www.myspace.com/norseblod