From 4698483f849ba8dfde20a5d649f1ea099291f241 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 13 Aug 2007 18:16:11 -0600 Subject: Added st_fb_orientation() function to determine the up/down orientation of the framebuffer. --- src/mesa/state_tracker/st_context.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/mesa/state_tracker/st_context.h') diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 8d82d53133..13843d9b7f 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -118,5 +118,32 @@ extern void st_init_driver_functions(struct dd_function_table *functions); +#define Y_0_TOP 1 +#define Y_0_BOTTOM 2 + +static INLINE GLuint +st_fb_orientation(const struct gl_framebuffer *fb) +{ + if (fb && fb->Name == 0) { + /* Drawing into a window (on-screen buffer). + * + * Negate Y scale to flip image vertically. + * The NDC Y coords prior to viewport transformation are in the range + * [y=-1=bottom, y=1=top] + * Hardware window coords are in the range [y=0=top, y=H-1=bottom] where + * H is the window height. + * Use the viewport transformation to invert Y. + */ + return Y_0_TOP; + } + else { + /* Drawing into user-created FBO (very likely a texture). + * + * For textures, T=0=Bottom, so by extension Y=0=Bottom for rendering. + */ + return Y_0_BOTTOM; + } +} + #endif -- cgit v1.2.3