Professional graphic libraries with dreamcast

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
Cormega
DCEmu Junior
DCEmu Junior
Posts: 44
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Wed Jun 08, 2005 12:37 pm
Has thanked: 0
Been thanked: 0

Professional graphic libraries with dreamcast

Post by Cormega »

How does one go about using a professional or advanced graphic library on Dreamcast? Do they have to rewrite the code (if it is open-source) to run on dreamcast? I noticed that the graphic libraries that are generally used are SDL or maybe allegro. I know that the Holly engine is in the works. But, I want to know if I can use an advanced 2D graphics engine in order to write games. Or do I have to go about the process of porting over engines in order to use them properly with the hardware.
User avatar
jerryjanis
DCEmu Newbie
DCEmu Newbie
Posts: 5
Joined: Mon Apr 12, 2004 1:25 am
Location: Upstate New York
Has thanked: 0
Been thanked: 0
Contact:

Post by jerryjanis »

KallistiOS includes a port of SDL. I used it to make Dziokzit for the Goat Games compilation.

http://www.goatstore.com/publishing/ind ... zit-060710

The advantage of using SDL was that I could compile and run the game on my PC, which made testing easier. The disadvantage is that it is slow. I fought with speed issues the entire time. Perhaps the game would have come out less primitive looking if speed weren't such an issue. The graphics for the game felt a little bit like they were running without hardware acceleration. I have since started using KGL (which I have read is much slower then writing non-portable Dreamcast code) and it is a dream to work with. I can put a lot of 3d textured models on the screen and get what feels like a solid 30 frames per second.

Using SDL was a great learning experience for me. It was a good first step, but understand that it comes at a cost. I'd be interested in hearing other peoples' experiences. It's quite possible that the slowness was something wrong that I did.
User avatar
henzenmann
Insane DCEmu
Insane DCEmu
Posts: 186
Joined: Wed Jul 12, 2006 4:58 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by henzenmann »

jerryjanis wrote:KallistiOS includes a port of SDL. I used it to make Dziokzit for the Goat Games compilation.

http://www.goatstore.com/publishing/ind ... zit-060710

The advantage of using SDL was that I could compile and run the game on my PC, which made testing easier. The disadvantage is that it is slow. I fought with speed issues the entire time. Perhaps the game would have come out less primitive looking if speed weren't such an issue. The graphics for the game felt a little bit like they were running without hardware acceleration. I have since started using KGL (which I have read is much slower then writing non-portable Dreamcast code) and it is a dream to work with. I can put a lot of 3d textured models on the screen and get what feels like a solid 30 frames per second.

Using SDL was a great learning experience for me. It was a good first step, but understand that it comes at a cost. I'd be interested in hearing other peoples' experiences. It's quite possible that the slowness was something wrong that I did.
The SDL port in kos-ports seems to be quite outdated. I recommend using Chui's port instead: http://chui.dcemu.co.uk/sdl.html

I cannot recommend KGL at this point. You have to work around so many issues that the cross-platform advantage of OpenGL kind of vanishes. Rather make your renderer flexible enough to support different backends and use KOSes PVR support directly on the Dreamcast.
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7499
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has thanked: 4 times
Been thanked: 10 times
Contact:

Post by Quzar »

For GL, you should check out KGLX. It's fairly usefull compared to KGL.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY
Has thanked: 0
Been thanked: 0

Post by OneThirty8 »

henzenmann wrote: The SDL port in kos-ports seems to be quite outdated. I recommend using Chui's port instead: http://chui.dcemu.co.uk/sdl.html
I haven't used Chui's SDL port, but I heard it comes with its own set of bugs. To squash some speed issues in SDL on the DC, you can tweak the timer functions. We had a short discussion of it a while back on the dcemu.co.uk boards which you can see here.
Since those forums seem to have messed up the formatting of our code, here's mine made prettier:

Code: Select all

