فهرست منبع

A fiew gl improvements

Panagiotis Christopoulos Charitos 13 سال پیش
والد
کامیت
e3886516ee
4فایلهای تغییر یافته به همراه28 افزوده شده و 30 حذف شده
  1. 15 0
      anki/gl/Fbo.cpp
  2. 3 15
      anki/gl/Fbo.h
  3. 6 6
      anki/renderer/Bl.cpp
  4. 4 9
      anki/renderer/Bs.cpp

+ 15 - 0
anki/gl/Fbo.cpp

@@ -69,6 +69,21 @@ uint Fbo::getCurrentFbo()
 }
 
 
+//==============================================================================
+void Fbo::setColorAttachments(const std::initializer_list<const Texture*>& 
+	textures)
+{
+	setNumOfColorAttachements(textures.size());
+	int i = 0;
+	for(const Texture* tex : textures)
+	{
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
+			GL_TEXTURE_2D, tex->getGlId(), 0);
+		++i;
+	}
+}
+
+
 //==============================================================================
 void Fbo::setOtherAttachment(GLenum attachment, const Texture& tex)
 {

+ 3 - 15
anki/gl/Fbo.h

@@ -6,6 +6,7 @@
 #include "anki/util/Exception.h"
 #include <GL/glew.h>
 #include <array>
+#include <initializer_list>
 
 
 namespace anki {
@@ -58,8 +59,8 @@ public:
 	void setNumOfColorAttachements(uint num) const;
 
 	/// Set the color attachments of this FBO
-	template<typename Container>
-	void setColorAttachments(const Container& textures);
+	void setColorAttachments(const std::initializer_list<const Texture*>& 
+		textures);
 
 	/// Set other attachment
 	void setOtherAttachment(GLenum attachment, const Texture& tex);
@@ -93,19 +94,6 @@ private:
 };
 
 
-//==============================================================================
-template<typename Container>
-void Fbo::setColorAttachments(const Container& textures)
-{
-	setNumOfColorAttachements(textures.size());
-	for(size_t i = 0; i < textures.size(); ++i)
-	{
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
-			GL_TEXTURE_2D, textures[i]->getGlId(), 0);
-	}
-}
-
-
 } // end namespace
 
 

+ 6 - 6
anki/renderer/Bl.cpp

@@ -28,8 +28,8 @@ void Bl::init(const RendererInitializer& initializer)
 
 		hBlurFbo.create();
 		hBlurFbo.bind();
-		std::array<Texture*, 1> fais = {{&blurFai}};
-		hBlurFbo.setColorAttachments(fais);
+		hBlurFbo.setColorAttachments({&blurFai});
+		hBlurFbo.checkIfGood();
 	}
 	catch(const std::exception& e)
 	{
@@ -46,8 +46,8 @@ void Bl::init(const RendererInitializer& initializer)
 	{
 		vBlurFbo.create();
 		vBlurFbo.bind();
-		std::array<const Texture*, 1> fais = {{&r->getPps().getPostPassFai()}};
-		vBlurFbo.setColorAttachments(fais);
+		vBlurFbo.setColorAttachments({&r->getPps().getPostPassFai()});
+		vBlurFbo.checkIfGood();
 	}
 	catch(std::exception& e)
 	{
@@ -64,8 +64,8 @@ void Bl::init(const RendererInitializer& initializer)
 	{
 		sideBlurFbo.create();
 		sideBlurFbo.bind();
-		std::array<const Texture*, 1> fais = {{&r->getMs().getNormalFai()}};
-		sideBlurFbo.setColorAttachments(fais);
+		sideBlurFbo.setColorAttachments({&r->getMs().getNormalFai()});
+		sideBlurFbo.checkIfGood();
 	}
 	catch(std::exception& e)
 	{

+ 4 - 9
anki/renderer/Bs.cpp

@@ -25,17 +25,12 @@ void Bs::createFbo()
 		fbo.create();
 		fbo.bind();
 	
-		std::array<>
-
-		fbo.setNumOfColorAttachements(1);
-
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-			GL_TEXTURE_2D, r.getPps().getPrePassFai().getGlId(), 0);
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
-			GL_TEXTURE_2D, r.getMs().getDepthFai().getGlId(), 0);
+		std::array<const Texture*, 1> fais = {{&r.getPps().getPrePassFai()}};
+		fbo.setColorAttachments(fais);
+		fbo.setOtherAttachments(GL_DEPTH_STENCIL_ATTACHMENT, 
+			r.getMs().getDepthFai());
 
 		fbo.checkIfGood();
-
 		fbo.unbind();
 	}
 	catch(std::exception& e)