gpt4 book ai didi

c++ - OpenGL 'reshape()' 功能视口(viewport)边框背景

转载 作者:太空宇宙 更新时间:2023-11-04 11:48:16 25 4
gpt4 key购买 nike

我已经在 OpenGL 3.2+ 程序中使用 Win32 创建了一个窗口,并且正在试验一些东西。目前我正在使用下面的 reshape() 函数来调整窗口大小等。

我在视口(viewport)内添加了一个边框,因此它在视口(viewport)周围留下了 50 像素的边框,这符合我的预期。

    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); 设置为黑色。

我的问题是,可以为边框指定不同的颜色给背景吗?(如果我改变颜色,背景和边框总是颜色集)。

最佳答案

使用scissor regions告诉 OpenGL 在哪里清除:

  1. glDisable( GL_SCISSOR_TEST )
  2. 清除边框颜色
  3. 将剪刀设置到边界区域
  4. glEnable( GL_SCISSOR_TEST )
  5. 清除内色
  6. 渲染场景

关于c++ - OpenGL 'reshape()' 功能视口(viewport)边框背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19234044/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com