void SDL_StartTicks(void) { 
  /* Set first ticks value */ 
  /*start = jiffies;*/
  /* 138's hack */ 
   Uint32 *milis, *secs;
   timer_ms_gettime(secs, milis); 
   start = ((Uint32)secs*1000)+(Uint32)milis; 
}

Uint32 SDL_GetTicks(void) {
   /*return((jiffies-start)*1000/HZ);*/
   /* 138's hack */
   Uint32 *milis, *secs; 
   timer_ms_gettime(secs, milis);
   return ((((Uint32)secs*1000)+(Uint32)milis)-start);
}
And here's Troy's made readable (I really hate the way their forums screw up the formatting like this...):

Code: Select all

void SDL_StartTicks(void) {
 /* Set first ticks value */ 
  start = timer_ms_gettime64();//jiffies; 
}
Uint32 SDL_GetTicks(void) {
 //return((jiffies-start)*1000/HZ); 
  return timer_ms_gettime64()-start; 
}
You can find these functions in your SDL source in timer/dc/SDL_systimer.c near the top of the file. Just change those to use my code or Troy's code (they both do essentially the same thing, but Troy's is obviously the more straightforward of the two) and recompile SDL.
User avatar
henzenmann
Insane DCEmu
Insane DCEmu
Posts: 186
Joined: Wed Jul 12, 2006 4:58 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by henzenmann »

OneThirty8 wrote:
henzenmann wrote: The SDL port in kos-ports seems to be quite outdated. I recommend using Chui's port instead: http://chui.dcemu.co.uk/sdl.html
I haven't used Chui's SDL port, but I heard it comes with its own set of bugs.
Could you be specific? I have had nothing but benefits so far from using Chui's version.
OneThirty8 wrote:
To squash some speed issues in SDL on the DC, you can tweak the timer functions. We had a short discussion of it a while back on the dcemu.co.uk boards which you can see here.
Since those forums seem to have messed up the formatting of our code, here's mine made prettier:

Code: Select all

void SDL_StartTicks(void) { 
  /* Set first ticks value */ 
  /*start = jiffies;*/
  /* 138's hack */ 
   Uint32 *milis, *secs;
   timer_ms_gettime(secs, milis); 
   start = ((Uint32)secs*1000)+(Uint32)milis; 
}

Uint32 SDL_GetTicks(void) {
   /*return((jiffies-start)*1000/HZ);*/
   /* 138's hack */
   Uint32 *milis, *secs; 
   timer_ms_gettime(secs, milis);
   return ((((Uint32)secs*1000)+(Uint32)milis)-start);
}
This code seems to be completely wrong! You are writing to uninitialized pointers
and then you multiply the pointers, not the results! You must be lucky that this is not crashing your program right away.
Look at the SDL_GetTicks implementation in Chui's port, which does the same thing you are trying to do, but does it correctly.
The speedups you think you are getting are probably caused by this function returning completely bogus values.
OneThirty8 wrote:
And here's Troy's made readable (I really hate the way their forums screw up the formatting like this...):

Code: Select all

void SDL_StartTicks(void) {
 /* Set first ticks value */ 
  start = timer_ms_gettime64();//jiffies; 
}
Uint32 SDL_GetTicks(void) {
 //return((jiffies-start)*1000/HZ); 
  return timer_ms_gettime64()-start; 
}
If you look at how timer_ms_gettime64 is implemented in KOS (kernel/arch/dreamcast/kernel/timer.c), you'll see that it uses timer_ms_gettime internally, so this code should not make any difference performance-wise.

And either way, you typically call SDL_GetTicks once per main-loop iteration, which boils down to only 60 times per second. Any optimization here should be hardly noticable.
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7499
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has thanked: 4 times
Been thanked: 10 times
Contact:

Post by Quzar »

Chui's code performs identically to the normal SDL (as far as I've been able to tell) as long as you don't use any of the things that he added. Almost all the DC specific things (from the keyboard mapping to the dma blitter) are buggy.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
Post Reply