minhlap.allgoo.us
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.


When we control the event,we control your lives
 
Trang ChínhLatest imagesTì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
to mau de qui Icon_minitimeTue Aug 13, 2013 4:18 pm by minhlap

» authentischen Hermes Lindy Taschen
to mau de qui Icon_minitimeWed Jan 23, 2013 11:15 am by cangliang

» Hermes Bag
to mau de qui Icon_minitimeWed Jan 23, 2013 11:14 am by cangliang

» Hermes Evelyn pm
to mau de qui Icon_minitimeWed Jan 23, 2013 11:13 am by cangliang

» Hermes Kelly bag billig
to mau de qui Icon_minitimeMon Jan 21, 2013 8:57 am by cangliang

» Hermes Constance Bag
to mau de qui Icon_minitimeMon Jan 21, 2013 8:56 am by cangliang

» Discout Hermes Belt
to mau de qui Icon_minitimeMon Jan 21, 2013 8:55 am by cangliang

» Christian Louboutin Love Flats
to mau de qui Icon_minitimeTue Jan 15, 2013 12:25 pm by cangliang

» Christian Louboutin Love Flats
to mau de qui 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
March 2024
MonTueWedThuFriSatSun
    123
45678910
11121314151617
18192021222324
25262728293031
CalendarCalendar
Diễn Đàn
Affiliates
free forum


 

 to mau de qui

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 : 34
Đến từ : TP Hồ Chí Minh

to mau de qui Empty
Bài gửiTiêu đề: to mau de qui   to mau de qui Icon_minitimeSat Dec 12, 2009 7:02 pm

#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
#include
#include"math.h"
#include "glut.h"
#define Round(x) int(x+0.5)
int width,height,xc,yc,xi,yi;

struct Colorentry
{
GLubyte Red;
GLubyte Blue;
GLubyte Green;
Colorentry() {Red=Green=Blue=0; }
Colorentry(GLbyte R,GLbyte G,GLbyte B)
{
Red=R;
Green=G;
Blue=B;
}
int operator==(Colorentry &c)
{
return (Red==c.Red && Green==c.Green && Blue==c.Blue);
}
int operator!=(Colorentry &c)
{
return !(*this==c);
}
};

void PutPixel(int x,int y,Colorentry c)
{
glColor3ub(c.Red,c.Green,c.Blue);
glBegin(GL_POINTS);
glVertex2f(x,y);
glEnd();
}
void PutPixel(int x,int y)
{
glBegin(GL_POINTS);
glVertex2f(x,y);
glEnd();
}
Colorentry GetPixel(int x,int y)
{
GLbyte color[3];
float Pos[4];
glRasterPos2d(x,y);
glGetFloatv(GL_CURRENT_RASTER_POSITION,Pos);
glReadPixels(Pos[0],Pos[1],1,1,GL_RGB,GL_UNSIGNED_BYTE,color);
return Colorentry(color[0],color[1],color[2]);
}
void Fillleft(int x,int y,Colorentry Fillcolor,Colorentry Boundarycolor);
void Fillright(int x,int y,Colorentry Fillcolor,Colorentry Boundarycolor);
void Filltop(int x,int y,Colorentry Fillcolor,Colorentry Boundarycolor);
void Fillbottom(int x,int y,Colorentry Fillcolor,Colorentry Boundarycolor);

void Fillleft(int x,int y,Colorentry Fillcolor,Colorentry Boundarycolor)
{
Colorentry color=GetPixel(x,y);
if(color!=Fillcolor && color!= Boundarycolor)
{
PutPixel(x,y,Fillcolor);
Fillleft (x-1, y , Fillcolor, Boundarycolor);
Filltop (x , y+1, Fillcolor, Boundarycolor);
Fillbottom (x , y-1, Fillcolor, Boundarycolor);
}
}
void Fillright(int x,int y,Colorentry Fillcolor,Colorentry Boundarycolor)
{
Colorentry color=GetPixel(x,y);
if(color!=Fillcolor && color!= Boundarycolor)
{
PutPixel(x,y,Fillcolor);
Fillright (x+1, y , Fillcolor, Boundarycolor);
Filltop (x , y+1, Fillcolor, Boundarycolor);
Fillbottom (x , y-1, Fillcolor, Boundarycolor);
}
}
void Filltop(int x,int y,Colorentry Fillcolor,Colorentry Boundarycolor)
{
Colorentry color=GetPixel(x,y);
if(color!=Fillcolor && color!= Boundarycolor)
{
PutPixel(x,y,Fillcolor);
Fillleft (x-1, y , Fillcolor, Boundarycolor);
Fillright (x+1, y , Fillcolor, Boundarycolor);
Filltop (x , y+1, Fillcolor, Boundarycolor);

}
}
void Fillbottom(int x,int y,Colorentry Fillcolor,Colorentry Boundarycolor)
{
Colorentry color=GetPixel(x,y);
if(color!=Fillcolor && color!= Boundarycolor)
{
PutPixel(x,y,Fillcolor);
Fillleft (x-1, y , Fillcolor, Boundarycolor);
Fillright (x+1, y , Fillcolor, Boundarycolor);
Fillbottom (x , y-1, Fillcolor, Boundarycolor);
}
}
void BundaryFill(int x, int y, Colorentry Fillcolor, Colorentry Boundarycolor)
{
Colorentry color=GetPixel(x,y);
if(color != Fillcolor && color != Boundarycolor)
{
PutPixel(x,y,Fillcolor);
Fillleft (x-1, y , Fillcolor, Boundarycolor);
Fillright (x+1, y , Fillcolor, Boundarycolor);
Filltop (x , y+1, Fillcolor, Boundarycolor);
Fillbottom (x , y-1, Fillcolor, Boundarycolor);
}
}
void DrawRectangle_Rotate(int xc,int yc,int a, int b)
{
int dPoints[][2] = { {-a,b},{a,b},{a,-b},{-a,-b} };
int n = 4;
int x,y;
glBegin(GL_LINE_LOOP);

for(int i=0;i {
x = xc + dPoints[i][0];
y = yc + dPoints[i][1];
glVertex2f(x,y);
}
glEnd();
}
void test()
{
DrawRectangle_Rotate(xc,yc,30,20);
Colorentry a(255,255,0);
Colorentry b(255,0,0);
BundaryFill(xc,yc,a,b);
}
//-----------------------------------
void myInit()
{
width=glutGet(GLUT_WINDOW_WIDTH);
height=glutGet(GLUT_WINDOW_HEIGHT);
xc=width/2;
yc=height/2;
}
void mydraw()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3ub(255,0,0);
test();
glFlush();
glutSwapBuffers();
}
void onkey(unsigned char key,int x,int y)
{
switch(key)
{
case 27:
exit(0);
}
}
void OnSize(int width,int height)
{
glViewport(0, 0 , (GLsizei)width,(GLsizei)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,(GLdouble)width,0, (GLdouble)height);
}

void main()
{
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE);
glutInitWindowPosition(100,100);
glutInitWindowSize(640,480);
glutCreateWindow("hello");
myInit();
glutDisplayFunc(mydraw);
glutReshapeFunc(OnSize);
glutKeyboardFunc(onkey);
glutMainLoop();
}
Về Đầu Trang Go down
https://minhlap.forumvi.com
 
to mau de qui
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