1. Christian Fischer
  2. wiesel

Commits

Christian Fischer  committed cf9468b

OpenGL: shaders no longer fails, when an attribute was not found

  • Participants
  • Parent commits b2fff9f
  • Branches default

Comments (0)

Files changed (2)

File src/opengl/wiesel/video/gl/gl_render_context.cpp

View file
 		// assign vertex positions
 		if (vertex_buffer->hasPositions()) {
 			GLint  attr_vertex_position = active_shader_content->getAttribHandle(Shader::VertexPosition, 0);
-			assert(attr_vertex_position != -1);
 
 			if (attr_vertex_position != -1) {
 				glVertexAttribPointer(
 				glEnableVertexAttribArray(attr_vertex_position);
 				CHECK_GL_ERROR;
 			}
-			else {
-				return false;
-			}
 		}
 
 		// assign vertex normals
 		if (vertex_buffer->hasNormals()) {
 			GLint  attr_vertex_normals = active_shader_content->getAttribHandle(Shader::VertexNormal, 0);
-			assert(attr_vertex_normals != -1);
 
 			if (attr_vertex_normals != -1) {
 				glVertexAttribPointer(
 				glEnableVertexAttribArray(attr_vertex_normals);
 				CHECK_GL_ERROR;
 			}
-			else {
-				return false;
-			}
 		}
 
 		// assign vertex colors
 		if (vertex_buffer->hasColors()) {
 			GLint  attr_vertex_colors = active_shader_content->getAttribHandle(Shader::VertexColor, 0);
-			assert(attr_vertex_colors != -1);
 
 			if (attr_vertex_colors != -1) {
 				glVertexAttribPointer(
 				glEnableVertexAttribArray(attr_vertex_colors);
 				CHECK_GL_ERROR;
 			}
-			else {
-				return false;
-			}
 		}
 
 		// assign textures
 		for(int i=0; i<num_textures; i++) {
 			GLint  attr_vertex_texcoord = active_shader_content->getAttribHandle(Shader::VertexTextureCoordinate, i);
 			GLint  attr_vertex_texture  = active_shader_content->getAttribHandle(Shader::Texture, i);
-			assert(attr_vertex_texcoord != -1);
 
 			if (attr_vertex_texcoord != -1) {
 				glVertexAttribPointer(
 
 				glEnableVertexAttribArray(attr_vertex_texcoord);
 				CHECK_GL_ERROR;
+			}
 
+			if (attr_vertex_texture != -1) {
 				GlTextureContent *texture_content = active_textures_content[i];
-				if (texture_content && attr_vertex_texture != -1) {
-					assert(attr_vertex_texture  != -1);
 
+				if (texture_content) {
 				//	glActiveTexture(GL_TEXTURE0 + i);
 				//	glBindTexture(GL_TEXTURE_2D, texture_content->getGlHandle());
 					glUniform1i(attr_vertex_texture, i);
 					CHECK_GL_ERROR;
 				}
 			}
-			else {
-				return false;
-			}
 		}
 
 		return true;

File src/opengl/wiesel/video/gl/gl_shader_content.cpp

View file
 				Log::warn << "Could not find member '" << name << "' in current shader." << std::endl;
 			}
 
-			assert(handle != -1);
 			attribute_handles[attr][index] = handle;
 		}
 	}
 
 
 GLint GlShaderContent::getAttribHandle(Shader::Attribute attr, uint8_t index) const {
-	if (attribute_handles.size() >= attr) {
+	if (attribute_handles.size() > attr) {
 		const AttributeHandlesByIndex* attrib_handles_by_index = &(attribute_handles[attr]);
 
-		if (attrib_handles_by_index->size() >= index) {
+		if (attrib_handles_by_index->size() > index) {
 			return (*attrib_handles_by_index)[index];
 		}
 	}