Output different with and without (simple) shader

Hello oF’ers!

There is something I am not understanding quite yet regarding the shader behavior in piece of code.

    ofSetColor(255, 255);
    ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2);
    ofScale(700, 700);

    //I know this is ugly, but I'm just hacking thing together right now
    char *VertexShaderSource = "#version 330 core layout (location = 0) in vec3 position; void main(){ gl_Position = vec4(position, 1.0); }";
    char *FragmentShaderSource = "#version 330 core out vec4 color; void main(){ color = vec4(1.0, 1.0, 1.0, 1.0);}"; 

    ofShader ShaderProgram;
    ShaderProgram.setupShaderFromSource(GL_VERTEX_SHADER, VertexShaderSource);
    ShaderProgram.setupShaderFromSource(GL_FRAGMENT_SHADER, FragmentShaderSource);

#define USE_SHADER 1 //just a switch for helping me

    ofVbo vbo;
    vbo.setVertexData((float*)VerticesBuffer, 3, VerticesCount, GL_STATIC_DRAW, 0); 
    vbo.setIndexData(IndexesBuffer, IndexesCount, GL_STATIC_DRAW);
    vbo.drawElements(GL_TRIANGLES, IndexesCount);

Both the Vertex and the Fragment shader are fairly simple, no transformation going on regarding position and the color is set to white.
I get the vertices and indexes from model, and is rendered correctly.

My current understanding of how things work, I would expect the same output whether or not I am using the shader.

(Since I’m new I can post only one image, so I will explained with the best of my abilities how this output looks like)
The output WHITOUT the shader is a simple teapot (classic) upside down but with the proportion correctly respected.

And here is the output WITH the shader enabled:

As you might see, the teapot is NOT upside down, and a little flattened (as if I scaled it on Y axis).

My current hypothesis is that somehow there are some transformation happening that I am not aware of, which confuses me.

Thank you for you time!

You can find here what is the “basic” vertex shader in OF:

// vertex shader
#version 150

uniform mat4 modelViewProjectionMatrix;
in vec4 position;

void main(){
    gl_Position = modelViewProjectionMatrix * position;

You have to apply the matrix that OF pass to each shader if you want to write a custom shader with the same geometrical behavior than the default OF shader.

(I don’t know if this vertex shader work with #version 330 )

Thank lilive,

Adding the `modelViewProjectionMatrix does indeed solve my problem. I suspect every change made with ofTranslate, ofScale, ofRotate are concatenated into that matrix, is that correct?

Yes it is !

Perfect, all the information I needed!

Thank you again!