Grafika Komputer buat Huruf dengan C++

Minggu lalu sempat belajar buat Huruf . Ngulik ngulik koordinat lagi dengan C++. gak ada yang susah kalo kita mau belajar. .
nihh contoh sintak huruf. .
Semoga bermanfaat. -,-
#include<windows.h>
#include<gl\gl.h>
#include<gl\glut.h>

//<<<<<<<<<<< myInit >>>>>>>>>>>>
void myInit(void)
{
     glClearColor(0.2,0.3,1.0,0.3);//set white background color
     glColor3f(0.3,1.0,0.1);
     glColor3f(1.0,1.0,0.0);
     glColor3f(0.2,1.0,0.1);
     glPointSize(20.0);//a 'dot' is 4 by 4 pixels
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     gluOrtho2D(0.0,640.0,0.0,480.0);
     }


//<<<<<<<<<<< myDisplay >>>>>>>>>>>
 void myDisplay(void)
{
     //glClear(GL_COLOR_BUFFER_BIT);// clear the screen
     glLineWidth(3.0);
     glLineStipple(3,0xAAAAA);
     glEnable(GL_LINE_STIPPLE);
     glBegin(GL_LINE_STRIP); //draw  OPEN Polyline
    
     glVertex2i(100,30);//draw three points
     glColor3f(0.3,0.9,0.1);
     glVertex2i(100,100);
     glVertex2i(100,60);
     glColor3f(0.3,0.2,0.0);
     glVertex2i(150,60);
     glVertex2i (150,30);
     glVertex2i(150,100);
     glEnd();
      glBegin(GL_LINE_STRIP); //draw  OPEN Polyline
    
     glVertex2i(160,30);//draw three points
     glColor3f(0.3,0.9,0.1);
     glVertex2i(160,100);
     glVertex2i(210,100);
     glColor3f(0.3,0.2,0.0);
     glVertex2i(160,100);
     glVertex2i (160,60);
     glVertex2i(210,60);
     glVertex2i (160,60);
     glVertex2i (210,60);
     glVertex2i (160,60);
     glVertex2i (160,30);
     glVertex2i (210,30);
     glEnd();
     glBegin(GL_LINE_STRIP); //draw  OPEN Polyline
    
     glColor3f(0.3,0.2,0.0);
     glVertex2i(220,30);//draw three points
     glColor3f(0.3,0.9,0.1);
     glVertex2i(220,100);
     glVertex2i(265,80);
     glVertex2i(220,50);
     glColor3f(0.3,0.2,0.0);
   
     glEnd();
     glBegin(GL_LINE_STRIP); //draw  OPEN Polyline
    
     glColor3f(0.3,0.2,0.0);
     glVertex2i(270,30);//draw three points
     glColor3f(0.3,0.9,0.1);
     glVertex2i(270,100);
     glVertex2i(310,80);
     glVertex2i(270,50);
     glColor3f(0.3,0.2,0.0);
   
     glEnd();
    
     glBegin(GL_LINE_STRIP); //draw  OPEN Polyline
    
     glColor3f(0.3,0.2,0.0);
     glVertex2i(340,30);//draw three points
     glColor3f(0.3,0.9,0.1);
     glVertex2i(340,80);
     glVertex2i(310,100);
     glVertex2i(340,80);
     glVertex2i(360,100);
     glColor3f(0.3,0.2,0.0);
   
     glEnd();
     glFlush();//send all output to display
     }
     int main(int argc, char**argv){
     glutInit(&argc,argv);//initialize the toolkit
     glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); // set display mode
     glutInitWindowSize(640,480);// set windows size
     glutInitWindowPosition(100,150);//set windows position on screen
     glutCreateWindow("my first attempt");// open the screen window
     glutDisplayFunc(myDisplay);// register redraw function
     myInit();
     glutMainLoop();//go into a perpetual loop
     }
Posting Komentar (0)
Lebih baru Lebih lama