资源简介
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 < nNumPoints; 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
评论
共有 条评论