ThienThanCNTT
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.

Vẽ Măt Trăng

Go down

Vẽ Măt Trăng Empty Vẽ Măt Trăng

Bài gửi by nth 09/11/09, 11:31 pm

#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();
}
nth
nth
Admin
Admin

Tổng số bài gửi : 550
Số điểm : 1113
Số lần được cám ơn : 33
Ngày đến diễn đàn: : 01/08/2009
Tuổi : 35
Đến từ : Thiên Đường

https://thuhuong.forumvi.net

Về Đầu Trang Go down

Về Đầu Trang

- Similar topics

 
Permissions in this forum:
Bạn không có quyền trả lời bài viết