Layered Display

Hi,

Will, you might confuse me with another person, although I’ve used
IRC in the past :slight_smile:
The first goal is not really to make a parallax scrolling mechanism,
although I have mentioned it in the previous message.
The main concern is, I have a graphical application which needs
more than one display layer/plane, and there’re some sprites/animations
on those layers/planes, and of course, if something gets modified on a layer
I need to re- “project” all the other layers on the screen in the right order for
the modified area. This is a really annoying task for a game developer I think,
that’s why I’m proposing this tool.
Z-buffering is a technic aimed at 3D rendering: you can look at: http://en.wikipedia.org/wiki/Z-buffer
It is something far easier I want to do, and yet maybe it can help.

Let me know, I wouldn’t begin a development without knowing if there is some
kind of interest.

By the way, thank you Edward for your message. You can help in a simple manner:
look at the interface I’ve sent and tell me if you see missing functionalities, and if
you imagine you can use such functions in your programs. You can mail me directly
if you want.

Thank you guys, other comments/suggestions/ideas are welcome !

Regards

Julien_____________________________________________________________________________
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr

I think the Julian I knew spelled his name with an ‘a’ rather than an
’e’… so… yeah.

Anyway, he had a really funky idea that worked pretty good as a faux z
buffer as a per pixel paralax scrolling setup. I can’t recall the
details :). Was a bright guy.

-Will

Hi,

I didn’t really finish my email off very well…

The system I used was developed exclusively for game development, and although written in Java using
heavily abstracted OpenGL, it was great. I don’t have the source, only the javadoc (some of which is
below). I’m not saying it needs to be this complicated…

The main “control” of which layer your surface (“Component”) was drawn on is the setDepth method, but as you can see the API
has loads of methods to do just about everything you could want.

Apologies to people who get plain-text emails only

Regards
Ed

Method Summary
void enableClipping(boolean enable)
Enables or disables the clipping for the component.
int getAbsoluteTopLeftX()
Returns the x coordinate of the absolute location of this component.
int getAbsoluteTopLeftY()
Returns the y coordinate of the absolute location of this component.
int getAbsoluteX()
Returns the x coordinate of the absolute location of this component.
int getAbsoluteY()
Returns the y coordinate of the absolute location of this component.
int getBlend()
Returns the alpha blend level.
int getDepth()
Returns the depth (or z-value) of the component.
int getHandleX()
Returns the x coordinate of the component’s handle.
int getHandleY()
Returns the y coordinate of the component’s handle.
int getHeight()
Returns the height of the component surface.
java.lang.String getName()
Returns the name of the node.
Container getParent()
Returns the parent of this Component.
double getRotationAngle()
Returns the rotation angle.
double getRotationCenterX()
Returns the horizontal center of rotation.
double getRotationCenterY()
Returns the vertical center of rotation.
int getScaledHeight()
Returns the height coordinate of the scaled component.
int getScaledWidth()
Returns the width coordinate of the scaled component.
double getScaleX()
Returns the horizontal scale.
double getScaleY()
Returns the vertical scale.
Surface getSurface()
Returns the component’s current surface.
int getTopLeftX()
Returns the x coordinate of the component’s top-left corner.
int getTopLeftY()
Returns the y coordinate of the component’s top-left corner.
int getWidth()
Returns the width of the component surface.
int getX()
Returns the X coordinate of this component.
int getY()
Returns the Y coordinate of this component.
boolean isAlphaSensibilityEnabled()
Returns the state of the alpha-mask-tolerance-based event response flag.
boolean isAutoScaleEnabled()
Checks if the surface’s auto-scaling feauture is enabled.
boolean isChild(Component component)
Tests if this Component is child of a given Component object; by definition only a Container can be parent, so a call to this method is sensible only from a Container instance.
boolean isClippingEnabled()
Checks if clipping is enabled or not.
boolean isEnabled()
Returns the state of the event response ability flag.
boolean isLocationAlphaSensitive(int x, int y)
Checks if pixel specified by given coords (x, y) is alpha-mask tolerated.
boolean isPressed()
Checks if the component is pressed.
boolean isScaleHandleEnabled()
Checks if the handle’s scaling feauture is enabled.
boolean isTransparent()
Return a value that specifies if the background fill color is transparent or not.
boolean isVisible()
Tests if the component is visible.
void mouseDragged(MouseEvent event)
Method executed when the mouse cursor is moved in the screen while the button is pressed.
void mousePressed(MouseEvent event)
Method executed when a mouse button is pressed.
void mouseReleased(MouseEvent event)
Method executed when a mouse button is released.
void setAlphaSensibilityEnabled(boolean enabled)
Sets the state of the alpha sensibility feature.
void setAutoScaleEnabled(boolean autoScale)
Activates/deactivates the component’s auto-scaling feature.
void setBlend(int blend)
Sets the alpha blend level in the range 0 (transparent) - 100 (opaque).
void setBlendFunction(BlendFunction bFunction)

