hmmm, difficult because its in various files.
this is the main code:
#include <GL/glut.h>
#include "ball.h"
#include "paddle.h"
Ball ball;
Paddle paddle;
void resize( int width, int height )
{
if( width == 0 )
{
width = 1;
}
glViewport( 0, 0 , width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
glOrtho( -100, 100, -100, 100, 100, -100 ); //doesnt keep anything square
glMatrixMode( GL_MODELVIEW );
glLoadIdentity( );
}
void mouse( int button, int state, int x, int y )
{
switch( button )
{
case GLUT_LEFT_BUTTON:
if( state == GLUT_DOWN )
{
ball.getMove( )->triple[ 0 ] = 0.0f;
ball.getMove( )->triple[ 1 ] = 1.0f;
ball.getMove( )->triple[ 2 ] = 0.0f;
}
break;
case GLUT_RIGHT_BUTTON:
if( state == GLUT_DOWN )
{
exit( 0 );
}
break;
default:
break;
}
glutPostRedisplay( );
}
void idle( )
{
ball.moveBall( );
glutPostRedisplay( );
}
void special( int key, int x, int y )
{
switch( key )
{
case GLUT_KEY_LEFT:
paddle.movePaddle( -2.5f );
break;
case GLUT_KEY_RIGHT:
paddle.movePaddle( 2.5f );
break;
default:
break;
}
glutPostRedisplay( );
}
void renderScene( )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glColor3f( 1.0f, 0.0f, 0.0f );
glLoadIdentity( );
ball.drawBall( );
paddle.drawPaddle( );
glutSwapBuffers( );
}
void init( )
{
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glEnable( GL_DEPTH_TEST );
}
int main( int argc, char**argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB );
glutInitWindowSize( 350, 450 );
glutInitWindowPosition( 100, 100 );
glutCreateWindow( “balltest glut program” );
init( );
glutDisplayFunc( renderScene );
glutReshapeFunc( resize );
glutIdleFunc( idle );
glutMouseFunc( mouse );
glutSpecialFunc( special );
glutMainLoop( );
return 1;
}