-1
我正確設置OpenGL上下文我想我只能調用glClear()成功(背景顏色變化)。當我試圖畫東西的時候,什麼都不會被看到。只能使用glClear(xy | xy),沒有圖紙被「取走」
int main()
{
// Opening a Window
h3d::Window App(h3d::Vec2<unsigned int>(800,600),L"Test",h3d::Style::Default);
// Init Extensions
glewInit();
glViewport(0, 0, 800, 600);
//Set up the orthographic projection so that coordinates (0, 0) are in the top left
//and the minimum and maximum depth is -10 and 10. To enable depth just put in
//glEnable(GL_DEPTH_TEST)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 800, 600, 0, -10, 10);
//Back to the modelview so we can draw stuff
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear the screen and depth buffer
int i = 0;
App.setActive();
while (App.isOpen())
{
cout << "new loop " << i << endl; i++;
App.update();
if(i%2 == 0)
glClearColor(1.0, 0.75, 0.5, 1.0);
else
glClearColor(1.0, 0.75, 1.0, 0.5);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glBegin(GL_QUADS);
glColor3f(0.0, 0.0, 0.0);
glVertex2f(0.0,0.0);
glVertex2f(1.0,0.0);
glVertex2f(1.0,1.0);
glVertex2f(0.0,1.0);
glEnd();
App.swapBuffers();
}
}
因此,窗口可以正確打開,並且存在交替的背景顏色。 我的圖紙仍然不在屏幕上。
假設這個'h3d :: Window'構造函數創建了一個文檔上下文/兼容性配置文件,您應該在窗口左上角看到一個_single_黑色像素。你確定那不在嗎? – derhass
不,檢查出來 –