2 #include <lib/gdi/sdl.h>
4 #include <lib/base/init.h>
5 #include <lib/base/init_num.h>
9 gSDLDC *gSDLDC::m_instance;
13 if (SDL_Init(SDL_INIT_VIDEO) < 0)
15 eWarning("Could not initialize SDL: %s", SDL_GetError());
19 m_screen = SDL_SetVideoMode(720, 576, 32, SDL_HWSURFACE);
22 eWarning("Could not create SDL surface: %s", SDL_GetError());
29 m_surface.x = m_screen->w;
30 m_surface.y = m_screen->h;
31 m_surface.bpp = m_screen->format->BitsPerPixel;
32 m_surface.bypp = m_screen->format->BytesPerPixel;
33 m_surface.stride = m_screen->pitch;
34 m_surface.data = m_screen->pixels;
35 m_surface.clut.colors=256;
36 m_surface.clut.data=new gRGB[m_surface.clut.colors];
38 m_pixmap = new gPixmap(&m_surface);
40 memset(m_surface.clut.data, 0, sizeof(*m_surface.clut.data)*m_surface.clut.colors);
49 void gSDLDC::setPalette()
51 if (!m_surface.clut.data)
54 /* for (int i=0; i<256; ++i)
56 fb->CMAP()->red[i]=ramp[m_surface.clut.data[i].r]<<8;
57 fb->CMAP()->green[i]=ramp[m_surface.clut.data[i].g]<<8;
58 fb->CMAP()->blue[i]=ramp[m_surface.clut.data[i].b]<<8;
59 fb->CMAP()->transp[i]=rampalpha[m_surface.clut.data[i].a]<<8;
60 if (!fb->CMAP()->red[i])
61 fb->CMAP()->red[i]=0x100;
66 void gSDLDC::exec(gOpcode *o)
70 case gOpcode::setPalette:
86 eAutoInitPtr<gSDLDC> init_gSDLDC(eAutoInitNumbers::graphic-1, "gSDLDC");