OpenGL 'reshape()'函数视口边框背景

OpenGL 'reshape()' function Viewport Border Background

本文关键字:视口 边框 背景 函数 reshape OpenGL      更新时间:2023-10-16

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

我在视口

中添加了一个边框,因此它在视口周围留下了一个 50px 的边框,这符合我的预期。

    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); 、 黑色进行设置。

我的问题是,可以将边框分配给背景不同的颜色吗?(如果我更改颜色,背景和边框始终是颜色集)。

使用剪刀区域告诉 OpenGL 清除位置:

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