麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

OpenGL 學(xué)習(xí)筆記3_1(繪制點(diǎn)相關(guān))

2019-11-11 04:43:55
字體:
供稿:網(wǎng)友

藍(lán)寶書 第三章

畫點(diǎn) Point

1)單個(gè)點(diǎn)

glVertex3f(50.0f,50.0f,0.0f)  3D圖像的點(diǎn)

glVertex2f(50.0f,50.0f)         2D圖像的點(diǎn)

2)多個(gè)點(diǎn)

glBegin(GL_POINTS)

……

glEnd();

相關(guān)代碼見例3.2

3)設(shè)置點(diǎn)大小

void glPointSize(GLfloatsize);設(shè)置點(diǎn)的大小

GLfloat sizes[2]; // 存放點(diǎn)大小的范圍

GLfloat step; // 存放每次改變點(diǎn)大小的最小增量

glGetFloatv(GL_POINT_SIZE_RANGE,sizes);

glGetFloatv(GL_POINT_SIZE_GRANULARITY,&step);

相關(guān)代碼見例3.3

例3.1 窗口改變響應(yīng)函數(shù)--3D版

void ChangeSize(GLsizei w, GLsizei 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 projection matrix stack	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);	// Reset Model view matrix stack	glMatrixMode(GL_MODELVIEW);	glLoadIdentity();}例3.2   顯示多個(gè)點(diǎn)

#include <windows.h>#include <math.h>#include <GL/GL.h>#include <GL/GLU.h>#include <GL/glut.h>// Define a constant for the value of PI#define GL_PI 3.1415f// This function does any needed initialization on the renderingvoid RenderScene(void){	GLfloat x, y, z, angle; // Storage 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(30.0f, 1.0f, 0.0f, 0.0f);//書中的xRot代表x軸偏移的角度,此處改為x軸偏移30度	glRotatef(30.0f, 0.0f, 1.0f, 0.0f);//書中的yRot代表y軸偏移的角度,此處改為y軸偏移30度	// Call only once for all remaining points	glBegin(GL_POINTS);	z = -50.0f;	for (angle = 0.0f; angle <= (2.0f*GL_PI)*3.0f; angle += 0.1f)	{		x = 50.0f*sin(angle);//sin輸入為弧度		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();}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 ChangeSize(GLsizei w, GLsizei 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 projection matrix stack	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);	// Reset Model view matrix stack	glMatrixMode(GL_MODELVIEW);	glLoadIdentity();}int main(int argc, char* argv[]){	glutInit(&argc, argv);	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);	glutInitWindowSize(800, 600);	glutCreateWindow("Bounce");	glutDisplayFunc(RenderScene);//顯示回調(diào)函數(shù)	glutReshapeFunc(ChangeSize);//窗口大小變形回調(diào)函數(shù)	SetupRC();	glutMainLoop();	return 0;}例3.3 點(diǎn)大小的改變

#include <windows.h>#include <math.h>#include <GL/GL.h>#include <GL/GLU.h>#include <GL/glut.h>// Define a constant for the value of PI#define GL_PI 3.1415f// This function does any needed initialization on the renderingvoid RenderScene(void){	GLfloat x, y, z, angle; // Storage for coordinates and angles	GLfloat sizes[2]; // Store supported point size range	GLfloat step; // Store supported point size increments	GLfloat curSize; // Store current point size		// Clear the window with current clearing color	glClear(GL_COLOR_BUFFER_BIT);	// Save matrix state and do the rotation	glPushMatrix();	glRotatef(30.0f, 1.0f, 0.0f, 0.0f);//書中的xRot代表x軸偏移的角度	glRotatef(30.0f, 0.0f, 1.0f, 0.0f);//書中的yRot代表y軸偏移的角度	// Get supported point size range and step size	glGetFloatv(GL_POINT_SIZE_RANGE, sizes);	glGetFloatv(GL_POINT_SIZE_GRANULARITY, &step);	// Set the initial point size	curSize = sizes[0];	// Set beginning z coordinate	z = -50.0f;	// Call only once for all remaining points	glBegin(GL_POINTS);	z = -50.0f;	for (angle = 0.0f; angle <= (2.0f*GL_PI)*3.0f; angle += 0.1f)	{		// Calculate x and y values on the circle		x = 50.0f*sin(angle);		y = 50.0f*cos(angle);		// Specify the point size before the primitive is specified		glPointSize(curSize);		// Draw the point		glBegin(GL_POINTS);		glVertex3f(x, y, z);		glEnd();		// Bump up the z value and the point size		z += 0.5f;		curSize += step;	}	// Done drawing points	glEnd();	// Restore transformations	glPopMatrix();	// Flush drawing commands	glutSwapBuffers();}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 ChangeSize(GLsizei w, GLsizei 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 projection matrix stack	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);	// Reset Model view matrix stack	glMatrixMode(GL_MODELVIEW);	glLoadIdentity();}int main(int argc, char* argv[]){	glutInit(&argc, argv);	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);	glutInitWindowSize(800, 600);	glutCreateWindow("Bounce");	glutDisplayFunc(RenderScene);//顯示回調(diào)函數(shù)	glutReshapeFunc(ChangeSize);//窗口大小變形回調(diào)函數(shù)	SetupRC();	glutMainLoop();	return 0;}


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 性毛片视频| 国产精品视频一区二区三区四区五区 | 亚洲欧美一区二区三区在线观看 | 久草视频在线资源 | 欧美成网 | 精品在线观看一区二区 | 欧美成人一二三区 | 毛片免费视频在线观看 | 国产高潮好爽好大受不了了 | 欧洲a级片 | 狠狠干视频网站 | 国产精品剧情一区二区三区 | 成人羞羞在线观看网站 | 羞羞的视频免费在线观看 | 销魂美女一区二区 | 免费看污视频在线观看 | 国产精品剧情一区二区在线观看 | 精品国产乱码久久久久久丨区2区 | 欧美一级淫片免费视频1 | 欧美成人视 | 香蕉黄色网| 国产一级αv片免费观看 | 久久久三级免费电影 | 国产精品久久久久久久模特 | 美国一级黄色毛片 | 宅男噜噜噜66国产在线观看 | 亚洲国产视频网 | 亚洲精品7777xxxx青睐 | 亚洲国产精品久久久久久久 | 国产精品久久久久久久久久久久午夜 | 欧美性受ⅹ╳╳╳黑人a性爽 | 男女隐私免费视频 | 久久精品日韩 | 激情亚洲一区二区三区 | 双性精h调教灌尿打屁股的文案 | 欧美亚成人 | 国产一区二区精品91 | 亚洲成人福利在线观看 | 国产免费一区二区三区在线能观看 | 视频二区国产 | 九九视频在线观看黄 |