Search
lxdream.org :: lxdream/src/drivers/video_gl.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/video_gl.c
changeset 854:130928a3cdcb
prev736:a02d1475ccfd
next1076:18c164e8aec4
author nkeynes
date Tue Sep 09 00:51:43 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Add general gl_window_to_system_coords function to convert window system coordinates
back into something in the DC range of 640x480, update mouse events to use it
file annotate diff log raw
1.1 --- a/src/drivers/video_gl.c Mon Jul 14 07:44:42 2008 +0000
1.2 +++ b/src/drivers/video_gl.c Tue Sep 09 00:51:43 2008 +0000
1.3 @@ -51,6 +51,34 @@
1.4 gl_texture_window( buffer->width, buffer->height, buffer->buf_id, buffer->inverted );
1.5 }
1.6
1.7 +/**
1.8 + * Convert window coordinates to dreamcast device coords (640x480) using the
1.9 + * same viewable area as gl_texture_window.
1.10 + * If the coordinates are outside the viewable area, the result is -1,-1.
1.11 + */
1.12 +void gl_window_to_system_coords( int *x, int *y )
1.13 +{
1.14 + int x1=0,y1=0,x2=video_width,y2=video_height;
1.15 +
1.16 + int ah = video_width * 0.75;
1.17 +
1.18 + if( ah > video_height ) {
1.19 + int w = (video_height/0.75);
1.20 + x1 = (video_width - w)/2;
1.21 + x2 -= x1;
1.22 + } else if( ah < video_height ) {
1.23 + y1 = (video_height - ah)/2;
1.24 + y2 -= y1;
1.25 + }
1.26 + if( *x < x1 || *x >= x2 || *y < y1 || *y >= y2 ) {
1.27 + *x = -1;
1.28 + *y = -1;
1.29 + } else {
1.30 + *x = (*x - x1) * DISPLAY_WIDTH / (x2-x1);
1.31 + *y = (*y - y1) * DISPLAY_HEIGHT / (y2-y1);
1.32 + }
1.33 +}
1.34 +
1.35 void gl_texture_window( int width, int height, int tex_id, gboolean inverted )
1.36 {
1.37 float top, bottom;
.