Tangent128 / luasdl2

A pure C binding of SDL 2.0 for Lua 5.1, Lua 5.2, and LuaJIT.
ISC License
385 stars 73 forks source link

[REQUEST] more examples #25

Open lewislepton opened 9 years ago

lewislepton commented 9 years ago

the examples given are great, but only really go to a certain point.

SDL in itself is pretty big, and think that addressing things like, drawing shapes, working with and importing other lua files, and interaction are a good thing to have. really it could go on, but i think the main crux would be the have a few more examples for people to dive into further and to keep interested. if you get me?

plus since there is not really any other info online for this, then would be more useful to others who are using this repo

cheers

ghost commented 9 years ago

A simple benchmark would be welcomed!

lewislepton commented 9 years ago

ive started to make some now. just tearing apart the ones given plus looking at other places. have done a pull request for using keyboard to move something round on screen. just some small things, but hopefully useful as well

ghost commented 9 years ago

I'd like to be able to get the fps and based on that make some simple benchmarks like displaying 5000 images and see how's the fps.

lewislepton commented 9 years ago

what i would suggest just now until more come - is to go through some SDL2 stuff. some things are the same in context. it is just the change to lua thats one of the bigger things

lewislepton commented 9 years ago

here is a link to a SDL2 tutorial series i came across. has helped as well. im dyslexic so reading can be just hard to do and understand, but videos are cool because you get to see what happening also another im adding since its a deeper SDL2 tutorial

coding made easy https://www.youtube.com/playlist?list=PLHJE4y54mpC5_eEz9gCqIkNpU-n_2eyNt

making games with ben. personal favourite since it build on making SDL engine. but good learning ;) https://www.youtube.com/channel/UCL5m1_llmeiAdZMo_ZanIvg

lewislepton commented 9 years ago

another to add to this list of possible looks at. whilst love2d and lua-SDL2 are apart, its more thu lua side you need to look at. but good to know also ;) though, i cant stand the guy talking, just waffles on about things which are not pretinent to the tutorial at hand. plus shouts. odd.

https://www.youtube.com/user/sockmunkeedevelopmen

ghost commented 9 years ago

@lewislepton You have a long path till you can get to actually make games with lua-sdl.First of all you wont be able to make something bigger than a space invaders clone because of the performance.You need to make a simple sprite class or smt like this in C++ and from there render all your objects and use lua just for logic.I'll probably start doing this in the next days.

ghost commented 9 years ago

But since I dislike C++ this will probably take a while ...

lewislepton commented 9 years ago

i do some openframeworks/c++ tutorials, which i dont mind. though dont like c++ myself. have linked a lua addon with it, but its limited.

in my own game making wihh lua-sdl2 i dont want to do really big projects. really minimal 2d based just now. hopefully if more examples and also more info on lua-sdl2 come to light to help with more on it and for more bigger game things. then by time projects could become bigger. but again, its all time really. its just unlearning things i know now to make way for these things.

but really if we wele to use c++ with sdl2 we would be in the same position

Tangent128 commented 9 years ago

@Murii: by all means profile, but if you need sprite performance, keep in mind that you would probably want to let SDL manage the window but do the actual rendering with OpenGL.

As I understand it, SDL's built-in renderer is not strongly optimized and lacks batching support, since they assume people with performance needs will use OpenGL anyways.

lewislepton commented 9 years ago

@Tangent128 a mix with openGL is most welcomed in my camp ;) plus in any of the tutorials or anything like that ive come across, openGl is quickly introduced how would we get this with working with lua-SDL2? more a future thing i guess. but if we would be able mix it up with openGL and lua-SDL2, then id love to know more ;)

lewislepton commented 9 years ago

@Tangent128 but as you said, openGL would manage the graphical side, rendering etc. SDL is really is for the other stuff, like window mangament, joysticks, input etc

lewislepton commented 9 years ago

actually did just come across this. which has recently been updated http://luagl.sourceforge.net/

though again, mac users seem to be left in the dark. but would think this would work since it can build on linux. mac and linux do have some, some build similarites

lewislepton commented 9 years ago

did just contact one of the guys who puts the downloads up and takes care of it. just to ask in how to build on mac. since it seems active just for windows/linux users.

but if this works. then i wouldnt see how having these 2 would be a problem. wait and see

lewislepton commented 9 years ago

actually just working with the guy who built luaGL to do a mac build. since it has the same thing of not locating lua off the bat from the usr/local/etcetcetc

so hopefully have that up and running soon. which should in turn be good with working in lua-SDL2 for handling

