[SDL] looking for something equivalent to context.translate(x, y)

Jonathan Dearborn grimfang4 at gmail.com
Mon Mar 26 18:01:00 PDT 2012


SDL doesn't define a drawing API like those you mention.  It is entirely
raster-based and low-level.  You get access to the raw pixel data and
there's a blitting routine.  Other APIs may use SDL to provide an interface
to graphics primitives (SDL_gfx, SPriG), vector graphics (similar to
Canvas), or matrix transformations on pixel data (similar to OpenGL).  You
could even implement the Java2D API on top of SDL.  The graphic primitives
need to be aware of this global transformation state, and that is just not
within the scope of SDL proper.

If you're not interested in doing it yourself, you might have a look at
cairo (http://cairographics.org/).  I did once try it out with SDL and it
was pretty neat.  If you need better performance, you would want to use
OpenGL in the end (and cairo does have an OpenGL backend that can be set up
with SDL).

Jonny D


On Mon, Mar 26, 2012 at 7:46 PM, sombriks <sombriks at gmail.com> wrote:

> **
> Hello everyone,
>
> On similar drawing api's i have a function which i use to implement camera
> movement. For instance, on Java2D i can use [1] and javascript i can use
> [2], they are quite similar (not complete equal, but similar)
>
> But on SDL i had no success on find something similar to this.
>
> I've solved my issue by using a second buffer to draw the background
> buffer and the sprites and then draw that on the screen. But find a
> solution able to make the 3 research codebases more similar to each other
> would be nice.
>
> For context, please see the following Cameras and Scenarios (see links,
> not going to pollute the post.)
>
> SDL version
>
> http://code.google.com/p/sombriks-hq/source/browse/trunk/yarpg-cpp/Camera.cc?r=360
>
> http://code.google.com/p/sombriks-hq/source/browse/trunk/yarpg-cpp/Scenario.cc?r=360#65
>
> Java2D version
>
> http://code.google.com/p/sombriks-hq/source/browse/trunk/yarpg-java/src/yarpg/Camera.java?r=360
>
> http://code.google.com/p/sombriks-hq/source/browse/trunk/yarpg-java/src/yarpg/Scenario.java?r=360#67
>
> Canvas/Javascript version
>
> http://code.google.com/p/sombriks-hq/source/browse/trunk/yarpg-js/yarpg-js/Camera.js?r=360
>
> http://code.google.com/p/sombriks-hq/source/browse/trunk/yarpg-js/yarpg-js/Scenario.js?r=360#53
>
>
> [1]
> http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html#translate%28int,%20int%29
> [2]
> https://developer.mozilla.org/en/Canvas_tutorial/Transformations#Translating
>
> Thanks in advance.
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120326/a6d94a49/attachment.htm>


More information about the SDL mailing list