Author Topic: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library  (Read 140433 times)

0 Members and 3 Guests are viewing this topic.

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: nSDL 1.0.1—A very fast & robust graphics library
« Reply #270 on: September 17, 2012, 02:24:10 pm »
By the way, is the mouse supported or nope?

I want to port some demos! :p

EDIT: aw right, removed because stability issues...
« Last Edit: September 17, 2012, 02:25:32 pm by Eiyeron »

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Re: nSDL 1.0.1—A very fast & robust graphics library
« Reply #271 on: September 17, 2012, 03:05:51 pm »
Is there any way SDL_GetTicks() can get implemented? It currently aborts due to SDL Threads not being implemented.
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: nSDL 1.0.1—A very fast & robust graphics library
« Reply #272 on: September 17, 2012, 03:54:15 pm »
SDL_GetTicks()? It should be working according to my knowledge. It doesn't even require any threads or anything. Are you sure you don't mean timers? What version of nSDL are you using? Could you post the code that doesn't work?

@Eiyeron: yeah, too unstable/buggy for my taste. Got it to work smoothly when SDL_WaitEvent() was used; it was a staggering mess with SDL_PollEvent(), never really figured out what the issue was because of a lack of time (got my ass conscripted, as the profile picture suggests). I wanted my last real release to be as clean and stable as possible, see. You can still grab an older version of nSDL though if you want (here), but check the changelog for the latest version that had experimental mouse support.
« Last Edit: September 17, 2012, 04:04:23 pm by hoffa »

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #273 on: November 29, 2012, 11:50:56 am »
Tiny update that handles arrow keys better (diagonal arrow keys supported) and maps the Nspire's touchpad click button to SDLK_KB_ENTER. Those were supposed to be included in an update with functional mouse support, but as it's been taking so long and can't test my code on an actual TI-Nspire (and probably won't for long), I decided to push those changes to master so they're outta the way.

(Download's on the website, as usual)

Offline SpiroH

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +153/-23
    • View Profile
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #274 on: November 29, 2012, 12:14:49 pm »
Thank you soldier. Have a nice pleasant fight. ;)

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #275 on: November 29, 2012, 12:31:51 pm »
(offtopic, is it normal to have post ratings disabled on this topic ?)

Anyway, this is great to see an update on this project, even a "tiny" one. It shows that even if you don't have a lot of time, you did not discontinue it completely :)
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #276 on: December 07, 2012, 05:25:18 pm »
Yeah, they created a sub-forum for the project but forgot to enable post ratings in it (it's disabled by default). You could PM an admin about it.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #277 on: January 03, 2013, 04:24:14 am »
Bump,

I've several questions :

  • In my program, I'm loading a bitmap with SDL_LoadBMP(path), but it seems that relative path doesn't work. If I have image.bmp.tns in the same directory as my program, just typing SDL_LoadBMP("image.bmp.tns"); doesn't work. Is there a way to fix that ?

  • Second question, I have sprites that have transparent parts, but it seems that transparency isn't supported due to the NTI format and get replaced by white 0xffff. Is there a way to use transparent sprites or are they forbidden ?

    EDIT : in fact it's ok, I wrote several functions to resolve my problems :) including a masked form of SDL_BlitSurface, which I think I can post here :

    Code: [Select]
    void setPixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
    {
        int bpp = surface->format->BytesPerPixel;

        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;

        switch(bpp) {
        case 1:
            *p = pixel;
            break;

        case 2:
            *(Uint16 *)p = pixel;
            break;

        case 3:
            if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
                p[0] = (pixel >> 16) & 0xff;
                p[1] = (pixel >> 8) & 0xff;
                p[2] = pixel & 0xff;
            } else {
                p[0] = pixel & 0xff;
                p[1] = (pixel >> 8) & 0xff;
                p[2] = (pixel >> 16) & 0xff;
            }
            break;

        case 4:
            *(Uint32 *)p = pixel;
            break;
        }
    }

    Uint32 getPixel(SDL_Surface *surface, int x, int y)
    {
        int bpp = surface->format->BytesPerPixel;
    Uint32 value;
        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;

        switch(bpp) {
        case 1:
            value = *p;
            break;

        case 2:
            value = *(Uint16 *)p;
            break;

        case 3:
            if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
                value = (p[0] & 0xff) | (p[1] << 8) | (p[2] << 16);
            } else {
                value = (p[2] & 0xff) | (p[1] << 8) | (p[0] << 16);
            }
            break;

        case 4:
            value = *(Uint32 *)p;
            break;
        }
    return value;
    }

    void nSDL_BlitSurfaceAlpha(SDL_Surface *src, SDL_Rect *srcRect, SDL_Surface *dst, SDL_Rect *dstRect, Uint16 alpha)
    {
    int x,y;
    Uint32 color;

    SDL_LockSurface(src);
    SDL_LockSurface(dst);

    for(y = 0 ; y < srcRect->h ; y++)
    {
    for(x = 0 ; x < srcRect->w ; x++)
    {
    if((Uint16)(color = getPixel(src, x + srcRect->x, y + srcRect->y)) != alpha)
    {
    setPixel(dst, x + dstRect->x, y + dstRect->y, color);
    }
    }
    }
    SDL_UnlockSurface(src);
    SDL_UnlockSurface(dst);
    }

    Also, to resolve my first problem I set the directory of the program as the current folder :
    Code: [Select]
    char curDir[256];

    strncpy(curDir, argv[0], strflc(argv[0], '/'));
    chdir(curDir);

    ...

    size_t strflc(const char *src, char character)
    {
    size_t offset = strlen(src) - 1;

    while(offset > 0)
    {
    if(src[offset] == character) break;
    offset--;
    }
    return offset;
    }
