Changeset 1208


Ignore:
Timestamp:
Apr 10, 2012, 3:12:52 AM (8 years ago)
Author:
sam
Message:

win32: start porting the graphical backend to DirectX 9. Apparently I
cannot used DirectX 10 because my video card only supports DX9, and there
is no compatibility layer. DX11 has feature levels for older hardware so
it would work with a DX9 card, but it's not available for WinXP.

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/debug/quad.cpp

    r1173 r1208  
    1313#endif
    1414
    15 #if !defined _XBOX /* This file is meaningless on Xbox */
     15#if !defined USE_D3D9 && !defined _XBOX /* This file is meaningless on Xbox */
    1616
    1717#if defined WIN32 && !_XBOX
  • trunk/src/debug/sphere.cpp

    r1173 r1208  
    1313#endif
    1414
    15 #if !defined _XBOX /* This file is meaningless on Xbox */
     15#if !defined USE_D3D9 && !defined _XBOX /* This file is meaningless on Xbox */
    1616
    1717#if defined WIN32
  • trunk/src/gpu/shader.cpp

    r1194 r1208  
    2020#   define WIN32_LEAN_AND_MEAN
    2121#   include <windows.h>
     22#   if defined USE_D3D9
     23#       include <d3d9.h>
     24#       include <d3dx9shader.h>
     25#   endif
    2226#endif
    2327
     
    2630
    2731using namespace std;
     32
     33#if defined USE_D3D9
     34extern IDirect3DDevice9 *g_d3ddevice;
     35#elif defined _XBOX
     36extern D3DDevice *g_d3ddevice;
     37#endif
    2838
    2939namespace lol
     
    3949
    4050private:
    41 #if defined _XBOX
     51#if defined USE_D3D9
     52    IDirect3DVertexShader9 *vert_shader;
     53    IDirect3DPixelShader9 *frag_shader;
     54    ID3DXConstantTable *vert_table, *frag_table;
     55#elif defined _XBOX
    4256    D3DVertexShader *vert_shader;
    4357    D3DPixelShader *frag_shader;
     
    93107  : data(new ShaderData())
    94108{
    95 #if defined _XBOX
    96     extern D3DDevice *g_d3ddevice;
     109#if defined USE_D3D9 || defined _XBOX
    97110    ID3DXBuffer *shader_code, *error_msg;
    98111    HRESULT hr;
     
    110123    /* Compile vertex shader */
    111124    data->vert_crc = Hash::Crc32(vert);
    112 #if defined _XBOX
     125#if defined USE_D3D9 || defined _XBOX
    113126    hr = D3DXCompileShader(vert, (UINT)strlen(vert), NULL, NULL, "main",
    114127                           "vs_2_0", 0, &shader_code, &error_msg,
     
    149162    /* Compile fragment shader */
    150163    data->frag_crc = Hash::Crc32(frag);
    151 #if defined _XBOX
     164#if defined USE_D3D9 || defined _XBOX
    152165    hr = D3DXCompileShader(frag, (UINT)strlen(frag), NULL, NULL, "main",
    153166                           "ps_2_0", 0, &shader_code, &error_msg,
     
    186199#endif
    187200
    188 #if !defined _XBOX && !defined __CELLOS_LV2__
     201#if !defined USE_D3D9 && !defined _XBOX && !defined __CELLOS_LV2__
    189202    /* Create program */
    190203    data->prog_id = glCreateProgram();
     
    199212int Shader::GetAttribLocation(char const *attr) const
    200213{
    201 #if defined _XBOX
     214#if defined USE_D3D9 || defined _XBOX
    202215    /* FIXME: do we have attribs? */
    203216    return 0;
     
    212225int Shader::GetUniformLocation(char const *uni) const
    213226{
    214 #if defined _XBOX
    215     D3DXHANDLE hr1 = data->frag_table->GetConstantByName(NULL, uni);
    216     D3DXHANDLE hr2 = data->vert_table->GetConstantByName(NULL, uni);
     227#if defined USE_D3D9 || defined _XBOX
     228    UINT hr1 = (uintptr_t)data->frag_table->GetConstantByName(NULL, uni);
     229    UINT hr2 = (uintptr_t)data->vert_table->GetConstantByName(NULL, uni);
    217230    return (int)(((uint32_t)hr1 << 16) | (uint32_t)hr2);
    218231#elif !defined __CELLOS_LV2__
     
    230243void Shader::SetUniform(int uni, float f)
    231244{
    232 #if defined _XBOX
     245#if defined USE_D3D9 || defined _XBOX
    233246    SetUniform(uni, vec4(f, 0, 0, 0));
    234247#elif !defined __CELLOS_LV2__
     
    241254void Shader::SetUniform(int uni, vec2 const &v)
    242255{
    243 #if defined _XBOX
     256#if defined USE_D3D9 || defined _XBOX
    244257    SetUniform(uni, vec4(v, 0, 0));
    245258#elif !defined __CELLOS_LV2__
     
    252265void Shader::SetUniform(int uni, vec3 const &v)
    253266{
    254 #if defined _XBOX
     267#if defined USE_D3D9 || defined _XBOX
    255268    SetUniform(uni, vec4(v, 0));
    256269#elif !defined __CELLOS_LV2__
     
    264277{
    265278    /* FIXME: use the array versions of these functions */
    266 #if defined _XBOX
    267     extern D3DDevice *g_d3ddevice;
    268     D3DXHANDLE hr1 = (uint32_t)uni >> 16;
    269     D3DXHANDLE hr2 = (uint32_t)(uint16_t)uni;
     279#if defined USE_D3D9 || defined _XBOX
     280    UINT hr1 = (uint32_t)uni >> 16;
     281    UINT hr2 = (uint32_t)(uint16_t)uni;
    270282    g_d3ddevice->SetPixelShaderConstantF(hr1, &v[0], 1);
    271283    g_d3ddevice->SetVertexShaderConstantF(hr2, &v[0], 1);
     
    279291void Shader::SetUniform(int uni, mat4 const &m)
    280292{
    281 #if defined _XBOX
    282     extern D3DDevice *g_d3ddevice;
    283     D3DXHANDLE hr1 = (uint32_t)uni >> 16;
    284     D3DXHANDLE hr2 = (uint32_t)(uint16_t)uni;
     293#if defined USE_D3D9 || defined _XBOX
     294    UINT hr1 = (uint32_t)uni >> 16;
     295    UINT hr2 = (uint32_t)(uint16_t)uni;
    285296    g_d3ddevice->SetPixelShaderConstantF(hr1, &m[0][0], 4);
    286297    g_d3ddevice->SetVertexShaderConstantF(hr2, &m[0][0], 4);
     
    294305void Shader::Bind() const
    295306{
    296 #if defined _XBOX
    297     extern D3DDevice *g_d3ddevice;
    298     g_d3ddevice->SetVertexShader(data->vert_shader);
    299     g_d3ddevice->SetPixelShader(data->frag_shader);
     307#if defined USE_D3D9 || defined _XBOX
     308    HRESULT hr;
     309    hr = g_d3ddevice->SetVertexShader(data->vert_shader);
     310    hr = g_d3ddevice->SetPixelShader(data->frag_shader);
    300311#elif !defined __CELLOS_LV2__
    301312    glUseProgram(data->prog_id);
     
    310321Shader::~Shader()
    311322{
    312 #if defined _XBOX
    313     extern D3DDevice *g_d3ddevice;
     323#if defined USE_D3D9 || defined _XBOX
    314324    data->vert_shader->Release();
    315325    data->vert_table->Release();
     
    334344    static int version = 0;
    335345
    336 #if !defined _XBOX && !defined __CELLOS_LV2__
     346#if !defined USE_D3D9 && !defined _XBOX && !defined __CELLOS_LV2__
    337347    if (!version)
    338348    {
  • trunk/src/gradient.cpp

    r1189 r1208  
    3333private:
    3434    Shader *shader;
    35 #if !defined _XBOX /* This file is meaningless on Xbox */
     35#if !defined USE_D3D9 && !defined _XBOX /* This file is meaningless on Xbox */
    3636
    3737    GLuint bufs[2];
     
    6666    Entity::TickDraw(deltams);
    6767
    68 #if !defined _XBOX /* This file is meaningless on Xbox */
     68#if !defined USE_D3D9 && !defined _XBOX /* This file is meaningless on Xbox */
    6969    if (!data->shader)
    7070    {
  • trunk/src/platform/sdl/sdlapp.cpp

    r1106 r1208  
    1515#if defined USE_SDL
    1616#   include <SDL.h>
     17#   if defined USE_D3D9
     18#       include <d3d9.h>
     19#       include <SDL_syswm.h>
     20#   endif
    1721#endif
    1822
     
    2125#include "platform/sdl/sdlapp.h"
    2226#include "platform/sdl/sdlinput.h"
     27
     28#if defined USE_D3D9
     29HWND g_hwnd = NULL;
     30#endif
    2331
    2432namespace lol
     
    5260    }
    5361
     62#   if defined USE_D3D9
     63    SDL_Surface *video = SDL_SetVideoMode(res.x, res.y, 16, 0);
     64    SDL_SysWMinfo wminfo;
     65    SDL_VERSION(&wminfo.version);
     66    SDL_GetWMInfo(&wminfo);
     67    g_hwnd = wminfo.window;
     68#   else
    5469    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    5570    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    5671    SDL_Surface *video = SDL_SetVideoMode(res.x, res.y, 0, SDL_OPENGL);
     72#   endif
    5773    if (!video)
    5874    {
    59         Log::Error("cannot create OpenGL screen: %s\n", SDL_GetError());
     75        Log::Error("cannot create rendering window: %s\n", SDL_GetError());
    6076        SDL_Quit();
    6177        exit(EXIT_FAILURE);
     
    85101    while (!Ticker::Finished())
    86102    {
     103#if defined USE_SDL && defined USE_D3D9
     104        extern IDirect3DDevice9 *g_d3ddevice;
     105        g_d3ddevice->BeginScene();
     106#endif
    87107        /* Tick the renderer, show the frame and clamp to desired framerate. */
    88108        Ticker::TickDraw();
    89109#if defined USE_SDL
     110#   if defined USE_D3D9
     111        g_d3ddevice->EndScene();
     112        g_d3ddevice->Present(NULL, NULL, NULL, NULL);
     113#   else
    90114        SDL_GL_SwapBuffers();
     115#   endif
    91116#endif
    92117    }
  • trunk/src/scene.cpp

    r1198 r1208  
    6161    float angle;
    6262
    63 #if defined _XBOX
     63#if defined USE_D3D9 || defined _XBOX
    6464#   define STR0(x) #x
    6565#   define STR(x) STR0(x)
     
    9191    data->angle = angle;
    9292
    93 #if defined _XBOX
     93#if defined USE_D3D9 || defined _XBOX
    9494#   define STR0(x) #x
    9595#   define STR(x) STR0(x)
     
    109109Scene::~Scene()
    110110{
    111 #if defined _XBOX
     111#if defined USE_D3D9 || defined _XBOX
    112112#   define STR0(x) #x
    113113#   define STR(x) STR0(x)
     
    145145void Scene::AddTile(TileSet *tileset, int id, vec3 pos, int o, vec2 scale)
    146146{
    147 #if !defined _XBOX /* No WPOS on Xbox */
     147#if !defined USE_D3D9 && !defined _XBOX
    148148    if ((data->ntiles % 1024) == 0)
    149149        data->tiles = (Tile *)realloc(data->tiles,
     
    162162void Scene::Render() // XXX: rename to Blit()
    163163{
    164 #if !defined _XBOX /* No WPOS on Xbox */
     164#if !defined USE_D3D9 && !defined _XBOX /* No WPOS on Xbox, what about Win32? */
    165165    if (!stdshader)
    166166    {
     
    344344    stdshader->SetUniform(uni_mat, data->model_matrix);
    345345
    346 #if defined _XBOX
     346#if defined USE_D3D9 || defined _XBOX
    347347#   define STR0(x) #x
    348348#   define STR(x) STR0(x)
     
    359359#endif
    360360
    361 #if defined _XBOX
     361#if defined USE_D3D9 || defined _XBOX
    362362#   define STR0(x) #x
    363363#   define STR(x) STR0(x)
     
    381381    for (int buf = 0, i = 0, n; i < data->ntiles; i = n, buf += 2)
    382382    {
    383 #if defined _XBOX
     383#if defined USE_D3D9 || defined _XBOX
    384384#   define STR0(x) #x
    385385#   define STR(x) STR0(x)
     
    423423        glBindVertexArray(data->vao);
    424424#endif
    425 #if defined _XBOX
     425#if defined USE_D3D9 || defined _XBOX
    426426#   define STR0(x) #x
    427427#   define STR(x) STR0(x)
     
    474474    data->ntiles = 0;
    475475
    476 #if defined _XBOX
     476#if defined USE_D3D9 || defined _XBOX
    477477#   define STR0(x) #x
    478478#   define STR(x) STR0(x)
     
    490490    glDisable(GL_BLEND);
    491491#endif
    492 #endif /* _XBOX */
     492#endif /* _XBOX || USE_D3D9 */
    493493}
    494494
  • trunk/src/tileset.cpp

    r1198 r1208  
    4747
    4848    Image *img;
    49 #if defined _XBOX
     49#if defined USE_D3D9 || defined _XBOX
    5050#   define STR0(x) #x
    5151#   define STR(x) STR0(x)
     
    7070
    7171    data->tiles = NULL;
    72 #if defined _XBOX
     72#if defined USE_D3D9 || defined _XBOX
    7373#   define STR0(x) #x
    7474#   define STR(x) STR0(x)
     
    119119        if (data->img)
    120120            delete data->img;
    121 #if defined _XBOX
     121#if defined USE_D3D9 || defined _XBOX
    122122#   define STR0(x) #x
    123123#   define STR(x) STR0(x)
     
    132132    else if (data->img)
    133133    {
    134 #if defined _XBOX
     134#if defined USE_D3D9 || defined _XBOX
    135135#   define STR0(x) #x
    136136#   define STR(x) STR0(x)
     
    204204void TileSet::Bind()
    205205{
    206 #if defined _XBOX
     206#if defined USE_D3D9 || defined _XBOX
    207207#   define STR0(x) #x
    208208#   define STR(x) STR0(x)
     
    229229    int dz = o ? data->size.y * scale.y : 0;
    230230
    231 #if defined _XBOX
     231#if defined USE_D3D9 || defined _XBOX
    232232#   define STR0(x) #x
    233233#   define STR(x) STR0(x)
  • trunk/src/video.cpp

    r1199 r1208  
    1515#include <cmath>
    1616
    17 #if _XBOX
     17#if defined USE_D3D9
     18#   include <d3d9.h>
     19#elif defined _XBOX
    1820#   include <xtl.h>
    1921#   undef near /* Fuck Microsoft */
     
    3133using namespace std;
    3234
    33 #if defined _XBOX
    3435/* FIXME: g_d3ddevice should never be exported */
     36#if defined USE_D3D9
     37IDirect3DDevice9 *g_d3ddevice;
     38#   if defined USE_SDL
     39extern HWND g_hwnd;
     40#   endif
     41#elif defined _XBOX
    3542D3DDevice *g_d3ddevice;
    3643#endif
     
    4653    static mat4 proj_matrix, view_matrix;
    4754    static ivec2 saved_viewport;
    48 #if defined _XBOX
     55#if defined USE_D3D9
     56    static IDirect3D9 *d3d_ctx;
     57    static IDirect3DDevice9 *d3d_dev;
     58    static D3DCOLOR clear_color;
     59#elif defined _XBOX
    4960    static Direct3D *d3d_ctx;
    5061    static D3DDevice *d3d_dev;
     
    5768ivec2 VideoData::saved_viewport(0, 0);
    5869
    59 #if defined _XBOX
     70#if defined USE_D3D9
     71IDirect3D9 *VideoData::d3d_ctx;
     72IDirect3DDevice9 *VideoData::d3d_dev;
     73D3DCOLOR VideoData::clear_color;
     74#elif defined _XBOX
    6075Direct3D *VideoData::d3d_ctx;
    6176D3DDevice *VideoData::d3d_dev;
     
    6984void Video::Setup(ivec2 size)
    7085{
    71 #if defined _XBOX
     86#if defined USE_D3D9 || defined _XBOX
    7287    VideoData::d3d_ctx = Direct3DCreate9(D3D_SDK_VERSION);
    7388    if (!VideoData::d3d_ctx)
     
    7792    }
    7893
     94    HWND window = 0;
    7995    D3DPRESENT_PARAMETERS d3dpp;
    8096    memset(&d3dpp, 0, sizeof(d3dpp));
    8197
     98#   if defined USE_SDL
     99    window = g_hwnd;
     100    d3dpp.hDeviceWindow = g_hwnd;
     101    d3dpp.Windowed = TRUE;
     102#   elif defined _XBOX
    82103    XVIDEO_MODE VideoMode;
    83104    XGetVideoMode( &VideoMode );
     
    86107    if (size.y > VideoMode.dwDisplayHeight)
    87108        size.y = VideoMode.dwDisplayHeight;
     109#   endif
    88110    VideoData::saved_viewport = size;
    89111
     
    99121    d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
    100122
    101     if (FAILED(VideoData::d3d_ctx->CreateDevice(0, D3DDEVTYPE_HAL, NULL,
    102                                                 D3DCREATE_HARDWARE_VERTEXPROCESSING,
    103                                                 &d3dpp, &VideoData::d3d_dev)))
     123    HRESULT hr = VideoData::d3d_ctx->CreateDevice(0, D3DDEVTYPE_HAL, window,
     124                                                  D3DCREATE_HARDWARE_VERTEXPROCESSING,
     125                                                  &d3dpp, &VideoData::d3d_dev);
     126    if (FAILED(hr))
    104127    {
    105128        Log::Error("cannot create D3D device\n");
     
    178201void Video::SetDepth(bool set)
    179202{
    180 #if defined _XBOX
     203#if defined USE_D3D9 || defined _XBOX
    181204#   define STR0(x) #x
    182205#   define STR(x) STR0(x)
     
    192215void Video::SetClearColor(vec4 color)
    193216{
    194 #if defined _XBOX
     217#if defined USE_D3D9 || defined _XBOX
    195218    VideoData::clear_color = D3DCOLOR_XRGB((int)(color.r * 255.999f),
    196219                                           (int)(color.g * 255.999f),
     
    204227{
    205228    ivec2 size = GetSize();
    206 #if defined _XBOX
     229#if defined USE_D3D9 || defined _XBOX
    207230    VideoData::d3d_dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER
    208231                                        | D3DCLEAR_STENCIL,
     
    223246void Video::Capture(uint32_t *buffer)
    224247{
    225 #if _XBOX
     248#if defined USE_D3D9 || defined _XBOX
    226249    /* TODO */
    227250#else
     
    259282ivec2 Video::GetSize()
    260283{
    261 #if _XBOX
     284#if defined USE_D3D9 || defined _XBOX
    262285    return VideoData::saved_viewport;
    263286#elif 1
  • trunk/test/tutorial/tut01.cpp

    r1197 r1208  
    2020using namespace lol;
    2121
     22#if defined _WIN32 && defined USE_D3D9
     23#   define FAR
     24#   define NEAR
     25#   include <d3d9.h>
     26#endif
     27
    2228#if USE_SDL && defined __APPLE__
    2329#   include <SDL_main.h>
     
    3137#   undef main /* FIXME: still needed? */
    3238#   include <direct.h>
     39#endif
     40
     41#if defined USE_D3D9
     42extern IDirect3DDevice9 *g_d3ddevice;
     43#elif defined _XBOX
     44extern D3DDevice *g_d3ddevice;
    3345#endif
    3446
     
    5163        {
    5264            m_shader = Shader::Create(
    53 #if !defined __CELLOS_LV2__ && !defined _XBOX
     65#if !defined __CELLOS_LV2__ && !defined _XBOX && !defined USE_D3D9
    5466                "#version 120\n"
    5567                "attribute vec2 in_Position;"
     
    7385#endif
    7486            );
    75 #if !defined _XBOX
     87#if !defined _XBOX && !defined USE_D3D9
    7688            m_attrib = m_shader->GetAttribLocation("in_Position");
    7789#endif
    7890            m_ready = true;
    7991
    80 #if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined _XBOX
     92#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined _XBOX && !defined USE_D3D9
    8193            /* Method 1: store vertex buffer on the GPU memory */
    8294            glGenBuffers(1, &m_vbo);
     
    8496            glBufferData(GL_ARRAY_BUFFER, sizeof(m_vertices), m_vertices,
    8597                         GL_STATIC_DRAW);
    86 #elif !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined _XBOX
     98#elif !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined _XBOX && !defined USE_D3D9
    8799            /* Method 2: upload vertex information at each frame */
    88 #elif defined _XBOX
    89             extern D3DDevice *g_d3ddevice;
     100#elif defined _XBOX || defined USE_D3D9
    90101            D3DVERTEXELEMENT9 const elements[2] =
    91102            {
     
    109120
    110121        m_shader->Bind();
    111 #if defined _XBOX
    112         extern D3DDevice *g_d3ddevice;
     122#if defined _XBOX || defined USE_D3D9
    113123        g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
    114124        g_d3ddevice->SetVertexDeclaration(m_vdecl);
     
    127137#endif
    128138
    129 #if defined _XBOX
    130         g_d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
     139#if defined _XBOX || defined USE_D3D9
     140        g_d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 3);
    131141#else
    132142        glDrawArrays(GL_TRIANGLES, 0, 3);
    133143#endif
    134144
    135 #if defined _XBOX
     145#if defined _XBOX || defined USE_D3D9
    136146        /* FIXME: do we need to unset anything here? */
    137147#elif !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
     
    149159    vec2 m_vertices[3];
    150160    Shader *m_shader;
    151 #if defined _XBOX
     161#if defined USE_D3D9
     162    IDirect3DVertexDeclaration9 *m_vdecl;
     163    IDirect3DVertexBuffer9 *m_vbo;
     164#elif defined _XBOX
    152165    D3DVertexDeclaration *m_vdecl;
    153166    D3DVertexBuffer *m_vbo;
  • trunk/test/tutorial/tut02.cpp

    r1196 r1208  
    2020using namespace lol;
    2121
     22#if defined _WIN32 && defined USE_D3D9
     23#   define FAR
     24#   define NEAR
     25#   include <d3d9.h>
     26#endif
     27
    2228#if USE_SDL && defined __APPLE__
    2329#   include <SDL_main.h>
     
    2733#   undef main /* FIXME: still needed? */
    2834#   include <direct.h>
     35#endif
     36
     37#if defined USE_D3D9
     38extern IDirect3DDevice9 *g_d3ddevice;
     39#elif defined _XBOX
     40extern D3DDevice *g_d3ddevice;
    2941#endif
    3042
     
    93105        {
    94106            m_shader = Shader::Create(
    95 #if !defined __CELLOS_LV2__ && !defined _XBOX
     107#if !defined __CELLOS_LV2__ && !defined _XBOX && !defined USE_D3D9
    96108                "#version 120\n"
    97109                "attribute vec3 in_Vertex;"
     
    127139#endif
    128140            );
    129 #if !defined _XBOX
     141#if !defined _XBOX && !defined USE_D3D9
    130142            m_coord = m_shader->GetAttribLocation("in_Vertex");
    131143            m_color = m_shader->GetAttribLocation("in_Color");
     
    134146            m_ready = true;
    135147
    136 #if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined _XBOX
     148#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined _XBOX && !defined USE_D3D9
    137149            /* Method 1: store vertex buffer on the GPU memory */
    138150            glGenBuffers(1, &m_vbo);
     
    148160            glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(m_indices), m_indices,
    149161                         GL_STATIC_DRAW);
    150 #elif defined _XBOX
    151             extern D3DDevice *g_d3ddevice;
     162#elif defined _XBOX || defined USE_D3D9
    152163            D3DVERTEXELEMENT9 const elements[] =
    153164            {
     
    192203        m_shader->Bind();
    193204        m_shader->SetUniform(m_mvp, m_matrix);
    194 #if defined _XBOX
    195         extern D3DDevice *g_d3ddevice;
     205#if defined _XBOX || defined USE_D3D9
    196206        g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
    197207        g_d3ddevice->SetVertexDeclaration(m_vdecl);
     
    233243    i16vec3 m_indices[12];
    234244    Shader *m_shader;
    235 #if defined _XBOX
     245#if defined USE_D3D9
     246    IDirect3DVertexDeclaration9 *m_vdecl;
     247    IDirect3DVertexBuffer9 *m_vbo, *m_cbo;
     248    IDirect3DIndexBuffer9 *m_ibo;
     249#elif defined _XBOX
    236250    D3DVertexDeclaration *m_vdecl;
    237251    D3DVertexBuffer *m_vbo, *m_cbo;
  • trunk/win32/Lol.Rules.props

    r1201 r1208  
    1111      <FloatingPointModel>Fast</FloatingPointModel>
    1212      <AdditionalIncludeDirectories>$(SolutionDir)\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    13       <AdditionalIncludeDirectories Condition="'$(Platform)'=='Win32'">$(GlIncludes);$(SdlIncludes);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     13      <AdditionalIncludeDirectories Condition="'$(Platform)'=='Win32'">$(GlIncludes);$(SdlIncludes);$(D3d9Includes);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    1414      <PreprocessorDefinitions Condition="'$(Platform)'=='Win32'">WIN32;$(Win32Defines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
    1515      <PreprocessorDefinitions Condition="'$(Platform)'=='Xbox 360'">_XBOX;$(XboxDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
     
    3333      <GenerateDebugInformation>true</GenerateDebugInformation>
    3434      <!-- FIXME: not for the static library! -->
    35       <AdditionalDependencies Condition="'$(Platform)'=='Win32'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;$(SdlDeps);$(GdiDeps);$(GlDeps);%(AdditionalDependencies)</AdditionalDependencies>
    36       <AdditionalLibraryDirectories Condition="'$(Platform)'=='Win32'">$(SdlLibs);$(GlLibs);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
     35      <AdditionalDependencies Condition="'$(Platform)'=='Win32'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;$(SdlDeps);$(GdiDeps);$(GlDeps);$(D3d9Deps);%(AdditionalDependencies)</AdditionalDependencies>
     36      <AdditionalLibraryDirectories Condition="'$(Platform)'=='Win32'">$(SdlLibs);$(GlLibs);$(D3d9Libs);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
    3737      <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">xapilibd.lib;d3d9d.lib;d3dx9d.lib;xgraphicsd.lib;xboxkrnl.lib;xnetd.lib;xaudiod2.lib;xactd3.lib;x3daudiod.lib;xmcored.lib;xbdm.lib;vcompd.lib;%(AdditionalDependencies)</AdditionalDependencies>
    3838      <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">xapilib.lib;d3d9.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3.lib;x3daudio.lib;xmcore.lib;vcomp.lib;%(AdditionalDependencies)</AdditionalDependencies>
  • trunk/win32/Lol.Vars.props

    r1201 r1208  
    44  <PropertyGroup Label="UserMacros">
    55    <ContribDir>$(SolutionDir)\..\contrib</ContribDir>
    6     <GlewDir>$(ContribDir)\glew-1.7.0</GlewDir>
    7     <GtkDir>$(ContribDir)\gtk-2.22.1</GtkDir>
    8     <GtkGlDir>$(ContribDir)\gtkglarea-2.0.1</GtkGlDir>
     6
     7    <!-- SDL -->
    98    <SdlDir>$(ContribDir)\sdl-1.2.14</SdlDir>
    109    <SdlImageDir>$(ContribDir)\sdl-image-1.2.10</SdlImageDir>
    1110    <SdlMixerDir>$(ContribDir)\sdl-mixer-1.2.11</SdlMixerDir>
     11    <SdlIncludes>$(SdlDir)\include;$(SdlImageDir)\include;$(SdlMixerDir)\include</SdlIncludes>
     12    <SdlLibs>$(SdlDir)\lib\i686-w64-mingw32;$(SdlImageDir)\lib\i686-w64-mingw32;$(SdlMixerDir)\lib\i686-w64-mingw32</SdlLibs>
     13    <SdlDeps>SDL.lib;SDLmain.lib;SDL_image.lib;SDL_mixer.lib</SdlDeps>
     14
     15    <!-- GTK+ & GtkGl -->
     16    <GtkDir>$(ContribDir)\gtk-2.22.1</GtkDir>
     17    <GtkGlDir>$(ContribDir)\gtkglarea-2.0.1</GtkGlDir>
     18    <GtkIncludes>$(GtkDir)\lib\glib-2.0\include;$(GtkDir)\lib\gtk-2.0\include;$(GtkDir)\include\glib-2.0;$(GtkDir)\include\gtk-2.0;$(GtkDir)\include\cairo;$(GtkDir)\include\pango-1.0;$(GtkDir)\include\gdk-pixbuf-2.0;$(GtkDir)\include\atk-1.0;$(GtkGlDir)\include</GtkIncludes>
     19    <GtkLibs>$(GtkDir)\lib;$(GtkDir)\bin;$(GtkGlDir)\lib</GtkLibs>
     20    <GtkDeps>gobject-2.0.lib;gthread-2.0.lib;glib-2.0.lib;gdk-win32-2.0.lib;gtk-win32-2.0.lib;gtkgl-2.0.lib</GtkDeps>
     21
     22    <!-- GDI+ -->
     23    <GdiDeps>Gdiplus.lib</GdiDeps>
     24
     25    <!-- OpenGL & GLEW -->
     26    <GlewDir>$(ContribDir)\glew-1.7.0</GlewDir>
    1227    <GlIncludes>$(GlewDir)\include\GL</GlIncludes>
    13     <GtkIncludes>$(GtkDir)\lib\glib-2.0\include;$(GtkDir)\lib\gtk-2.0\include;$(GtkDir)\include\glib-2.0;$(GtkDir)\include\gtk-2.0;$(GtkDir)\include\cairo;$(GtkDir)\include\pango-1.0;$(GtkDir)\include\gdk-pixbuf-2.0;$(GtkDir)\include\atk-1.0;$(GtkGlDir)\include</GtkIncludes>
    14     <SdlIncludes>$(SdlDir)\include;$(SdlImageDir)\include;$(SdlMixerDir)\include</SdlIncludes>
    1528    <GlLibs>$(GlewDir)\lib\i686-w64-mingw32</GlLibs>
    16     <GtkLibs>$(GtkDir)\lib;$(GtkDir)\bin;$(GtkGlDir)\lib</GtkLibs>
    17     <SdlLibs>$(SdlDir)\lib\i686-w64-mingw32;$(SdlImageDir)\lib\i686-w64-mingw32;$(SdlMixerDir)\lib\i686-w64-mingw32</SdlLibs>
    18     <GdiDeps>Gdiplus.lib</GdiDeps>
    1929    <GlDeps>opengl32.lib;glew32.lib</GlDeps>
    20     <GtkDeps>gobject-2.0.lib;gthread-2.0.lib;glib-2.0.lib;gdk-win32-2.0.lib;gtk-win32-2.0.lib;gtkgl-2.0.lib</GtkDeps>
    21     <SdlDeps>SDL.lib;SDLmain.lib;SDL_image.lib;SDL_mixer.lib</SdlDeps>
    22     <Win32Defines>USE_GLEW;GLEW_STATIC;HAVE_SDL_H;USE_SDL;USE_GDIPLUS</Win32Defines>
     30
     31    <!-- Direct3D 9 -->
     32    <D3d9Includes>$(DXSDK_DIR)\Include</D3d9Includes>
     33    <D3d9Libs Condition="'$(Platform)'=='Win32'">$(DXSDK_DIR)\Lib\x86</D3d9Libs>
     34    <D3d9Libs Condition="'$(Platform)'=='Win64'">$(DXSDK_DIR)\Lib\x64</D3d9Libs>
     35    <D3d9Deps Condition="'$(Configuration)'=='Release'">d3d9.lib;d3dx9.lib</D3d9Deps>
     36    <D3d9Deps Condition="'$(Configuration)'=='Debug'">d3d9.lib;d3dx9d.lib</D3d9Deps>
     37
     38    <Win32Defines>HAVE_SDL_H;USE_SDL;USE_GDIPLUS;USE_D3D9</Win32Defines>
    2339    <XboxDefines></XboxDefines>
    2440  </PropertyGroup>
     
    2743  <ItemGroup>
    2844    <BuildMacro Include="ContribDir"><Value>$(ContribDir)</Value></BuildMacro>
    29     <BuildMacro Include="GlewDir"><Value>$(GlewDir)</Value></BuildMacro>
    30     <BuildMacro Include="GtkDir"><Value>$(GtkDir)</Value></BuildMacro>
    31     <BuildMacro Include="GtkGlDir"><Value>$(GtkGlDir)</Value></BuildMacro>
    3245    <BuildMacro Include="SdlDir"><Value>$(SdlDir)</Value></BuildMacro>
    3346    <BuildMacro Include="SdlImageDir"><Value>$(SdlImageDir)</Value></BuildMacro>
    3447    <BuildMacro Include="SdlMixerDir"><Value>$(SdlMixerDir)</Value></BuildMacro>
     48    <BuildMacro Include="SdlIncludes"><Value>$(SdlIncludes)</Value></BuildMacro>
     49    <BuildMacro Include="SdlLibs"><Value>$(SdlLibs)</Value></BuildMacro>
     50    <BuildMacro Include="SdlDeps"><Value>$(SdlDeps)</Value></BuildMacro>
     51    <BuildMacro Include="GtkDir"><Value>$(GtkDir)</Value></BuildMacro>
     52    <BuildMacro Include="GtkGlDir"><Value>$(GtkGlDir)</Value></BuildMacro>
     53    <BuildMacro Include="GtkIncludes"><Value>$(GtkIncludes)</Value></BuildMacro>
     54    <BuildMacro Include="GtkLibs"><Value>$(GtkLibs)</Value></BuildMacro>
     55    <BuildMacro Include="GtkDeps"><Value>$(GtkDeps)</Value></BuildMacro>
     56    <BuildMacro Include="GdiDeps"><Value>$(GdiDeps)</Value></BuildMacro>
     57    <BuildMacro Include="GlewDir"><Value>$(GlewDir)</Value></BuildMacro>
    3558    <BuildMacro Include="GlIncludes"><Value>$(GlIncludes)</Value></BuildMacro>
    36     <BuildMacro Include="GtkIncludes"><Value>$(GtkIncludes)</Value></BuildMacro>
    37     <BuildMacro Include="SdlIncludes"><Value>$(SdlIncludes)</Value></BuildMacro>
    3859    <BuildMacro Include="GlLibs"><Value>$(GlLibs)</Value></BuildMacro>
    39     <BuildMacro Include="GtkLibs"><Value>$(GtkLibs)</Value></BuildMacro>
    40     <BuildMacro Include="SdlLibs"><Value>$(SdlLibs)</Value></BuildMacro>
    41     <BuildMacro Include="GdiDeps"><Value>$(GdiDeps)</Value></BuildMacro>
    4260    <BuildMacro Include="GlDeps"><Value>$(GlDeps)</Value></BuildMacro>
    43     <BuildMacro Include="GtkDeps"><Value>$(GtkDeps)</Value></BuildMacro>
    44     <BuildMacro Include="SdlDeps"><Value>$(SdlDeps)</Value></BuildMacro>
     61    <BuildMacro Include="D3d9Includes"><Value>$(D3d9Includes)</Value></BuildMacro>
     62    <BuildMacro Include="D3d9Libs"><Value>$(D3d9Libs)</Value></BuildMacro>
     63    <BuildMacro Include="D3d9Deps"><Value>$(D3d9Deps)</Value></BuildMacro>
    4564    <BuildMacro Include="Win32Defines"><Value>$(Win32Defines)</Value></BuildMacro>
    4665    <BuildMacro Include="XboxDefines"><Value>$(XboxDefines)</Value></BuildMacro>
Note: See TracChangeset for help on using the changeset viewer.