there is however a LuaRock, but it is different - in that it has not been updated in about a year. and LuaGL had just been updated about 5 or 6 days ago

here is the original luaGL location http://luagl.sourceforge.net/

here is the LuaRock location, which does link the above link. i have contacted the luaRock guy to ask if it will be updated to the newer build. have not heard anything back yet https://luarocks.org/modules/luarocks/luagl

never worked with LuaRocks before, but really tempted now, but dont want to use something which is older than the source, even if it is easier to install

lewislepton commented 9 years ago

got luaGL to build, but getting it into to work is more than just dropping it in the folder with /usr/local/lua/etcetc

but its getting near, will keep posted. but if this works with SDL, which it should. then this will answer that performance question. leave SDL for the file managment, inputs etc and use OpenGL for the graphics and other heavy stuff

ghost commented 9 years ago

There must be a better solution! try using glew or smt?

lewislepton commented 9 years ago

what way though. because everything that i have seen that uses SDL also uses opnGL

when i get luaGL working that will answer a lot for me. plus can just get on with maing things. true ill more than likely have to do some other coding to get things working properly, but thats what you get if youre using something like sdl and opengl

if its quick coding and getting stuff done in lua, why notook into love2d or even moonscript?

ghost commented 9 years ago

Let us know if you manage to make luaGL to work!

lewislepton commented 9 years ago

@Murii will do. but as the guy has said to me, it should build fine in linux and also windows. just mac seems to be the problem for some reason. but think its the same as to what it was when building Lua-SDL2

but its getting close. just needs to find the .dylib to start running, but thats the only trouble

lewislepton commented 9 years ago

but once we get these solved a new update will go up that should fix everything for all platforms

lewislepton commented 9 years ago

BOOM. working now. have not gone into the nitty gritty and made something. BUT, it works through using sublime to build. the guy will more than likely be doing a new download and build soon. but this problem was with mac, so think linux users and windows are fine from what i know

here is a screenshot just to show it building. will do a simple thing to show it working soon screen shot 2015-05-01 at 19 11 21

lewislepton commented 9 years ago

forgot to metion, it also uses luaglu as well as luagl

ghost commented 9 years ago

nice,nice! I'm looking forward to see a simple example!

lewislepton commented 9 years ago

just now finished making a dirty auto complete for it, just to help. so will now try making something

ghost commented 9 years ago

OK

lewislepton commented 9 years ago

ill have something soon. i really have just started with luaGL, but it so different, since it does not deal with some things. so really am getting it to talk to SDL nicely.

will have something just not quickly ;)

lewislepton commented 9 years ago

just having a little trouble due to the examples are using different video out, not SDL. so just figuring that out now. but will continue in the morning since its late http://luagl.sourceforge.net/examples/

lewislepton commented 9 years ago

have not been able to get something running with luaGL, just so different really. it has not ran into any problems with errors. just getting something off the groud is more hard. the examples for luaGl are using something else for window management, but even changing things to lua-SDL2 have been some what crap and do error.

i need to really stick with lua-SDL2 more right now. but really i feel that luaGL is working, though i cant get something right now. ill keep pressing on and trying when i feel up to it. but for now, just want to try and learn SDL more because that initially what i was after.

sitll having some trouble in getting some of that to run, even if i am changing the syntax to what it should be, still trouble. but have to press on. ive even gone to using love2d a little bit because i love the layout and coding style. sadly lua-SDL2 is not that straight forward but hey. would be best to actually make functions to call up with lua-SDL2 and make your own kind of language to suit needs i think

ghost commented 9 years ago

Yeah...lua and sdl is not enought.You still need to put lots of time and effort to start actually make something.

On Du, mai 3, 2015 at 2:27 , leòdhas lepton notifications@github.com wrote:

have not been able to get something running with luaGL, just so different really. it has not ran into any problems with errors. just getting something off the groud is more hard. the examples for luaGl are using something else for window management, but even changing things to lua-SDL2 have been some what crap and do error.

i need to really stick with lua-SDL2 more right now. but really i feel that luaGL is working, though i cant get something right now. ill keep pressing on and trying when i feel up to it. but for now, just want to try and learn SDL more because that initially what i was after.

sitll having some trouble in getting some of that to run, even if i am changing the syntax to what it should be, still trouble. but have to press on. ive even gone to using love2d a little bit because i love the layout and coding style. sadly lua-SDL2 is not that straight forward but hey. would be best to actually make functions to call up with lua-SDL2 and make your own kind of language to suit needs i think

