如何創建一個在運行時計算大小的GLTexture nullptrs數組? 。下面的實現創建一個數組GLTexture指針,初始化爲nullptr,常量大小爲[11] [32]。我希望下面頭文件中顯示的11和32與運行時計算的值互換。如何在不構建對象的情況下在運行時設置數組大小?
頭文件
#pragma once
#include <GLEW\glew.h>
#include "GLTexture.h"
namespace Nova
{
class TextureBinder
{
private:
GLuint m_activeUnit;
GLint m_maxTextureUnits;
GLint m_maxTextureTargets;
GLTexture* m_boundTextures[11][32] = {nullptr};
public:
static TextureBinder& GetInstance()
{
static TextureBinder binder;
return binder;
}
TextureBinder(TextureBinder const&) = delete;
void operator=(TextureBinder&) = delete;
private:
TextureBinder();
};
}
CPP文件
#pragma once
#include "TextureBinder.h"
namespace Nova
{
/* zero is the default opengl active texture unit
- glActiveTexture(unit) only needs to be called for multitexturing
*/
TextureBinder::TextureBinder()
:
m_activeUnit(0),
m_maxTextureTargets(11)
{
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &m_maxTextureUnits);
}
}
哪個變量是你想要的數組大小?你的代碼很長。 –
@ArifBurhan對不起,錯過了! m_boundTextures [m_maxTextureTargets] [m_maxTextureUnits] – DanielCollier
是指向此類擁有的紋理的m_boundTextures指針,還是在別處管理的? –