Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualic0de

Posted 10 July 2013 - 12:25 PM

Just a tip, if you call glGetUniformLocation every time you update your variable you run the risk of stalling your pipeline which heavily degrades performance.

 

It's better to get the location once after linking your shader and then storing that location to be used everytime you update or use a static variable to cache that data like so:

void updateTimeOfDay()
{
	static bool haveLoc;
	static GLuint loc;

	if(!haveLoc)
	{
		loc = glGetUniformLocation(shaderOne.getShaderIndex(), "TimeOfDay");
		haveLoc = true;
	}

	glUniform1f(loc, timeOfDay);
}

#4ic0de

Posted 10 July 2013 - 12:25 PM

Just a tip, if you call glGetUniformLocation every time you update your variable you run the risk of stalling your pipeline which heavily degrades performance.

It's better to get the location once after linking your shader and then storing that location to be used everytime you update or use a static variable to cache that data like so:

void updateTimeOfDay()
{
	static bool haveLoc;
	static GLuint loc;

	if(!haveLoc)
	{
		loc = glGetUniformLocation(shaderOne.getShaderIndex(), "TimeOfDay");
		haveLoc = true;
	}

	glUniform1f(loc, timeOfDay);
}

#3ic0de

Posted 10 July 2013 - 12:25 PM

Just a tip, if you call glGetUniformLocation every time you update your variable you run the risk of stalling your pipeline which heavily degrades performance.
It's better to get the location once after linking your shader and then storing that location to be used everytime you update or use a static variable to cache that data like so:

void updateTimeOfDay()
{
	static bool haveLoc;
	static GLuint loc;

	if(!haveLoc)
	{
		loc = glGetUniformLocation(shaderOne.getShaderIndex(), "TimeOfDay");
		haveLoc = true;
	}

	glUniform1f(loc, timeOfDay);
}

#2ic0de

Posted 10 July 2013 - 12:25 PM

Just a tip, if you call glGetUniformLocation every time you update your variable you run the risk of stalling your pipeline which heavily degrades performance.
 

GLint loc = glGetUniformLocation(shaderOne.getShaderIndex(), "TimeOfDay");
glUniform1f(loc, timeOfDay)

It's better to get the location once after linking your shader and then storing that location to be used everytime you update or use a static variable to cache that data like so:

void updateTimeOfDay()
{
	static bool haveLoc;
	static GLuint loc;

	if(!haveLoc)
	{
		loc = glGetUniformLocation(shaderOne.getShaderIndex(), "TimeOfDay");
		haveLoc = true;
	}

	glUniform1f(loc, timeOfDay);
}

#1ic0de

Posted 10 July 2013 - 12:24 PM

Just a tip, if you call glGetUniformLocation every time you update your variable you run the risk of stalling your pipeline which heavily degrades performance.
 

GLint loc = glGetUniformLocation(shaderOne.getShaderIndex(), "TimeOfDay");
glUniform1f(loc, timeOfDay)

It's better to get the location once after linking your shader and then storing that location to be used everytime you update or use a static variable to cache that data like so:

void updateTimeOfDay()
{
	static bool haveLoc;
	static GLuint loc;

	if(!haveLoc)
	{
		loc = glGetUniformLocation(shaderOne.getShaderIndex(), "TimeOfDay");
		haveLoc = true;
	}

	glUniform1f(loc, timeOfDay)
}

PARTNERS