mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-09-20 04:10:18 +02:00
[svn r42] Disabled the extensive logging by default. Use the -vv flag to get it back.
Fiddled a bit the the testing system. Added a very simple SDL graphics demo.
This commit is contained in:
+46
@@ -0,0 +1,46 @@
|
||||
module sdl;
|
||||
|
||||
version(build)
|
||||
pragma(link,"SDL");
|
||||
|
||||
extern(C):
|
||||
struct SDL_Rect {
|
||||
short x, y;
|
||||
ushort w, h;
|
||||
}
|
||||
struct SDL_PixelFormat {
|
||||
//SDL_Palette *palette;
|
||||
void *palette;
|
||||
ubyte BitsPerPixel, BytesPerPixel, Rloss, Gloss, Bloss, Aloss, Rshift, Gshift, Bshift, Ashift;
|
||||
uint Rmask, Gmask, Bmask, Amask, colorkey; ubyte alpha;
|
||||
}
|
||||
struct SDL_Surface {
|
||||
uint flags;
|
||||
SDL_PixelFormat *format;
|
||||
int w, h;
|
||||
ushort pitch;
|
||||
void *pixels;
|
||||
int offset;
|
||||
void *hwdata;
|
||||
SDL_Rect clip_rect;
|
||||
uint unused;
|
||||
uint locked;
|
||||
void *map;
|
||||
uint format_version;
|
||||
int refcount;
|
||||
}
|
||||
uint SDL_MapRGBA(SDL_PixelFormat *format, ubyte r, ubyte g, ubyte b, ubyte a);
|
||||
void SDL_GetRGBA(uint pixel, SDL_PixelFormat *fmt, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
|
||||
int SDL_LockSurface(SDL_Surface *);
|
||||
void SDL_UnlockSurface(SDL_Surface *);
|
||||
SDL_Surface * SDL_SetVideoMode(int width, int height, int bpp, uint flags);
|
||||
int SDL_Flip(SDL_Surface *);
|
||||
void SDL_Delay(uint);
|
||||
int SDL_FillRect(SDL_Surface*,SDL_Rect*,uint);
|
||||
enum : uint {
|
||||
SDL_SWSURFACE=0,
|
||||
SDL_HWSURFACE=1,
|
||||
SDL_DOUBLEBUF=0x40000000,
|
||||
SDL_FULLSCREEN=0x80000000
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
module sdldemo1;
|
||||
import sdl;
|
||||
void main()
|
||||
{
|
||||
auto disp = SDL_SetVideoMode(640,480,0,SDL_HWSURFACE|SDL_DOUBLEBUF);
|
||||
auto r = SDL_Rect(0,190,100,100);
|
||||
auto c = SDL_MapRGBA(disp.format,255,100,0,255);
|
||||
while (r.x < disp.w-100) {
|
||||
SDL_FillRect(disp, null, 0);
|
||||
SDL_FillRect(disp, &r, c);
|
||||
SDL_Flip(disp);
|
||||
r.x++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user