2007-10-12 04:17:00 -04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2007-05-02 16:05:29 -04:00
|
|
|
#include "config.h"
|
2007-10-12 04:17:00 -04:00
|
|
|
#endif
|
2007-05-02 16:05:29 -04:00
|
|
|
|
|
|
|
#include "clutter-stage-sdl.h"
|
|
|
|
#include "clutter-sdl.h"
|
|
|
|
|
|
|
|
#include "../clutter-main.h"
|
|
|
|
#include "../clutter-feature.h"
|
|
|
|
#include "../clutter-color.h"
|
|
|
|
#include "../clutter-util.h"
|
|
|
|
#include "../clutter-event.h"
|
|
|
|
#include "../clutter-enum-types.h"
|
|
|
|
#include "../clutter-private.h"
|
|
|
|
#include "../clutter-debug.h"
|
2007-05-22 05:31:40 -04:00
|
|
|
#include "../clutter-units.h"
|
2008-04-25 08:17:01 -04:00
|
|
|
#include "../clutter-stage-window.h"
|
2007-05-02 16:05:29 -04:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
#include "cogl/cogl.h"
|
2007-05-02 16:05:29 -04:00
|
|
|
|
2008-04-25 08:17:01 -04:00
|
|
|
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (ClutterStageSDL,
|
|
|
|
clutter_stage_sdl,
|
|
|
|
CLUTTER_TYPE_ACTOR,
|
|
|
|
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW,
|
|
|
|
clutter_stage_window_iface_init));
|
2007-05-02 16:05:29 -04:00
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_sdl_show (ClutterActor *actor)
|
|
|
|
{
|
2007-11-26 07:07:25 -05:00
|
|
|
CLUTTER_ACTOR_SET_FLAGS (actor, CLUTTER_ACTOR_MAPPED);
|
2009-03-09 14:40:58 -04:00
|
|
|
CLUTTER_ACTOR_SET_FLAGS (CLUTTER_STAGE_SDL (actor)->wrapper,
|
|
|
|
CLUTTER_ACTOR_MAPPED);
|
2007-11-26 07:07:25 -05:00
|
|
|
|
|
|
|
CLUTTER_ACTOR_CLASS (clutter_stage_sdl_parent_class)->show (actor);
|
2007-05-02 16:05:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_sdl_hide (ClutterActor *actor)
|
|
|
|
{
|
|
|
|
/* No way to easily unmap SDL window ? */
|
2007-11-26 07:07:25 -05:00
|
|
|
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_MAPPED);
|
2009-03-09 14:40:58 -04:00
|
|
|
CLUTTER_ACTOR_UNSET_FLAGS (CLUTTER_STAGE_SDL (actor)->wrapper,
|
|
|
|
CLUTTER_ACTOR_MAPPED);
|
2007-11-26 07:07:25 -05:00
|
|
|
|
|
|
|
CLUTTER_ACTOR_CLASS (clutter_stage_sdl_parent_class)->hide (actor);
|
2007-05-02 16:05:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_sdl_unrealize (ClutterActor *actor)
|
|
|
|
{
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_sdl_realize (ClutterActor *actor)
|
|
|
|
{
|
|
|
|
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (actor);
|
|
|
|
gboolean is_offscreen, is_fullscreen;
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "Realizing main stage");
|
|
|
|
|
2008-04-25 08:17:01 -04:00
|
|
|
is_offscreen = is_fullscreen = FALSE;
|
|
|
|
g_object_get (stage_sdl->wrapper,
|
|
|
|
"offscreen", &is_offscreen,
|
|
|
|
"fullscreen", &is_fullscreen,
|
|
|
|
NULL);
|
2007-05-02 16:05:29 -04:00
|
|
|
|
|
|
|
if (G_LIKELY (!is_offscreen))
|
|
|
|
{
|
|
|
|
gint flags = SDL_OPENGL;
|
|
|
|
|
2008-04-25 08:17:01 -04:00
|
|
|
if (is_fullscreen)
|
|
|
|
flags |= SDL_FULLSCREEN;
|
2007-05-02 16:05:29 -04:00
|
|
|
|
2008-04-25 08:17:01 -04:00
|
|
|
SDL_GL_SetAttribute (SDL_GL_ACCUM_RED_SIZE, 0);
|
|
|
|
SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
|
|
|
|
SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
|
|
|
|
SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
|
2007-05-02 16:05:29 -04:00
|
|
|
|
2008-04-25 08:17:01 -04:00
|
|
|
if (SDL_SetVideoMode (stage_sdl->win_width,
|
|
|
|
stage_sdl->win_height,
|
|
|
|
0, flags) == NULL)
|
2007-05-02 16:05:29 -04:00
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "SDL appears not to handle this mode - %s",
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 11:26:37 -04:00
|
|
|
SDL_GetError ());
|
2008-04-25 08:17:01 -04:00
|
|
|
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 11:26:37 -04:00
|
|
|
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
|
|
|
return;
|
2007-05-02 16:05:29 -04:00
|
|
|
}
|
2008-04-25 08:17:01 -04:00
|
|
|
else
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 11:26:37 -04:00
|
|
|
CLUTTER_ACTOR_SET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
2007-05-02 16:05:29 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME */
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 11:26:37 -04:00
|
|
|
g_critical ("SDL Backend does not yet support offscreen rendering");
|
2008-04-25 08:17:01 -04:00
|
|
|
|
2007-05-02 16:05:29 -04:00
|
|
|
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-06-11 06:12:44 -04:00
|
|
|
clutter_stage_sdl_get_preferred_width (ClutterActor *self,
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 11:44:47 -04:00
|
|
|
gfloat for_height,
|
|
|
|
gfloat *min_width_p,
|
|
|
|
gfloat *natural_width_p)
|
2007-05-02 16:05:29 -04:00
|
|
|
{
|
|
|
|
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (self);
|
|
|
|
|
2008-06-11 06:12:44 -04:00
|
|
|
if (min_width_p)
|
|
|
|
*min_width_p = CLUTTER_UNITS_FROM_DEVICE (stage_sdl->win_width);
|
|
|
|
|
|
|
|
if (natural_width_p)
|
|
|
|
*natural_width_p = CLUTTER_UNITS_FROM_DEVICE (stage_sdl->win_width);
|
2007-05-02 16:05:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-06-11 06:12:44 -04:00
|
|
|
clutter_stage_sdl_get_preferred_height (ClutterActor *self,
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 11:44:47 -04:00
|
|
|
gfloat for_width,
|
|
|
|
gfloat *min_height_p,
|
|
|
|
gfloat *natural_height_p)
|
2008-06-11 06:12:44 -04:00
|
|
|
{
|
|
|
|
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (self);
|
|
|
|
|
|
|
|
if (min_height_p)
|
|
|
|
*min_height_p = CLUTTER_UNITS_FROM_DEVICE (stage_sdl->win_height);
|
|
|
|
|
|
|
|
if (natural_height_p)
|
|
|
|
*natural_height_p = CLUTTER_UNITS_FROM_DEVICE (stage_sdl->win_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-06-03 09:02:06 -04:00
|
|
|
clutter_stage_sdl_allocate (ClutterActor *self,
|
|
|
|
const ClutterActorBox *box,
|
|
|
|
ClutterAllocationFlags flags)
|
2007-05-02 16:05:29 -04:00
|
|
|
{
|
|
|
|
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (self);
|
|
|
|
gint new_width, new_height;
|
2008-06-11 06:12:44 -04:00
|
|
|
ClutterActorClass *parent_class;
|
2007-05-02 16:05:29 -04:00
|
|
|
|
2008-06-11 06:12:44 -04:00
|
|
|
/* FIXME: some how have X configure_notfiy call this ? */
|
2007-05-22 05:31:40 -04:00
|
|
|
new_width = ABS (CLUTTER_UNITS_TO_INT (box->x2 - box->x1));
|
|
|
|
new_height = ABS (CLUTTER_UNITS_TO_INT (box->y2 - box->y1));
|
2007-05-02 16:05:29 -04:00
|
|
|
|
|
|
|
if (new_width != stage_sdl->win_width ||
|
|
|
|
new_height != stage_sdl->win_height)
|
|
|
|
{
|
|
|
|
if (SDL_SetVideoMode(new_width,
|
|
|
|
new_height,
|
|
|
|
0, SDL_OPENGL) == NULL)
|
|
|
|
{
|
|
|
|
/* Failed */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
stage_sdl->win_width = new_width;
|
|
|
|
stage_sdl->win_height = new_height;
|
|
|
|
|
2008-04-25 08:17:01 -04:00
|
|
|
CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_SYNC_MATRICES);
|
2007-05-02 16:05:29 -04:00
|
|
|
}
|
2008-04-25 08:17:01 -04:00
|
|
|
|
2008-06-11 06:12:44 -04:00
|
|
|
parent_class = CLUTTER_ACTOR_CLASS (clutter_stage_sdl_parent_class);
|
2009-06-03 09:02:06 -04:00
|
|
|
parent_class->allocate (self, box, flags);
|
2007-05-02 16:05:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-04-25 08:17:01 -04:00
|
|
|
clutter_stage_sdl_set_fullscreen (ClutterStageWindow *stage_window,
|
|
|
|
gboolean fullscreen)
|
2007-05-02 16:05:29 -04:00
|
|
|
{
|
2008-04-25 08:17:01 -04:00
|
|
|
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (stage_window);
|
2007-05-02 16:05:29 -04:00
|
|
|
int flags = SDL_OPENGL;
|
|
|
|
|
2008-04-25 08:17:01 -04:00
|
|
|
if (fullscreen)
|
|
|
|
flags |= SDL_FULLSCREEN;
|
2007-05-02 16:05:29 -04:00
|
|
|
|
2008-06-11 06:12:44 -04:00
|
|
|
SDL_SetVideoMode (stage_sdl->win_width,
|
|
|
|
stage_sdl->win_height,
|
|
|
|
0, flags);
|
2007-05-02 16:05:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-04-25 08:17:01 -04:00
|
|
|
clutter_stage_sdl_set_cursor_visible (ClutterStageWindow *stage_window,
|
|
|
|
gboolean show_cursor)
|
2007-05-02 16:05:29 -04:00
|
|
|
{
|
2008-04-25 08:17:01 -04:00
|
|
|
SDL_ShowCursor (show_cursor);
|
2007-05-02 16:05:29 -04:00
|
|
|
}
|
|
|
|
|
2007-06-19 05:10:37 -04:00
|
|
|
static void
|
2008-04-25 08:17:01 -04:00
|
|
|
clutter_stage_sdl_set_title (ClutterStageWindow *stage_window,
|
|
|
|
const gchar *title)
|
2007-06-19 05:10:37 -04:00
|
|
|
{
|
|
|
|
SDL_WM_SetCaption (title, NULL);
|
|
|
|
}
|
|
|
|
|
2007-05-02 16:05:29 -04:00
|
|
|
static void
|
|
|
|
clutter_stage_sdl_dispose (GObject *gobject)
|
|
|
|
{
|
|
|
|
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (gobject);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_stage_sdl_parent_class)->dispose (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_sdl_class_init (ClutterStageSDLClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->dispose = clutter_stage_sdl_dispose;
|
|
|
|
|
|
|
|
actor_class->show = clutter_stage_sdl_show;
|
|
|
|
actor_class->hide = clutter_stage_sdl_hide;
|
|
|
|
actor_class->realize = clutter_stage_sdl_realize;
|
|
|
|
actor_class->unrealize = clutter_stage_sdl_unrealize;
|
2008-06-11 06:12:44 -04:00
|
|
|
actor_class->get_preferred_width = clutter_stage_sdl_get_preferred_width;
|
|
|
|
actor_class->get_preferred_height = clutter_stage_sdl_get_preferred_height;
|
|
|
|
actor_class->allocate = clutter_stage_sdl_allocate;
|
2008-04-25 08:17:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
|
|
|
{
|
|
|
|
iface->set_fullscreen = clutter_stage_sdl_set_fullscreen;
|
|
|
|
iface->set_cursor_visible = clutter_stage_sdl_set_cursor_visible;
|
|
|
|
iface->set_title = clutter_stage_sdl_set_title;
|
2007-05-02 16:05:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_sdl_init (ClutterStageSDL *stage)
|
|
|
|
{
|
|
|
|
stage->win_width = 640;
|
|
|
|
stage->win_height = 480;
|
|
|
|
}
|
|
|
|
|