Module: wine Branch: master Commit: 50861156e25467b84406e01e70513e85d0b7b791 URL: http://source.winehq.org/git/wine.git/?a=commit;h=50861156e25467b84406e01e70...
Author: Matteo Bruni mbruni@codeweavers.com Date: Wed Mar 18 21:07:35 2015 +0100
wined3d: Introduce a get_modelview_matrix() function.
---
dlls/wined3d/state.c | 17 +++++------------ dlls/wined3d/utils.c | 8 ++++++++ dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 67570d5..f434a99 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3844,6 +3844,7 @@ static void shader_bumpenv(struct wined3d_context *context, const struct wined3d void transform_world(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_info *gl_info = context->gl_info; + struct wined3d_matrix mat;
/* This function is called by transform_view below if the view matrix was changed too * @@ -3855,18 +3856,10 @@ void transform_world(struct wined3d_context *context, const struct wined3d_state gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW); checkGLcall("glMatrixMode");
- if (context->last_was_rhw) - { - gl_info->gl_ops.gl.p_glLoadIdentity(); - checkGLcall("glLoadIdentity()"); - } - else - { - gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW].u.m[0][0]); - checkGLcall("glLoadMatrixf"); - gl_info->gl_ops.gl.p_glMultMatrixf(&state->transforms[WINED3D_TS_WORLD_MATRIX(0)].u.m[0][0]); - checkGLcall("glMultMatrixf"); - } + get_modelview_matrix(context, state, &mat); + + gl_info->gl_ops.gl.p_glLoadMatrixf((GLfloat *)&mat); + checkGLcall("glLoadMatrixf"); }
void clipplane(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 551dca8..116ab9a 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -3130,6 +3130,14 @@ void get_identity_matrix(struct wined3d_matrix *mat) *mat = identity; }
+void get_modelview_matrix(const struct wined3d_context *context, const struct wined3d_state *state, struct wined3d_matrix *mat) +{ + if (context->last_was_rhw) + get_identity_matrix(mat); + else + multiply_matrix(mat, &state->transforms[WINED3D_TS_VIEW], &state->transforms[WINED3D_TS_WORLD_MATRIX(0)]); +} + /* Setup this textures matrix according to the texture flags. */ /* Context activation is done by the caller (state handler). */ void set_texture_matrix(const struct wined3d_gl_info *gl_info, const float *smat, DWORD flags, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 4f03b1b..8d000e8 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3038,6 +3038,8 @@ static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader, }
void get_identity_matrix(struct wined3d_matrix *mat) DECLSPEC_HIDDEN; +void get_modelview_matrix(const struct wined3d_context *context, const struct wined3d_state *state, + struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
/* Using additional shader constants (uniforms in GLSL / program environment * or local parameters in ARB) is costly: