X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2Fblog-0010.html-inc;h=21af3c62575cc586c0963c4e159ff88dcc5aae7f;hb=e785862422f3e827a242fc244bd57b23443887ce;hp=fe4b8d48d37cc0a4205e7c209051f61deb0a418b;hpb=d502f71f4cb7e6073e2629cdba69f20e7001b721;p=sdlgit%2FSDL-Site.git diff --git a/pages/blog-0010.html-inc b/pages/blog-0010.html-inc index fe4b8d4..21af3c6 100644 --- a/pages/blog-0010.html-inc +++ b/pages/blog-0010.html-inc @@ -1,6 +1,38 @@

-The beginnings of modular design for SDL Perl +Perl+SDL 3D Rendering

-
“Do or do not... there is no try.”
--yoda

The design before


The bindings before were all in one huge XS file. This was then exported into the SDL module. This means that the XS file has to handle with macros if any component (e.x SDL_Mixer) is not compiled. Moreover having ever binding in one XS file prevents use to treat C structs as object with only one point of free and malloc. This would be BEGIN and DESTROY in Perl. Also the monolithic design introduces a lot of bugs because we have to use free and malloc all over the place. Lastly SDL monolithic design has the constructor for all structs in both Perl and in XS.

The design we are aiming for

Simple one XS per Module. This would also simplify the Build code.

First Step


We have began with SDL Rect. It is in github master branch now. We are in the progress of making it back compatible. Originally SDL::Rect took named variables as parameters for new(). Now since the constructor is in XS we have only unnamed parameters.


Before


SDL::Rect->new( -x => 0, -y => 0, -width => 0, -height => 0);

After


SDL::Rect->new(0, 0, 0, 0);

Ideally we would like both ways of constructing Rect.
\ No newline at end of file +Recently we have done a lot of work on the next release of SDL Perl. But it all pays off when I see users do cool things as one of the users has done below. Talon^++! This project is a great example for people wanting to learn 3D from scratch.
+
+--yapgh
+
+
This was a project to test how well Perl+SDL performs and does not use OpenGL at all. This is all perl and SDL, with the help of libsdl_gfx for SDL::GFX::Primitives. Texture mapping doesn't use SDL::GFX::Primitives because textured_polygon just takes a surface, tiles it, and clips out the polygon, which doesn't look 3D at all.
+
+Below are some screen shots of this little toy in action. If you'd like to try it yourself, you can download the entire project here. You can rotate the objects with the mouse, or keyboard arrows. Also press shift to toggle shading and space to switch objects.
+
+NOTE: the project is compressed in the .tgz format, if you are a windows user, you may need a tool like 7zip to extract the contents.
+
+
Standard Cube:
+

+

Standard Cube with Pseudo Shading:
+
+

+

Standard Diamond:
+
+

+

Standard Diamond with Pseudo Shading:
+
+

+

Textured Cube:
+
+

+

Perspectively Correct Textured Cube:
+
+

+

Perspectively Correct Textured Cube with shading:
+
+

+
+


+

\ No newline at end of file