我有一个程序,有大约3个不同大小的帧缓冲区.我在开始时初始化它们,为它们提供适当的渲染目标并更改每个渲染目标的视口大小.
我原本以为你只glViewport需要在初始化帧缓冲区时调用,但这会在我的程序中产生问题所以我认为这是错的?因为它们的分辨率都不同,所以当我在每个帧中渲染时,我绑定第一个帧缓冲区,更改视口大小以适合该帧缓冲区,绑定第二个帧缓冲区,更改视口大小以适应第二个帧缓冲区的分辨率,绑定第三个帧缓冲区,更改视口大小以适合它,然后绑定窗口帧缓冲区并将视口大小更改为窗口的分辨率.
这是必要的,还是程序中的其他东西应该归咎于什么?这是每一帧完成的,所以我担心如果我不必这样做会有一点点不必要的开销.
所以基本上我在VS2013中有一些看起来像这样的c ++代码
#include "stdafx.h"
#include <malloc.h>
#include <stdio.h>
class Test_Class {
public:
Test_Class() {
printf("In Test_Class()\n");
allocated_array = (int*)malloc(sizeof(int) * 64);
printf("Allocated %p\n", allocated_array);
}
~Test_Class() {
printf("In ~Test_Class()\n");
printf("Freeing %p\n", allocated_array);
free(allocated_array);
printf("Freed %p\n", allocated_array);
}
private:
int* allocated_array;
};
class Holder {
public:
Holder() {
printf("In Holder()\n");
m_test_class = Test_Class();
}
~Holder() {
printf("In ~Holder()\n");
}
private:
Test_Class m_test_class;
};
class Game {
public:
Game() {
printf("In Game()\n");
m_holder = Holder();
}
~Game() {
printf("In ~Game()");
}
private: …Run Code Online (Sandbox Code Playgroud)