When we control the event,we control your lives
 
Trang ChínhTìm kiếmĐăng kýĐăng Nhập
Tìm kiếm
 
 

Display results as :
 
Rechercher Advanced Search
Latest topics
» Tô màu theo vùng quét
banh xe bai so5 Icon_minitimeTue Aug 13, 2013 4:18 pm by minhlap

» authentischen Hermes Lindy Taschen
banh xe bai so5 Icon_minitimeWed Jan 23, 2013 11:15 am by cangliang

» Hermes Bag
banh xe bai so5 Icon_minitimeWed Jan 23, 2013 11:14 am by cangliang

» Hermes Evelyn pm
banh xe bai so5 Icon_minitimeWed Jan 23, 2013 11:13 am by cangliang

» Hermes Kelly bag billig
banh xe bai so5 Icon_minitimeMon Jan 21, 2013 8:57 am by cangliang

» Hermes Constance Bag
banh xe bai so5 Icon_minitimeMon Jan 21, 2013 8:56 am by cangliang

» Discout Hermes Belt
banh xe bai so5 Icon_minitimeMon Jan 21, 2013 8:55 am by cangliang

» Christian Louboutin Love Flats
banh xe bai so5 Icon_minitimeTue Jan 15, 2013 12:25 pm by cangliang

» Christian Louboutin Love Flats
banh xe bai so5 Icon_minitimeTue Jan 15, 2013 12:25 pm by cangliang

Navigation
 Portal
 Diễn Đàn
 Thành viên
 Lý lịch
 Trợ giúp
 Tìm kiếm
January 2020
MonTueWedThuFriSatSun
  12345
6789101112
13141516171819
20212223242526
2728293031  
CalendarCalendar
Diễn Đàn
Affiliates
free forum


Share
 

 banh xe bai so5

Go down 
Tác giảThông điệp
minhlap
Admin - Quản trị viên
Admin - Quản trị viên
minhlap

Tổng số bài gửi : 129
Points : 374
Reputation : 5
Join date : 22/07/2009
Age : 30
Đến từ : TP Hồ Chí Minh

banh xe bai so5 Empty
Bài gửiTiêu đề: banh xe bai so5   banh xe bai so5 Icon_minitimeSat Dec 12, 2009 6:57 pm