— Reply to this email directly or view it on GitHub.

lewislepton commented 9 years ago

true. but also time and effort for anything. but for my current needs right now, i dont need anything really hardcore or super fast. i dont need to create hundreds of objects myself right now, or even really lush graphics. maybe soon, but not now. and really, lua-SDL2 is already confusing to me with just loading images from different classes, so then having opengl on top is too much for me at this moment. have to take it all one at a time, or when i need to really know about it

love2d has been fun because i just get to make something. sadly its doesnt yet export to touch devices. that will come though. plus pity the syntax in sDL is not the same nicety of love2d, but the pay off is something pretty hardcore itself

anyhow...

ghost commented 9 years ago

Love runs on android and ios :)

On Du, mai 3, 2015 at 2:36 , leòdhas lepton notifications@github.com wrote:

true. but also time and effort for anything. but for my current needs right now, i dont need anything really hardcore or super fast. i dont need to create hundreds of objects myself right now, or even really lush graphics. maybe soon, but not now. and really, lua-SDL2 is already confusing to me with just loading images from different classes, so then having opengl on top is too much for me at this moment. have to take it all one at a time, or when i need to really know about it

love2d has been fun because i just get to make something. sadly its doesnt yet export to touch devices. that will come though. plus pity the syntax in sDL is not the same nicety of love2d, but the pay off is something pretty hardcore itself

anyhow...

— Reply to this email directly or view it on GitHub.

ghost commented 9 years ago

Have a look at Libgdx.Even tho is not in Lua it's wroth looking into.Also take a look at NON.It's based on Libgdx but it has Lua and the API looks very very much like Love's !

On Du, mai 3, 2015 at 2:36 , leòdhas lepton notifications@github.com wrote:

true. but also time and effort for anything. but for my current needs right now, i dont need anything really hardcore or super fast. i dont need to create hundreds of objects myself right now, or even really lush graphics. maybe soon, but not now. and really, lua-SDL2 is already confusing to me with just loading images from different classes, so then having opengl on top is too much for me at this moment. have to take it all one at a time, or when i need to really know about it

love2d has been fun because i just get to make something. sadly its doesnt yet export to touch devices. that will come though. plus pity the syntax in sDL is not the same nicety of love2d, but the pay off is something pretty hardcore itself

anyhow...

— Reply to this email directly or view it on GitHub.

lewislepton commented 9 years ago

ive tried the state it was in a while back on my ipad, which is still 0.9.2, but that was a major hack and not something that is currently built in. its not a deal breaker for me. what breaks it for me is that code is not safe within your application if you want it to be right away. anybody can easily grab it. not to say my code is worth hiding, but i like it if things arent out in the open as much as what love currently has

actually just caught wind of NON yesterday. looks nice. its pretty much just like love, even the guy has said its just like it. few differences

known about libgdx for a while, but would prefer to stick to lua. but ill look at it. but really would like to stick to lua-SDL.

ghost commented 9 years ago

The hiding aspect of the whole src,assets it's something in Love but not many people will actually understand what you have done there. I mean not everyone is a programmer.

On Du, mai 3, 2015 at 2:44 , leòdhas lepton notifications@github.com wrote:

ive tried the state it was in a while back on my ipad, which is still 0.9.2, but that was a major hack and not something that is currently built in. its not a deal breaker for me. what breaks it for me is that code is not safe within your application if you want it to be right away. anybody can easily grab it. not to say my code is worth hiding, but i like it if things arent out in the open as much as what love currently has

actually just caught wind of NON yesterday. looks nice. its pretty much just like love, even the guy has said its just like it. few differences

known about libgdx for a while, but would prefer to stick to lua. but ill look at it. but really would like to stick to lua-SDL.

— Reply to this email directly or view it on GitHub.

lewislepton commented 9 years ago

true. but personally i just dont like seeing code out in the open. its one pet peeve i have about love. i would actually use it all the time if i knew how to build aplications properly that hid code. but have never found info on the subject

lewislepton commented 9 years ago

but in all honesty i have been tempted by NON though. because you can work with love files you have made, you can kind of protect things also by locking them. plus you can export to iOS/android

im going to give it a deeper look. annoying i have to install JDK, dont like having java stuff nor flash on my computer ;)

ghost commented 9 years ago

:O Java ftw

On Du, mai 3, 2015 at 2:55 , leòdhas lepton notifications@github.com wrote:

but in all honesty i have been tempted by NON though. because you can work with love files you have made, you can kind of protect things also by locking them. plus you can export to iOS/android

