my program given some erroe (computer graphics)

Reply

Join Date: Aug 2005
Posts: 10
Reputation: iqbal is an unknown quantity at this point 
Solved Threads: 0
iqbal iqbal is offline Offline
Newbie Poster

my program given some erroe (computer graphics)

 
0
  #1
Mar 24th, 2007
i am just start Computer grahics. that is my first program please help me
  1. #include <GL/glut.h>
  2.  
  3. void DrawPixels();
  4. void OurPixelsDrawingFunction();
  5. void SetView();
  6.  
  7. void SetView(int w, int h)
  8. {
  9. glViewport(0,0,w,h);
  10. glMatrixMode(GL_PROJECTION);
  11. glLoadIdentity();
  12. glMatrixMode (GL_MODELVIEW);
  13. glLoadIdentity();
  14.  
  15. }
  16.  
  17. void DrawPixels()
  18. {
  19. glClearColor(1.0,1.0,1.0,0);
  20.  
  21. glClear(GL_COLOR_BUFFER_BIT);
  22.  
  23.  
  24.  
  25. glMatrixMode(GL_PROJECTION);
  26.  
  27. gluOrtho2D (0.0,600.0,0.0,600.0);
  28.  
  29.  
  30. OurPixelsDrawingFunction();
  31.  
  32.  
  33.  
  34. void OurPixelsDrawingFuntion()
  35. {
  36. glColor3f(0,1,0);
  37. /*Set current pixels drwaing color to green*/
  38. glPointSize(10);
  39. /* Sets the pixel size to 10 units*/
  40. glBegin(GL_POINTS);
  41. /* Tells the Open GL that we want to draw points, similarly we can tell OpenGL
  42. that we want to draw lines using GL_LINES and then we will use line drawing
  43. functons.*/
  44. /*====================================================================*/
  45. /* Drawing one horizental line covering full window (0 to 600) */
  46. /* at Y = 100 and x from 0 to 600 */
  47. /*====================================================================*/
  48. for(int i = 0; i <= 600; i++)
  49. glVertex2i(i,100);
  50. /*=========================================================================*/
  51.  
  52. /*=========================================================================*/
  53. /* Drawing only one pixel of blue color form zero
  54.   /*=========================================================================*/
  55. glColor3f(0,0,1);
  56. glVertex2i(140,120);
  57. /*=========================================================================*/
  58.  
  59. /*=========================================================================*/
  60. /* Drawing one Vertical line of four pixels for fourd */
  61. /*=========================================================================*/
  62. glColor3f(0,1,0);
  63. glVertex2i(160,120);
  64. glVertex2i(160,140);
  65. glVertex2i(160,160);
  66. glVertex2i(160,180);
  67. /*=========================================================================*/
  68.  
  69. /*=========================================================================*/
  70. /* Draewing only one pixel of blue color for Zero */
  71. /*=========================================================================*/
  72. glColor3f(0,0,1);
  73. glVertex2i(180,120);
  74. /*=========================================================================*/
  75. /*=========================================================================*/
  76. /* Drawing one Vertical line of Two pixels for two */
  77. /*=========================================================================*/
  78. glColor3f(0,1,0);
  79. glVertex2i(200,120);
  80. glVertex2i(200,140);
  81. /*=========================================================================*/
  82.  
  83. /*=========================================================================*/
  84. /* Drawing only one Pixel of blue color for zero */
  85.  
  86. /*=========================================================================*/
  87. glColor3f(0,0,1);
  88. glVertex2i(220,120);
  89. /*=========================================================================*/
  90.  
  91. /*=========================================================================*/
  92. /* Drawing only one pexel of blue color for zero */
  93. /*=========================================================================*/
  94. glColor3f(0,0,1);
  95. glVertex2i(240,120);
  96. /*=========================================================================*/
  97.  
  98. /*=========================================================================*/
  99. /* Drawing one Vertical line of two pexels for two */
  100. /*=========================================================================*/
  101. glColor3f(0,1,0);
  102. glVertex2i(260,120);
  103. glVertex2i(260,140);
  104. /*=========================================================================*/
  105.  
  106. /*=========================================================================*/
  107. /* drawing one Vertical line of five pixels for five */
  108. /*=========================================================================*/
  109. glColor3f(0,1,0);
  110. glVertex2i(280,120);
  111. glVertex2i(280,140);
  112. glVertex2i(280,160);
  113. glVertex2i(280,180);
  114. glVertex2i(280,200);
  115. /*=========================================================================*/
  116.  
  117. /*=========================================================================*/
  118. /* Drawing only one pexel of blue color for zero
  119.   /*=========================================================================*/
  120. glColor3f(0,0,1);
  121. glVertex2i(300,120);
  122. /*=========================================================================*/
  123.  
  124. /*=========================================================================*/
  125. /* We can use loops if we want to for this purpose as well.*/
  126. /*=========================================================================*/
  127. glEnd();
  128. /* tells Open GL that we have finished drawing pixels*/
  129.  
  130. /*=========================================================================*/
  131. /* Writng Text */
  132. /*=========================================================================*/
  133.  
  134. /*===========Write your Id=================================================*/
  135.  
  136. glRasterPos2i(140,80);
  137.  
  138. /* this pixels are wrtien using raster mod see the handouts of Lecture no. 3
  139.   for more details. In this mode we have fexed no. of horizontal and vertical
  140.   lines we can't draw pexels using this mode
  141.   */
  142.  
  143. char id[12] = "bc040200250";
  144. int id_count = (int)strlen (id);
  145. for (int i=0; i < id_count; i++)
  146. {
  147. glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, id[i]);
  148. }
  149.  
  150. glFlush();
  151. /* this command out put pexels on the screen without this commmand the pixels
  152.   will not be displayed to the screen*/
  153.  
  154. }
  155.  
  156. /*/////////////////////////////////////////////////////////////////////////////
  157.   //
  158. This is reshape function mean that this function is called whenever we resizw//
  159. our window and in this fuction we are adjusting the contents of our window //
  160. according to its new size. This function can be used in any graphics program //
  161. and you don't need to understand it thoroughly at this moment,*/ //
  162. /////////////////////////////////////////////////////////////////////////////*/
  163.  
  164.  
  165.  
  166. /*/////////////////////////////////////////////////////////////////////////*/
  167. int main (int argc ,char ** argv)
  168.  
  169. {
  170. glutInit(&argc,argv);
  171. glutInitWindowSize(800,600);
  172. glutCreateWindow ("-----bc040200250.........Your Name------");
  173. glutDisplayFunc(DrawPixels);
  174. glutReshapeFunc(SetView);
  175. glutMainLoop ();
  176. return 0;
  177. }
