annotate test/testmmousetablet.c @ 3100:7dc982143c06

Date: Sun, 22 Mar 2009 12:52:29 +0000 From: Luke Benstead Subject: OpenGL 3.0 Context Creation I've attached a patch which implements OpenGL 3.x context creation on the latest SVN. I've added two options to SDL_GL_SetAttribute, these are SDL_GL_CONTEXT_MAJOR_VERSION and SDL_GL_CONTEXT_MINOR_VERSION. These default to 2 and 1 respectively. If the major version is less than 3 then the current context creation method is used, otherwise the appropriate new context creation function is called (depending on the platform). Sample code: if (SDL_Init(SDL_INIT_VIDEO) != 0) { printf("Unable to initialize SDL: %s\n", SDL_GetError()); return 1; } SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); //Without these 2 lines, SDL will create a GL 2.x context SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_Surface* screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL | SDL_FULLSCREEN ); I've implemented context creation on both Win32 and X and run basic tests on both. This patch doesn't provide access to all the options allowed by the new context creation (e.g. shared contexts, forward compatible contexts) but they can be added pretty easily.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 24 Mar 2009 10:43:53 +0000
parents ae653575d4af
children 975fd903466b
rev   line source
2734
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
1 #include <stdio.h>
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
2 #include "SDL.h"
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
3
2736
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
4 SDL_Surface *screen;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
5 int quit = 0;
2734
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
6
2736
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
7 int
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
8 main()
2734
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
9 {
2736
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
10 SDL_Event event;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
11 int mice;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
12 int i;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
13 printf("Initing...\n");
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
14 if (SDL_Init(0) != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
15 return 1;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
16 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
17 if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
18 return 1;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
19 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
20 screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
21 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
22 mice = SDL_GetNumMice();
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
23 printf("%d pointing devices found\n", mice);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
24 for (i = 0; i < mice; ++i) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
25 printf("device index: %d name:%s\n", i, SDL_GetMouseName(i));
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
26 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
27 while (quit != 1) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
28 if (SDL_PollEvent(&event) == 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
29 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
30 switch (event.type) {
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
31 case SDL_MOUSEMOTION:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
32 printf
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
33 ("Device id: %d x: %d y: %d relx: %d rely: %d pressure: %d\n \
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
34 pressure_max: %d pressure_min: %d current cursor:%d\n",
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
35 event.motion.which, event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel,
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
36 event.motion.pressure, event.motion.pressure_max, event.motion.pressure_min,
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
37 event.motion.cursor);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
38 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
39 case SDL_PROXIMITYIN:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
40 printf("proximity in id: %d x: %d y: %d\n",
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
41 (int) event.proximity.which, event.proximity.x,
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
42 event.proximity.y);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
43 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
44 case SDL_PROXIMITYOUT:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
45 printf("proximity out id: %d x: %d y: %d\n",
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
46 (int) event.proximity.which, event.proximity.x,
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
47 event.proximity.y);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
48 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
49 case SDL_MOUSEBUTTONDOWN:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
50 printf("mouse button down id: %d button:%d\n",
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
51 event.button.which, event.button.button);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
52 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
53 case SDL_MOUSEBUTTONUP:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
54 printf("mouse button up id: %d button: %d\n",
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
55 event.button.which, event.button.button);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
56 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
57 case SDL_QUIT:
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
58 printf("Quitting\n");
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
59 SDL_QuitSubSystem(SDL_INIT_VIDEO);
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
60 SDL_Quit();
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
61 quit = 1;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
62 break;
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
63 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
64 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
65 }
Sam Lantinga <slouken@libsdl.org>
parents: 2734
diff changeset
66 return 0;
2734
dd25eabe441c Many mouse and tablet linux test file added
Szymon Wilczek <kazeuser@gmail.com>
parents:
diff changeset
67 }