more of projection work

This commit is contained in:
Tomas Frydrych 2007-06-13 11:20:10 +00:00
parent 5f4a7a4812
commit 14e00cb904
6 changed files with 59 additions and 16 deletions

View File

@ -1,3 +1,20 @@
2007-06-13 Tomas Frydrych <tf@openedhand.com>
* clutter/clutter-actor.c:
(clutter_actor_project_vertices):
(clutter_actor_project_proint):
Fixed translation of Y coords to match the windowing system.
* clutter/egl/clutter-stage-egl.c:
* clutter/glx/clutter-stage-glx.c:
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_*_request_size):
Initialize viewport when setting/resetting stage side.
* tests/Makefile.am
* tests/test-project.c:
An interactive test of the projection stuff.
2007-06-12 Tomas Frydrych <tf@openedhand.com>
* clutter/clutter-main.c:

View File

@ -370,6 +370,10 @@ clutter_actor_transform_point (ClutterActor *actor,
((CFX_DIV (x,w) + CFX_ONE) >> 1), v1) \
+ v2)
#define MTX_GL_SCALE_Y(y,w,v1,v2) (v1 - CFX_MUL( \
((CFX_DIV (y,w) + CFX_ONE) >> 1), v1) \
+ v2)
#define MTX_GL_SCALE_Z(z,w) ((CFX_DIV (z,w) + CFX_ONE) >> 1)
/**
@ -404,8 +408,8 @@ clutter_actor_project_point (ClutterActor *self,
mtx_transform (mtx_p, x, y, z, &w);
*x = MTX_GL_SCALE(*x,w,v[2],v[0]);
*y = MTX_GL_SCALE(*y,w,v[3],v[1]);
*z = MTX_GL_SCALE_Z(*z,w);
*y = MTX_GL_SCALE_Y(*y,w,v[3],v[1]);
*z = MTX_GL_SCALE(*z,w,v[2],v[0]);
}
/* Recursively tranform supplied vertices with the tranform for the current
@ -570,8 +574,8 @@ clutter_actor_project_vertices (ClutterActor * self,
&w[0]);
verts[0].x = MTX_GL_SCALE (verts[0].x, w[0], v[2], v[0]);
verts[0].y = MTX_GL_SCALE (verts[0].y, w[0], v[3], v[1]);
verts[0].z = MTX_GL_SCALE_Z (verts[0].z, w[0]);
verts[0].y = MTX_GL_SCALE_Y (verts[0].y, w[0], v[3], v[1]);
verts[0].z = MTX_GL_SCALE (verts[0].z, w[0], v[2], v[0]);
mtx_transform (mtx_p,
&verts[1].x,
@ -580,8 +584,8 @@ clutter_actor_project_vertices (ClutterActor * self,
&w[1]);
verts[1].x = MTX_GL_SCALE (verts[1].x, w[1], v[2], v[0]);
verts[1].y = MTX_GL_SCALE (verts[1].y, w[1], v[3], v[1]);
verts[1].z = MTX_GL_SCALE_Z (verts[1].z, w[1]);
verts[1].y = MTX_GL_SCALE_Y (verts[1].y, w[1], v[3], v[1]);
verts[1].z = MTX_GL_SCALE (verts[1].z, w[1], v[2], v[0]);
mtx_transform (mtx_p,
&verts[2].x,
@ -590,8 +594,8 @@ clutter_actor_project_vertices (ClutterActor * self,
&w[2]);
verts[2].x = MTX_GL_SCALE (verts[2].x, w[2], v[2], v[0]);
verts[2].y = MTX_GL_SCALE (verts[2].y, w[2], v[3], v[1]);
verts[2].z = MTX_GL_SCALE_Z (verts[2].z, w[2]);
verts[2].y = MTX_GL_SCALE_Y (verts[2].y, w[2], v[3], v[1]);
verts[2].z = MTX_GL_SCALE (verts[2].z, w[2], v[2], v[0]);
mtx_transform (mtx_p,
&verts[3].x,
@ -600,8 +604,8 @@ clutter_actor_project_vertices (ClutterActor * self,
&w[3]);
verts[3].x = MTX_GL_SCALE (verts[3].x, w[3], v[2], v[0]);
verts[3].y = MTX_GL_SCALE (verts[3].y, w[3], v[3], v[1]);
verts[3].z = MTX_GL_SCALE_Z (verts[3].z, w[3]);
verts[3].y = MTX_GL_SCALE_Y (verts[3].y, w[3], v[3], v[1]);
verts[3].z = MTX_GL_SCALE (verts[3].z, w[3], v[2], v[0]);
#if 0
g_debug ("Projection Matrix:\n"

View File

@ -89,6 +89,7 @@ clutter_stage_egl_realize (ClutterActor *actor)
EGLConfig configs[2];
EGLint config_count;
EGLBoolean status;
ClutterPerspective perspective;
gboolean is_offscreen;
@ -182,7 +183,13 @@ clutter_stage_egl_realize (ClutterActor *actor)
/* FIXME */
}
CLUTTER_SET_PRIVATE_FLAGS(actor, CLUTTER_ACTOR_SYNC_MATRICES);
clutter_stage_get_perspectivex (CLUTTER_STAGE (actor), &perspective);
cogl_setup_viewport (clutter_actor_get_width (actor),
clutter_actor_get_height (actor),
perspective.fovy,
perspective.aspect,
perspective.z_near,
perspective.z_far);
}
static void

