what graphics API to use for raytracing, SDL

Started by Mark_Larson, September 24, 2008, 02:19:58 PM

Previous topic - Next topic

Mark_Larson

I highly recommend learning SDL.  It is MUCH easier to understand than directx or opengl.  I can get a fast framerate without using any hardware acceleration.  It'll work on slow computers better.  You can of course use the hardware acceleration, but since we are just writing to a framebuffer it isn't necessary.

http://www.libsdl.org/

simple introduction from the sdl webpage
http://www.libsdl.org/intro.en/toc.html

tutorials on gaming programming using SDL
http://lazyfoo.net/SDL_tutorials/index.php


the pluses of SDL
  runs on Windows and Linux, so you don't have to do anything special for either OS.
  supports 2d graphics - what we are doing
  supports 3d graphics
  supports directx under windows
  supporst opengl under windows and linux - this is what you would use if you wanted hardware acceleration under both OSes
  supports threads - this is really important since the threading models between Linux and Windows are really different.
  sound
  cd rom audio
  events

  it is completely simple to set up a graphics windows.  It only requires ONE call to the API, not the numerous calls it requires under Windows or Linux.  You don't have to do any kind of event handling procedure.  You simply call a SDL function ( like peekmsg), and it returns info about the mouse and keyboard.  That part is quite similar to the way it works in Windows.  You use a case  statement to break out the different times of events.

I had a problem getting SDL to run under 64-bit Linux, so that is what was holding up my tutorial.  I am good now, and will be posting something later today or tomorrow.
BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

Mark Jones

Quote from: Mark_Larson on September 24, 2008, 02:19:58 PM
[SDL] is completely simple to set up a graphics windows.  It only requires ONE call to the API...

Sounds nice. I like programming when it doesn't involve miles of red-tape. :U
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Mark_Larson

  MSVC doesn't do a good job of optimizing for the core 2 duo.  So I installed ICC, which will run under Windows and Linux.  Currently I am getting 330 FPS without doing ANY raytracing.  I am simply writing 0x00FFFFFF to the window as fast as I can.  This is in C.  With ASM I will be able to hit higher frame rates.  I am going to try and recompile SDL with ICC and see what kind of speed up I get.

  If ya'll have ICC ( I downloaded an evaluation version for free), I'd recommend also re-compiling SDL with ICC.  And optimize it for your processor.  It has full source code.  I forgot to mention that.

BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

publicminx

mark ...

how much fps do you get if you do the same with 64 bit? - possible to try?

Mark_Larson

Quote from: publicminx on February 06, 2009, 08:21:40 PM
mark ...

how much fps do you get if you do the same with 64 bit? - possible to try?


64-bit gives a nice speed up.  I have 64-bit linux installed as a dual boot with Windows XP.

BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

ecube

wow nice find, Mark, i'll definitely give the library a go in the next few days. In an unrelated question are you planning on doing a 64bit optimization guide like your 32bit verison?

Mark_Larson

 
Quote from: E^cube on March 13, 2009, 05:54:11 PM
wow nice find, Mark, i'll definitely give the library a go in the next few days. In an unrelated question are you planning on doing a 64bit optimization guide like your 32bit verison?

It wouild be a lot more complicated.    Optimizing the core 2 duo in 64-bit is more challenging, if you want to take full power of the architecture.  You can  stay with C and let the compiler to do it for you.
BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

ecube

Wow, recommending C to me over ASM for optimization on and ASM forum :\ hope the mighty hasn't fallen,as I still have faith in you!  :U

Mark_Larson

Quote from: E^cube on March 14, 2009, 07:41:45 AM
Wow, recommending C to me over ASM for optimization on and ASM forum :\ hope the mighty hasn't fallen,as I still have faith in you!  :U

hehee,   you can do it in 64-bit asm, it is just a lot more complicated.  and you also get bigger speed ups from using asm over C.  I have 64-bit asm code already.  I had started the prject in C in 64-bit and converted it to 64-bit asm under Linux.  And then I switched to 32-bit C and 32-bit asm for the Windows Xp users.
BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

Mark_Larson

the P4 was the first intel processor in a long time that required lots of asm optimization to make it run fast.  I hated what Intel did with the P4.  Core 2 duo is a great design, but it is also complex.  It has lots of ways to speed it up.
BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm