Changeset 1173


Ignore:
Timestamp:
Mar 26, 2012, 8:18:40 PM (8 years ago)
Author:
sam
Message:

xbox: start working on an Xbox/Direct3D port.

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r1168 r1173  
    4747dnl  Available platforms: some of these are not public
    4848AM_CONDITIONAL(HAVE_PS3, test -f src/platform/ps3/ps3app.cpp)
     49AM_CONDITIONAL(HAVE_XBOX, false)
    4950
    5051AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
  • trunk/src/Makefile.am

    r1160 r1173  
    2020    \
    2121    $(ps3_sources) \
     22    $(xbox_sources) \
    2223    $(nacl_sources) \
    2324    $(sdl_sources) \
     
    5556
    5657if HAVE_PS3
    57 ps3_sources =  \
     58ps3_sources = \
    5859    platform/ps3/threadbase.h \
    5960    platform/ps3/ps3app.cpp platform/ps3/ps3app.h \
     
    6162endif
    6263
     64if HAVE_XBOX
     65xbox_sources = \
     66    platform/xbox/xboxapp.cpp platform/xbox/xboxapp.h
     67endif
     68
  • trunk/src/application/application.cpp

    r1106 r1173  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    1818#if defined __CELLOS_LV2__
    1919#   include "platform/ps3/ps3app.h"
     20#elif defined _XBOX
     21#   include "platform/xbox/xboxapp.h"
    2022#elif defined __native_client__
    2123#   include "platform/nacl/naclapp.h"
     
    4244#if defined __CELLOS_LV2__
    4345    Ps3App app;
     46#elif defined _XBOX
     47    XboxApp app;
    4448#elif defined __native_client__
    4549    NaClApp app;
  • trunk/src/debug/quad.cpp

    r1135 r1173  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    1313#endif
    1414
    15 #if defined WIN32 && !defined _XBOX
     15#if !defined _XBOX /* This file is meaningless on Xbox */
     16
     17#if defined WIN32 && !_XBOX
    1618#   define _USE_MATH_DEFINES /* for M_PI */
    1719#   define WIN32_LEAN_AND_MEAN
     
    11181120} /* namespace lol */
    11191121
     1122#endif /* !defined _XBOX */
  • trunk/src/debug/sphere.cpp

    r1163 r1173  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    1313#endif
    1414
    15 #if defined WIN32 && !defined _XBOX
     15#if !defined _XBOX /* This file is meaningless on Xbox */
     16
     17#if defined WIN32
    1618#   define _USE_MATH_DEFINES /* for M_PI */
    1719#   define WIN32_LEAN_AND_MEAN
     
    209211} /* namespace lol */
    210212
     213#endif /* !defined _XBOX */
  • trunk/src/dict.cpp

    r958 r1173  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    1818#include "core.h"
    1919
    20 #if defined WIN32
     20#if defined _WIN32 || defined _XBOX
    2121#   define strcasecmp _stricmp
    2222#endif
  • trunk/src/gradient.cpp

    r960 r1173  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    1212#   include "config.h"
    1313#endif
     14
     15#if !defined _XBOX /* This file is meaningless on Xbox */
    1416
    1517#include <cmath>
     
    242244} /* namespace lol */
    243245
     246#endif /* !defined _XBOX */
  • trunk/src/real.cpp

    r1163 r1173  
    1313#endif
    1414
    15 #if defined WIN32 && !defined _XBOX
     15#if defined _XBOX
     16#   define _USE_MATH_DEFINES /* for M_PI */
     17#   include <xtl.h>
     18#   undef near /* Fuck Microsoft */
     19#   undef far /* Fuck Microsoft again */
     20#elif defined WIN32
    1621#   define _USE_MATH_DEFINES /* for M_PI */
    1722#   define WIN32_LEAN_AND_MEAN
  • trunk/src/shader/shader.cpp

    r832 r1173  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    3939
    4040private:
     41#if defined _XBOX
     42
    4143#if !defined __CELLOS_LV2__
    4244    GLuint prog_id, vert_id, frag_id;
  • trunk/src/thread/threadbase.h

    r1144 r1173  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    1919#if defined HAVE_PTHREAD_H
    2020#   include <pthread.h>
     21#elif defined _XBOX
     22#   include <xtl.h>
     23#   undef near /* Fuck Microsoft */
     24#   undef far /* Fuck Microsoft again */
    2125#elif defined _WIN32
    2226#   include <windows.h>
     27#   undef near /* Fuck Microsoft */
     28#   undef far /* Fuck Microsoft again */
    2329#else
    2430#   error No threading support yet :(
  • trunk/src/timer.cpp

    r1082 r1173  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    2121#elif defined _XBOX
    2222#   include <xtl.h>
     23#   undef near /* Fuck Microsoft */
     24#   undef far /* Fuck Microsoft again */
    2325#   include <xbox.h>
    2426#elif defined _WIN32
  • trunk/src/vector.cpp

    r1149 r1173  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    1313#endif
    1414
    15 #if defined WIN32 && !defined _XBOX
     15#if defined _XBOX
     16#   define _USE_MATH_DEFINES /* for M_PI */
     17#   include <xtl.h>
     18#   undef near /* Fuck Microsoft */
     19#   undef far /* Fuck Microsoft again */
     20#elif defined _WIN32
    1621#   define _USE_MATH_DEFINES /* for M_PI */
    1722#   define WIN32_LEAN_AND_MEAN
  • trunk/src/video.cpp

    r1108 r1173  
    22// Lol Engine
    33//
    4 // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
     4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
    55//   This program is free software; you can redistribute it and/or
    66//   modify it under the terms of the Do What The Fuck You Want To
     
    1515#include <cmath>
    1616
    17 #if defined _WIN32 && !defined _XBOX
     17#if _XBOX
     18#   include <xtl.h>
     19#   undef near /* Fuck Microsoft */
     20#   undef far /* Fuck Microsoft again */
     21#elif defined _WIN32
    1822#   define WIN32_LEAN_AND_MEAN
    1923#   include <windows.h>
     
    3741    static mat4 proj_matrix, view_matrix;
    3842    static ivec2 saved_viewport;
     43#if defined _XBOX
     44    static Direct3D *d3d_ctx;
     45    static D3DDevice *d3d_dev;
     46#endif
    3947};
    4048
    4149mat4 VideoData::proj_matrix;
    4250mat4 VideoData::view_matrix;
    43 
    4451ivec2 VideoData::saved_viewport(0, 0);
     52
     53#if defined _XBOX
     54Direct3D *VideoData::d3d_ctx;
     55D3DDevice *VideoData::d3d_dev;
     56#endif
    4557
    4658/*
     
    5062void Video::Setup(ivec2 size)
    5163{
    52 #if defined USE_GLEW && !defined __APPLE__
     64#if defined _XBOX
     65    VideoData::d3d_ctx = Direct3DCreate9(D3D_SDK_VERSION);
     66    if (!VideoData::d3d_ctx)
     67    {
     68        Log::Error("cannot initialise D3D\n");
     69        exit(EXIT_FAILURE);
     70    }
     71
     72    D3DPRESENT_PARAMETERS d3dpp;
     73    memset(&d3dpp, 0, sizeof(d3dpp));
     74
     75    XVIDEO_MODE VideoMode;
     76    XGetVideoMode( &VideoMode );
     77    if (size.x > VideoMode.dwDisplayWidth)
     78        size.x = VideoMode.dwDisplayWidth;
     79    if (size.y > VideoMode.dwDisplayHeight)
     80        size.y = VideoMode.dwDisplayHeight;
     81    VideoData::saved_viewport = size;
     82
     83    d3dpp.BackBufferWidth = size.x;
     84    d3dpp.BackBufferHeight = size.y;
     85    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
     86    d3dpp.BackBufferCount = 1;
     87    d3dpp.EnableAutoDepthStencil = TRUE;
     88    d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
     89    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
     90    d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
     91
     92    if (!VideoData::d3d_ctx->CreateDevice(0, D3DDEVTYPE_HAL, NULL,
     93                                          D3DCREATE_HARDWARE_VERTEXPROCESSING,
     94                                          &d3dpp, &VideoData::d3d_dev))
     95    {
     96        Log::Error("cannot create D3D device\n");
     97        exit(EXIT_FAILURE);
     98    }
     99#else
     100#   if defined USE_GLEW && !defined __APPLE__
    53101    /* Initialise GLEW if necessary */
    54102    GLenum glerr = glewInit();
     
    58106        exit(EXIT_FAILURE);
    59107    }
    60 #endif
     108#   endif
    61109
    62110    /* Initialise OpenGL */
     
    67115    glClearDepth(1.0);
    68116
    69 #if defined HAVE_GL_2X && !defined __APPLE__
     117#   if defined HAVE_GL_2X && !defined __APPLE__
    70118    glShadeModel(GL_SMOOTH);
    71119    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
     120#   endif
    72121#endif
    73122}
     
    127176{
    128177    ivec2 size = GetSize();
     178#if defined _XBOX
     179    VideoData::d3d_dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER
     180                                        | D3DCLEAR_STENCIL,
     181                              D3DCOLOR_XRGB(26, 51, 77), 1.0f, 0);
     182#else
    129183    glViewport(0, 0, size.x, size.y);
    130184    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
     185#endif
    131186
    132187    SetFov(0.0f);
     
    140195void Video::Capture(uint32_t *buffer)
    141196{
     197#if _XBOX
     198    /* TODO */
     199#else
    142200    GLint v[4];
    143 #if defined __CELLOS_LV2__
     201#   if defined __CELLOS_LV2__
    144202    // FIXME: use psglCreateDeviceAuto && psglGetDeviceDimensions
    145203    v[2] = 1920;
    146204    v[3] = 1080;
    147 #else
     205#   else
    148206    glGetIntegerv(GL_VIEWPORT, v);
    149 #endif
     207#   endif
    150208    int width = v[2], height = v[3];
    151209
    152 #if defined HAVE_GL_2X
     210#   if defined HAVE_GL_2X
    153211    glPixelStorei(GL_PACK_ROW_LENGTH, 0);
    154 #endif
     212#   endif
    155213    glPixelStorei(GL_PACK_ALIGNMENT, 1);
    156214
    157 #if defined GL_BGRA
     215#   if defined GL_BGRA
    158216    glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
    159 #else
     217#   else
    160218    glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
    161 #endif
     219#   endif
    162220
    163221    for (int j = 0; j < height / 2; j++)
     
    168226            buffer[(height - j - 1) * width + i] = tmp;
    169227        }
     228#endif
    170229}
    171230
    172231ivec2 Video::GetSize()
    173232{
     233#if _XBOX
     234    return VideoData::saved_viewport;
     235#elif 1
    174236    /* GetSize() is called too often on the game thread; we cannot rely on
    175237     * the GL context at this point */
    176 #if 1
    177238    return VideoData::saved_viewport;
    178239#elif defined __CELLOS_LV2__
  • trunk/win32/lolcore.vcxproj

    r1166 r1173  
    170170    <ClCompile Include="..\src\platform\sdl\sdlapp.cpp" />
    171171    <ClCompile Include="..\src\platform\sdl\sdlinput.cpp" />
     172    <ClCompile Include="..\src\platform\xbox\xboxapp.cpp" />
    172173    <ClCompile Include="..\src\profiler.cpp" />
    173174    <ClCompile Include="..\src\real.cpp" />
     
    224225    <ClInclude Include="..\src\platform\sdl\sdlapp.h" />
    225226    <ClInclude Include="..\src\platform\sdl\sdlinput.h" />
     227    <ClInclude Include="..\src\platform\xbox\xboxapp.h" />
    226228    <ClInclude Include="..\src\profiler.h" />
    227229    <ClInclude Include="..\src\sample.h" />
  • trunk/win32/lolcore.vcxproj.filters

    r1155 r1173  
    3939      <UniqueIdentifier>{123803f1-1722-4421-8245-098667654cda}</UniqueIdentifier>
    4040    </Filter>
     41    <Filter Include="src\platform\xbox">
     42      <UniqueIdentifier>{317cb5cc-5dcc-4e14-be90-40a125a2e2ec}</UniqueIdentifier>
     43    </Filter>
    4144  </ItemGroup>
    4245  <ItemGroup>
     
    185188      <Filter>src\image\codec</Filter>
    186189    </ClCompile>
     190    <ClCompile Include="..\src\platform\xbox\xboxapp.cpp">
     191      <Filter>src\platform\xbox</Filter>
     192    </ClCompile>
    187193  </ItemGroup>
    188194  <ItemGroup>
     
    346352      <Filter>src\image</Filter>
    347353    </ClInclude>
     354    <ClInclude Include="..\src\platform\xbox\xboxapp.h">
     355      <Filter>src\platform\xbox</Filter>
     356    </ClInclude>
    348357  </ItemGroup>
    349358</Project>
Note: See TracChangeset for help on using the changeset viewer.