topical media & game development

talk show tell print

lib-game-darkgdk-samples-FX-Main.cpp / cpp



  
  // Dark GDK - The Game Creators - www.thegamecreators.com
  
  // include Dark GDK header file
  include <DarkGDK.h>
  
  // main entry point for program
  void DarkGDK ( void )
  {
          // switch to the media directory
          dbSetDir ( "media\\media" );
  
          // set program properties
          dbSyncOn   ( );
          dbSyncRate ( 0 );
          dbAutoCamOff ( );
  
          // load effects files with their objects
          dbSetEffectOn ( 1, "bubble\\bubble.fx", 1 );
          dbSetEffectOn ( 2, "aniso\\aniso.fx", 1 );
          dbSetEffectOn ( 3, "cartoon\\cartoon.fx", 1 );
          dbSetEffectOn ( 4, "rainbow\\rainbow.fx", 1 );
          
          // adjust scales
          dbScaleObject ( 4, 1.5f, 1.5f, 1.5f );
          dbScaleObject ( 3, 7, 7, 7 );
  
          // position objects
          dbPositionObject ( 1,  1.5f, 0, 0 );
          dbPositionObject ( 2, 0, -1.0, 0 );
          dbPositionObject ( 3, -0.2f, 1.5f, 0 );
          dbPositionObject ( 4, -1.5f, 0, 0 );
  
          // make sky boxes
          dbLoadObject ( "sky\\skybox2.x", 5 );
          dbSetObjectTexture ( 5, 3, 1 );
          dbSetAmbientLight ( 90 );
  
          // move camera back
          dbMoveCamera ( -4 );
  
          // main loop
          while ( LoopGDK ( ) )
          {
                  // quit out on escape key
                  if ( dbEscapeKey ( ) )
                          return;
  
                  // rotate our objects
                  dbRotateObject ( 2, 0.0f, dbObjectAngleY ( 2 ) + 0.1f, 0.0f );
                  dbRotateObject ( 3, dbObjectAngleX ( 3 ) + 0.1f, dbObjectAngleY ( 3 ) + 0.1f, dbObjectAngleZ ( 3 ) + 0.1f );
                  dbRotateObject ( 4, dbObjectAngleX ( 4 ) + 0.1f, dbObjectAngleY ( 4 ) + 0.1f, dbObjectAngleZ ( 4 ) + 0.1f );
                  dbRotateObject ( 5, 0.0f, dbObjectAngleY ( 5 ) + 0.01f, 0.0f );
  
                  // print some text
                  dbText ( 20, dbScreenHeight ( ) - 40, "Using FX shaders" );
  
                  // update our screen
                  dbSync ( );
          }
  }


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.