Make games that sell. |  |
| download
| order now
KWindow
> Introduction
> Examples
> Showcase
> Documentation
| KWindow
| KGraphic
| KMiscTools
| KInput
| KText
| KTrueText
| KSpline
| KWeb
| KIniReader
| KResource
| K3D
| KSound
| KSound2
> History
> Download
> FAQ
> Credits
KWindow : #include "KWindow.h" KWindow *gameWindow = KPTK::createKWindow( K_OPENGL or K_DIRECTX ) K_OPENGL to use openGL rendering. K_DIRECTX to use D3D 7 rendering. K_DIRECTX will use openGL on Mac os X. | Quick Reference createGameWindow flipBackBuffer getAccelerationCap getWindowHandle hasFocus isQuit minimize processEvents saveBackBuffer setCallBack setClearColor setPTKCallback setGamma setMaxFrameRate setRectangleTexCap setDefaultWorldView setWorldView setTitle terminate toggleFullScreen
bool createGameWindow( short width , short height , short depth , bool windowed , const char *windowTitle ) ;
Call this function once at the beginning at your program, it will initialize openGL and create a window for your game. width = width of the client area of the window height = height of the client area of the window depth = bpp of the screen ( note in windowed it will change the desktop depth to the requested bpp, if you don't want that to happen pass -1 as a parameter it'll use the desktop settings ) windowed = true create a window, false launch the game fullscreen windowTitle is the title you want to give to the window, this parameter is optional. Example : KWindow *mysuperGameWindow = NULL ; mysuperGameWindow = KPTK::createKWindow( K_OPENGL ) ; mysuperGameWindow->createGameWindow( 640,480,16,true,"My Game will rock!" ) ; to end the life of the window and wait for events to be processed, we recommand that you call : mysuperGameWindow->terminate() ; Then delete mysuperGameWindow ; mysuperGameWindow = NULL ;
void setMaxFrameRate( long desiredFrameRate )
Defines the maximum frame rate for the game. If the video card doesn't support VSync this will "slow down" your game to try to match the desired rate. Passing a value of -1 switches to "unlimited" speed mode. ( no vsync, no wait ) Passing a value of 0 doesn't lock the max frame rate but vsyncs the display Example : mysuperGameWindow->setMaxFrameRate( 75 ) ; //max 75 fps
static void setClearColor( float r,float g , float b , float alpha ) ;
Sets the default clear color. Color componant ranges from 0 to 1 Example : gameWindow->setClearColor( 1,0,0,1 ) ; //red clear color
void setDefaultWorldView( void ) ;
Call this at least once before you start rendering. It resets the transformation matrix. Example : gameWindow->setDefaultWorldView( ) ; //resets the transformation matrix drawMyGame( ) ; // draws the game gameWindow->flipBackBuffer() ; //display the drawing
void setWorldView( float translateX , float translateY , float rotation , float zoom, bool clearworld ) ;
Call this function before rendering your drawing if you want to transform the whole world. ( zoom or rotate the whole game field for example ) translateX = translate the display by X pixels horizontally translateY = translate the display by Y pixels vertically rotation = rotate the screen zoom = zoom the content of the screen clearworld = clears the screen with the default color ( like a cls ) Example : gameWindow->setClearColor( 1,0,0,1 ) ; gameWindow->setWorldView( 0 , 0 , 30 , 1 , true ) // clears the screen in red and rotates the world by 30 degrees
bool saveBackBuffer( const char *fileName , long imageFormat = 0 , long resizeW =0, long resizeH =0 ) ;
Saves the backBuffer in the specified format. you can also resize the picture to do thumbnails for example. #define K_IMAGE_BMP 0 #define K_IMAGE_JPG 1 #define K_IMAGE_TGA 2 #define K_IMAGE_PNG 3 Example : gameWindow->saveBackBuffer( KMiscTools::makeFilePath( "screenshot.tga" ) , K_IMAGE_TGA , 320,240 ) ;
void setGamma( float gamma )
changes the gamma of the display. gamma ranges from 0 to 1 note that it is not a real gamma fade, the effect is generated by applying a black layer with opacity, you'll need to redraw the whole scene to do real time fade in/out.
void terminate( void ) ;
Sends a "quit" message to the application. Example : mysuperGameWindow->terminate() ;
bool hasFocus();
Returns the number focus state of the current window ( it it is in the foreground or not ) Returns true if active. Example : bool isActive ; isActive= gameWindow->hasFocus( );
void setTitle( const char * title ) ;
Changes the title of the window. Example : gameWindow->setTitle("A new window name!" ) ;
void flipBackBuffer( bool waitifBackWindow = true ) ;
Flips the content of the backbuffer to the front buffer. ( displays your rendering ) set waitifBackWindow to true if you want the game to be "paused" when the game window is sent to the background. ( Happens when people are switching tasks ) Example : gameWindow->flipBackBuffer( false ) ;
void processEvents( void ) ;
Process system events. Call this function often if you are experiencing Rainbow wheels on Mac os X. Example : gameWindow->processEvents( ) ;
bool isQuit( void ) ;
returns true if a termination has been asked. Windows : Alt-F4, Close Box. Mac OS X : APPLE-Q , Close Box. Example : bool endGame = gameWindow->isQuit() ; if ( endGame == true ) { quitTheGameNow() ; }
HWND getWindowHandle(void ) ;
Retrieves the handle of the game window. Example : HWND gameHWND = gameWindow->getWindowHandle() ;
void minimize(void ) ;
Minimizes the application to the task bar or the dock. you can call restore() to restore the window. ( or let the user click on the task bar to bring the application back )
void setCallback(ptkWindowCallBack callbackFunc ) ;
sends all the received events to the callback function. Events remain processed by the PTK event message handler. windows: typedef bool ( *ptkWindowCallBak ) ( HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam ); return false if you don't want the event to be processed by the system. Mac OS X : typedef bool ( *ptkWindowCallBak ) ( EventRef *event ); return false if you don't want the event to be processed by the system. (be cautious!) most developpers return true.
void setPTKCallback(ptkWindowCallBack callbackFunc ) ;
sends all the received events to the multiplatform PTK event callback function. typedef bool ( *ptkNativeCallBak ) ( KEvent *eventPtr ); return false if you don't want the event to be processed by the system. Check KInput.h for the structure.
bool getAccelerationCap();
Returns the state of openGL acceleration. Returns true if the drivers are properly installed, false if it's a software implementation of openGL. ( always returns true under DirectX ) Example : bool isAccellerated ; isAccellerated= gameWindow->getAccelerationCap( );
void toggleFullScreen( bool fullscreen);
changes the state of the display ( true for fullscreen, false for windowed ) Example : gameWindow->toggleFullScreen( true); //turns a windowed game in fullscreen
© 2003-2005, Phelios, inc. - All rights reserved. Trademarks mentioned are the property of their respective owners.