OpenGL 'reshape()' 函数视口边框背景 [英] OpenGL 'reshape()' function Viewport Border Background
问题描述
我已经在 OpenGL 3.2+ 程序中使用 Win32 创建了一个窗口,并且正在试验中.目前我正在使用下面的 reshape()
函数来调整窗口大小等
I've created a window using Win32 in an OpenGL 3.2+ program and I'm experimenting with things.
Currently I'm using the reshape()
function below to resize the window etc.
我在视口内添加了一个边框,因此它在视口周围留下了一个 50 像素的边框,这符合我的预期.
I've added a border within the viewport so it leaves a 50px border around the viewport which does what I was expecting.
void reshape(int width, int height, int pers_Dist)
{
screenWidth = width;
screenHeight = height;
float border = 50;
glViewport(0+border,0+border,width-(border*2),height-(border*2));
MatrixRoutines<float>::perspective(pers_Dist, (GLfloat)screenWidth/(GLfloat)screenHeight, 1, 200, ProjectionMatrix);
}
背景颜色在 init()
函数内部使用:glClearColor(0.0,0.0,0.0,0.0);
设置为黑色.
The background colour is set inside the init()
function using: glClearColor(0.0,0.0,0.0,0.0);
, to black.
我的问题是,边框可以为背景指定不同的颜色吗?(如果我改变颜色,背景和边框总是设置的颜色).
My question is, can the border be assigned a different colour to the background? (if I change the colour, both the background and border are always the colour set).
推荐答案
使用 剪刀区域告诉OpenGL在哪里清除:
Use scissor regions to tell OpenGL where to clear:
glDisable( GL_SCISSOR_TEST )
- 用边框颜色清除
- 将剪刀设置为边界区域
glEnable(GL_SCISSOR_TEST)
- 内部颜色清晰
- 渲染场景
这篇关于OpenGL 'reshape()' 函数视口边框背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!