2013-10-07 25 views
1

我已經在OpenGL 3.2+程序中使用Win32創建了一個窗口,我正在試驗一些東西。 目前我使用下面的reshape()功能調整窗口大小等OpenGL'reshape()'函數視口邊框背景

所以給人們留下圍繞着做什麼,我期待的視口的一個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);,爲黑色。

我的問題是,邊框是否可以爲背景分配不同的顏色? (如果我改變顏色,背景和邊框始終是顏色設置)。

回答

1

使用scissor regions告訴OpenGL的情況下清除:

  1. glDisable(GL_SCISSOR_TEST)
  2. 清除與邊框顏色
  3. 設置剪刀邊境地區
  4. glEnable(GL_SCISSOR_TEST)
  5. 清除與內部顏色
  6. 渲染場景
+0

啊,太簡單了:)謝謝發貼!很好的幫助。 – Reanimation