annotate test/testeyes.c @ 4785:ef8b32ef9793

Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
author Eli Gottlieb <eligottlieb@gmail.com>
date Tue, 06 Jul 2010 22:05:22 -0400
parents cf7976fd3258
children 6f0bc179771c
rev   line source
4770
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
1 #include <stdlib.h>
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
2 #include <math.h>
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
3 #include <SDL_events.h>
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
4 #include <SDL_rect.h>
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
5 #include <SDL_pixels.h>
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
6 #include <SDL_video.h>
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
7 #include <SDL_shape.h>
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
8 #include "testeyes_bitmap.h"
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
9 #include "testeyes_mask_bitmap.h"
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
10
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
11 /* The following code for the calculation of pupil positions has been taken and rewritten from the original xeyes. The
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
12 copyright notice is included as follows, and the code is now under the same license as the rest of this file. */
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
13 /*
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
14
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
15 Copyright (c) 1991 X Consortium
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
16
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
17 Permission is hereby granted, free of charge, to any person obtaining
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
18 a copy of this software and associated documentation files (the
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
19 "Software"), to deal in the Software without restriction, including
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
20 without limitation the rights to use, copy, modify, merge, publish,
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
21 distribute, sublicense, and/or sell copies of the Software, and to
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
22 permit persons to whom the Software is furnished to do so, subject to
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
23 the following conditions:
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
24
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
25 The above copyright notice and this permission notice shall be included
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
26 in all copies or substantial portions of the Software.
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
27
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
28 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
29 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
30 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
31 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
32 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
33 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
34 OTHER DEALINGS IN THE SOFTWARE.
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
35
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
36 Except as contained in this notice, the name of the X Consortium shall
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
37 not be used in advertising or otherwise to promote the sale, use or
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
38 other dealings in this Software without prior written authorization
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
39 from the X Consortium.
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
40
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
41 */
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
42 # define NUM_EYES 2
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
43 # define EYE_X(n) ((n) * 2.0)
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
44 # define EYE_Y(n) (0.0)
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
45 # define EYE_THICK (0.175) /* thickness of eye rim */
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
46 # define EYE_OFFSET (0.1) /* padding between eyes */
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
47 # define EYE_WIDTH (2.0 - (EYE_THICK + EYE_OFFSET) * 2)
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
48 # define EYE_HEIGHT EYE_WIDTH
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
49 # define EYE_HWIDTH (EYE_WIDTH / 2.0)
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
50 # define EYE_HHEIGHT (EYE_HEIGHT / 2.0)
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
51 # define BALL_WIDTH (0.3)
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
52 # define BALL_HEIGHT BALL_WIDTH
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
53 # define BALL_PAD (0.05)
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
54 # define BALL_DIST ((EYE_WIDTH - BALL_WIDTH) / 2.0 - BALL_PAD)
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
55
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
56 SDL_Point computePupil (int num,SDL_Point mouse) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
57 double dx = mouse.x - EYE_X(num);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
58 double dy = mouse.y - EYE_Y(num);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
59 double cx = 0.0,cy = 0.0;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
60 if(dx == 0 && dy == 0) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
61 cx = EYE_X(num);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
62 cy = EYE_Y(num);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
63 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
64 else {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
65 double angle = atan2((double)dy,(double)dx);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
66 double cosa = cos(angle);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
67 double sina = sin(angle);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
68 double hypotenuse = hypot(EYE_HHEIGHT * cosa, EYE_HWIDTH * sina);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
69 double dist = BALL_DIST * hypot((EYE_HWIDTH * EYE_HHEIGHT) * cosa / hypotenuse,
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
70 (EYE_HWIDTH * EYE_HHEIGHT) * sina / hypotenuse);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
71 if(dist > hypot((double)dx,(double)dy)) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
72 cx = dx + EYE_X(num);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
73 cy = dy + EYE_Y(num);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
74 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
75 else {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
76 cx = dist * cosa + EYE_X(num);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
77 cy = dist * sina + EYE_Y(num);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
78 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
79 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
80 SDL_Point ret = {cx,cy};
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
81 return ret;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
82 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
83
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
84 /* Here begins the code exclusively and entirely written by Eli Gottlieb in May 2010. */
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
85 typedef struct {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
86 SDL_Rect left;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
87 SDL_Rect right;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
88 } Pupil_Pair;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
89 typedef struct {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
90 SDL_Point left;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
91 SDL_Point right;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
92 } Pupil_Points;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
93
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
94 Pupil_Pair compute_pupil_positions(SDL_Point target) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
95 Pupil_Pair result;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
96 Pupil_Points points;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
97 points.left = computePupil(0,target);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
98 points.right = computePupil(1,target);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
99 result.left.x = points.left.x - BALL_WIDTH / 2.0;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
100 result.left.y = points.left.y - BALL_HEIGHT / 2.0;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
101 result.right.x = points.right.x - BALL_WIDTH / 2.0;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
102 result.right.y = points.right.y - BALL_HEIGHT / 2.0;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
103 result.left.w = result.right.w = BALL_WIDTH;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
104 result.left.h = result.left.w = BALL_HEIGHT;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
105 return result;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
106 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
107
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
108 void render_eyes(SDL_Window *window,SDL_Texture *eyes_texture,Pupil_Pair pupils) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
109 SDL_SelectRenderer(window);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
110
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
111 //Clear render-target to blue.
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
112 SDL_SetRenderDrawColor(0x00,0x00,0xff,0xff);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
113 SDL_RenderClear();
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
114
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
115 //Render the whites of the eyes.
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
116 SDL_Rect srcdestrect = {0,0,eyes_width,eyes_height};
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
117 SDL_RenderCopy(eyes_texture,&srcdestrect,&srcdestrect);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
118
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
119 //Render the pupils.
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
120 SDL_SetRenderDrawColor(0x00,0x00,0x00,0xff);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
121 const SDL_Rect eyes[2] = {pupils.left,pupils.right};
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
122 SDL_RenderFillRects((const SDL_Rect**)&eyes,2);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
123
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
124 SDL_RenderPresent();
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
125 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
126
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
127 int main(int argc,char** argv) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
128 if(SDL_VideoInit(NULL,0) == -1) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
129 printf("Could not initialize SDL video.\n");
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
130 exit(-1);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
131 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
132
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
133 SDL_Window *window = SDL_CreateShapedWindow("Big Brother is watching you.",eyes_x_hot,eyes_y_hot,eyes_width,eyes_height,SDL_WINDOW_RESIZABLE);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
134 if(window == NULL) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
135 SDL_VideoQuit();
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
136 printf("Could not create shaped window for eyes.\n");
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
137 exit(-2);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
138 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
139 if(SDL_CreateRenderer(window,-1,SDL_RENDERER_PRESENTFLIP2) == -1) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
140 SDL_DestroyWindow(window);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
141 SDL_VideoQuit();
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
142 printf("Could not create rendering context for SDL_Eyes window.\n");
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
143 exit(-3);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
144 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
145
4785
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
146 SDL_Color bnw_palette[2] = {{0,0,0,255},{255,255,255,255}};
4770
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
147 SDL_Texture *eyes_texture = SDL_CreateTexture(SDL_PIXELFORMAT_INDEX1LSB,SDL_TEXTUREACCESS_STREAMING,eyes_width,eyes_height);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
148 if(eyes_texture == NULL) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
149 SDL_DestroyRenderer(window);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
150 SDL_DestroyWindow(window);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
151 SDL_VideoQuit();
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
152 printf("Could not create eyes texture.\n");
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
153 exit(-4);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
154 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
155 SDL_SetTexturePalette(eyes_texture,bnw_palette,0,2);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
156
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
157 void *pixels = NULL;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
158 int pitch = 0;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
159 SDL_Rect rect = {0,0,eyes_width,eyes_height};
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
160 SDL_LockTexture(eyes_texture,&rect,1,&pixels,&pitch);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
161 for(int row = 0;row<eyes_height;row++)
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
162 memcpy(pixels+pitch*row,eyes_bits+(eyes_width/8)*row,eyes_width/8);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
163 SDL_UnlockTexture(eyes_texture);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
164
4785
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
165 int bpp = 0;
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
166 Uint32 r = 0,g = 0,b = 0,a = 0;
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
167 SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ARGB4444,&bpp,&r,&g,&b,&a);
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
168 SDL_Surface *mask = SDL_CreateRGBSurface(0,eyesmask_width,eyesmask_height,bpp,r,g,b,a);
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
169 if(mask == NULL) {
4770
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
170 SDL_DestroyTexture(eyes_texture);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
171 SDL_DestroyRenderer(window);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
172 SDL_DestroyWindow(window);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
173 SDL_VideoQuit();
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
174 printf("Could not create shape mask texture.\n");
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
175 exit(-5);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
176 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
177
4785
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
178 if(SDL_MUSTLOCK(mask))
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
179 SDL_LockSurface(mask);
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
180 pixels = mask->pixels;
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
181 for(int y=0;y<eyesmask_height;y++)
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
182 for(int x=0;x<eyesmask_width;x++) {
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
183 Uint8 alpha = *(Uint8*)(eyesmask_bits+(eyesmask_width/8)*y+(x/8)) & (1 << (7 - x % 8)) ? 1 : 0;
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
184 *(Uint16*)(pixels+pitch*y+x*bpp/8) = SDL_MapRGBA(mask->format,0,0,0,alpha);
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
185 }
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
186 if(SDL_MUSTLOCK(mask))
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
187 SDL_UnlockSurface(mask);
4770
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
188
4785
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
189 SDL_WindowShapeMode mode = {ShapeModeDefault,1};
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
190 SDL_SetWindowShape(window,mask,&mode);
4770
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
191
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
192 SDL_Event event;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
193 int event_pending = 0;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
194 event_pending = SDL_PollEvent(&event);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
195 SDL_Point mouse_position;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
196 Pupil_Pair pupil_positions;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
197 SDL_SelectMouse(0);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
198 SDL_GetMouseState(&mouse_position.x,&mouse_position.y);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
199 pupil_positions = compute_pupil_positions(mouse_position);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
200 while(event.type != SDL_QUIT) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
201 if(event.type == SDL_MOUSEMOTION) {
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
202 mouse_position.x = event.motion.x;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
203 mouse_position.y = event.motion.y;
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
204 pupil_positions = compute_pupil_positions(mouse_position);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
205 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
206 render_eyes(window,eyes_texture,pupil_positions);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
207 event_pending = SDL_PollEvent(&event);
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
208 }
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
209
4785
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
210 SDL_FreeSurface(mask);
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
211 SDL_DestroyTexture(eyes_texture);
ef8b32ef9793 Updated test code, updated win32 code a bit (still not complete, but hopefully tonight), and removed the last vestiges of ellipse and polygon drawing support.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4770
diff changeset
212 SDL_DestroyWindow(window);
4770
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
213 //Call SDL_VideoQuit() before quitting.
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
214 SDL_VideoQuit();
cf7976fd3258 Moved the SDL_Eyes test program for shaped windows into the Hg repository and got it building and linking as a test.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
215 }