- if(bind_point>=0)
- {
- used_bindings[0].insert(bind_point);
- uniforms[iface.block_name].bind_point = bind_point;
- }
- else
- unbound_blocks.push_back(&iface);
- }
+ if(func.definition==&func && func.name=="main" && !r_position_z_assigned)
+ {
+ VariableReference *position = new VariableReference;
+ position->name = "gl_Position";
+
+ MemberAccess *z = new MemberAccess;
+ z->left = position;
+ z->member = "z";
+
+ Literal *scale = new Literal;
+ scale->token = "2.0";
+ scale->value = 2.0f;
+
+ BinaryExpression *multiply = new BinaryExpression;
+ multiply->oper = &Operator::get_operator("*", Operator::BINARY);
+ multiply->left = z;
+ multiply->right = scale;
+
+ MemberAccess *w = new MemberAccess;
+ w->left = position->clone();
+ w->member = "w";
+
+ BinaryExpression *subtract = new BinaryExpression;
+ subtract->oper = &Operator::get_operator("-", Operator::BINARY);
+ subtract->left = multiply;
+ subtract->right = w;
+
+ Assignment *assign = new Assignment;
+ assign->oper = &Operator::get_operator("=", Operator::BINARY);
+ assign->left = z->clone();
+ assign->right = subtract;
+
+ ExpressionStatement *statement = new ExpressionStatement;
+ statement->expression = assign;
+
+ func.body.body.push_back(statement);