Changeset 758


Ignore:
Timestamp:
Apr 28, 2011, 9:01:37 PM (10 years ago)
Author:
sam
Message:

ps3: start a minimal PS3 port using PSGL, but not CG yet.

Location:
trunk
Files:
4 added
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/board.cpp

    r752 r758  
    2020#include "core.h"
    2121
     22using namespace std;
    2223using namespace lol;
    2324
  • trunk/monsterz/mash.cpp

    r746 r758  
    1818#include "core.h"
    1919
     20using namespace std;
    2021using namespace lol;
    2122
  • trunk/monsterz/monsterz.cpp

    r745 r758  
    2121#include "loldebug.h"
    2222
     23using namespace std;
    2324using namespace lol;
    2425
    25 #if defined HAVE_GLES_2X
     26#if defined __CELLOS_LV2__
     27#   include "ps3app.h"
     28#elif defined HAVE_GLES_2X
    2629#   include "eglapp.h"
    2730#else
     
    3740int main(int argc, char **argv)
    3841{
    39 #if defined HAVE_GLES_2X
     42#if defined __CELLOS_LV2__
     43    Ps3App app("Monsterz", vec2i(640, 480), 60.0f);
     44#elif defined HAVE_GLES_2X
    4045    EglApp app("Monsterz", vec2i(640, 480), 60.0f);
    4146#else
  • trunk/monsterz/piece.cpp

    r750 r758  
    1818#include "core.h"
    1919
     20using namespace std;
    2021using namespace lol;
    2122
  • trunk/monsterz/title.cpp

    r756 r758  
    2525#include "core.h"
    2626
     27using namespace std;
    2728using namespace lol;
    2829
  • trunk/src/debugfps.cpp

    r686 r758  
    1717#include "core.h"
    1818#include "debugfps.h"
     19
     20using namespace std;
    1921
    2022namespace lol
  • trunk/src/debugquad.cpp

    r745 r758  
    1818#include "lolgl.h"
    1919#include "loldebug.h"
     20
     21using namespace std;
    2022
    2123namespace lol
     
    160162    attr_tex = data->shader->GetAttribLocation("in_TexCoord");
    161163
     164#if !defined __CELLOS_LV2__
    162165    glEnableVertexAttribArray(attr_pos);
    163166    glEnableVertexAttribArray(attr_col);
     
    185188    glDisableVertexAttribArray(attr_col);
    186189    glDisableVertexAttribArray(attr_tex);
     190#endif
    187191}
    188192
  • trunk/src/debugrecord.cpp

    r755 r758  
    2121#include "core.h"
    2222#include "debugrecord.h"
     23
     24using namespace std;
    2325
    2426namespace lol
  • trunk/src/debugsphere.cpp

    r735 r758  
    2424#include "lolgl.h"
    2525#include "debugsphere.h"
     26
     27using namespace std;
    2628
    2729namespace lol
  • trunk/src/debugstats.cpp

    r686 r758  
    1717#include "core.h"
    1818#include "debugstats.h"
     19
     20using namespace std;
    1921
    2022namespace lol
  • trunk/src/dict.cpp

    r735 r758  
    2121#   define strcasecmp _stricmp
    2222#endif
     23
     24using namespace std;
    2325
    2426namespace lol
  • trunk/src/font.cpp

    r686 r758  
    1313#endif
    1414
    15 #include <string.h>
    16 #include <stdio.h>
     15#include <cstring>
     16#include <cstdio>
    1717
    1818#include "core.h"
     19
     20using namespace std;
    1921
    2022namespace lol
  • trunk/src/image.cpp

    r735 r758  
    2626
    2727#include "core.h"
     28
     29using namespace std;
    2830
    2931namespace lol
  • trunk/src/layer.cpp

    r686 r758  
    1616
    1717#include "core.h"
     18
     19using namespace std;
    1820
    1921namespace lol
  • trunk/src/lolgl.h

    r748 r758  
    3636#       include <OpenGLES/ES2/gl.h>
    3737#       include <OpenGLES/ES2/glext.h>
     38#   elif defined __CELLOS_LV2__
     39#       include <PSGL/psgl.h>
     40#       include <PSGL/psglu.h>
    3841#   else
    3942#       include <GLES2/gl2.h>
  • trunk/src/map.cpp

    r734 r758  
    2020
    2121#include "core.h"
     22
     23using namespace std;
    2224
    2325namespace lol
  • trunk/src/matrix.cpp

    r735 r758  
    1717
    1818#include "core.h"
     19
     20using namespace std;
    1921
    2022namespace lol
  • trunk/src/matrix.h

    r757 r758  
    114114    inline float len() const \
    115115    { \
    116         return sqrtf((float)sqlen()); \
     116        return std::sqrtf((float)sqlen()); \
    117117    }
    118118
  • trunk/src/numeric.h

    r748 r758  
    2727static inline float RandF()
    2828{
    29     return (float)rand() / RAND_MAX;
     29    return (float)std::rand() / RAND_MAX;
    3030}
    3131
  • trunk/src/sample.cpp

    r734 r758  
    2424
    2525#include "core.h"
     26
     27using namespace std;
    2628
    2729namespace lol
  • trunk/src/scene.cpp

    r745 r758  
    158158    attr_tex = stdshader->GetAttribLocation("in_TexCoord");
    159159
     160#if !defined __CELLOS_LV2__ // Use cgGetNamedParameter etc.
    160161    stdshader->Bind();
    161162    uni_mat = stdshader->GetUniformLocation("model_matrix");
     
    163164    uni_tex = stdshader->GetUniformLocation("in_Texture");
    164165    glUniform1i(uni_tex, 0);
     166#endif
    165167
    166168    glEnable(GL_TEXTURE_2D);
     
    209211        glBindVertexArray(data->vao);
    210212#endif
     213#if !defined __CELLOS_LV2__ // Use cgGLEnableClientState etc.
    211214        glEnableVertexAttribArray(attr_pos);
    212215        glEnableVertexAttribArray(attr_tex);
     
    221224                     texture, GL_STATIC_DRAW);
    222225        glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, 0);
     226#endif
    223227
    224228        /* Draw arrays */
     
    228232        glBindVertexArray(0);
    229233#endif
     234#if !defined __CELLOS_LV2__ // Use cgGLEnableClientState etc.
    230235        glDisableVertexAttribArray(attr_pos);
    231236        glDisableVertexAttribArray(attr_tex);
     237#endif
    232238
    233239        free(vertex);
  • trunk/src/shader.cpp

    r745 r758  
    8080    GLsizei len;
    8181
     82#if !defined __CELLOS_LV2__
    8283    data->vert_crc = Hash::Crc32(vert);
    8384    data->vert_id = glCreateShader(GL_VERTEX_SHADER);
     
    104105    glLinkProgram(data->prog_id);
    105106    glValidateProgram(data->prog_id);
     107#endif
    106108}
    107109
    108110int Shader::GetAttribLocation(char const *attr) const
    109111{
     112#if defined __CELLOS_LV2__
     113    return 0;
     114#else
    110115    return glGetAttribLocation(data->prog_id, attr);
     116#endif
    111117}
    112118
    113119int Shader::GetUniformLocation(char const *uni) const
    114120{
     121#if defined __CELLOS_LV2__
     122    return 0;
     123#else
    115124    return glGetUniformLocation(data->prog_id, uni);
     125#endif
    116126}
    117127
    118128void Shader::Bind() const
    119129{
     130#if defined __CELLOS_LV2__
     131    ;
     132#else
    120133    glUseProgram(data->prog_id);
     134#endif
    121135}
    122136
    123137Shader::~Shader()
    124138{
     139#if defined __CELLOS_LV2__
     140    ;
     141#else
    125142    glDetachShader(data->prog_id, data->vert_id);
    126143    glDetachShader(data->prog_id, data->frag_id);
     
    129146    glDeleteProgram(data->prog_id);
    130147    delete data;
     148#endif
    131149}
    132150
  • trunk/src/text.cpp

    r686 r758  
    1818
    1919#include "core.h"
     20
     21using namespace std;
    2022
    2123namespace lol
  • trunk/src/tileset.cpp

    r724 r758  
    2525#include "core.h"
    2626#include "lolgl.h"
     27
     28using namespace std;
    2729
    2830namespace lol
  • trunk/src/timer.cpp

    r735 r758  
    2222#   define WIN32_LEAN_AND_MEAN
    2323#   include <windows.h>
     24#elif defined __CELLOS_LV2__
     25#   include <sys/sys_time.h>
     26#   include <sys/timer.h>
     27#   include <sys/time_util.h>
    2428#else
    2529#   include <SDL.h>
     
    4953        ms_per_cycle = 1e3f / tmp.QuadPart;
    5054        QueryPerformanceCounter(&cycles0);
     55#elif defined __CELLOS_LV2__
     56        ms_per_cycle = 1e3f / sys_time_get_timebase_frequency();
     57        SYS_TIMEBASE_GET(cycles0);
    5158#else
    5259        SDL_Init(SDL_INIT_TIMER);
     
    7784        if (towait > 5e-4f)
    7885            Sleep((int)(towait + 0.5f));
     86#elif defined __CELLOS_LV2__
     87        uint64_t cycles;
     88        SYS_TIMEBASE_GET(cycles);
     89        ret = ms_per_cycle * cycles;
     90        if (update)
     91            cycles0 = cycles;
     92        towait = deltams - ret;
     93        if (towait > 0.0f)
     94            sys_timer_usleep((int)(towait * 1e3f));
    7995#else
    8096        /* The crappy SDL fallback */
     
    95111    float ms_per_cycle;
    96112    LARGE_INTEGER cycles0;
     113#elif defined __CELLOS_LV2__
     114    float ms_per_cycle;
     115    uint64_t cycles0;
    97116#else
    98117    Uint32 ticks0;
  • trunk/src/video.cpp

    r755 r758  
    2222#include "core.h"
    2323#include "lolgl.h"
     24
     25using namespace std;
    2426
    2527namespace lol
     
    189191
    190192    stdshader->Bind(); /* Required on GLES 2.x? */
     193#if !defined __CELLOS_LV2__ // Use cgGetNamedParameter etc.
    191194    GLuint uni;
    192195    uni = stdshader->GetUniformLocation("proj_matrix");
     
    194197    uni = stdshader->GetUniformLocation("view_matrix");
    195198    glUniformMatrix4fv(uni, 1, GL_FALSE, &view_matrix[0][0]);
     199#endif
    196200}
    197201
     
    221225{
    222226    GLint v[4];
     227#if defined __CELLOS_LV2__
     228    // FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions
     229    v[2] = 1920;
     230    v[3] = 1080;
     231#else
    223232    glGetIntegerv(GL_VIEWPORT, v);
     233#endif
    224234    int width = v[2], height = v[3];
    225235
     
    248258#if defined ANDROID_NDK
    249259    return saved_viewport;
     260#elif defined __CELLOS_LV2__
     261    // FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions
     262    return vec2i(1920, 1080);
    250263#else
    251264    GLint v[4];
Note: See TracChangeset for help on using the changeset viewer.