コード例 #1
0
ファイル: Renderer.cpp プロジェクト: juliendehos/librarium.so
	void Renderer::ShaderToy(std::string pShader, vec2 pPosition, vec2 pSize, std::string pTexture1, std::string pTexture2, std::string pTexture3, std::string pTexture4)
	{
		if (_userPrograms.find(pShader) != _userPrograms.end())
		{
			Program* program = _userPrograms[pShader];
			glUseProgram(program->GetProgram());
			glBindVertexArray(_baseVAO);
			glUniform4f(program->GetUniforms()["PositionSize"].Location, pPosition.x, pPosition.y, pSize.x, pSize.y);
				
			if(pTexture1 != "" && program->IsUniformActive("Texture0"))
				glUniformHandleui64ARB(program->GetUniforms()["Texture0"].Location, _userTextures[pTexture1]->GetHandle());
			if (pTexture2 != "" && program->IsUniformActive("Texture1"))
				glUniformHandleui64ARB(program->GetUniforms()["Texture1"].Location, _userTextures[pTexture2]->GetHandle());
			if (pTexture3 != "" && program->IsUniformActive("Texture2"))
				glUniformHandleui64ARB(program->GetUniforms()["Texture2"].Location, _userTextures[pTexture3]->GetHandle());
			if (pTexture4 != "" && program->IsUniformActive("Texture3"))
				glUniformHandleui64ARB(program->GetUniforms()["Texture3"].Location, _userTextures[pTexture4]->GetHandle());

			if (program->IsUniformActive("iGlobalTime"))
				glUniform1f(program->GetUniforms()["iGlobalTime"].Location, Clock::GetRef().GetTotalTime());
				
			if (program->IsUniformActive("iMouse"))
			{
				vec4 mouse = vec4(
					_uiFunctionPtr->GetCurrentInputPtr()->IsLeftButtonDown() || _uiFunctionPtr->GetCurrentInputPtr()->IsRightButtonDown() ?
					_uiFunctionPtr->GetCurrentInputPtr()->GetMousePosition() : vec2(0.0,0.0), 
					_uiFunctionPtr->GetCurrentInputPtr()->IsLeftButtonDown() ? 1.0 : 0.0,
					_uiFunctionPtr->GetCurrentInputPtr()->IsRightButtonDown() ? 1.0 : 0.0);

				glUniform4f(program->GetUniforms()["iMouse"].Location,mouse.x,mouse.y,mouse.z,mouse.w);
			}

			glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
		}
	}
コード例 #2
0
ファイル: Renderer.cpp プロジェクト: juliendehos/librarium.so
	void Renderer::DrawText(std::string pPath, vec2 pPosition)
	{
		Program* program = _programs["Texture"];
		glUseProgram(program->GetProgram());
		glBindVertexArray(_baseVAO);
		glUniform4f(program->GetUniforms()["PositionSize"].Location, pPosition.x, pPosition.y, (GLfloat)_userTexts[pPath]->GetWidth(), (GLfloat)_userTexts[pPath]->GetHeight());
		glUniformHandleui64ARB(program->GetUniforms()["Texture"].Location, _userTexts[pPath]->GetHandle());
		glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	}
コード例 #3
0
ファイル: Renderer.cpp プロジェクト: juliendehos/librarium.so
	void Renderer::DrawImage(GLuint64 pHandle, vec2 pPosition, vec2 pSize)
	{
		Program* program = _programs["Texture"];
		glUseProgram(program->GetProgram());
		glBindVertexArray(_baseVAO);
		glUniform4f(program->GetUniforms()["PositionSize"].Location, pPosition.x, pPosition.y, pSize.x, pSize.y);
		glUniformHandleui64ARB(program->GetUniforms()["Texture"].Location, pHandle);
		glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	}