X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogram.cpp;h=00bca8343cb4d89e05f619f78bda72773a76ce77;hp=d8827ab5d0f5f095fed0d53424571aff7147f472;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hpb=a170be7d2b295c4a3bbcea6585634bece3e1638b diff --git a/source/program.cpp b/source/program.cpp index d8827ab5..00bca834 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -28,15 +28,6 @@ Program::Program() init(); } -Program::Program(const ProgramBuilder::StandardFeatures &features) -{ - init(); - - ProgramBuilder builder(features); - builder.add_shaders(*this); - link(); -} - Program::Program(const std::string &source) { init(); @@ -129,7 +120,6 @@ void Program::link() (*i)->compile(); uniforms.clear(); - legacy_vars = false; glLinkProgram(id); linked = get_program_i(id, GL_LINK_STATUS); @@ -144,6 +134,26 @@ void Program::link() query_uniforms(); query_attributes(); + + for(UniformMap::const_iterator i=uniforms.begin(); i!=uniforms.end(); ++i) + require_type(i->second.type); + for(AttributeMap::const_iterator i=attributes.begin(); i!=attributes.end(); ++i) + require_type(i->second.type); +} + +void Program::require_type(GLenum t) +{ + switch(t) + { + case GL_FLOAT_MAT2x3: + case GL_FLOAT_MAT2x4: + case GL_FLOAT_MAT3x2: + case GL_FLOAT_MAT3x4: + case GL_FLOAT_MAT4x2: + case GL_FLOAT_MAT4x3: + { static Require _req(NV_non_square_matrices); } + break; + } } void Program::query_uniforms() @@ -173,8 +183,6 @@ void Program::query_uniforms() info.type = type; uniforms_by_index[i] = &info; } - else - legacy_vars = true; } if(ARB_uniform_buffer_object) @@ -294,8 +302,6 @@ void Program::query_attributes() info.size = size; info.type = type; } - else - legacy_vars = true; } } @@ -315,10 +321,9 @@ bool Program::uniform_location_compare(const UniformInfo *uni1, const UniformInf string Program::get_info_log() const { GLsizei len = get_program_i(id, GL_INFO_LOG_LENGTH); - char *buf = new char[len+1]; - glGetProgramInfoLog(id, len+1, &len, buf); - string log(buf, len); - delete[] buf; + string log(len+1, 0); + glGetProgramInfoLog(id, len+1, &len, &log[0]); + log.erase(len); return log; } @@ -384,7 +389,6 @@ Program::Loader::Loader(Program &p): add("attribute", &Loader::attribute); add("fragment_shader", &Loader::fragment_shader); add("geometry_shader", &Loader::geometry_shader); - add("standard", &Loader::standard); add("vertex_shader", &Loader::vertex_shader); } @@ -408,14 +412,6 @@ void Program::Loader::geometry_shader(const string &src) obj.attach_shader_owned(new GeometryShader(src)); } -void Program::Loader::standard() -{ - ProgramBuilder::StandardFeatures feat; - load_sub(feat); - ProgramBuilder builder(feat); - builder.add_shaders(obj); -} - void Program::Loader::vertex_shader(const string &src) { obj.attach_shader_owned(new VertexShader(src));