hi...my name is agus ..i'm from indonesian...i'm new here... i want to ask something... i have project but i dont know about my wrong and solutions....this is mY project

void OpenGLInit(void);

static void Animate(void );
static void Key_r(void );
static void Key_s(void );
static void Key_up(void );
static void Key_down(void );
static void ResizeWindow(int w, int h);

#include <stdlib.h>
#include <stdio.h>
#include <GL/lut.h>

static GLenum spinMode = GL_TRUE;
static GLenum singleStep = GL_FALSE;

static float HourOfDay = 0.0;
static float DayOfYear = 0.0;
static float AnimateIncrement = 24.0; 
static void KeyPressFunc( unsigned char Key, int x, int y )
{
	switch ( Key ) {
	case 'R':
	case 'r':
		Key_r();
		break;
	case 's':
	case 'S':
		Key_s();
		break;
	case 27:
		exit(1);
	}
}

static void SpecialKeyFunc( int Key, int x, int y )
{
	switch ( Key ) {
	case GLUT_KEY_UP:		
		Key_up();
		break;
	case GLUT_KEY_DOWN:
		Key_down();
		break;
	}
}


static void Key_r(void)
{
	if ( singleStep ) {			
		singleStep = GL_FALSE;
		spinMode = GL_TRUE;		
	}
	else {
		spinMode = !spinMode;	
	}
}

static void Key_s(void)
{
	singleStep = GL_TRUE;
	spinMode = GL_TRUE;
}

static void Key_up(void)
{
    AnimateIncrement *= 2.0;			
}

static void Key_down(void)
{
    AnimateIncrement /= 2.0;			
	
}
static void Animate(void)
{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if (spinMode) {
        HourOfDay += AnimateIncrement;
        DayOfYear += AnimateIncrement/24.0;

        HourOfDay = HourOfDay - ((int)(HourOfDay/24))*24;
        DayOfYear = DayOfYear - ((int)(DayOfYear/365))*365;
		}
	
    glLoadIdentity();

    glTranslatef ( 0.0, 0.0, -8.0 );

	glRotatef( 15.0, 1.0, 0.0, 0.0 );

	glColor3f( 1.0, 1.0, 0.0 );			
    glutWireSphere( 1.0, 15, 15 );

    glRotatef( 360.0*DayOfYear/365.0, 0.0, 1.0, 0.0 );
    glTranslatef( 4.0, 0.0, 0.0 );
    glPushMatrix();					

	glRotatef( 360.0*HourOfDay/24.0, 0.0, 1.0, 0.0 );

    glColor3f( 0.2, 0.2, 1.0 );
    glutWireSphere( 0.4, 10, 10);
    glPopMatrix();					

   	glRotatef( 360.0*12.0*DayOfYear/365.0, 0.0, 1.0, 0.0 );
    glTranslatef( 0.7, 0.0, 0.0 );
    glColor3f( 0.3, 0.7, 0.3 );
    glutWireSphere( 0.1, 5, 5 );

    glFlush();
    glutSwapBuffers();

	if ( singleStep ) {
		spinMode = GL_FALSE;
	}

	glutPostRedisplay();	

}

void OpenGLInit(void)
{
    glShadeModel( GL_FLAT );
    glClearColor( 0.0, 0.0, 0.0, 0.0 );
    glClearDepth( 1.0 );
    glEnable( GL_DEPTH_TEST );
}

static void ResizeWindow(int w, int h)
{
    float aspectRatio;
	h = (h == 0) ? 1 : h;
	w = (w == 0) ? 1 : w;
	glViewport( 0, 0, w, h );
	aspectRatio = (float)w/(float)h;

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    gluPerspective( 60.0, aspectRatio, 1.0, 30.0 );

    glMatrixMode( GL_MODELVIEW );
}


int main( int argc, char** argv )
{
	glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );

    glutInitWindowPosition( 0, 0 );
    glutInitWindowSize( 600, 360 );
    glutCreateWindow( "Tata Surya" );

    OpenGLInit();

	glutKeyboardFunc( KeyPressFunc );
	glutSpecialFunc( SpecialKeyFunc );

    glutReshapeFunc( ResizeWindow );

    glutDisplayFunc( Animate );
	
	glutMainLoop(  );

    return(0);	
  	
}

that is...i don't know about that....maybe you can help me to check thiss...i'm so dizzy about that...thanks if you want to help me....From Agus...

Recommended Answers

All 6 Replies

What's obvious is that you failed to read
Announcement: Please use BB Code and Inlinecode tags and the watermark at the back of the edit window.

If you had, that code would not be an unformatted mess.
Fewer people are prepared to even look at unformatted code.

Unless you tell us what is your code supposed to do and what problem are you facing, you will not get any help.

oh i see...this is Tata Surya.... i want build Tata Surya...but it was error... that error is #include<GL/lut.h> no open directory... i dont know about it..maybe you can tell me...about #include this..why is not open

use:

#include <GL/glut.h>

instead of:

#include<GL/lut.h>

I think that you know how to include a file in your source code so that you wrote something like this.

Good luck.

switch ( Key ) {
case 'R':
case 'r':
Key_r();
break;
case 's':
case 'S':
Key_s();
break;
case 27:
exit(1);
}

Consider using tolower() or toupper() from <ctype.h>.

consider moving lines 10 thru 12 to the top of the program, above line 1. Traditionally include files go at the top of the programs and everything else follows. Sometime its a lot more than just tradition but a requirement :).

Without knowing more about what your program is supposed to do, and what it does not do that it should, can not answer any more.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.