Changeset 831


Ignore:
Timestamp:
Aug 17, 2011, 5:20:02 PM (8 years ago)
Author:
sam
Message:

gl: implement the PS3 version of our bitmap renderer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scene.cpp

    r821 r831  
    136136    if (!stdshader)
    137137    {
     138#if !defined __CELLOS_LV2__
    138139        stdshader = Shader::Create(
    139140            "#version 130\n"
     
    211212            "    gl_FragColor = col;\n"
    212213            "}\n");
     214#else
     215        stdshader = Shader::Create(
     216            "void main(float4 in_Position : POSITION,"
     217            "          float2 in_TexCoord : TEXCOORD0,"
     218            "          uniform float4x4 proj_matrix,"
     219            "          uniform float4x4 view_matrix,"
     220            "          uniform float4x4 model_matrix,"
     221            "          out float2 out_TexCoord : TEXCOORD0,"
     222            "          out float4 out_Position : POSITION)"
     223            "{"
     224            "    out_Position = mul(proj_matrix, mul(view_matrix, mul(model_matrix, in_Position)));"
     225            "    out_TexCoord = in_TexCoord;"
     226            "}",
     227
     228            "void main(float2 in_TexCoord : TEXCOORD0,"
     229            "          uniform sampler2D tex,"
     230            "          out float4 out_FragColor : COLOR)"
     231            "{"
     232            "    out_FragColor = tex2D(tex, in_TexCoord);"
     233            "}");
     234#endif
    213235    }
    214236
     
    238260
    239261    GLuint uni_mat, uni_tex, attr_pos, attr_tex;
     262#if !defined __CELLOS_LV2__
    240263    attr_pos = stdshader->GetAttribLocation("in_Position");
    241264    attr_tex = stdshader->GetAttribLocation("in_TexCoord");
    242 
    243 #if !defined __CELLOS_LV2__ // Use cgGetNamedParameter etc.
     265#endif
     266
    244267    stdshader->Bind();
    245268
     269#if !defined __CELLOS_LV2__
    246270    uni_mat = stdshader->GetUniformLocation("proj_matrix");
    247271    glUniformMatrix4fv(uni_mat, 1, GL_FALSE, &Video::GetProjMatrix()[0][0]);
     
    253277    uni_tex = stdshader->GetUniformLocation("in_Texture");
    254278    glUniform1i(uni_tex, 0);
     279#else
     280    uni_mat = stdshader->GetUniformLocation("proj_matrix");
     281    cgGLSetMatrixParameterfc((CGparameter)(intptr_t)uni_mat, &Video::GetProjMatrix()[0][0]);
     282    uni_mat = stdshader->GetUniformLocation("view_matrix");
     283    cgGLSetMatrixParameterfc((CGparameter)(intptr_t)uni_mat, &Video::GetViewMatrix()[0][0]);
     284    uni_mat = stdshader->GetUniformLocation("model_matrix");
     285    cgGLSetMatrixParameterfc((CGparameter)(intptr_t)uni_mat, &data->model_matrix[0][0]);
     286
     287    // WTF? this doesn't exist
     288    //uni_tex = stdshader->GetUniformLocation("in_Texture");
     289    //cgGLSetParameter1i((CGparameter)(intptr_t)uni_tex, 0);
    255290#endif
    256291
     
    313348                     texture, GL_STATIC_DRAW);
    314349        glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, 0);
     350#else
     351        glEnableClientState(GL_VERTEX_ARRAY);
     352        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
     353
     354        glVertexPointer(3, GL_FLOAT, 0, vertex);
     355        glTexCoordPointer(2, GL_FLOAT, 0, texture);
    315356#endif
    316357
     
    324365        glDisableVertexAttribArray(attr_pos);
    325366        glDisableVertexAttribArray(attr_tex);
     367#else
     368        glDisableClientState(GL_VERTEX_ARRAY);
     369        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    326370#endif
    327371
Note: See TracChangeset for help on using the changeset viewer.