Ignore:
Timestamp:
Apr 10, 2012, 3:12:52 AM (11 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.