im going to give it a deeper look. annoying i have to install JDK, dont like having java stuff nor flash on my computer ;)

— Reply to this email directly or view it on GitHub.

lewislepton commented 9 years ago

to lastly say on a lua based platform of game making. there is MOAI as well.

though my experience is slightly tattered. not much documentation or really any, no commented examples and kind of poorly shown what it can do, apart from people who have used it well. though it is is fast, plus it does export to desktops and touch devices

www.getmoai.com

ghost commented 9 years ago

It works on Web,phones,desktop and it's faster than Libgdx which is quite a big wow.You can go to their irc on freenode - /join #moai

On Du, mai 3, 2015 at 12:09 , leòdhas lepton notifications@github.com wrote:

to lastly say on a lua based platform of game making. there is MOAI as well.

though my experience is slightly tattered. not much documentation, no commented examples. though it is is fast, plus it does export to desktops and touch devices

getmoai.com

— Reply to this email directly or view it on GitHub.

ghost commented 9 years ago

I've worked with it for 2-3 weeks but I don't like all the MoaiClass.function stuff.

On Du, mai 3, 2015 at 12:09 , leòdhas lepton notifications@github.com wrote:

to lastly say on a lua based platform of game making. there is MOAI as well.

though my experience is slightly tattered. not much documentation, no commented examples. though it is is fast, plus it does export to desktops and touch devices

getmoai.com

— Reply to this email directly or view it on GitHub.

lewislepton commented 9 years ago

it was ok for myself, but really getting any kind of thing made was an annoyance for myself. also the same as yourself, the functions stuff was annoying. biggest probably for me was the documentation

i guess in some small stretch love2d would be good, then use NON to convert to touch platforms. but that in one way is the easiest of the bunch. the coding style is lovely i think. but as said before, the security of files is pretty crap. but then again, lua code is not secure in its own right

i may give love2d another big bash. i did enjoy coding on it. sitll want to do lua-SDL2 as well, but it really needs more examples and ways of explaining things in a game making type of way

lewislepton commented 9 years ago

also as well there is openframeworks. whilst it is a c++ framework, you can use add-on to extend it. its actually better than c++ since its a bunch of frameworks, libraries etc to make coding easier. its not really meant for games off the bat, but is possible.

an add-on i use frequently is ofxLua, and the syntax is just openframeworks one, but put in a love2d type of way. so to draw a circle it would be of.circle(stuff), where as in openframeworks it is ofCircle(stuff)

lewislepton commented 9 years ago

bt things like controllers are not supported, plus if you use other add-ons with ofxLua, you have to use SWIG to bind them. though have not done that yet

ghost commented 9 years ago

hm

On Du, mai 3, 2015 at 2:21 , leòdhas lepton notifications@github.com wrote:

bt things like controllers are not supported, plus if you use other add-ons with ofxLua, you have to use SWIG to bind them. though have not done that yet

— Reply to this email directly or view it on GitHub.

ghost commented 9 years ago

I've been using Libgdx for 2.4years and I like it.Try libgdx or monogame or just stick with love and bother about how to hide the code later.I remember josenpfhat(one of love's memebers) saying something about a program which can obfuscate lua code.

On Du, mai 3, 2015 at 2:21 , leòdhas lepton notifications@github.com wrote:

bt things like controllers are not supported, plus if you use other add-ons with ofxLua, you have to use SWIG to bind them. though have not done that yet

— Reply to this email directly or view it on GitHub.

lewislepton commented 9 years ago

but i do think that if you want te get down and make something, probably love2d is best, then use NON to make it into touch device output, even desktop, since it uses java to secure it a little better. i asked and they said it makes it readable but not editable, which is good in my book. better than just open in the open to be edited

lewislepton commented 9 years ago

it is tempting. libgdx i mean. i just dont want to use another language right now. though did see LuaJ, but dont know about that, have not tried. if you know if just using lua with libgdx is good, then i might give it a go.

but true. stick to something then try later on. its the fact of making that should matter and other stuff comes later but with this new NON, that looks like it will address some things for me, such a multiplatform output with both iOS and android would be good if there was a proper built LOVE2D version, but hey

lewislepton commented 9 years ago

monogame is also a good choice, but again, thats C#, not lua. id rather stick to a language i like. c# is alright but would prefer lua in all honesty

lewislepton commented 9 years ago

also the cost of xamarin is ridiculous for mono. borderline retarded expensive. id just want to use xcode really, or at the least sublime