Ask coding questions

← Back to all posts
SDL for repl?
CullenDAvello (18)

i have been made aware that using the SDL api is a lot easier than normal c code and i was wondering if there is a way to use it on repl. i have all of the files to what i believe to be in-compiler installation , but i don't know if they work in repl does anyone know if this is possible and if not, advice on what i could do instead would be much appreciated. thanks!

Commentshotnewtop
theangryepicbanana (1629)

you can use SDL/SDL2 fine, but it doesn't have SDL_image yet

CullenDAvello (18)

@theangryepicbanana thanks a lot, um...how do i get SDL to work for repl though?

SPQR (533)

https://repl.it/@SPQR/SDLtest made this a while back as a proof of concept. Like @theangryepicbanana said, though, SDL_image doesn't work yet, so I'd recommend using SFML instead, which I have working at https://repl.it/@SPQR/SFML. SFML is (in my humble opinion) easier to learn and use anyways and for a beginner (which I assume you are) is the more viable choice imo.

CullenDAvello (18)

@SPQR yes i've heard but since i have already started SDL and know most of the basics i prefer to use it over SFML anyway now that i know that it does work how do i get it to work

SPQR (533)

@CullenDAvello basically, you have to use http://repl.it/languages/polygott, at least if you want to be able to use textures. You're probably gonna have to fiddle around with makefiles or bash a bit to get it working, though.

CullenDAvello (18)

@SPQR OK awesome, fyi i'm completely new to APIs, someone did it for me the last time and it got undone... any way i could get a step to step or maybe you can set it up and i can open it?

SPQR (533)

@CullenDAvello I've tried setting up SDL_image here to no avail, but I can try again when I get the chance. That might not be until tomorrow, though.

CullenDAvello (18)

@SPQR thanks i dont need SDL_image or SDL2 though, only SDL, also i would like it to work with C if possible

SPQR (533)

@CullenDAvello Just write a quick program that you need SDL for and link it for me and i'll get it to work with SDL and you can fork that

CullenDAvello (18)

@SPQR hey got the program thanks a lot for doing this for me here's the link
PDL code

CullenDAvello (18)

@SPQR oh i lied sorry im using SDL2

SPQR (533)

@CullenDAvello Well, you've got a bunch of errors, but the SDL bit works. I tried fixing a thing or two but I never got super into SDL so you're probably better off than me. Good luck with this though, let me know if you ever need anything else :)
https://repl.it/@SPQR/SDL-C-program

CullenDAvello (18)

@SPQR thanks, yeah i realized that i had bugs i went back and fixed them later, thanks for all the help, hey when i'm done with this (which should only take a week or so i can get a untextured beta going pretty fast) do you want to multiplayer it and test it out?

CullenDAvello (18)

@SPQR found the problem that was practice code on SDL_Image really sorry about that. hey does the file work with SDL as well as SDL2? and if not can you do that? i'm so sorry i didn't clarify more really sorry! P.S. <---- that's the repl link (i'm sure you knew that but i didn't want to be unclear again, so sorry about that)

SPQR (533)

@CullenDAvello sure just hmu and i'll be here

SPQR (533)

@CullenDAvello Yeah, I'll reconfigure it for SDL for you

SPQR (533)

@CullenDAvello https://repl.it/@SPQR/SDL-C-program-1 This should work with SDL, but you might have to do some syntax tweaks. Let me know if it doesn't work properly.

CullenDAvello (18)

@SPQR hey its working but i'm getting a lot of "unknown type name" can you check it out? https://repl.it/@CullenDAvello/SDL-C-program-1

SPQR (533)

@CullenDAvello Try looking into the documentation for setting up a SDL project on Linux and making sure all the libraries are linked in main.bash

CullenDAvello (18)

@SPQR ? i don't know what you mean, are you talking about the linux computer? i use windows

SPQR (533)

@CullenDAvello Yes, but repl.it runs on linux

CullenDAvello (18)

@SPQR oh ok....what do i do?

SPQR (533)

@CullenDAvello edit the line in main.bash where libraries are linked (foer example, -lSDLmain to include any other libraries that may be needed. Also, you may need to add some #includes as well

CullenDAvello (18)

@SPQR ok cool, is there a link or something to what the libraries are called?

SPQR (533)

@CullenDAvello I don't know, honestly. However, after looking back at what you said you were experiencing, I think you should just ignore the cquery things unless it gives you an actual error when you run it. The code intelligence on here for c++ isn't the best at the moment.

CullenDAvello (18)

@SPQR oh yeah the cpp thing was something completely different but i assume it's the same for c, so have you ever been able to open a window using repl? because that's what that is supposed to do and it isn't its just telling me cquery's