資源簡介
opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習

代碼片段和文件信息
#include?
#include?
???GLsizei?winWidth?=?800?winHeight?=?600;?//?窗口的大小
???GLfloat?red?=?1.0?green?=?0.0?blue?=?0.0;?//顏色
???GLenum?fillMode?=?GL_SMOOTH;?
???bool?LineCircleRectanger;
???int?xstartystartxendyend;//鼠標的坐標
???float?r;//圓的半徑
???int?NUM=200;//?定義繪制圓時用的頂點數(用頂點組成的線段逼近圓)(new)
???
void?fillOption(GLint?s){
//glutPostRedisplay();
}
void?graphics(GLint?selectedOption)
{
???switch?(selectedOption)?{
???????????case?1:Line=trueCircle=falseRectanger=false;?break;
???????????case?2:Line=falseCircle=trueRectanger=false;?break;
???????????case?3:Line=falseCircle=falseRectanger=true;?break;?????????
????}
??//??glutPostRedisplay?(?);
}
void?colorselection(GLint?selectedOption)
{
???switch?(selectedOption)?{
???????????case?1:red?=?1.0?green?=?0.0?blue?=?0.0;?break;
???????????case?2:red?=?0.0?green?=?1.0?blue?=?0.0;?break;
???????????case?3:red?=?0.0?green?=?0.0?blue?=?1.0;?break;?????????
????}
???//?glutPostRedisplay?(?);
}
void?mousemove(int?xmoveint?ymove)
{
if(Line){
glEnable(GL_COLOR_LOGIC_OP);
????????glLogicOp(GL_XOR);
????????glBegin(GL_LINES);
???????????glVertex2i(xstartystart);
???????????glVertex2i(xendyend);
????????glEnd();
????????xend=xmove;
????????yend=winHeight-ymove;
????????glBegin(GL_LINES);
??????????glVertex2i(xstartystart);
??????????glVertex2i(xendyend);
????????glEnd();
????????glFlush();
}
else?if(Rectanger){
?????????glEnable(GL_COLOR_LOGIC_OP);//啟動邏輯異或
?????????glLogicOp(GL_XOR);
?????????glBegin(GL_LINE_LOOP);
????glVertex2i(xstartystart);
glVertex2i(xstartyend);
glVertex2i(xendyend);
glVertex2i(xendystart);
//glVertex2i(xstartystart);
?glEnd();
?????????xend=xmove;
?????????yend=winHeight-ymove;
????????glBegin(GL_LINE_LOOP);
?????????glVertex2i(xstartystart);
?????glVertex2i(xstartyend);
?????glVertex2i(xendyend);
?????glVertex2i(xendystart);
//?glVertex2i(xstartystart);
?glEnd();
?????????glFlush();
}
else?if(Circle){
?glEnable(GL_COLOR_LOGIC_OP);//啟動邏輯異或
?????????glLogicOp(GL_XOR);
?r=sqrt((xstart-xend)*(xstart-xend)+(ystart-yend)*(ystart-yend)*1.0)/2;???//計算圓的半徑
????????
glBegin(GL_LINE_LOOP); ? //?繪制圓(new)
for(int?i=0;?i {
glVertex2f((xstart+xend)/2+r*float(sin(2*3.14*i/NUM))(ystart+yend)/2+?r*float(cos(2*3.14*i/NUM)));
}
????glEnd();?????????????????????????????????????????????????????//?圓繪制結束
xend=xmove;
????????yend=winHeight-ymove;
????????r=sqrt((xstart-xend)*(xstart-xend)+(ystart-yend)*(ystart-yend)*1.0)/2;???//計算圓的半徑
glBegin(GL_LINE_LOOP); ? //?繪制圓(new)
for(int?i=0;?i {
glVertex2f((xstart+xend)/2+r*float(sin(2*3.14*i/NUM))(ystart+yend)/2+?r*float(cos(2*3.14*i/NUM)));
}
????glEnd();????????????????????????????????????????//?圓繪制結束
glFlush();
}
}
void?mouseud?(int?btnint?stateint?xint?y)
{
if(Line){
if
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????37376??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\Debug\interGraphics.exe
?????文件?????350084??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\Debug\interGraphics.ilk
?????文件?????420864??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\Debug\interGraphics.pdb
?????文件??????10910??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\Debug\BuildLog.htm
?????文件??????24964??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\Debug\Graphics.obj
?????文件????????663??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\Debug\interGraphics.exe.em
?????文件????????728??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\Debug\interGraphics.exe.em
?????文件????????621??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\Debug\interGraphics.exe.intermediate.manifest
?????文件?????????67??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\Debug\mt.dep
?????文件??????44032??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\Debug\vc90.idb
?????文件??????53248??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\Debug\vc90.pdb
?????文件???????7686??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\Graphics.cpp
?????文件???????3932??2009-10-26?18:03??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\interGraphics.vcproj
?????文件???????1427??2009-10-27?20:19??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\interGraphics.vcproj.HP-B23A3C94F490.hp.user
?????文件?????732160??2009-10-27?20:19??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics.ncb
?????文件????????905??2009-10-26?18:02??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics.sln
????..A..H.?????13312??2009-10-27?20:19??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics.suo
?????目錄??????????0??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics\Debug
?????目錄??????????0??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\Debug
?????目錄??????????0??2009-10-27?19:44??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics\interGraphics
?????目錄??????????0??2009-10-26?18:03??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習\interGraphics
?????目錄??????????0??2018-11-30?05:27??opengl的鼠標畫線,圓,矩形,還有個菜單,很適合opengl初學者學習
-----------?---------??----------?-----??----
??????????????1702979????????????????????22
評論
共有 條評論