資源簡介
BezierSurface.cpp為bezier曲面繪制的源程序,并且按鼠標右鍵菜單可實現,1顯示控制點 2。顯示網格曲面, 3 顯示光照曲面, 4 圖案紋理曲面, 5文件圖

代碼片段和文件信息
//程序10-1?Bezier曲線繪制實例
//?win32Test.cpp?:?Defines?the?entry?point?for?the?application.//
#include?“stdafx.h“
#include?
//?The?number?of?control?points?for?this?curve
GLint?nNumPoints?=?4;
?//control?point?group1
GLfloat?ctrlPoints[4][3]=?{{??-4.0f?0.0f?0.0f} //?End?Point
{?-6.0f?4.0f?0.0f} //?Control?Point
{??6.0f?-4.0f?0.0f} //?Control?Point
{??4.0f?0.0f?0.0f?}}; //?End?Point
void?ChangeSize(int?w?int?h);
void?DrawPoints(void);
void?RenderScene(void);
void?SetupRC();
int?APIENTRY?_tWinMain(HINSTANCE?hInstance
?????????????????????HINSTANCE?hPrevInstance
?????????????????????LPTSTR????lpCmdLine
?????????????????????int???????nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
?
char?*argv[]?=?{“hello?“?“?“};
int?argc?=?2;?//?must/should?match?the?number?of?strings?in?argv
glutInit(&argc?argv);????//初始化GLUT庫;
glutInitDisplayMode(GLUT_DOUBLE?|?GLUT_RGB);???//設置顯示模式;(緩沖,顏色類型)
glutInitWindowSize(500?500);
glutInitWindowPosition(1024?/?2?-?250?768?/?2?-?250);
glutCreateWindow(“Bezier?Curve“);??//創建窗口,標題為“Rotating?3D?World”;
glutReshapeFunc(ChangeSize);
SetupRC();;
glutDisplayFunc(RenderScene);??//用于繪制當前窗口;
glutMainLoop();???//表示開始運行程序,用于程序的結尾;
return?0;
}
void?DrawPoints(void)
????{
????int?i; //?Counting?variable
????//?Set?point?size?larger?to?make?more?visible
????glPointSize(5.0f);
????//?Loop?through?all?control?points?for?this?example
????glBegin(GL_POINTS);
????????for(i?=?0;?i????????????glVertex2fv(ctrlPoints[i]);
????glEnd();
????}
//?Called?to?draw?scene
void?RenderScene(void)
????{
????int?i;
????
????//?Clear?the?window?with?current?clearing?color
????glClear(GL_COLOR_BUFFER_BIT);
????//?Sets?up?the?bezier
????//?This?actually?only?needs?to?be?called?once?and?could?go?in
????//?the?setup?function
????glMap1f(GL_MAP1_VERTEX_3 //?Type?of?data?generated
????0.0f //?Lower?u?range
????100.0f //?Upper?u?range
????3 //?Distance?between?points?in?the?data
????nNumPoints //?number?of?control?points
????&ctrlPoints[0][0]); //?array?of?control?points
????//?Enable?the?evaluator
????glEnable(GL_MAP1_VERTEX_3);
//?Use?a?line?strip?to?“connect-the-dots“
glBegin(GL_LINE_STRIP);
for(i?=?0;?i?<=?100;?i++)
{
//?Evaluate?the?curve?at?this?point
glEvalCoord1f((GLfloat)?i);?
????????????}
????glEnd();
????//?Use?higher?level?functions?to?map?to?a?grid?then?evaluate?the
????//?entire?thing.
????//?Put?these?two?functions?in?to?replace?above?loop
????//?Map?a?grid?of?100?points?from?0?to?100
???//glMapGrid1d(1000.0100.0);
????//?Evaluate?the?grid?using?lines
????//glEvalMesh1(GL_LINE0100);
????//?Draw?the?Control?Points
????DrawPoints();
????//?Flush?drawing?commands
????glutSwapBuffers();
????}
//?This?function?does?any?needed?initialization?on?the?rendering
//?context.?
void?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-06-17?08:01??lab16-BezierCurveSurface\
?????目錄???????????0??2015-06-17?09:26??lab16-BezierCurveSurface\lab16-BezierCurveSurface\
?????文件????????3627??2015-06-14?23:12??lab16-BezierCurveSurface\lab16-BezierCurveSurface\BezierCurve.cpp
?????文件????????5280??2015-06-14?23:14??lab16-BezierCurveSurface\lab16-BezierCurveSurface\BezierSurface.cpp
?????文件???????10620??2015-06-03?09:29??lab16-BezierCurveSurface\lab16-BezierCurveSurface\Texture.cpp
?????文件?????????437??2007-12-04?13:55??lab16-BezierCurveSurface\lab16-BezierCurveSurface\Texture.h
?????文件??????164675??2003-05-10?14:27??lab16-BezierCurveSurface\lab16-BezierCurveSurface\tuxture.jpg
?????文件??????286720??2015-06-17?09:14??lab16-BezierCurveSurface\lab16-BezierCurveSurface\實驗十六????Bezier曲線曲面繪制.doc
- 上一篇:N76E003單片機串口BUG修改
- 下一篇:基于8086的交通燈.zip
評論
共有 條評論