User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Oct 2007
Posts: 2
Reputation: 51al is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
51al 51al is offline Offline
Newbie Poster

Question Question about my project

  #1  
Oct 17th, 2007
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
  1. void OpenGLInit(void);
  2.  
  3. static void Animate(void );
  4. static void Key_r(void );
  5. static void Key_s(void );
  6. static void Key_up(void );
  7. static void Key_down(void );
  8. static void ResizeWindow(int w, int h);
  9.  
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <GL/lut.h>
  13.  
  14. static GLenum spinMode = GL_TRUE;
  15. static GLenum singleStep = GL_FALSE;
  16.  
  17. static float HourOfDay = 0.0;
  18. static float DayOfYear = 0.0;
  19. static float AnimateIncrement = 24.0;
  20. static void KeyPressFunc( unsigned char Key, int x, int y )
  21. {
  22. switch ( Key ) {
  23. case 'R':
  24. case 'r':
  25. Key_r();
  26. break;
  27. case 's':
  28. case 'S':
  29. Key_s();
  30. break;
  31. case 27:
  32. exit(1);
  33. }
  34. }
  35.  
  36. static void SpecialKeyFunc( int Key, int x, int y )
  37. {
  38. switch ( Key ) {
  39. case GLUT_KEY_UP:
  40. Key_up();
  41. break;
  42. case GLUT_KEY_DOWN:
  43. Key_down();
  44. break;
  45. }
  46. }
  47.  
  48.  
  49. static void Key_r(void)
  50. {
  51. if ( singleStep ) {
  52. singleStep = GL_FALSE;
  53. spinMode = GL_TRUE;
  54. }
  55. else {
  56. spinMode = !spinMode;
  57. }
  58. }
  59.  
  60. static void Key_s(void)
  61. {
  62. singleStep = GL_TRUE;
  63. spinMode = GL_TRUE;
  64. }
  65.  
  66. static void Key_up(void)
  67. {
  68. AnimateIncrement *= 2.0;
  69. }
  70.  
  71. static void Key_down(void)
  72. {
  73. AnimateIncrement /= 2.0;
  74.  
  75. }
  76. static void Animate(void)
  77. {
  78.  
  79. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  80.  
  81. if (spinMode) {
  82. HourOfDay += AnimateIncrement;
  83. DayOfYear += AnimateIncrement/24.0;
  84.  
  85. HourOfDay = HourOfDay - ((int)(HourOfDay/24))*24;
  86. DayOfYear = DayOfYear - ((int)(DayOfYear/365))*365;
  87. }
  88.  
  89. glLoadIdentity();
  90.  
  91. glTranslatef ( 0.0, 0.0, -8.0 );
  92.  
  93. glRotatef( 15.0, 1.0, 0.0, 0.0 );
  94.  
  95. glColor3f( 1.0, 1.0, 0.0 );
  96. glutWireSphere( 1.0, 15, 15 );
  97.  
  98. glRotatef( 360.0*DayOfYear/365.0, 0.0, 1.0, 0.0 );
  99. glTranslatef( 4.0, 0.0, 0.0 );
  100. glPushMatrix();
  101.  
  102. glRotatef( 360.0*HourOfDay/24.0, 0.0, 1.0, 0.0 );
  103.  
  104. glColor3f( 0.2, 0.2, 1.0 );
  105. glutWireSphere( 0.4, 10, 10);
  106. glPopMatrix();
  107.  
  108. glRotatef( 360.0*12.0*DayOfYear/365.0, 0.0, 1.0, 0.0 );
  109. glTranslatef( 0.7, 0.0, 0.0 );
  110. glColor3f( 0.3, 0.7, 0.3 );
  111. glutWireSphere( 0.1, 5, 5 );
  112.  
  113. glFlush();
  114. glutSwapBuffers();
  115.  
  116. if ( singleStep ) {
  117. spinMode = GL_FALSE;
  118. }
  119.  
  120. glutPostRedisplay();
  121.  
  122. }
  123.  
  124. void OpenGLInit(void)
  125. {
  126. glShadeModel( GL_FLAT );
  127. glClearColor( 0.0, 0.0, 0.0, 0.0 );
  128. glClearDepth( 1.0 );
  129. glEnable( GL_DEPTH_TEST );
  130. }
  131.  
  132. static void ResizeWindow(int w, int h)
  133. {
  134. float aspectRatio;
  135. h = (h == 0) ? 1 : h;
  136. w = (w == 0) ? 1 : w;
  137. glViewport( 0, 0, w, h );
  138. aspectRatio = (float)w/(float)h;
  139.  
  140. glMatrixMode( GL_PROJECTION );
  141. glLoadIdentity();
  142. gluPerspective( 60.0, aspectRatio, 1.0, 30.0 );
  143.  
  144. glMatrixMode( GL_MODELVIEW );
  145. }
  146.  
  147.  
  148. int main( int argc, char** argv )
  149. {
  150. glutInit(&argc,argv);
  151. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
  152.  
  153. glutInitWindowPosition( 0, 0 );
  154. glutInitWindowSize( 600, 360 );
  155. glutCreateWindow( "Tata Surya" );
  156.  
  157. OpenGLInit();
  158.  
  159. glutKeyboardFunc( KeyPressFunc );
  160. glutSpecialFunc( SpecialKeyFunc );
  161.  
  162. glutReshapeFunc( ResizeWindow );
  163.  
  164. glutDisplayFunc( Animate );
  165.  
  166. glutMainLoop( );
  167.  
  168. return(0);
  169.  
  170. }
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...
Last edited by Ancient Dragon : Oct 20th, 2007 at 6:57 pm. Reason: add code tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: Question about my project

  #2  
Oct 17th, 2007
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.
Reply With Quote  
Join Date: May 2006
Location: ★ ijug.net ★
Posts: 1,018
Reputation: ithelp will become famous soon enough ithelp will become famous soon enough 
Rep Power: 6
Solved Threads: 68
ithelp ithelp is online now Online
Veteran Poster

Re: Question about my project

  #3  
Oct 17th, 2007
Unless you tell us what is your code supposed to do and what problem are you facing, you will not get any help.
Reply With Quote  
Join Date: Oct 2007
Posts: 2
Reputation: 51al is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
51al 51al is offline Offline
Newbie Poster

Re: Question about my project

  #4  
Oct 17th, 2007
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
Reply With Quote  
Join Date: Jul 2006
Posts: 138
Reputation: mostafadotnet is on a distinguished road 
Rep Power: 3
Solved Threads: 8
mostafadotnet's Avatar
mostafadotnet mostafadotnet is offline Offline
Junior Poster

Re: Question about my project

  #5  
Oct 17th, 2007
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.
Reply With Quote  
Join Date: Nov 2005
Location: Canada
Posts: 236
Reputation: dwks will become famous soon enough dwks will become famous soon enough 
Rep Power: 4
Solved Threads: 21
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: Question about my project

  #6  
Oct 20th, 2007
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>.
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
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,541
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 40
Solved Threads: 972
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: Question about my project

  #7  
Oct 20th, 2007
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.
<<Freelance Programmer>> << Hobby Site>>
Signature links for sale. PM me for details
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 5:15 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC