画曲线
来源:互联网 发布:广州鹰眼数据周训威 编辑:程序博客网 时间:2024/05/08 01:34
#include<windows.h>
#include<math.h>
#include<gl/gl.h>
#include<gl/glut.h>
#define pi 3.1415926
#define MAXSIZE 1366
const int screenWidth=1366;
const int screenHeight=768;
struct GLdoublePoint
{
GLdouble x,y;
};
struct GLdoublePoint CP;
GLdouble x[MAXSIZE],y[MAXSIZE];
void myInit()
{
glClearColor(1.0,1.0,1.0,0.0);//背景颜色为白
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0f,0.0f,0.0f);//画图颜色为黑
glLineWidth(1.0);//画线线粗大小
glMatrixMode(GL_PROJECTION);//设置"相机形状"
glLoadIdentity();
gluOrtho2D(0.0,(GLdouble)screenWidth,0.0,(GLdouble)screenHeight);
}
void moveTo(GLdouble x,GLdouble y)
{
CP.x=x;
CP.y=y;
}
void lineTo(GLdouble x,GLdouble y)
{
glBegin(GL_LINES);
glVertex2d(CP.x,CP.y);
glVertex2d(x,y);
glEnd();
glFlush();
CP.x=x;
CP.y=y;
}
void myDisplay()
{
int i;
for(i=0;i<MAXSIZE;i++)
{
x[i]=i;
y[i]=100*cos(-pi*i/200)+300;
}
moveTo(x[0],y[0]);
for(i=0;i<MAXSIZE;i++)
lineTo(x[i]+5.0,y[i]);
}
void main(int argc,char** argv)
{
glutInit(&argc,argv); //初始化工具包
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);//设置显示模式
glutInitWindowSize(screenWidth,screenHeight);//设置窗口大小
glutInitWindowPosition(0,0);//设置窗口在屏幕上的位置
glutCreateWindow("OpenGL DEMO");
glutDisplayFunc(myDisplay);//注册重画函数
myInit();
glutMainLoop();
}
- 画曲线
- 画平滑曲线 & 曲线加粗
- caffe 画损失曲线和准确率曲线
- 画图(画曲线)
- Excel 画函数曲线
- as3画曲线
- VC++画动态曲线
- Flot画实时曲线
- flot画曲线坐标
- plot画基本曲线
- java画Koch曲线
- 画直线和曲线
- java画Hibert曲线
- matlab画曲线
- GDI画sin曲线
- 画ROC曲线
- 使用GDI+画曲线
- windows画sin曲线
- UVA 10161 Ant on a Chessboard
- Cocos2d-x利用CCSpriteBatchNode提高渲染效率
- java top 10 book
- 【C/S通信交互之Http篇】Cocos2dx(Client)使用Curl与Jetty(Server)实现手机网游Http通信框架(内含解决curl.h头文件找不到问题)
- Databases are fun, Until you use them...
- 画曲线
- 【JAVA】 protected和default访问属性实例
- uva 12554 - A Special "Happy Birthday" Song!!!
- OCP-1Z0-053-V12.02-68题
- 求解圆形的面积和周长
- 《程序员面试宝典》(第三版)笔记整理
- golismero
- UVA 10970 Big Chocolate
- Cookie报错java.lang.IllegalArgumentException