Last edited by ~s.o.s~; Mar 24th, 2007 at 4:22 pm. Reason: Added code tags, learn to use them.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: my program given some erroe (computer graphics)

 
0
  #2
Mar 24th, 2007
Please use [code][/code] tags around your code.
Nobody wants to read a whole mess of unindented code.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 163
Reputation: grunge man is an unknown quantity at this point 
Solved Threads: 2
grunge man grunge man is offline Offline
Junior Poster

Re: my program given some erroe (computer graphics)

 
0
  #3
Mar 24th, 2007
lol that was funny reading all that like that but ya i totally agree with salem
THE ONLY WAY TO MOVE IN THE FUTURE IS TO ABSTRACT IN THE PAST
(My interpretation of abstract, is, to change something little by little until it morphs into something new)
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: my program given some erroe (computer graphics)

 
0
  #4
Mar 24th, 2007
Some problems with your code...

First of all, what platform are you trying to compile this on? On my Mac, I include GLUT/glut.h (you had included GL/glut.h). Getting the header right removes about 8 errors.

You forgot a closing brace here:
  1. void DrawPixels()
  2. {
  3. glClearColor(1.0,1.0,1.0,0);
  4.  
  5. glClear(GL_COLOR_BUFFER_BIT);
  6.  
  7.  
  8.  
  9. glMatrixMode(GL_PROJECTION);
  10.  
  11. gluOrtho2D (0.0,600.0,0.0,600.0);
  12.  
  13.  
  14. OurPixelsDrawingFunction();
  15.  
  16. // need } here
  17.  
  18. // you forgot 'c' in 'Funtion'
  19. void OurPixelsDrawingFuntion()

Finally, to use strlen(), you must #include <cstring>. Anyway, there weren't any bugs in the program, and it ran fine after I made these minor corrections.

And this is in the wrong forum, Game Development is better suited for this...
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC