www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - GDC 2006 2D Physics Demo for D

reply clayasaurus <clayasaurus gmail.com> writes:
After quite a conversion process, I've successfully converted the c++ 
GDC 2006 2D Physics demo to D.

Original:
http://www.gphysics.com/archives/18

D Version: 
http://www.dsource.org/projects/arcgames/browser/trunk/physics/demo.zip?format=raw

Use keys 1-9 to switch through demo, and space bar to launch the 'bomb'.

It also comes with a public domain red black tree implementation that 
seems to work. The author of 
http://eternallyconfuzzled.com/tuts/redblack.html told me he is going to 
add a license page that says all the code on his pages are in public 
domain.

Special thanks to Christian Kamm for helping me track done a bug.

~ Clay
Oct 30 2006
next sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"clayasaurus" <clayasaurus gmail.com> wrote in message 
news:ei67hf$2dgi$1 digitaldaemon.com...
 After quite a conversion process, I've successfully converted the c++ GDC 
 2006 2D Physics demo to D.

 Original:
 http://www.gphysics.com/archives/18

 D Version: 
 http://www.dsource.org/projects/arcgames/browser/trunk/physics/demo.zip?format=raw

 Use keys 1-9 to switch through demo, and space bar to launch the 'bomb'.

 It also comes with a public domain red black tree implementation that 
 seems to work. The author of 
 http://eternallyconfuzzled.com/tuts/redblack.html told me he is going to 
 add a license page that says all the code on his pages are in public 
 domain.

 Special thanks to Christian Kamm for helping me track done a bug.

 ~ Clay

Sweet, but it runs at about 3000 FPS, and so is nearly impossible to see anything running except the pyramid demo. I see some kind of delta timing with the "dt" global in main.d, but it's set to a constant 1/60, and in windowed mode on Windows, it'll try to update the screen as fast as possible, so the frame time will be something other than 1/60 of a second. Is there maybe a way to force it to run in fullscreen, so it's limited to the refresh rate? I'd recompile it but I don't have Derelict, so..
Oct 30 2006
parent reply clayasaurus <clayasaurus gmail.com> writes:
Jarrett Billingsley wrote:
 "clayasaurus" <clayasaurus gmail.com> wrote in message 
 news:ei67hf$2dgi$1 digitaldaemon.com...
 After quite a conversion process, I've successfully converted the c++ GDC 
 2006 2D Physics demo to D.

 Original:
 http://www.gphysics.com/archives/18

 D Version: 
 http://www.dsource.org/projects/arcgames/browser/trunk/physics/demo.zip?format=raw

 Use keys 1-9 to switch through demo, and space bar to launch the 'bomb'.

 It also comes with a public domain red black tree implementation that 
 seems to work. The author of 
 http://eternallyconfuzzled.com/tuts/redblack.html told me he is going to 
 add a license page that says all the code on his pages are in public 
 domain.

 Special thanks to Christian Kamm for helping me track done a bug.

 ~ Clay

Sweet, but it runs at about 3000 FPS, and so is nearly impossible to see anything running except the pyramid demo. I see some kind of delta timing with the "dt" global in main.d, but it's set to a constant 1/60, and in windowed mode on Windows, it'll try to update the screen as fast as possible, so the frame time will be something other than 1/60 of a second. Is there maybe a way to force it to run in fullscreen, so it's limited to the refresh rate? I'd recompile it but I don't have Derelict, so..

Derelict comes with the demo.zip package along with SDL.dll. If you have the D compiler and build, all you need to do is 'build main.d -Rn -full -release -O' to build it. Throw in an SDL_Delay(40) in the main while loop if you want a quick solution, or add a 'flags = SDL_OPENGL | SDL_FULLSCREEN' to the SDL video flags for fullscreen in main.d around line 668. Within the next year or so I'm going to integrate this into my 2D game library ( http://arcgames.dsource.org/arc/arc/time.html ) which has a delay timer that will delay the main loop as needed to keep a constant frame rate. I need to figure out how to add circle shapes and eventually polygon shapes, however the author says at GDC 2007 he'll put more shapes in his demo. There is also a java port that supports circle and line shapes http://code.google.com/p/phys2d/
Oct 30 2006
next sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"clayasaurus" <clayasaurus gmail.com> wrote in message 
news:ei6dp6$2i50$1 digitaldaemon.com...
 Derelict comes with the demo.zip package along with SDL.dll. If you have 
 the D compiler and build, all you need to do is 'build 
 main.d -Rn -full -release -O' to build it.

 Throw in an SDL_Delay(40) in the main while loop if you want a quick 
 solution, or add a 'flags = SDL_OPENGL | SDL_FULLSCREEN' to the SDL video 
 flags for fullscreen in main.d around line 668.

