Vẽ Măt Trăng
Trang 1 trong tổng số 1 trang
Vẽ Măt Trăng
#include
#include "stdlib.h"
#include "string.h"
#include "math.h"
#include "glut.h"
#define P 3.14159265358979
#define RAD(goc) ((goc)*(P/180.0))
struct colorentry
{
unsigned char red;
unsigned char green;
unsigned char blue;
colorentry(unsigned char _r,unsigned char _g,unsigned char _b)
{ red = _r; green = _g; blue = _b; }
};
void vecungtron(int xc,int yc,int st_a,int en_a,int r)
{
int n=100;
while((en_a - st_a) <0) en_a += 360;
float da =RAD((en_a - st_a)%360)/n;
glColor3ub(255,255,0);
glBegin(GL_POLYGON);
{
for(int i=0;i{
glVertex2f(xc+r*cos(RAD(st_a)+i*da),yc+r*
sin(RAD(st_a)+i*da));
}
}
glEnd();
}
void veelip(int xc,int yc,int rx,int ry,int st_a,int en_a)
{
int n=100;
//float da=2*P/n;
while((en_a - st_a) <0) en_a += 360;
float da =RAD((en_a - st_a)%360)/n;
glColor3ub(255,255,255);
glBegin(GL_POLYGON);
{
for(int i=0;i{
int x=xc+rx*cos(RAD(st_a)+i*da);
int y=yc+ry*sin(RAD(st_a)+i*da);
glVertex2f(x,y);
}
}
glEnd();
}
void mydisplay()
{
glClear(GL_COLOR_BUFFER_BIT);
vecungtron(250,250,90,275,200);
veelip(250,250,125,200,90,275);
glFlush();
glutSwapBuffers();
}
void OnSize(int width, int height)
{
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,width,0,height);
}
void main()
{
/* Thiet lap thuoc tinh cua so */
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowPosition(100,150);
glutInitWindowSize(640,480);
/* Tao cua so */
glutCreateWindow("MAT TRANG!");
/* Mot so lenh khoi tao */
//glutDisplayFunc(mydisplay);
glClearColor(1.0,1.0,1.0,0.0);
/* Dang ky su kien */
glutDisplayFunc(mydisplay);
//glutKeyboardFunc(OnKeyDown);
glutReshapeFunc(OnSize);
//glutTimerFunc(100,OnTime,5);
//glutIdleFunc(OnDraw);
/* Vong lap thong diep */
glutMainLoop();
}
Similar topics
» HiVi 2S Fashion - Phần mềm quản lý shop thời trang (dành riêng cho ngành thời trang)
» Các trang web học oop hay
» Trang web đầu tiên
» code làm trang firefox bay bay
» trang download một số phần mềm khá hay
» Các trang web học oop hay
» Trang web đầu tiên
» code làm trang firefox bay bay
» trang download một số phần mềm khá hay
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|