FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

porting SDL_Gfx

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
michaelp



Joined: 27 Jul 2008
Posts: 114

PostPosted: Wed Aug 19, 2009 3:26 pm    Post subject: porting SDL_Gfx Reply with quote

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. Smile
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
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Fri Aug 21, 2009 8:43 pm    Post subject: Reply with quote

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 Smile

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
View user's profile Send private message Send e-mail
michaelp



Joined: 27 Jul 2008
Posts: 114

PostPosted: Sat Aug 22, 2009 4:11 pm    Post subject: Reply with quote

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. Smile
Back to top
View user's profile Send private message
michaelp



Joined: 27 Jul 2008
Posts: 114

PostPosted: Sun Aug 30, 2009 8:47 am    Post subject: Reply with quote

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
View user's profile Send private message
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Mon Aug 31, 2009 2:46 am    Post subject: Reply with quote

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
View user's profile Send private message
michaelp



Joined: 27 Jul 2008
Posts: 114

PostPosted: Fri Aug 13, 2010 1:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
wicks



Joined: 03 Aug 2010
Posts: 5

PostPosted: Fri Dec 02, 2011 12:03 pm    Post subject: Reply with quote

The files have vanished. Are they available somewhere else or can they be re-uploaded, perhaps?

Thanks for your efforts btw!
Back to top
View user's profile Send private message
mutable



Joined: 22 Jun 2010
Posts: 87

PostPosted: Fri Dec 02, 2011 12:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
wicks



Joined: 03 Aug 2010
Posts: 5

PostPosted: Fri Dec 02, 2011 12:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
wicks



Joined: 03 Aug 2010
Posts: 5

PostPosted: Fri Dec 02, 2011 2:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
mutable



Joined: 22 Jun 2010
Posts: 87

PostPosted: Fri Dec 02, 2011 3:51 pm    Post subject: Reply with quote

I created the lib with dmd 2.054. Here i ask several months ago the same as you and michaelp helped me to figure out how i can use it: http://www.dsource.org/forums/viewtopic.php?t=5547
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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