Hello,
I feel like it's time for me to start learning how to use the SDL graphics functions for stuff like drawing sprites (or bitmaps) to the screen, scaling & rotating them, and so on.
I'm going to examine the source code of the example Snake game to see if I can learn from that, but at the same time I would appreciate if anyone would give me some clear examples in this thread. e.g. How would you load a picture from a .bmp (or perhaps .png) and then use SDL functions to draw it on the screen, or scale it and rotate it?
Anyway, I'll examine the snake game as I said, and I'll post in this thread later on if I work out how to do it.
PM
I'd like to start using SDL graphics functions
-
- Posts: 177
- Joined: Mon 02 Apr 2018, 21:51
Re: I'd like to start using SDL graphics functions
Hi Patrick,
Snakes looks like a decent starting point. I seem to recall Richard did a port of David Williams' Forces of Darkness, which I know uses lots of bitmaps etc, but may be a bit overwhelming!
I assume you know about the SDL wiki:
https://wiki.libsdl.org/FrontPage
and on Richard's BBC-SDL differences page:
http://www.bbcbasic.co.uk/bbcsdl/differences.html
there are some links to useful resources, including the main wiki listed above, and one to the graphics subsystem:
http://www.ferzkopp.net/Software/SDL2_g ... index.html
I look forward to seeing some nice examples - and perhaps a tutorial for beginners (like me!)?
Best wishes,
D
Snakes looks like a decent starting point. I seem to recall Richard did a port of David Williams' Forces of Darkness, which I know uses lots of bitmaps etc, but may be a bit overwhelming!
I assume you know about the SDL wiki:
https://wiki.libsdl.org/FrontPage
and on Richard's BBC-SDL differences page:
http://www.bbcbasic.co.uk/bbcsdl/differences.html
there are some links to useful resources, including the main wiki listed above, and one to the graphics subsystem:
http://www.ferzkopp.net/Software/SDL2_g ... index.html
I look forward to seeing some nice examples - and perhaps a tutorial for beginners (like me!)?

Best wishes,
D
Re: I'd like to start using SDL graphics functions
There's also Richard's BBCSDL ports of my Torus demo (a small-ish program) and Xmas Demo II.
So that's FOD, Snake, Torus, and Xmas Demo II for starters, but also Richard's Jigsaw program which contains lots of useful code. There's doubtlessly other examples that have slipped my mind right now. Plenty of examples to get started, I think.
David.
--
So that's FOD, Snake, Torus, and Xmas Demo II for starters, but also Richard's Jigsaw program which contains lots of useful code. There's doubtlessly other examples that have slipped my mind right now. Plenty of examples to get started, I think.
David.
--
-
- Posts: 177
- Joined: Mon 02 Apr 2018, 21:51
Re: I'd like to start using SDL graphics functions
Hello David & DDRM,
Thanks. I think the torus2d program is a good example of what I want to do. I'm going to study it over the weekend.
While I'm at it, there's something I noticed and wanted to mention. As a demonstration, it's a fine example of the power of BBCSDL. Really nice graphics demo.
But as an example program, it's not terribly friendly. The code is very terse with minimal comments and most variables have single letter names.
For example, I can understand what the intention of FN_gpa is, but it might be daunting for someone completely new to BBC BASIC (or programming) to know what's going on or what the purpose of that function is.
Anyway, I'm confident I can learn how to use the SDL graphics functions from this code, but it'll take me more time analysing it and checking the manual and BBCSDL documents than it might otherwise have done.
I just thought I would mention this. If the purpose of the example programs is only to demonstrate that BBCSDL can do some cool stuff, then it's not important. But if the purpose of the example programs is also to help people who are new to BBC BASIC learn how to do stuff, then it could be a good idea to add meaningful variable names, and comments explaining stuff like what FN_gpa is doing, explaining the bits where @platform% is checked to test whether the version of BBCSDL is 64bit or not and the special actions taken when that is the case, etc.
Anyway thanks again for the information. Over the weekend I'll probably write a test program that uses SDL graphics functions.
Thanks. I think the torus2d program is a good example of what I want to do. I'm going to study it over the weekend.
While I'm at it, there's something I noticed and wanted to mention. As a demonstration, it's a fine example of the power of BBCSDL. Really nice graphics demo.
But as an example program, it's not terribly friendly. The code is very terse with minimal comments and most variables have single letter names.
For example, I can understand what the intention of FN_gpa is, but it might be daunting for someone completely new to BBC BASIC (or programming) to know what's going on or what the purpose of that function is.
Anyway, I'm confident I can learn how to use the SDL graphics functions from this code, but it'll take me more time analysing it and checking the manual and BBCSDL documents than it might otherwise have done.
I just thought I would mention this. If the purpose of the example programs is only to demonstrate that BBCSDL can do some cool stuff, then it's not important. But if the purpose of the example programs is also to help people who are new to BBC BASIC learn how to do stuff, then it could be a good idea to add meaningful variable names, and comments explaining stuff like what FN_gpa is doing, explaining the bits where @platform% is checked to test whether the version of BBCSDL is 64bit or not and the special actions taken when that is the case, etc.
Anyway thanks again for the information. Over the weekend I'll probably write a test program that uses SDL graphics functions.