Ahh, great, that worked :) So much cooler when it's running at a reasonable speed. Though strangely putting it in fullscreen didn't help. Apparently, there's a way to make SDL wait until a vertical retrace until it updates the screen, using SDL_DOUBLEBUF for the video flags and SDL_Flip() at the end of the loop, but I tried that and that didn't help either.
Oct 30 2006
parent reply Olli Aalto <oaalto gmail.com> writes:
Jarrett Billingsley wrote:
 "clayasaurus" <clayasaurus gmail.com> wrote in message 
 news:ei6dp6$2i50$1 digitaldaemon.com...
 Derelict comes with the demo.zip package along with SDL.dll. If you have 
 the D compiler and build, all you need to do is 'build 
 main.d -Rn -full -release -O' to build it.

 Throw in an SDL_Delay(40) in the main while loop if you want a quick 
 solution, or add a 'flags = SDL_OPENGL | SDL_FULLSCREEN' to the SDL video 
 flags for fullscreen in main.d around line 668.

Ahh, great, that worked :) So much cooler when it's running at a reasonable speed. Though strangely putting it in fullscreen didn't help. Apparently, there's a way to make SDL wait until a vertical retrace until it updates the screen, using SDL_DOUBLEBUF for the video flags and SDL_Flip() at the end of the loop, but I tried that and that didn't help either.

The SDL_DOUBLEBUF and SDL_Flip() are not used in OpenGL mode. The SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) and SDL_GL_SwapBuffers() are used instead respectively. I haven't looked at the code yet, but I believe those are used there. As what comes to the vsync you could try SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1)[1]. Put it before the call to SDL_SetVideoMode(). O. 1. http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fGL_5fSetAttribute http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fGLattr
Oct 31 2006
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Olli Aalto" <oaalto gmail.com> wrote in message 
news:ei7088$2vl4$1 digitaldaemon.com...
 The SDL_DOUBLEBUF and SDL_Flip() are not used in OpenGL mode. The 
 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) and SDL_GL_SwapBuffers() are 
 used instead respectively. I haven't looked at the code yet, but I believe 
 those are used there.

 As what comes to the vsync you could try 
 SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1)[1]. Put it before the call to 
 SDL_SetVideoMode().

