http://expert.csdn.net/Expert/TopicView1.asp?id=1528912
解决方案 »
- WIN32API、串口、同步、WriteFile、阻塞
- 高分回赠!小弟学习VC++有一个月了,但是还是不能上手,我应该掌握哪些VC++的知识点?
- 有人对adsl信息读取,dns性能检测,路由路径检测有了解吗,类似星空急速里网络诊断功能的,能做的联系我价格可以谈
- [请教] MSDN 怎么老是装不上,装到"指定路径"这一不就出问题了!提示:路径有错误,请另找一个!
- [新手提问]将3个字节的高低位拆分,再合成数值的问题
- msn的mail的乱码
- 如何把:会计上的金额:123456789.321转换成中文大写 和 英文.??
- 哪里有visual c++6.0可以下载。。。急用。。。。谢谢
- MFC如何在自己定义的类中调用CWnd类中的Invalidate重绘?
- 工具条不能切换
- 如果说你把“CRect”印成“Crect”我还能够容忍的话,那你把“4-KB”印成“4-MB”我就不能不说点什么了!--读《Visual C++ 6.0技术内幕
- 关于窗口切分的问题
如果不这样,就需要记录关键点时时计算,这设计到曲线拟和,相当复杂。
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
#include <math.h>
// Define a constant for the value of PI
#define GL_PI 3.1415f// Rotation amounts
static GLfloat xRot = 0.0f;
static GLfloat yRot = 0.0f;
// Called to draw scene
void RenderScene(void)
{
GLfloat x,y,z,angle; // Storeage for coordinates and angles // Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT); // Save matrix state and do the rotation
glPushMatrix();
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
glRotatef(yRot, 0.0f, 1.0f, 0.0f); // Call only once for all remaining points
glBegin(GL_LINE_STRIP); z = -50.0f;
for(angle = 0.0f; angle <= (2.0f*3.1415f)*3.0f; angle += 0.1f)
{
x = 50.0f*sin(angle);
y = 50.0f*cos(angle);
// Specify the point and move the Z value up a little
glVertex3f(x, y, z);
z += 0.5f;
} // Done drawing points
glEnd(); // Restore transformations
glPopMatrix(); // Flush drawing commands
glutSwapBuffers();
}// This function does any needed initialization on the rendering
// context.
void SetupRC()
{
// Black background
glClearColor(0.0f, 0.0f, 0.0f, 1.0f ); // Set drawing color to green
glColor3f(0.0f, 1.0f, 0.0f);
}void SpecialKeys(int key, int x, int y)
{
if(key == GLUT_KEY_UP)
xRot-= 5.0f; if(key == GLUT_KEY_DOWN)
xRot += 5.0f; if(key == GLUT_KEY_LEFT)
yRot -= 5.0f; if(key == GLUT_KEY_RIGHT)
yRot += 5.0f; if(key > 356.0f)
xRot = 0.0f; if(key < -1.0f)
xRot = 355.0f; if(key > 356.0f)
yRot = 0.0f; if(key < -1.0f)
yRot = 355.0f; // Refresh the Window
glutPostRedisplay();
}
void ChangeSize(int w, int h)
{
GLfloat nRange = 100.0f; // Prevent a divide by zero
if(h == 0)
h = 1; // Set Viewport to window dimensions
glViewport(0, 0, w, h); // Reset coordinate system
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // Establish clipping volume (left, right, bottom, top, near, far)
if (w <= h)
glOrtho (-nRange, nRange, -nRange*h/w, nRange*h/w, -nRange, nRange);
else
glOrtho (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange); glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("Line Strips Example");
glutReshapeFunc(ChangeSize);
glutSpecialFunc(SpecialKeys);
glutDisplayFunc(RenderScene);
SetupRC();
glutMainLoop(); return 0;
}