Chlac P
Chlac P

Reputation: 11

SDL2_gfx install and USE - Mac OS X

I've been trying for about 6 hours... to make use of the SDL2_gfx library in my project on Xcode 8.0.

I'll tell you right now, I'm a complete newbie to all of this, terminal commands, including libraries and stuff.

I've managed to use SDL2 fine, for there is a .framework, but the SDL2_gfx only comes as a folder with a .a, .dylib, .h and a mysterious .json.

I've installed it through homebrew whithout problems, but now, how do I make a project using it ??

In the Build Phases and Build Settings : I've tried linking .a and .dylib via "Link Binary With Libraries", I've added the headers paths in "Headers Search Paths" in "Search Paths", I've tried adding the .h to my project directly, and I have absolutely no idea of what to put in "Other Linker Flags" as it what suggested in many answers.

I keep getting the very simple error "no matching function for call ..." whenever I try using a function. But I'm doing it the same way as in some examples on the internet, and I checked in the .h, the functions do exist...

Please help T_T

EDIT : I've managed to find functions that are apparently recognized :

Sint16 circleR = 100;
Sint16 circleX = 300;
Sint16 circleY = 300;

int result = filledCircleColor(gRenderer, circleX, circleY, circleR, 0xFF0000FF);
        std::cout << "draw circle result " << result << std::endl;

int a = pixelRGBA(gRenderer, circleR, circleR, 0xFF, 0x00, 0x00, 0xFF);
        std::cout << "draw pixel result " << a << std::end;

But come out with result -1, which means it didn't work. Still can't figure it out... I suppose I'm not using them correctly, but I can't find any different example on the internet.

Upvotes: 0

Views: 1400

Answers (1)

cocoabeginner
cocoabeginner

Reputation: 11

i think i see your problem : you are calling with as 1st parameter a RENDERER. The function header expects a SURFACE :

http://www.ferzkopp.net/Software/SDL_gfx-2.0/Docs/html/_s_d_l__gfx_primitives_8h.html#a4f7b717b958ef39bfc8c958476dd0de1

clearly defines the function as :

SDL_GFXPRIMITIVES_SCOPE int filledCircleColor   (   SDL_Surface *   dst,
Sint16  x,
Sint16  y,
Sint16  rad,
Uint32  color 
)   

Upvotes: 0

Related Questions