Crap! The version of SDL that Derelict (or at least the Derelict that comes with Clay's demo) is 1.2.0, and SDL_GL_SWAP_CONTROL is only available starting with 1.2.10. Have to do some more fiddling this afternoon..
Oct 31 2006
parent reply Mike Parker <aldacron71 yahoo.com> writes:
Jarrett Billingsley wrote:
 "Olli Aalto" <oaalto gmail.com> wrote in message 
 
 Crap!  The version of SDL that Derelict (or at least the Derelict that comes 
 with Clay's demo) is 1.2.0, and SDL_GL_SWAP_CONTROL is only available 
 starting with 1.2.10.  Have to do some more fiddling this afternoon.. 
 

Actually, the version of Derelict with the demo should support SDL 1.2.10 (as defined in sdlversion.d). The missing enum was a bug. It was also missing SDL_GL_ACCELERATED_VISUAL. The Derelict trunk has been updated with the fix.
Oct 31 2006
parent Mike Parker <aldacron71 yahoo.com> writes:
Mike Parker wrote:
 Jarrett Billingsley wrote:
 "Olli Aalto" <oaalto gmail.com> wrote in message
 Crap!  The version of SDL that Derelict (or at least the Derelict that 
 comes with Clay's demo) is 1.2.0, and SDL_GL_SWAP_CONTROL is only 
 available starting with 1.2.10.  Have to do some more fiddling this 
 afternoon..

Actually, the version of Derelict with the demo should support SDL 1.2.10 (as defined in sdlversion.d). The missing enum was a bug. It was also missing SDL_GL_ACCELERATED_VISUAL. The Derelict trunk has been updated with the fix.

Correction -- the trunk is being updated with the fix. I keep timing out. I'll post on the Derelict forums when it succeeds.
Oct 31 2006
prev sibling parent Lucas Goss <lgoss007 gmail.com> writes:
clayasaurus wrote:
 Within the next year or so I'm going to integrate this into my 2D game 
 library ( http://arcgames.dsource.org/arc/arc/time.html ) which has a 
 delay timer that will delay the main loop as needed to keep a constant 
 frame rate.

I think it would be better to use frame rate independence. By delaying the main loop some input can become jagged and seem unresponsive (mouse jumping places). I know I've seen some articles on gamedev.net, now where were they... http://www.gamedev.net/reference/articles/article1604.asp http://www.gamedev.net/reference/articles/article1382.asp lucas
Oct 31 2006
prev sibling next sibling parent Hasan Aljudy <hasan.aljudy gmail.com> writes:
wow .. just amazing!!

clayasaurus wrote:
 After quite a conversion process, I've successfully converted the c++ 
 GDC 2006 2D Physics demo to D.
 
 Original:
 http://www.gphysics.com/archives/18
 
 D Version: 
 http://www.dsource.org/projects/arcgames/browser/trunk/physics
demo.zip?format=raw 
 
 
 Use keys 1-9 to switch through demo, and space bar to launch the 'bomb'.
 
 It also comes with a public domain red black tree implementation that 
 seems to work. The author of 
 http://eternallyconfuzzled.com/tuts/redblack.html told me he is going to 
 add a license page that says all the code on his pages are in public 
 domain.
 
 Special thanks to Christian Kamm for helping me track done a bug.
 
 ~ Clay

Oct 30 2006
prev sibling parent reply Walter Bright <newshound digitalmars.com> writes:
clayasaurus wrote:
 After quite a conversion process, I've successfully converted the c++ 
 GDC 2006 2D Physics demo to D.
 
 Original:
 http://www.gphysics.com/archives/18
 
 D Version: 
 http://www.dsource.org/projects/arcgames/browser/trunk/physics
demo.zip?format=raw 

Could you please put some sort of descriptive page about it on dsource so one can see what it is without needing to download and unzip it?
 It also comes with a public domain red black tree implementation that 
 seems to work. The author of 
 http://eternallyconfuzzled.com/tuts/redblack.html told me he is going to 
 add a license page that says all the code on his pages are in public 
 domain.

Thanks for taking care of this.
Oct 31 2006
parent reply clayasaurus <clayasaurus gmail.com> writes:
Walter Bright wrote:
 clayasaurus wrote:
 After quite a conversion process, I've successfully converted the c++ 
 GDC 2006 2D Physics demo to D.

 Original:
 http://www.gphysics.com/archives/18

 D Version: 
 http://www.dsource.org/projects/arcgames/browser/trunk/physics
demo.zip?format=raw 

Could you please put some sort of descriptive page about it on dsource so one can see what it is without needing to download and unzip it?

Here you go http://svn.dsource.org/projects/arcgames/trunk/physics/html/index.html
Oct 31 2006
parent reply Walter Bright <newshound digitalmars.com> writes:
clayasaurus wrote:
 Walter Bright wrote:
 clayasaurus wrote:
 After quite a conversion process, I've successfully converted the c++ 
 GDC 2006 2D Physics demo to D.

 Original:
 http://www.gphysics.com/archives/18

 D Version: 
 http://www.dsource.org/projects/arcgames/browser/trunk/physics
demo.zip?format=raw 

Could you please put some sort of descriptive page about it on dsource so one can see what it is without needing to download and unzip it?

Here you go http://svn.dsource.org/projects/arcgames/trunk/physics/html/index.html

That's a great start. But please include the links, the title, and the dscription you put in the original post!
Oct 31 2006
parent reply clayasaurus <clayasaurus gmail.com> writes:
Walter Bright wrote:
 clayasaurus wrote:
 Walter Bright wrote:
 clayasaurus wrote:
 After quite a conversion process, I've successfully converted the 
 c++ GDC 2006 2D Physics demo to D.

 Original:
 http://www.gphysics.com/archives/18

 D Version: 
 http://www.dsource.org/projects/arcgames/browser/trunk/physics
demo.zip?format=raw 

Could you please put some sort of descriptive page about it on dsource so one can see what it is without needing to download and unzip it?

Here you go http://svn.dsource.org/projects/arcgames/trunk/physics/html/index.html

That's a great start. But please include the links, the title, and the dscription you put in the original post!

Done. ~ Clay
Oct 31 2006
parent Walter Bright <newshound digitalmars.com> writes:
clayasaurus wrote:
 Walter Bright wrote:
 clayasaurus wrote:
 Here you go

 http://svn.dsource.org/projects/arcgames/trunk/physics/html/index.html

That's a great start. But please include the links, the title, and the dscription you put in the original post!

Done. ~ Clay

Much better!
Oct 31 2006