Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualuselessChiP

Posted 13 May 2013 - 02:26 PM

Hi, sorry for the late reply.

So i tried to change the code so the get uniform location is called only once(i was confused about the getuniformlocation, i did not realize that it actully gives me the uniform position, so thanks now it's more clear), in the constructor of my program class like this:

Program::Program() : 
	_ID(0)
{
	_ID = LoadShaders("shaders/Blinn-Phong.vs", "shaders/Blinn-Phong.fs");
	_cam = uniform("camera");
	_mod = uniform("model");
	_rough = uniform("roughness");
	_kd = uniform("Kd");
	_ks = uniform("Ks");
	_lightPos = uniform("lightPos");
	_int = uniform("intensity");
	_camPos = uniform("cameraPos");
}

GLint Program::uniform(const GLchar* uniformName) const {
	if(!uniformName)
		throw std::runtime_error("uniformName is NULL");

	GLint uniform = glGetUniformLocation(_ID, uniformName);
	if(uniform == -1)
		throw std::runtime_error(std::string("Program uniform not found: ") + uniformName);

	return uniform;
}

 

(the uniform == -1 is still there but i'll change it)

 

and then set the uniforms without getting again the location: 

GLint Program::uniform(ShProp type) const {
	switch(type) {
	case CAMERA:
		return _cam;
	case MODEL:
		return _mod;
	case ROUGHNESS:
		return _rough;
	case KD:
		return _kd;
	case KS:
		return _ks;
	case LIGHTPOS:
		return _lightPos;
	case INTENSITY:
		return _int;
	case CAMERAPOS:
		return _camPos;
	default: return -1;
	}
}

void Program::setUniform(ShProp type, GLint v0) {
	glUniform1i(uniform(type), v0);
}

void Program::setUniform(ShProp type, const glm::mat4& m) {
	glUniformMatrix4fv(uniform(type), 1, GL_FALSE, glm::value_ptr(m));
}

void Program::setUniform(ShProp type, const glm::vec3& v) {
	glUniform3fv(uniform(type), 1, glm::value_ptr(v));
}

void Program::setUniform(ShProp type, GLfloat v0) {
	glUniform1f(uniform(type), v0);
}

 

(for now the code is like this because i'm testing)

 

I also removed the asserts with the glGetIntegerv call but i'm continuing to have 13 fps, and this despite where i'm looking, they never go down or up.

So I have the same problem.

 

As for the index buffer part, I tried using unsigned shorts but after that my rabbit mesh was all messed up so i changed it back to unsigned int.


#4uselessChiP

Posted 13 May 2013 - 02:26 PM

Hi, sorry for the late reply.

So i tried to change the code so the get uniform location is called only once(i was confused about the getuniformlocation, i did not realize that it actully gives me the uniform position, so thanks now it's more clear), in the constructor of my program class like this:

Program::Program() : 
	_ID(0)
{
	_ID = LoadShaders("shaders/Blinn-Phong.vs", "shaders/Blinn-Phong.fs");
	_cam = uniform("camera");
	_mod = uniform("model");
	_rough = uniform("roughness");
	_kd = uniform("Kd");
	_ks = uniform("Ks");
	_lightPos = uniform("lightPos");
	_int = uniform("intensity");
	_camPos = uniform("cameraPos");
}

GLint Program::uniform(const GLchar* uniformName) const {
	if(!uniformName)
		throw std::runtime_error("uniformName is NULL");

	GLint uniform = glGetUniformLocation(_ID, uniformName);
	if(uniform == -1)
		throw std::runtime_error(std::string("Program uniform not found: ") + uniformName);

	return uniform;
}

 

(the uniform == -1 is still there but i'll change it)

 

and then set the uniforms without getting again the location: 

GLint Program::uniform(ShProp type) const {
	switch(type) {
	case CAMERA:
		return _cam;
	case MODEL:
		return _mod;
	case ROUGHNESS:
		return _rough;
	case KD:
		return _kd;
	case KS:
		return _ks;
	case LIGHTPOS:
		return _lightPos;
	case INTENSITY:
		return _int;
	case CAMERAPOS:
		return _camPos;
	default: return -1;
	}
}

void Program::setUniform(ShProp type, GLint v0) {
	glUniform1i(uniform(type), v0);
}

void Program::setUniform(ShProp type, const glm::mat4& m) {
	glUniformMatrix4fv(uniform(type), 1, GL_FALSE, glm::value_ptr(m));
}

void Program::setUniform(ShProp type, const glm::vec3& v) {
	glUniform3fv(uniform(type), 1, glm::value_ptr(v));
}

void Program::setUniform(ShProp type, GLfloat v0) {
	glUniform1f(uniform(type), v0);
}

 

(for now the code is like this because i'm testing)

 

I also removed the asserts with the glGetIntegerv call but i'm continuing to have 13 fps, and this despite where i'm looking, they never go down or up.

So I have the same problem.

 

As for the index buffer part, I tried using unsigned shorts but after that my rabbit mesh was all messed up so i changed back to unsigned int.


#3uselessChiP

Posted 13 May 2013 - 02:25 PM

Hi, sorry for the late reply.

So i tried to change the code so the get uniform location is called only once(i was confused about the getuniformlocation, i did not realize that it actully gives me the uniform position, so thanks now it's more clear), in the constructor of my program class like this:

Program::Program() : 
	_ID(0)
{
	_ID = LoadShaders("shaders/Blinn-Phong.vs", "shaders/Blinn-Phong.fs");
	_cam = uniform("camera");
	_mod = uniform("model");
	_rough = uniform("roughness");
	_kd = uniform("Kd");
	_ks = uniform("Ks");
	_lightPos = uniform("lightPos");
	_int = uniform("intensity");
	_camPos = uniform("cameraPos");
}

GLint Program::uniform(const GLchar* uniformName) const {
	if(!uniformName)
		throw std::runtime_error("uniformName is NULL");

	GLint uniform = glGetUniformLocation(_ID, uniformName);
	if(uniform == -1)
		throw std::runtime_error(std::string("Program uniform not found: ") + uniformName);

	return uniform;
}

 

(the uniform == -1 is still there but i'll change it)

 

and then set the uniforms without getting again the location: 

GLint Program::uniform(ShProp type) const {
	switch(type) {
	case CAMERA:
		return _cam;
	case MODEL:
		return _mod;
	case ROUGHNESS:
		return _rough;
	case KD:
		return _kd;
	case KS:
		return _ks;
	case LIGHTPOS:
		return _lightPos;
	case INTENSITY:
		return _int;
	case CAMERAPOS:
		return _camPos;
	default: return -1;
	}
}

void Program::setUniform(ShProp type, GLint v0) {
	glUniform1i(uniform(type), v0);
}

void Program::setUniform(ShProp type, const glm::mat4& m) {
	glUniformMatrix4fv(uniform(type), 1, GL_FALSE, glm::value_ptr(m));
}

void Program::setUniform(ShProp type, const glm::vec3& v) {
	glUniform3fv(uniform(type), 1, glm::value_ptr(v));
}

void Program::setUniform(ShProp type, GLfloat v0) {
	glUniform1f(uniform(type), v0);
}

 

(for now the code is like this because i'm testing)

 

I also removed the asserts with the glGetIntegerv call but i'm continuing to have 13 fps, and this despite where i'm looking, they never go down or up.

So I have the same problem.

 

As for the index buffer part, I tried using unsigned shorts but after this my rabbit mesh was all messed up so i changed back to unsigned int.


#2uselessChiP

Posted 13 May 2013 - 02:25 PM

Hi, sorry for the late reply.

So i tried to change the code so the get uniform location is called only once(i was confused about the getuniformlocation, i did not realize that it actully gives me the uniform position, so thanks now it's moreclear), in the constructor of my program class like this:

Program::Program() : 
	_ID(0)
{
	_ID = LoadShaders("shaders/Blinn-Phong.vs", "shaders/Blinn-Phong.fs");
	_cam = uniform("camera");
	_mod = uniform("model");
	_rough = uniform("roughness");
	_kd = uniform("Kd");
	_ks = uniform("Ks");
	_lightPos = uniform("lightPos");
	_int = uniform("intensity");
	_camPos = uniform("cameraPos");
}

GLint Program::uniform(const GLchar* uniformName) const {
	if(!uniformName)
		throw std::runtime_error("uniformName is NULL");

	GLint uniform = glGetUniformLocation(_ID, uniformName);
	if(uniform == -1)
		throw std::runtime_error(std::string("Program uniform not found: ") + uniformName);

	return uniform;
}

 

(the uniform == -1 is still there but i'll change it)

 

and then set the uniforms without getting again the location: 

GLint Program::uniform(ShProp type) const {
	switch(type) {
	case CAMERA:
		return _cam;
	case MODEL:
		return _mod;
	case ROUGHNESS:
		return _rough;
	case KD:
		return _kd;
	case KS:
		return _ks;
	case LIGHTPOS:
		return _lightPos;
	case INTENSITY:
		return _int;
	case CAMERAPOS:
		return _camPos;
	default: return -1;
	}
}

void Program::setUniform(ShProp type, GLint v0) {
	glUniform1i(uniform(type), v0);
}

void Program::setUniform(ShProp type, const glm::mat4& m) {
	glUniformMatrix4fv(uniform(type), 1, GL_FALSE, glm::value_ptr(m));
}

void Program::setUniform(ShProp type, const glm::vec3& v) {
	glUniform3fv(uniform(type), 1, glm::value_ptr(v));
}

void Program::setUniform(ShProp type, GLfloat v0) {
	glUniform1f(uniform(type), v0);
}

 

(for now the code is like this because i'm testing)

 

I also removed the asserts with the glGetIntegerv call but i'm continuing to have 13 fps, and this despite where i'm looking, they never go down or up.

So I have the same problem.

 

As for the index buffer part, I tried using unsigned shorts but after this my rabbit mesh was all messed up so i changed back to unsigned int.


#1uselessChiP

Posted 13 May 2013 - 02:23 PM

Hi, sorry for the late reply.

So i tried to change the code so the get uniform location is called only once(i was confused about the getuniformlocation, i did not realize that it actully gives me the uniform position, so thanks now it's moreclear), in the constructor of my program class like this:

Program::Program() : 
	_ID(0)
{
	_ID = LoadShaders("shaders/Blinn-Phong.vs", "shaders/Blinn-Phong.fs");
	_cam = uniform("camera");
	_mod = uniform("model");
	_rough = uniform("roughness");
	_kd = uniform("Kd");
	_ks = uniform("Ks");
	_lightPos = uniform("lightPos");
	_int = uniform("intensity");
	_camPos = uniform("cameraPos");
}

 

and then set the uniforms without getting again the location: 

GLint Program::uniform(ShProp type) const {
	switch(type) {
	case CAMERA:
		return _cam;
	case MODEL:
		return _mod;
	case ROUGHNESS:
		return _rough;
	case KD:
		return _kd;
	case KS:
		return _ks;
	case LIGHTPOS:
		return _lightPos;
	case INTENSITY:
		return _int;
	case CAMERAPOS:
		return _camPos;
	default: return -1;
	}
}

void Program::setUniform(ShProp type, GLint v0) {
	glUniform1i(uniform(type), v0);
}

void Program::setUniform(ShProp type, const glm::mat4& m) {
	glUniformMatrix4fv(uniform(type), 1, GL_FALSE, glm::value_ptr(m));
}

void Program::setUniform(ShProp type, const glm::vec3& v) {
	glUniform3fv(uniform(type), 1, glm::value_ptr(v));
}

void Program::setUniform(ShProp type, GLfloat v0) {
	glUniform1f(uniform(type), v0);
}

 

(for now the code is like this because i'm testing)

 

I also removed the asserts with the glGetIntegerv call but i'm continuing to have 13 fps, and this despite where i'm looking, they never go down or up.

So I have the same problem.

 

As for the index buffer part, I tried using unsigned shorts but after this my rabbit mesh was all messed up so i changed back to unsigned int.


PARTNERS