annotate Xcode/TemplatesForXcode/SDL Custom Cocoa Application/MyController.h @ 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 4d2d0548f5b2
children
rev   line source
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 //
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 // MyController.h
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 // SDL Custom Cocoa App
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 //
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 // Created by Darrell Walisser on Fri Jul 18 2003.
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 // Copyright (c) 2003 __MyCompanyName__. All rights reserved.
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 //
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 #import <Cocoa/Cocoa.h>
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 #import "SDL.h"
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11
2220
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
12 extern id gController; // instance of this class from nib
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 // Declare SDL_QuartzWindowDelegate (defined in SDL.framework)
2220
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
15 @interface SDL_QuartzWindowDelegate : NSObject
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
16 @end
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
17
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
18 @interface MyController : NSObject
2215
23a2cb765052 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
19 {
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 // Interface Builder Outlets
2220
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
21 IBOutlet id _framesPerSecond;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
22 IBOutlet id _numSprites;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
23 IBOutlet id _window;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
24 IBOutlet id _view;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
25
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 // Private instance variables
2220
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
27 int _nSprites;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
28 int _max_speed;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
29 int _doFlip;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
30 Uint8* _mem;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
31
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
32 SDL_Surface* _screen;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
33 SDL_Surface* _sprite;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
34 SDL_Rect* _sprite_rects;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
35 SDL_Rect* _positions;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
36 SDL_Rect* _velocities;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
37 int _sprites_visible;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
38 Uint16 _sprite_w, _sprite_h;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
39
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
40 int _mouse_x, _mouse_y;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
41 }
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
42 // Interface Builder Actions
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
43 - (IBAction)changeNumberOfSprites:(id)sender;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
44 - (IBAction)selectUpdateMode:(id)sender;
4d2d0548f5b2 Don't run indent on the Xcode templates
Sam Lantinga <slouken@libsdl.org>
parents: 2215
diff changeset
45 @end
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
46