View previous topic :: View next topic |
Author |
Message |
michaelp
Joined: 27 Jul 2008 Posts: 114
|
Posted: Wed Aug 19, 2009 3:26 pm Post subject: porting SDL_Gfx |
|
|
Just wanted to saying that I am in the process of porting SDL_Gfx for use with Derelict.
Also, this guide needs to be updated for the Derelict2. Or just a message saying that it isn't for Derelict2. I'm not sure if it works with Derelict1, but I had to refer to DerelictSDL for how to do things.
Should be done soon.
edit: Okay, did it.
Here's the link:
http://www.sendspace.com/file/m6xr5j
And for Derelict1:
http://www.sendspace.com/file/7e2nhb
To use it, just put the sdlgfx.d file into your import path.
Things that still have to be done:
Some macro functions in SDL_gfxBlitFunc.h are not implemented. I'll do my best to get around to them.
Note:
DerelictSDL must be loaded before using SDLgfx.
Might not work on Macs because I made a wild guess at the shared library names based on SDL_Image.
Only works with Derelict2. If someone requests a port for Derelict1, I'll make it happen.
Load with SDLGfx.load();
If there's anything wrong, tell me.
edit: Example program:
Code: | module gfx;
import derelict.sdl.sdl;
import sdlgfx;
import std.string;
const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;
const char[] WINDOW_TITLE = "SDL Start";
int main()
{
DerelictSDL.load();
SDLGfx.load();
SDL_Init( SDL_INIT_VIDEO );
SDL_Surface* screen = SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_HWSURFACE | SDL_DOUBLEBUF );
SDL_WM_SetCaption( toStringz( WINDOW_TITLE ), null );
SDL_Event event;
bool gameRunning = true;
while (gameRunning)
{
if (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
gameRunning = false;
}
}
SDL_FillRect(screen, null, SDL_MapRGB(screen.format, 0, 0, 0));
pixelRGBA(screen, 10, 15, 255, 255, 255, 255);
lineRGBA(screen, 20, 10,70, 90, 255, 0, 0, 255);
trigonRGBA(screen,500, 50, 550, 200, 600, 150, 0, 255, 255, 255);
filledTrigonRGBA(screen,200, 200,300, 50, 400, 200, 0, 0, 255, 255);
rectangleRGBA(screen, -10, 300, 100, 380,0, 255, 0, 255);
boxRGBA(screen, 210, 76, 325, 300,255, 0, 0, 150);
ellipseRGBA(screen,600, 400,50, 90, 255, 255, 0, 200);
filledEllipseRGBA(screen, 600, 400,25, 150,0, 255, 0, 255);
short x[6] = [ 350, 275, 300, 325, 350, 400 ];
short y[6] = [ 325, 325, 390, 390, 375, 300 ];
polygonRGBA(screen, cast(short*)x, cast(short*)y, 6, 255, 255, 255, 155);
short s[5] = [ 400, 450, 450, 425, 300 ];
short t[5] = [ 400, 410, 450, 425, 500];
filledPolygonRGBA(screen, cast(short*)s, cast(short*)t,5, 255, 0, 255, 155);
SDL_Flip(screen);
}
SDL_Quit();
return 0;
} |
Update:
New links, Derelict 2 only:
sdlgfx.d:
http://www.sendspace.com/file/5g7ne7
sdlgfxfont.d:
http://www.sendspace.com/file/5wq042
See this post for usage.
Last edited by michaelp on Fri Aug 13, 2010 1:13 pm; edited 2 times in total |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Fri Aug 21, 2009 8:43 pm Post subject: |
|
|
Derelict 2 isn't complete yet, so there won't be updated docs for it for some time. I'm on a hiatus from all programming projects right now. Eventually, I'll pick it up again and get Derelict 2 ready to roll. Until then, anyone making custom bindings for it is on their own
You might want to add a link to your binding on the Derelict project page. Just make sure you indicate that it's for Derelict 2. _________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
michaelp
Joined: 27 Jul 2008 Posts: 114
|
Posted: Sat Aug 22, 2009 4:11 pm Post subject: |
|
|
Okay, I added it to the page.
It wasn't too hard without the docs, it's pretty easy to make bindings with Derelict. Just needed to look at DerelictSDL. |
|
Back to top |
|
|
michaelp
Joined: 27 Jul 2008 Posts: 114
|
Posted: Sun Aug 30, 2009 8:47 am Post subject: |
|
|
Okay, I made the port for Derelict1.
Same things apply as the other version. Load with SDLGfx.load(); case sensitive. use 'import sdlgfx'.
Most macro functions in SDLgfxBlitFunc.h aren't implemented. GFX_RGBA_FROM_PIXEL, GFX_DISEMBLE_RGBA, and GFX_PIXEL_FROM_RGBA should be working, but aren't tested.
Again, has only been tested on Ubuntu linux. Should work on Windows, it's a toss up on a Mac, because I didn't figure out the names of the shared lib names.
The example program in the first post works without changes.
Anyways, here is the dl link:
http://www.sendspace.com/file/7e2nhb |
|
Back to top |
|
|
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Mon Aug 31, 2009 2:46 am Post subject: |
|
|
The name and paths of the shared libs on mac are probably: "../Frameworks/SDL_gfx.framework/SDL_gfx, /Library/Frameworks/SDL_gfx.framework/SDL_gfx, /System/Library/Frameworks/SDL_gfx.framework/SDL_gfx" |
|
Back to top |
|
|
michaelp
Joined: 27 Jul 2008 Posts: 114
|
Posted: Fri Aug 13, 2010 1:03 pm Post subject: |
|
|
Files:
sdlgfx.d:
http://www.sendspace.com/file/5g7ne7
sdlgfxfont.d:
http://www.sendspace.com/file/5wq042
Usage:
Copy sdlgfx.d and sdlgfxfont.d into derelict/sdl, so that you have the files derelict/sdl/sdlgfx.d and derelict/sdl/sdlgfxfont.d. Then import SDLgfx with:
Code: |
import derelict.sdl.sdl;
import derelict.sdl.sdlgfx; //publicly imports derelict.sdl.sdlgfxfont
void main()
{
DerelictSDL.load();
SDLgfx.load();
...
}
|
The program in the first post still works, expect that you need to change "SDLGfx.load()" to "SDLgfx.load()". (Lowercase 'g'), and the import name is "derelict.sdl.sdlgfx;"
If someone could upload the files to a more permanent location, that would be great. |
|
Back to top |
|
|
wicks
Joined: 03 Aug 2010 Posts: 5
|
Posted: Fri Dec 02, 2011 12:03 pm Post subject: |
|
|
The files have vanished. Are they available somewhere else or can they be re-uploaded, perhaps?
Thanks for your efforts btw! |
|
Back to top |
|
|
mutable
Joined: 22 Jun 2010 Posts: 87
|
Posted: Fri Dec 02, 2011 12:25 pm Post subject: |
|
|
wicks wrote: | The files have vanished. Are they available somewhere else or can they be re-uploaded, perhaps?
Thanks for your efforts btw! |
Download this http://dgame.rswhite.de/download_dgame and then look in config/derelict_sdl. Otherwise use OpenGL, as i do now. |
|
Back to top |
|
|
wicks
Joined: 03 Aug 2010 Posts: 5
|
Posted: Fri Dec 02, 2011 12:49 pm Post subject: |
|
|
mutable wrote: | wicks wrote: | The files have vanished. Are they available somewhere else or can they be re-uploaded, perhaps?
Thanks for your efforts btw! |
Download this http://dgame.rswhite.de/download_dgame and then look in config/derelict_sdl. Otherwise use OpenGL, as i do now. |
Ah ha, thanks! |
|
Back to top |
|
|
wicks
Joined: 03 Aug 2010 Posts: 5
|
Posted: Fri Dec 02, 2011 2:23 pm Post subject: |
|
|
Would anyone know what might have changed in dmd since this lib was last used, and how to go about fixing it? (sorry novice here...)
The example app seg faults. The only function not to crash it is pixelRGBA(), so I'm assuming it's a breaking change in dmd(?).
I'm on ubuntu 11.10 32bit using dmd 2.56
Thanks in advance. |
|
Back to top |
|
|
mutable
Joined: 22 Jun 2010 Posts: 87
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|