| | |
my program given some erroe (computer graphics)
![]() |
•
•
Join Date: Aug 2005
Posts: 10
Reputation:
Solved Threads: 0
i am just start Computer grahics. that is my first program please help me
c Syntax (Toggle Plain Text)
#include <GL/glut.h> void DrawPixels(); void OurPixelsDrawingFunction(); void SetView(); void SetView(int w, int h) { glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode (GL_MODELVIEW); glLoadIdentity(); } void DrawPixels() { glClearColor(1.0,1.0,1.0,0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); gluOrtho2D (0.0,600.0,0.0,600.0); OurPixelsDrawingFunction(); void OurPixelsDrawingFuntion() { glColor3f(0,1,0); /*Set current pixels drwaing color to green*/ glPointSize(10); /* Sets the pixel size to 10 units*/ glBegin(GL_POINTS); /* Tells the Open GL that we want to draw points, similarly we can tell OpenGL that we want to draw lines using GL_LINES and then we will use line drawing functons.*/ /*====================================================================*/ /* Drawing one horizental line covering full window (0 to 600) */ /* at Y = 100 and x from 0 to 600 */ /*====================================================================*/ for(int i = 0; i <= 600; i++) glVertex2i(i,100); /*=========================================================================*/ /*=========================================================================*/ /* Drawing only one pixel of blue color form zero /*=========================================================================*/ glColor3f(0,0,1); glVertex2i(140,120); /*=========================================================================*/ /*=========================================================================*/ /* Drawing one Vertical line of four pixels for fourd */ /*=========================================================================*/ glColor3f(0,1,0); glVertex2i(160,120); glVertex2i(160,140); glVertex2i(160,160); glVertex2i(160,180); /*=========================================================================*/ /*=========================================================================*/ /* Draewing only one pixel of blue color for Zero */ /*=========================================================================*/ glColor3f(0,0,1); glVertex2i(180,120); /*=========================================================================*/ /*=========================================================================*/ /* Drawing one Vertical line of Two pixels for two */ /*=========================================================================*/ glColor3f(0,1,0); glVertex2i(200,120); glVertex2i(200,140); /*=========================================================================*/ /*=========================================================================*/ /* Drawing only one Pixel of blue color for zero */ /*=========================================================================*/ glColor3f(0,0,1); glVertex2i(220,120); /*=========================================================================*/ /*=========================================================================*/ /* Drawing only one pexel of blue color for zero */ /*=========================================================================*/ glColor3f(0,0,1); glVertex2i(240,120); /*=========================================================================*/ /*=========================================================================*/ /* Drawing one Vertical line of two pexels for two */ /*=========================================================================*/ glColor3f(0,1,0); glVertex2i(260,120); glVertex2i(260,140); /*=========================================================================*/ /*=========================================================================*/ /* drawing one Vertical line of five pixels for five */ /*=========================================================================*/ glColor3f(0,1,0); glVertex2i(280,120); glVertex2i(280,140); glVertex2i(280,160); glVertex2i(280,180); glVertex2i(280,200); /*=========================================================================*/ /*=========================================================================*/ /* Drawing only one pexel of blue color for zero /*=========================================================================*/ glColor3f(0,0,1); glVertex2i(300,120); /*=========================================================================*/ /*=========================================================================*/ /* We can use loops if we want to for this purpose as well.*/ /*=========================================================================*/ glEnd(); /* tells Open GL that we have finished drawing pixels*/ /*=========================================================================*/ /* Writng Text */ /*=========================================================================*/ /*===========Write your Id=================================================*/ glRasterPos2i(140,80); /* this pixels are wrtien using raster mod see the handouts of Lecture no. 3 for more details. In this mode we have fexed no. of horizontal and vertical lines we can't draw pexels using this mode */ char id[12] = "bc040200250"; int id_count = (int)strlen (id); for (int i=0; i < id_count; i++) { glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, id[i]); } glFlush(); /* this command out put pexels on the screen without this commmand the pixels will not be displayed to the screen*/ } /*///////////////////////////////////////////////////////////////////////////// // This is reshape function mean that this function is called whenever we resizw// our window and in this fuction we are adjusting the contents of our window // according to its new size. This function can be used in any graphics program // and you don't need to understand it thoroughly at this moment,*/ // /////////////////////////////////////////////////////////////////////////////*/ /*/////////////////////////////////////////////////////////////////////////*/ int main (int argc ,char ** argv) { glutInit(&argc,argv); glutInitWindowSize(800,600); glutCreateWindow ("-----bc040200250.........Your Name------"); glutDisplayFunc(DrawPixels); glutReshapeFunc(SetView); glutMainLoop (); return 0; }
Last edited by ~s.o.s~; Mar 24th, 2007 at 4:22 pm. Reason: Added code tags, learn to use them.
Some problems with your code...
First of all, what platform are you trying to compile this on? On my Mac, I include
You forgot a closing brace here:
Finally, to use
And this is in the wrong forum, Game Development is better suited for this...
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:
c Syntax (Toggle Plain Text)
void DrawPixels() { glClearColor(1.0,1.0,1.0,0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); gluOrtho2D (0.0,600.0,0.0,600.0); OurPixelsDrawingFunction(); // need } here // you forgot 'c' in 'Funtion' 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."
![]() |
Similar Threads
- What's the HARDEST program you've written? (Computer Science)
- Computer Won't Function Properly (Troubleshooting Dead Machines)
- Autostart IE or any program (Windows NT / 2000 / XP)
- Help w/ designing computer program for bibliometric citations (Computer Science)
- Computer Freezes if you look at it (Windows 95 / 98 / Me)
Other Threads in the C Forum
- Previous Thread: Set combinations function
- Next Thread: can't think of a title for it
| Thread Tools | Search this Thread |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush fgets file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix meter microsoft motherboard mqqueue mysql number odf open opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc process program programming pyramidusingturboccodes read recursion recv repetition research scanf scheduling segmentationfault send shape socket socketprograming socketprogramming stack standard string suggestions systemcall test unix urboc user voidmain() wab win32api windows.h






