Ignore:
Timestamp:
Feb 17, 2011, 1:53:38 AM (9 years ago)
Author:
sam
Message:

More shader crap. Texture coordinates now work. Still disabled.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/video.cpp

    r654 r656  
    4343    "in vec3 in_Position;\n"
    4444    "in vec3 in_Color;\n"
     45    "in vec2 in_TexCoord;\n"
    4546    "out vec3 pass_Color;\n"
    4647    "uniform mat4 projection_matrix;\n"
     
    5152    "{\n"
    5253    "    //gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_Position, 1.0f);\n"
    53     "    gl_Position = vec4(in_Position, 1.0f);\n"
     54    "    gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_Position, 1.0f);\n"
     55    "    gl_TexCoord[0] = vec4(in_TexCoord, 0.0, 0.0);\n"
    5456    "    pass_Color = in_Color;\n"
    5557    "}\n";
     
    5860    "#version 130\n"
    5961    "\n"
     62    "uniform sampler2D in_Texture;\n"
    6063    "in vec3 pass_Color;\n"
    6164    "out vec4 out_Color;\n"
     
    6366    "void main()\n"
    6467    "{\n"
    65     "    gl_FragColor = vec4(pass_Color, 1.0);\n"
     68    "    gl_FragColor = 0.5 * (texture2D(in_Texture, vec2(gl_TexCoord[0]))\n"
     69    "                           + vec4(pass_Color, 1.0));\n"
    6670    "}\n";
    6771#endif
     
    107111    glBindAttribLocation(prog, 0, "in_Position");
    108112    glBindAttribLocation(prog, 1, "in_Color");
     113    glBindAttribLocation(prog, 2, "in_TexCoord");
    109114    glLinkProgram(prog);
    110115    glValidateProgram(prog);
     
    123128    float width = GetWidth();
    124129    float height = GetHeight();
    125     float near = -width - height;
    126     float far = width + height;
     130    //float near = -width - height;
     131    //float far = width + height;
     132    float near = 20.0f;
     133    float far = 0.1f;
    127134    projection_matrix = float4x4::perspective(theta, width, height, near, far);
    128135#else
     
    187194    view_matrix = float4x4(1.0f);
    188195    view_matrix[3][0] = 0.0f;
    189     view_matrix[3][0] = 0.0f;
    190     view_matrix[3][0] = -5.0f;
     196    view_matrix[3][1] = 0.0f;
     197    view_matrix[3][2] = -5.0f;
    191198
    192199    model_matrix = float4x4(1.0f);
     
    209216#endif
    210217
    211     SetFov(0.0f);
     218#if SHADER_CRAP
     219    static float time;
     220    time += 0.01f;
     221    SetFov(1.0f + sinf(time));
     222#else
     223    SetFov(0.5f);
     224#endif
    212225}
    213226
Note: See TracChangeset for help on using the changeset viewer.