« Last Edit: January 03, 2013, 05:33:44 am by Matrefeytontias »

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #278 on: January 03, 2013, 07:26:17 am »
Isn't your strflc() similar to strrchr(...) - argv[0]?
Ndless.me with the finest TI-Nspire programs

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #279 on: January 03, 2013, 08:26:13 am »
Oh yeah, I didn't think of it that way ...

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #280 on: January 03, 2013, 03:09:28 pm »
  • In my program, I'm loading a bitmap with SDL_LoadBMP(path), but it seems that relative path doesn't work. If I have image.bmp.tns in the same directory as my program, just typing SDL_LoadBMP("image.bmp.tns"); doesn't work. Is there a way to fix that ?
Yeah that must be because of the way ndless (or syscalls, whatever) handle opening files (at some point in the code it's just calling fopen). Rather than implementing the relative path thing in nSDL, I think it would be better to do it in the fopen code itself for consistency across all programs. Despite that, I've never had to use "/documents/Examples/derp.bmp.tns" as the path, "Examples/derp.bmp.tns" has always worked IIRC.

  • Second question, I have sprites that have transparent parts, but it seems that transparency isn't supported due to the NTI format and get replaced by white 0xffff. Is there a way to use transparent sprites or are they forbidden ?
The format itself doesn't support transparency (neither does BMP), but SDL does support color keys for surfaces, and that's what you should be using. In the image, draw (in Paint or whatever) the parts that you want transparent with a certain color (#ff00ff is quite common) and after you've loaded it and have its SDL_Surface, do SDL_SetColorKey(surface, SDL_SRCCOLORKEY, SDL_MapRGB(screen->format, 0xff, 0x00, 0xff)). More info here.
« Last Edit: January 03, 2013, 03:42:18 pm by hoffa »

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #281 on: January 04, 2013, 04:24:57 pm »
Thanks for that :)

Do you think you'll port SDL_Image to Nspire someday ? It would be really, really useful to load various image formats :)

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #282 on: January 06, 2013, 04:24:48 pm »
Fuck me. For last few hours I've been trying to port SDL_image, and it has been one of the most frustrating experiences ever. I fucking hate debugging, someone please shoot me in the head, blow my brains out and burn my body with fire. ExtendeD I really would like you to fix the relocation issues, it's unbelievably horrible (but I suppose you know more than well enough the feeling I'm feeling right now, so no hurry). I even managed to film the whole process (actually now, the video begins after about 2 hours of debugging). Watch it. Feel my pain. We need to raise awareness!



I will never ever work as a code monkey in some gigantic corporation, I'd kill myself  before that. Debugging some mysterious black magic is not my thing. I don't mind coding but FUCK this is crazy my brain is completely fucked and I need to hit some boxing bag to release the tension inside me. My brain has been literally violated with the force of a thousand supermassive black holes. Goddamn global static arrays of structures with constant fucking strings and pointers to functions. The issues I'm having go against all the laws of physics and the behavior fluctuates faster than a Thai whore's mouth in Pattaya. It doesn't even have anything to do with the would-be complexity of the code. Even porting SDL and fixing its own flock of relocation issues wasn't this annoying. It should be a war crime to make me go through this kind of shit. If C was a person it would have been considered rape. Please ban me from the Internet for such vulgar terminology, tell me I'm a bad boy for saying no-no words and traumatizing the 7-year-old boys here. Give me a ticket, tell me I need to watch my language. Hack my IP, call the cyber cops, neg me to oblivion, tell your mom, I don't give a fuck. I feel like punching kittens right now.

Alright, calm down hoffa, everything's alright.

ALSO, I HATE THIS SHITTY LOW RESOLUTION ON MY LAPTOP.
« Last Edit: January 06, 2013, 05:34:03 pm by hoffa »

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #283 on: January 06, 2013, 04:40:49 pm »
Oh waw O.O

Too bad I can't watch the video : "This video isn't watchable in your country" D:

I haven't done many programs, but I think I can understand what you're feeling :P Debugging is also the thing I hate the most in coding. It's so annoying and so frustrating when it doesn't work :banghead:

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: nSDL 1.0.2—A very fast & robust graphics library
« Reply #284 on: January 06, 2013, 04:47:53 pm »
Yeah, worst thing there's no logic at all behind the issues I'm having. And I've done some serious debugging before, but this just takes it all to a whole new level.