void setDepth(int depth)
Sets the depth of the component and tell parent about this change in order parent can make effective any sort of children re-organization.
void setEnabled(boolean enabled)
Sets the state of the event response ability flag.
void setEventExclusive(boolean eventExclusive)
If this property is enabled, when this component is pressed or release it won’t transmit the event to other components.
void setHandleLocation(int x, int y)
Sets the handle location of this component specified.
void setHandleLocation(Point position)
Sets the handle location of this component.
void setHeight(int height)
Changes the component height.
void setLocation(int x, int y)
Sets the location of the component.
void setLocation(Point position)
Sets the location of the component.
void setName(java.lang.String name)
Sets the name of this Component.
void setParent(Container parent)
Sets the parent of this Component.
void setRotationAngle(double angle)
Sets the rotation angle.
void setRotationCenter(double x, double y)
Sets the center of rotation.
void setScale(double scale)
Sets the horizontal and vertical scale.
void setScale(Scale scale)
Sets the scale.
void setScaleHandleEnabled(boolean scaleHandle)
Activates/deactivates the handle’s scaling feature.
void setScaleX(double scaleX)
Sets the horizontal scale.
void setScaleY(double scaleY)
Sets the vertical scale.
void setSize(int width, int height)
Changes the component’s size.
void setSurface(Surface surface)
Sets the component surface (graphical representation of the component).
void setTransparent(boolean transparent)
Sets the value which specifies if the background fill color is transparent or not.
void setVisible(boolean visible)
Sets the visibility of the component.
void setWidth(int width)
Changes the component width.
void setX(int x)
Sets the x position of the component.
void setY(int y)
Sets the y position of the component.
void toBack()
Brings to back this Component.
void toFront()
Brings to front this Component.
void update(int x, int y)
Paints the component contents.__________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html

Hi Julien

Exactly right. I have many things I need to show and hide rapidly, or move around the screen.
I had plans to expand this and add rotation, scaling, etc, but haven’t got around to it yet!

Ed> ----- Original Message -----

From: clementj2005@yahoo.fr (Julien Clement)
To: A list for developers using the SDL library. (includes SDL-announce)
Sent: Friday, 13 June, 2008 9:58:27 AM
Subject: [SDL] Re : Re : Layered Display

Hi Edward,

In your project, what it the usage of “IMGOverlay” ? Reading the source code, I was wondering if you
were using it for moving sprites over a background or something like that, blitting a “mask” at the old
position and then blitting the sprite at the new position, updating the mask with the backgrnd
data ?

Julien

  __________________________________________________________

Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html

Hi,

I’m still not exactly sure what you’re trying to achieve.

Are you trying to implement ‘layers’ as one would see them in an image
manipulation program, such as The GIMP?

What would be the use-cases for such a facility in a RT interactive system?

Your API seems to be proposing something like this:

#define LAYER_BG (0)
#define LAYER_SPRITE (1)
#define LAYER_EFFECTS (2)
#define LAYERS_TOTAL (3)

SDL_Surface* layers[LAYERS_TOTAL];

void init(void)
{
int i;
for (i = 0; i < LAYERS_TOTAL; ++i) {
layers[i] = SDL_CreateRGBSurface(disp_flags, disp_width disp_height,
… // other params as main display.
);
}
}

void draw_everything(void)
{
SDL_BlitSurface(layers[LAYER_BG], NULL, display, NULL);
SDL_BlitSurface(layers[LAYER_SPRITE], NULL, display, NULL);
SDL_BlitSurface(layers[LAYER_EFFECTS], NULL, display, NULL);
}

Here are a list of thoughts:

  1. Unless the background (BG) is actually the same size as the display
    (i.e., you aren’t using it for a larger map, with only a small part of
    it being copied), then, you’ll have to add an additional blit to setup
    the BG. It would be more optimal (performance), but more costly (RAM) to
    have a larger ‘BG layer’, with a moving window into that layer.

  2. Setting up the sprites in a separate layer just adds an additional
    blit, when you could just blit the BG into the display then blit the
    sprites in. This would save in memory bandwidth and or CPU time, as
    you’re moving less about (blitting the entire surface would involve
    alpha testing every pixel). Granted, if sprites aren’t moving, then
    you’re going to save in function call overhead, but then, sprites are
    generally supposed to be moving, so it’s doubtful whether you’d
    actually save anything…

  3. ‘Effect’ implies things that aren’t too common / have limited
    lifespan. Again, you’re probably just adding additional an additional
    blit, as in 2.

Eddy

julien CLEMENT wrote:> Hi,

Will, you might confuse me with another person, although I’ve used
IRC in the past :slight_smile:
The first goal is not really to make a parallax scrolling mechanism,
although I have mentioned it in the previous message.
The main concern is, I have a graphical application which needs
more than one display layer/plane, and there’re some sprites/animations
on those layers/planes, and of course, if something gets modified on a layer
I need to re- “project” all the other layers on the screen in the right
order for
the modified area. This is a really annoying task for a game developer I
think,
that’s why I’m proposing this tool.
Z-buffering is a technic aimed at 3D rendering: you can look at:
http://en.wikipedia.org/wiki/Z-buffer
It is something far easier I want to do, and yet maybe it can help.

Let me know, I wouldn’t begin a development without knowing if there is some
kind of interest.

By the way, thank you Edward for your message. You can help in a simple
manner:
look at the interface I’ve sent and tell me if you see missing
functionalities, and if
you imagine you can use such functions in your programs. You can mail me
directly
if you want.

Thank you guys, other comments/suggestions/ideas are welcome !

Regards

Julien


Envoy? avec Yahoo! Mail
http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=52423/*http://fr.docs.yahoo.com/mail/overview/index.html.
Une boite mail plus intelligente.



SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org