Просмотр исходного кода

Added a flag to renderer to treat normal blending as premultiplied, made the screen entity size default to 0 instead of 1

Ivan Safrin 13 лет назад
Родитель
Сommit
4ed31d296e

+ 2 - 0
Core/Contents/Include/PolyRenderer.h

@@ -268,6 +268,8 @@ namespace Polycode {
 		std::vector<LightInfo> getSpotLights() { return spotLights;	}
 		
 		bool doClearBuffer;
+		
+		bool blendNormalAsPremultiplied;
 				
 	protected:	
 	

+ 4 - 0
Core/Contents/Source/PolyGLRenderer.cpp

@@ -413,7 +413,11 @@ void OpenGLRenderer::enableFog(bool enable) {
 void OpenGLRenderer::setBlendingMode(int blendingMode) {
 	switch(blendingMode) {
 		case BLEND_MODE_NORMAL:
+			if(blendNormalAsPremultiplied) {
+				glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);			
+			} else{
 				glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+			}
 		break;
 		case BLEND_MODE_LIGHTEN:
 				glBlendFunc (GL_SRC_ALPHA, GL_ONE);

+ 1 - 1
Core/Contents/Source/PolyRenderer.cpp

@@ -47,7 +47,7 @@ Renderer::Renderer() : currentTexture(NULL), xRes(0), yRes(0), renderMode(0), or
 	setAmbientColor(0.0,0.0,0.0);
 	cullingFrontFaces = false;
 	scissorEnabled = false;
-	
+	blendNormalAsPremultiplied = false;
 	
 	doClearBuffer = true;
 }

+ 2 - 2
Core/Contents/Source/PolyScreenEntity.cpp

@@ -35,8 +35,8 @@ using namespace Polycode;
 
 ScreenEntity::ScreenEntity() : Entity() {
 	color = Color(1.0f,1.0f,1.0f,1.0f);
-	width = 1;
-	height = 1;
+	width = 0;
+	height = 0;
 	setHitbox(1, 1);
 	backfaceCulled = false;
 	positionMode = POSITION_TOPLEFT;