1 #include <lib/gdi/sdl.h>
3 #include <lib/base/init.h>
4 #include <lib/base/init_num.h>
8 gSDLDC *gSDLDC::m_instance;
12 if (SDL_Init(SDL_INIT_VIDEO) < 0)
14 eWarning("Could not initialize SDL: %s", SDL_GetError());
18 m_screen = SDL_SetVideoMode(720, 576, 32, SDL_HWSURFACE);
21 eWarning("Could not create SDL surface: %s", SDL_GetError());
28 m_surface.x = m_screen->w;
29 m_surface.y = m_screen->h;
30 m_surface.bpp = m_screen->format->BitsPerPixel;
31 m_surface.bypp = m_screen->format->BytesPerPixel;
32 m_surface.stride = m_screen->pitch;
33 m_surface.data = m_screen->pixels;
34 m_surface.clut.colors=256;
35 m_surface.clut.data=new gRGB[m_surface.clut.colors];
37 m_pixmap = new gPixmap(&m_surface);
39 memset(m_surface.clut.data, 0, sizeof(*m_surface.clut.data)*m_surface.clut.colors);
48 void gSDLDC::setPalette()
50 if (!m_surface.clut.data)
53 /* for (int i=0; i<256; ++i)
55 fb->CMAP()->red[i]=ramp[m_surface.clut.data[i].r]<<8;
56 fb->CMAP()->green[i]=ramp[m_surface.clut.data[i].g]<<8;
57 fb->CMAP()->blue[i]=ramp[m_surface.clut.data[i].b]<<8;
58 fb->CMAP()->transp[i]=rampalpha[m_surface.clut.data[i].a]<<8;
59 if (!fb->CMAP()->red[i])
60 fb->CMAP()->red[i]=0x100;
65 void gSDLDC::exec(gOpcode *o)
69 case gOpcode::setPalette:
85 eAutoInitPtr<gSDLDC> init_gSDLDC(eAutoInitNumbers::graphic-1, "gSDLDC");