Skip to content
← Back to Community
SDL for repl?
Profile icon
CullenDAvello

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!

Voters
Profile icon
Awaards
Profile icon
ryanpcmcquen
Profile icon
OathOfCode
Profile icon
abc3354
Profile icon
CullenDAvello
Comments
hotnewtop
Profile icon
theangryepicbanana

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

Profile icon
CullenDAvello

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

Profile icon
CrazyVideoGamer

@CullenDAvello I have this make file, which should install everything. Though the SDL_image doesn't work.

.PHONY: all install compile run all: compile TARGET = main.cpp TARGET_NAME = $(TARGET:%.cpp=%) IMAGE = libjpeg-dev libwebp-dev libtiff5-dev libsdl2-image-dev libsdl2-image-2.0-0 libsdl-image1.2-dev MIXER = libmikmod-dev libfishsound1-dev libsmpeg-dev liboggz2-dev libflac-dev libfluidsynth-dev libsdl2-mixer-dev libsdl2-mixer-2.0-0 TRUE_TYPE_FONTS = libfreetype6-dev libsdl2-ttf-dev libsdl2-ttf-2.0-0 FLAGS = `sdl2-config --cflags --libs` -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf compile: g++ $(TARGET) -o $(TARGET_NAME) $(FLAGS) install: #install sdl2 install-pkg libsdl2-dev libsdl2-2.0-0 #install sdl image - if you want to display images install-pkg $(IMAGE) #install sdl mixer - if you want sound install-pkg $(MIXER) #install sdl true type fonts - if you want to use text install-pkg $(TRUE_TYPE_FONTS) run: ./$(TARGET_NAME)

You should create a reply with bash

Profile icon
SPQR

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.

Profile icon
CullenDAvello

@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

Profile icon
SPQR

@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.

Profile icon
CullenDAvello

@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?

Profile icon
SPQR

@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.

Profile icon
CullenDAvello

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

Profile icon
SPQR

@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

Profile icon
CullenDAvello

@SPQR ok thanks

Profile icon
CullenDAvello

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

Profile icon
CullenDAvello

@SPQR oh i lied sorry im using SDL2

Profile icon
SPQR

@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

Profile icon
CullenDAvello

@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?

Profile icon
CullenDAvello

@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)

Profile icon
SPQR

@CullenDAvello sure just hmu and i'll be here

Profile icon
SPQR

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

Profile icon
SPQR

@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.

Profile icon
CullenDAvello

@SPQR ight thanks a lot

Profile icon
CullenDAvello

@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

Profile icon
SPQR

@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

Profile icon
CullenDAvello

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

Profile icon
SPQR

@CullenDAvello Yes, but repl.it runs on linux

Profile icon
CullenDAvello

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

Profile icon
SPQR

@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

Profile icon
CullenDAvello

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

Profile icon
SPQR

@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.

Profile icon
CullenDAvello

@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