Browse Source

Renderer working as normal

Marko Pintera 11 years ago
parent
commit
b23fbf3bad

+ 1 - 1
BansheeEditorExec/BsEditorExec.cpp

@@ -11,7 +11,7 @@ int CALLBACK WinMain(
 	_In_  int nCmdShow
 	_In_  int nCmdShow
 	)
 	)
 {
 {
-	EditorApplication::startUp(RenderSystemPlugin::DX11);
+	EditorApplication::startUp(RenderSystemPlugin::OpenGL);
 	EditorApplication::instance().runMainLoop();
 	EditorApplication::instance().runMainLoop();
 	EditorApplication::shutDown();
 	EditorApplication::shutDown();
 
 

+ 12 - 14
BansheeGLRenderSystem/Source/BsGLRenderSystem.cpp

@@ -112,7 +112,7 @@ namespace BansheeEngine
 
 
 		// Initialize a window so we have something to create a GL context with
 		// Initialize a window so we have something to create a GL context with
 		RenderWindowPtr primaryWindow = RenderWindow::create(mPrimaryWindowDesc);
 		RenderWindowPtr primaryWindow = RenderWindow::create(mPrimaryWindowDesc);
-		             
+		      
 		// Get the context from the window and finish initialization
 		// Get the context from the window and finish initialization
 		GLContext *context = nullptr;
 		GLContext *context = nullptr;
 		primaryWindow->getCustomAttribute("GLCONTEXT", &context);
 		primaryWindow->getCustomAttribute("GLCONTEXT", &context);
@@ -125,8 +125,11 @@ namespace BansheeEngine
 		if (mCurrentContext)
 		if (mCurrentContext)
 			mCurrentContext->setCurrent();
 			mCurrentContext->setCurrent();
 
 
+		checkForErrors();
+
 		// Setup GLSupport
 		// Setup GLSupport
 		mGLSupport->initializeExtensions();
 		mGLSupport->initializeExtensions();
+		checkForErrors();
 
 
 		Vector<BansheeEngine::String> tokens = StringUtil::split(mGLSupport->getGLVersion(), ".");
 		Vector<BansheeEngine::String> tokens = StringUtil::split(mGLSupport->getGLVersion(), ".");
 
 
@@ -1620,15 +1623,21 @@ namespace BansheeEngine
 				"Trying to initialize GLRenderSystem from RenderSystemCapabilities that do not support OpenGL");
 				"Trying to initialize GLRenderSystem from RenderSystemCapabilities that do not support OpenGL");
 		}
 		}
 
 
+#if BS_DEBUG_MODE
+		if (mGLSupport->checkExtension("GL_ARB_debug_output"))
+		{
+			glDebugMessageCallback(&openGlErrorCallback, 0);
+			glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
+		}
+#endif
+
 		HardwareBufferManager::startUp<GLHardwareBufferManager>();
 		HardwareBufferManager::startUp<GLHardwareBufferManager>();
-		checkForErrors();
 
 
 		// GPU Program Manager setup
 		// GPU Program Manager setup
 		if(caps->isShaderProfileSupported("glsl"))
 		if(caps->isShaderProfileSupported("glsl"))
 		{
 		{
 			mGLSLProgramFactory = bs_new<GLSLProgramFactory>();
 			mGLSLProgramFactory = bs_new<GLSLProgramFactory>();
 			GpuProgramManager::instance().addFactory(mGLSLProgramFactory);
 			GpuProgramManager::instance().addFactory(mGLSLProgramFactory);
-			checkForErrors();
 		}
 		}
 
 
 		// Check for framebuffer object extension
 		// Check for framebuffer object extension
@@ -1638,7 +1647,6 @@ namespace BansheeEngine
 			{
 			{
 				// Create FBO manager
 				// Create FBO manager
 				GLRTTManager::startUp<GLRTTManager>();
 				GLRTTManager::startUp<GLRTTManager>();
-				checkForErrors();
 			}
 			}
 		}
 		}
 		else
 		else
@@ -1698,16 +1706,6 @@ namespace BansheeEngine
 				glEnable(GL_MULTISAMPLE_ARB);
 				glEnable(GL_MULTISAMPLE_ARB);
 			}
 			}
 		}
 		}
-
-#if BS_DEBUG_MODE
-		if (mGLSupport->checkExtension("GL_ARB_debug_output"))
-		{
-			glDebugMessageCallback(&openGlErrorCallback, 0);
-			glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
-		}
-#endif
-
-		checkForErrors();
 	}
 	}
 
 
 	void GLRenderSystem::switchContext(GLContext *context)
 	void GLRenderSystem::switchContext(GLContext *context)