View File

@ -129,6 +129,7 @@ clutter_stage_glx_realize (ClutterActor *actor)
{
ClutterStageGLX *stage_glx = CLUTTER_STAGE_GLX (actor);
gboolean is_offscreen;
ClutterPerspective perspective;
CLUTTER_NOTE (MISC, "Realizing main stage");
@ -294,8 +295,14 @@ clutter_stage_glx_realize (ClutterActor *actor)
}
CLUTTER_SET_PRIVATE_FLAGS(actor, CLUTTER_ACTOR_SYNC_MATRICES);
clutter_stage_get_perspectivex (CLUTTER_STAGE (actor), &perspective);
cogl_setup_viewport (clutter_actor_get_width (actor),
clutter_actor_get_height (actor),
perspective.fovy,
perspective.aspect,
perspective.z_near,
perspective.z_far);
return;
fail:

View File

@ -42,6 +42,7 @@ clutter_stage_sdl_realize (ClutterActor *actor)
ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (actor);
gboolean is_offscreen, is_fullscreen;
ClutterPerspective perspective;
CLUTTER_NOTE (BACKEND, "Realizing main stage");
@ -77,7 +78,13 @@ clutter_stage_sdl_realize (ClutterActor *actor)
return;
}
CLUTTER_SET_PRIVATE_FLAGS(actor, CLUTTER_ACTOR_SYNC_MATRICES);
clutter_stage_get_perspectivex (CLUTTER_STAGE (actor), &perspective);
cogl_setup_viewport (clutter_actor_get_width (actor),
clutter_actor_get_height (actor),
perspective.fovy,
perspective.aspect,
perspective.z_near,
perspective.z_far);
}
static void

View File

@ -1,5 +1,5 @@
noinst_PROGRAMS = test-textures test-events test-offscreen test-scale \
test-actors test-behave test-text test-entry
test-actors test-behave test-text test-entry test-project
INCLUDES = -I$(top_srcdir)/
LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la
@ -13,4 +13,5 @@ test_scale_SOURCES = test-scale.c
test_actor_SOURCES = test-actors.c
test_behave_SOURCES = test-behave.c
test_text_SOURCES = test-text.c
test_entry_SOURCES = test-entry.c
test_entry_SOURCES = test-entry.c
test_project_SOURCES = test-project.c