超级宝典第三章剔除弃用的例子

1、注释一定是我的,配置当然也是是我的。其他的是蓝宝书的。



/ Scissor.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#ifdef WIN32

#pragma comment(lib, "freeglut_static.lib")

#endif


#include <GLTools.h>

#define FREEGLUT_STATIC
#include <GL/glut.h>

//每次渲染执行剔除测试,减少绘制量

void renderScene(void)
{
	//blue,透明
	glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
	glClear(GL_COLOR_BUFFER_BIT);

	//红色区域启动剔除
	glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
	glScissor(100, 100, 600, 400);
	glEnable(GL_SCISSOR_TEST);//启动剔除测试
	glClear(GL_COLOR_BUFFER_BIT);

	glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
	glScissor(200, 200, 400, 200);
	glClear(GL_COLOR_BUFFER_BIT);

	glDisable(GL_SCISSOR_TEST);

	glutSwapBuffers();

}

void changeSize(int w, int h)
{
	//要预防计算时为0的除法溢出
	if (h==0)
	{
		h = 1;
	}
	glViewport(0, 0, w, h);
}





int _tmain(int argc, char* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
	glutInitWindowSize(800, 600);
	glutCreateWindow("OpenGL Scissor");

	glutReshapeFunc(changeSize);
	glutDisplayFunc(renderScene);

	glutMainLoop();

	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值