X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fprogram.cpp;h=dd155d5c5c9ed4c3296591bd1ea645b7018e46b8;hb=096481bcb88844ec28fd33147ed5010bfe2e15d9;hp=789fa32473392d75a0bd34a13aac7208ddf14637;hpb=c93e0613e96ec6817e26b533e90dc49d45787941;p=libs%2Fgl.git diff --git a/source/core/program.cpp b/source/core/program.cpp index 789fa324..dd155d5c 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -80,6 +80,9 @@ Program::~Program() void Program::add_stages(const Module &mod, const map &spec_values) { + if(!stage_ids.empty()) + throw invalid_operation("Program::add_stages"); + switch(mod.get_format()) { case Module::GLSL: return add_glsl_stages(static_cast(mod), spec_values); @@ -220,6 +223,9 @@ void Program::bind_fragment_data(unsigned index, const string &name) void Program::link() { + if(stage_ids.empty()) + throw invalid_operation("Program::link"); + uniforms.clear(); glLinkProgram(id); @@ -248,21 +254,6 @@ void Program::link() 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() { unsigned count = get_program_i(id, GL_ACTIVE_UNIFORMS); @@ -287,7 +278,7 @@ void Program::query_uniforms() info.size = size; info.array_stride = 0; info.matrix_stride = 0; - info.type = type; + info.type = from_gl_type(type); uniforms_by_index[i] = &info; } } @@ -364,10 +355,8 @@ void Program::query_uniform_blocks(const vector &uniforms_by_inde indices2.clear(); for(vector::iterator j=indices.begin(); j!=indices.end(); ++j) { - GLenum t = uniforms_by_index[*j]->type; - if(t==GL_FLOAT_MAT4 || t==GL_FLOAT_MAT3 || t==GL_FLOAT_MAT2 || - t==GL_FLOAT_MAT2x3 || t==GL_FLOAT_MAT2x4 || t==GL_FLOAT_MAT3x2 || - t==GL_FLOAT_MAT3x4 || t==GL_FLOAT_MAT4x2 || t==GL_FLOAT_MAT4x3) + DataType t = uniforms_by_index[*j]->type; + if(is_matrix(t)) indices2.push_back(*j); } if(!indices2.empty()) @@ -407,7 +396,7 @@ void Program::query_attributes() info.name = name; info.location = glGetAttribLocation(id, name); info.size = size; - info.type = type; + info.type = from_gl_type(type); } } }