X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fresolve.cpp;h=fec3cf143130a583c38a961b38b70087309b555e;hb=fe980fbd898645eba1ac06a5061b3a48db4638b0;hp=3201ea1bb2a70665507dd64469916fb0b09daa5c;hpb=631872e13c2670f7dece44512ed55af50b77f399;p=libs%2Fgl.git diff --git a/source/glsl/resolve.cpp b/source/glsl/resolve.cpp index 3201ea1b..fec3cf14 100644 --- a/source/glsl/resolve.cpp +++ b/source/glsl/resolve.cpp @@ -745,6 +745,17 @@ void ExpressionResolver::visit(BinaryExpression &binary, bool assign) if(!left_size || (left_size==1 && right_size!=1) || (left_size>1 && right_size!=1 && right_size!=left_size)) return; + /* If the left operand is a vector and right is scalar, convert the right + operand to a vector too. */ + if(left_size>1 && right_size==1) + { + BasicTypeDeclaration *vec_right = find_type(*elem_right, basic_left->kind, basic_left->size); + if(!vec_right) + return; + + convert_to(binary.right, *vec_right); + } + type = basic_left; // Don't perform conversion even if the operands are of different sizes. compat = SAME_TYPE; @@ -883,6 +894,8 @@ void ExpressionResolver::visit_constructor(FunctionCall &call) map::const_iterator i = stage->types.find(call.name); if(i==stage->types.end()) return; + else if(call.arguments.size()==1 && i->second==call.arguments[0]->type) + ; else if(BasicTypeDeclaration *basic = dynamic_cast(i->second)) { BasicTypeDeclaration *elem = get_element_type(*basic);