+ 1 - 1
BansheeGLRenderSystem/Source/BsGLSupport.cpp

@@ -9,10 +9,10 @@ namespace BansheeEngine
     void GLSupport::initializeExtensions()
     void GLSupport::initializeExtensions()
     {
     {
 		glewContextInit(this);
 		glewContextInit(this);
+		glGetError();
 
 
         // Set version string
         // Set version string
         const GLubyte* pcVer = glGetString(GL_VERSION);
         const GLubyte* pcVer = glGetString(GL_VERSION);
-
         assert(pcVer && "Problems getting GL version string using glGetString");
         assert(pcVer && "Problems getting GL version string using glGetString");
        
        
         String tmpStr = (const char*)pcVer;
         String tmpStr = (const char*)pcVer;

+ 9 - 11
BansheeRenderer/Source/BsBansheeLitTexRenderableHandler.cpp

@@ -104,7 +104,7 @@ namespace BansheeEngine
 			}
 			}
 		}
 		}
 
 
-		if (!foundLightDir || !foundLightDir || !foundWVP || !foundStatic || !foundPerFrame || !foundPerObject)
+		if (!foundLightDir || !foundTime || !foundWVP || !foundStatic || !foundPerFrame || !foundPerObject)
 			BS_EXCEPT(InternalErrorException, "Invalid default shader.");
 			BS_EXCEPT(InternalErrorException, "Invalid default shader.");
 
 
 		// Create global GPU param buffers and get parameter handles
 		// Create global GPU param buffers and get parameter handles
@@ -343,18 +343,17 @@ namespace BansheeEngine
 		}
 		}
 		else if (rsName == RenderSystemOpenGL)
 		else if (rsName == RenderSystemOpenGL)
 		{
 		{
-			String vsCode = R"(
-			#version 400\n
+			String vsCode = R"(#version 400
 
 
 			uniform PerFrame
 			uniform PerFrame
 			{
 			{
 				float time;
 				float time;
-			}
+			};
 
 
 			uniform PerObject
 			uniform PerObject
 			{
 			{
 				mat4 matWorldViewProj;
 				mat4 matWorldViewProj;
-			}
+			};
 
 
 			in vec3 bs_position;
 			in vec3 bs_position;
 
 
@@ -363,23 +362,22 @@ namespace BansheeEngine
 				gl_Position = matWorldViewProj * vec4(bs_position.xyz + vec3(sin(time), 0, 0), 1);
 				gl_Position = matWorldViewProj * vec4(bs_position.xyz + vec3(sin(time), 0, 0), 1);
 			})";
 			})";
 
 
-			String psCode = R"(
-			#version 400\n
+			String psCode = R"(#version 400
 
 
 			uniform Static
 			uniform Static
 			{
 			{
 				vec4 lightDir;
 				vec4 lightDir;
-			}
+			};
 
 
 			out vec4 fragColor;
 			out vec4 fragColor;
 
 
 			void main()
 			void main()
 			{
 			{
-				fragColor = dot(lightDir, vec4(0.5f, 0.5f, 0.5f, 0.5f));
+				fragColor = lightDir * vec4(0.5f, 0.5f, 0.5f, 0.5f);
 			})";
 			})";
 
 
-			vsProgram = GpuProgram::create(vsCode, "vs_main", "glsl", GPT_VERTEX_PROGRAM, GPP_VS_4_0);
-			psProgram = GpuProgram::create(psCode, "ps_main", "glsl", GPT_FRAGMENT_PROGRAM, GPP_PS_4_0);
+			vsProgram = GpuProgram::create(vsCode, "main", "glsl", GPT_VERTEX_PROGRAM, GPP_VS_4_0);
+			psProgram = GpuProgram::create(psCode, "main", "glsl", GPT_FRAGMENT_PROGRAM, GPP_PS_4_0);
 		}
 		}
 
 
 		vsProgram.synchronize();
 		vsProgram.synchronize();

+ 1 - 1
BansheeRenderer/Source/BsBansheeRenderer.cpp

@@ -587,7 +587,7 @@ namespace BansheeEngine
 			indexCount = indexBuffer->getNumIndices();
 			indexCount = indexBuffer->getNumIndices();
 
 
 		rs.setIndexBuffer(indexBuffer);
 		rs.setIndexBuffer(indexBuffer);
-		rs.drawIndexed(subMesh.indexOffset, indexCount, mesh->_getVertexOffset(), vertexData->vertexCount);
+		rs.drawIndexed(subMesh.indexOffset + mesh->_getIndexOffset(), indexCount, mesh->_getVertexOffset(), vertexData->vertexCount);
 
 
 		mesh->_notifyUsedOnGPU();
 		mesh->_notifyUsedOnGPU();
 	}
 	}