Author Topic: SDL2 gui  (Read 21088 times)

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
SDL2 gui
« on: August 12, 2014, 09:27:38 AM »
I don't have the energy to search if there are SDL2 gui/frameworks with non-GPL license (=free to use). I was thinking about creating one myself, but you know, why do it if something like it already exists?

reaver

  • Rogueliker
  • ***
  • Posts: 207
  • Karma: +0/-0
    • View Profile
Re: SDL2 gui
« Reply #1 on: August 12, 2014, 11:06:09 AM »
I've searched a bit as well, but nothing really nice. There's a game engine of sorts, oxygine (MIT licence), which provides a few gui things, but it's a mobile-oriented engine, not a gui library.. I'm sure I've seen another one, but not oriented for games, so I kinda tuned it out. If you discover anything else, do share!

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: SDL2 gui
« Reply #2 on: August 13, 2014, 05:02:55 AM »
I'm working on SDL2/OpenGL GUI. But it's still quite early in development.
Probably we can join forces?

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: SDL2 gui
« Reply #3 on: August 13, 2014, 07:34:27 AM »
Probably we can join forces?

I wonder if it could ever work.. however, think I'm going to migrate to SDL2 by writing a simple framework for a roguelike game. This time it could be interesting to try to create a modular gui without any game data in the gui itself, and also built-in configurable keyboard commands (difficult to add later if keyboard commands are static).

Edit: Well this was easier than I thought. I already have basic class for gui with keyboard support. Next I'm going to implement SDL_ttf routines rather than use a custom font routine.
« Last Edit: August 13, 2014, 10:20:11 AM by Krice »

mushroom patch

  • Rogueliker
  • ***
  • Posts: 554
  • Karma: +0/-0
    • View Profile
Re: SDL2 gui
« Reply #4 on: August 13, 2014, 12:21:19 PM »
You're going to have to move more quickly than usual to finish before SDL3 comes out.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: SDL2 gui
« Reply #5 on: August 13, 2014, 12:45:59 PM »
You're going to have to move more quickly than usual to finish before SDL3 comes out.

It's possible to spend some time if you want to create a better, more modular gui engine. However gui is such a small part of a (roguelike) game that I wouldn't be too worried about it. It's such fun and easy programming compared to gameplay design stuff.

chooseusername

  • Rogueliker
  • ***
  • Posts: 329
  • Karma: +0/-0
    • View Profile
    • Email
Re: SDL2 gui
« Reply #6 on: August 14, 2014, 12:25:21 AM »
Yes, it is easy.  I added the SDL2 support to libtcod with little difficulty.  The other advantage with SDL2, is that porting apps to other platforms like Android, is trivial.  The hard part is making them playable there with the different interface.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: SDL2 gui
« Reply #7 on: August 14, 2014, 08:21:25 AM »
SDL ttf crashes like bananas. The program .exe becomes invalid and gives permission denied error.

reaver

  • Rogueliker
  • ***
  • Posts: 207
  • Karma: +0/-0
    • View Profile
Re: SDL2 gui
« Reply #8 on: August 14, 2014, 09:20:35 AM »
Well this was easier than I thought. I already have basic class for gui with keyboard support. Next I'm going to implement SDL_ttf routines rather than use a custom font routine.

You've done a basic class and you think it's easy or you're halfway done? Tsk tsk.

I added the SDL2 support to libtcod with little difficulty. 

Cool, thanks! Yes, easy, but still a bit time-consuming, saved me some trouble :)

SDL ttf crashes like bananas. The program .exe becomes invalid and gives permission denied error.

SDL_ttf is crap, use your own or be doomed with bad performance. BMFont is an excellent starting point.
« Last Edit: August 14, 2014, 09:27:30 AM by reaver »

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: SDL2 gui
« Reply #9 on: August 14, 2014, 09:37:30 AM »
SDL_ttf is crap, use your own or be doomed with bad performance. BMFont is an excellent starting point.

Fixed the bug, tried to do testing stuff in the gui's constructor.

SDL_ttf performance can be fixed by creating font sets to SDL texture with pre-set color versions. After that it's just a normal texture. Of course only monospace fonts work that way. But I'm having some troubles understanding glyph information.. If I'm using FontHeight for height and 'advance' of glyph data for width it doesn't look right. The font is too narrow, or maybe the height is stretched?

reaver

  • Rogueliker
  • ***
  • Posts: 207
  • Karma: +0/-0
    • View Profile
Re: SDL2 gui
« Reply #10 on: August 14, 2014, 09:43:52 AM »
But I'm having some troubles understanding glyph information.. If I'm using FontHeight for height and 'advance' of glyph data for width it doesn't look right. The font is too narrow, or maybe the height is stretched?

http://www.angelcode.com/products/bmfont/doc/render_text.html

^-- stuff that you can find within the BMFont page. Seriously it's a really nice utility and you can easily use it in your own engine.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: SDL2 gui
« Reply #11 on: August 14, 2014, 10:03:27 AM »
Seriously it's a really nice utility and you can easily use it in your own engine.

How it's easier than SDL ttf? The only problem I'm having with ttf at the moment is that rendering is quite bad. It seems to be anti-aliasing fonts different (bad) way than paint.net to which I'm comparing the output.

reaver

  • Rogueliker
  • ***
  • Posts: 207
  • Karma: +0/-0
    • View Profile
Re: SDL2 gui
« Reply #12 on: August 14, 2014, 10:08:19 AM »
How it's easier than SDL ttf? The only problem I'm having with ttf at the moment is that rendering is quite bad. It seems to be anti-aliasing fonts different (bad) way than paint.net to which I'm comparing the output.

It's not easier, it's just better to use something like that in the long term. Fill your screen with text, try multiple lines, in general try a real-world scenario and you'll see SDL_ttf for what it is, a toy api, quick to use but not for anything remotely serious.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: SDL2 gui
« Reply #13 on: August 14, 2014, 10:36:55 AM »
in general try a real-world scenario and you'll see SDL_ttf for what it is, a toy api, quick to use but not for anything remotely serious.

I'll try. Setting hinting to mono already made anti-aliasing better, but it's still different than in paint.net. Maybe could play around with texture size to downscale bigger font? Who knows, it might work. I just want a ttf font transformed to texture bits so it's easy to change the font size.

Edit: hinting 'none' is similar to paint.net's style of rendering. Solved!
« Last Edit: August 14, 2014, 10:43:48 AM by Krice »

graspee

  • Guest
.
« Reply #14 on: September 07, 2014, 10:17:46 PM »
.
« Last Edit: April 30, 2015, 04:02:20 PM by graspee »