•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 456,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,453 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 529 | Replies: 6
![]() |
•
•
Join Date: Oct 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
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
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...
c Syntax (Toggle Plain Text)
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); }
Last edited by Ancient Dragon : Oct 20th, 2007 at 6:57 pm. Reason: add code tags
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.
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.
•
•
Join Date: May 2006
Location: ★ ijug.net ★
Posts: 1,018
Reputation:
Rep Power: 6
Solved Threads: 68
Unless you tell us what is your code supposed to do and what problem are you facing, you will not get any help.
use:
instead of:
I think that you know how to include a file in your source code so that you wrote something like this.
Good luck.
#include <GL/glut.h>
#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);
} dwk
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,541
Reputation:
Rep Power: 40
Solved Threads: 972
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.
.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.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- project problem (Java)
- help in project (VB.NET)
- Project Problem (Visual Basic 4 / 5 / 6)
- project question? (Java)
- project question? (C)
- question? (Community Introductions)
- Command-line Arguments. (C++)
- Help for semaphores programming project .. (C)
- include file problem (C++)
- Project Help (C)
Other Threads in the C Forum
- Previous Thread: number of times each number in array occurs?
- Next Thread: Encrypting and Decrypting text from file using keyword



Linear Mode