#include "glut.h"
#include
#include
using namespace std;
#define M_PI 3.14159265358979
#define round(n) (int)(n+0.5)
#define RAD(goc) ((goc)*(M_PI/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;
}
};
int _xc,_yc,_r;
int xx1,yy1,xx2,yy2,xx3,yy3;
int xxx;float yyy,m1,m2;
int _dgoc;
int status=0;
void onidle();
void ontime(int ms);
void ondraw();
void onsize(int width,int height);
void oninit();
void setpixel(int x,int y,colorentry c);
void setline(int xa,int xb,int y,colorentry c);
void set8pixel(int x,int y,colorentry c);
void set4line(int x,int y,colorentry c);
void banhxengoai(int xc,int yc,int r,int dgoc,colorentry c);
void banhxetrong(int xc,int yc,int r,colorentry c);
void main()
{
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(800,800);
glutInitWindowPosition(0,0);
glutCreateWindow("hello");
oninit();
glutDisplayFunc(ondraw);
glutReshapeFunc(onsize);
glutTimerFunc(10,ontime,10);
glutIdleFunc(onidle);
glutMainLoop();
}
void ondraw()
{
glClear(GL_COLOR_BUFFER_BIT);
banhxengoai(_xc,_yc,_r,_dgoc,colorentry(255,0,0));
banhxetrong(_xc,_yc,_r-20,colorentry(255,0,0));
glColor3ub(255,0,0);
glBegin(GL_LINE_STRIP);
glVertex2f(xx1,yy1);
glVertex2f(xx2,yy2);
glVertex2f(xx3,yy3);
glEnd();
glFlush();
glutSwapBuffers();
}
void onsize(int width,int height)
{
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,width,0,height);
}
void oninit()
{
glClearColor(1,1,1,0);
xx1=100;yy1=100;xx2=300;yy2=200;xx3=600;yy3=100;
float dx=xx2-xx1,dy=yy2-yy1;
_r=50;
_xc=xx1;_yc=((_r*sqrt(dx*dx+dy*dy)/dx)+yy1);
}
void setpixel(int x,int y,colorentry c)
{
glColor3ub(c.red,c.green,c.blue);
glBegin(GL_POINTS);
glVertex2f(x,y);
glEnd();
}
void setline(int xa,int xb,int y,colorentry c)
{
for(int x=xa;x<=xb;x++)
setpixel(x+_xc,y+_yc,c);
}
void set8pixel(int xc,int yc,int x,int y,colorentry c)
{
setpixel(x+xc,y+yc,c);
setpixel(x+xc,-y+yc,c);
setpixel(y+xc,x+yc,c);
setpixel(y+xc,-x+yc,c);
setpixel(-x+xc,y+yc,c);
setpixel(-x+xc,-y+yc,c);
setpixel(-y+xc,x+yc,c);
setpixel(-y+xc,-x+yc,c);
}
void set4line(int x,int y,colorentry c)
{
setline(-x,x,y,c);
setline(-y,y,x,c);
setline(-y,y,-x,c);
setline(-x,x,-y,c);
}
void banhxengoai(int xc,int yc,int r,int dgoc, colorentry c)
{
int x=0,y=r;
int p=1-r;
set8pixel(xc,yc,x,y,c);
while(x {
if(p<0)
p+=(x<<1)+3;
else
{
p+=((x-y)<<1)+5;
y--;
}
x++;
set8pixel(xc,yc,x,y,c);
}
float xi,yi;
int goc[4]={0,90,180,270};
glBegin(GL_LINES);
glColor3ub(c.red,c.green,c.blue);
for(int i=0;i<4;i++)
{
xi = _xc + _r*cos(RAD(goc[i]-dgoc));
yi = _yc + _r*sin(RAD(goc[i]-dgoc));
glVertex2f(xi,yi);
glVertex2f(_xc,_yc);
}
glEnd();
}

void banhxetrong(int xc,int yc,int r,colorentry c)
{
int x=0,y=r;
int p=1-r;
set4line(x,y,c);
while(x {
if(p<0)
p+=(x<<1)+3;
else
{
p+=((x-y)<<1)+5;
y--;
}
x++;
set4line(x,y,c);
}
}
void ontime(int ms)
{
if(_xc==xx1)
{
status=0;
xxx=_xc;
yyy=_yc;
}
else if(_xc==xx3)
{
status=1;
xxx=_xc;
yyy=_yc;
}

if(status==0)
{
m1=(float)(yy2-yy1)/(xx2-xx1);
m2=(float)(yy3-yy2)/(xx3-xx2);
if(xxx yyy+=m1;
else
yyy+=m2;
_xc=++xxx;
_yc=round(yyy);
_dgoc=(_dgoc+1)%360;
}
else
{
m1=(float)(yy2-yy3)/(xx2-xx3);
m2=(float)(yy1-yy2)/(xx1-xx2);
if(xxx>xx2)
yyy-=m1;
else
yyy-=m2;
_xc=--xxx;
_yc=round(yyy);
_dgoc=(_dgoc-1)%360;
}
glutTimerFunc(ms,ontime,ms);
}
void onidle()
{
glutPostRedisplay();
}

_________________
minhlapit
Về Đầu Trang Go down
https://minhlap.forumvi.com
 
banh xe bai so5
Về Đầu Trang 
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
minhlap.allgoo.us :: Lập trình :: Lập Trình Hướng Đối Tượng,Đồ Họa OpenGL C, C++-
Chuyển đến