MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / CFrameBufferObject

Class CFrameBufferObject

Common/rendercheck_gl.h:729–1112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

727};
728
729class CFrameBufferObject {
730 public:
731 CFrameBufferObject(unsigned int width, unsigned int height, unsigned int Bpp,
732 bool bUseFloat, GLenum eTarget)
733 : m_Width(width),
734 m_Height(height),
735 m_bUseFloat(bUseFloat),
736 m_eGLTarget(eTarget) {
737 glGenFramebuffersEXT(1, &m_fboData.fb);
738
739 m_fboData.colorTex =
740 createTexture(m_eGLTarget, width, height,
741 (bUseFloat ? GL_RGBA32F_ARB : GL_RGBA8), GL_RGBA);
742
743 m_fboData.depthTex = createTexture(
744 m_eGLTarget, width, height, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT);
745
746 attachTexture(m_eGLTarget, m_fboData.colorTex, GL_COLOR_ATTACHMENT0_EXT);
747 attachTexture(m_eGLTarget, m_fboData.depthTex, GL_DEPTH_ATTACHMENT_EXT);
748
749 // bool ret = checkStatus(__FILE__, __LINE__, true);
750 }
751
752 virtual ~CFrameBufferObject() {
753 // freeResources();
754 }
755
756 GLuint createTexture(GLenum target, int w, int h, GLint internalformat,
757 GLenum format) {
758 GLuint texid;
759 glGenTextures(1, &texid);
760 glBindTexture(target, texid);
761
762 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
763 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
764 glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
765 glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
766
767 glTexImage2D(target, 0, internalformat, w, h, 0, format, GL_FLOAT, 0);
768 return texid;
769 }
770
771 void attachTexture(GLenum texTarget, GLuint texId,
772 GLenum attachment = GL_COLOR_ATTACHMENT0_EXT,
773 int mipLevel = 0, int zSlice = 0) {
774 bindRenderPath();
775
776 switch (texTarget) {
777 case GL_TEXTURE_1D:
778 glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_1D,
779 texId, mipLevel);
780 break;
781
782 case GL_TEXTURE_3D:
783 glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_3D,
784 texId, mipLevel, zSlice);
785 break;
786

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected