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