⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swing.cpp

📁 数值分析的曲线插值算法
💻 CPP
字号:
// swing.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <stdlib.h>
#include "gl/glut.h"
#include "gl/gl.h"
#include "global.h"

#pragma comment(lib, "opengl32.lib")							// 包含OpenGL库
#pragma comment(lib, "glu32.lib")							
#pragma comment(lib, "glaux.lib")		
#pragma comment(lib, "glut32.lib")



void init()
{
	glClearColor (1.0, 1.0, 1.0, 0.0);
	glShadeModel (GL_SMOOTH);
	file = fopen("serial.txt","w");
	for(int i=0;i<(int)(190/delta);i++)
		fprintf(file,"%.1f\n",i*0.5);
	fclose;
}

void display()
{
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glColor3f(0.0,0.0,0.0);
	int i;
	glLineWidth(2.0);
	glBegin(GL_LINE_STRIP);
	for(i=0;i<(int)(190/delta);i++)
		glVertex2f(i*0.5,R[i]);
	glEnd();
	glPointSize(8.0);
	glColor3f(1.0,0.0,0.0);
	glBegin(GL_POINTS);
	for(i=0;i<N;i++)
		glVertex3f(X[i],Y[i],0);
	glEnd();
	glutSwapBuffers();
}

void reshape(int w,int h)
{
	glViewport(0,0,(GLsizei)w,(GLsizei)h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-10.0, 90.0, -((float)h/w*50), (float)h/w*50, -20.0, 20.0);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}

int _tmain(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode (GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
	glutInitWindowSize (800, 500);
	glutInitWindowPosition (150, 100);
	glutCreateWindow (argv[0]);
	init();
//	line(X,Y,R);
//	sqr(X,Y,R);
//	cub(X,Y,R);
	Spi(X,Y,R);
	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	glutMainLoop();
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -