make indent
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402573
This commit is contained in:
parent
3c6eee13ae
commit
7d8af0a113
31 changed files with 817 additions and 738 deletions
|
@ -10,4 +10,4 @@
|
||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDLMain.h"
|
#include "SDLMain.h"
|
||||||
|
|
|
@ -7,5 +7,4 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface SDLMain : NSObject
|
@ interface SDLMain:NSObject @ end
|
||||||
@end
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Please see the SDL documentation for details on using the SDL API:
|
Please see the SDL documentation for details on using the SDL API:
|
||||||
/Developer/Documentation/SDL/docs.html
|
/Developer/Documentation/SDL/docs.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -12,54 +12,54 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */
|
Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */
|
||||||
SDL_Surface *screen;
|
SDL_Surface *screen;
|
||||||
Uint8 video_bpp = 0;
|
Uint8 video_bpp = 0;
|
||||||
Uint32 videoflags = SDL_SWSURFACE;
|
Uint32 videoflags = SDL_SWSURFACE;
|
||||||
int done;
|
int done;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
/* Initialize the SDL library */
|
/* Initialize the SDL library */
|
||||||
if ( SDL_Init(initflags) < 0 ) {
|
if (SDL_Init(initflags) < 0) {
|
||||||
fprintf(stderr, "Couldn't initialize SDL: %s\n",
|
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||||
SDL_GetError());
|
exit(1);
|
||||||
exit(1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Set 640x480 video mode */
|
/* Set 640x480 video mode */
|
||||||
screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
|
screen = SDL_SetVideoMode(640, 480, video_bpp, videoflags);
|
||||||
if (screen == NULL) {
|
if (screen == NULL) {
|
||||||
fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
|
fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
|
||||||
video_bpp, SDL_GetError());
|
video_bpp, SDL_GetError());
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
done = 0;
|
done = 0;
|
||||||
while ( !done ) {
|
while (!done) {
|
||||||
|
|
||||||
/* Check for events */
|
/* Check for events */
|
||||||
while ( SDL_PollEvent(&event) ) {
|
while (SDL_PollEvent(&event)) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
/* Any keypress quits the app... */
|
/* Any keypress quits the app... */
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
done = 1;
|
done = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean up the SDL library */
|
/* Clean up the SDL library */
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,10 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface SDLMain : NSObject
|
@ interface SDLMain: NSObject - (IBAction) prefsMenu:(id) sender;
|
||||||
- (IBAction)prefsMenu:(id)sender;
|
-(IBAction) newGame:(id) sender;
|
||||||
- (IBAction)newGame:(id)sender;
|
-(IBAction) openGame:(id) sender;
|
||||||
- (IBAction)openGame:(id)sender;
|
-(IBAction) saveGame:(id) sender;
|
||||||
- (IBAction)saveGame:(id)sender;
|
-(IBAction) saveGameAs:(id) sender;
|
||||||
- (IBAction)saveGameAs:(id)sender;
|
-(IBAction) help:(id) sender;
|
||||||
- (IBAction)help:(id)sender;
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Please see the SDL documentation for details on using the SDL API:
|
Please see the SDL documentation for details on using the SDL API:
|
||||||
/Developer/Documentation/SDL/docs.html
|
/Developer/Documentation/SDL/docs.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -12,54 +12,54 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */
|
Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */
|
||||||
SDL_Surface *screen;
|
SDL_Surface *screen;
|
||||||
Uint8 video_bpp = 0;
|
Uint8 video_bpp = 0;
|
||||||
Uint32 videoflags = SDL_SWSURFACE;
|
Uint32 videoflags = SDL_SWSURFACE;
|
||||||
int done;
|
int done;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
/* Initialize the SDL library */
|
/* Initialize the SDL library */
|
||||||
if ( SDL_Init(initflags) < 0 ) {
|
if (SDL_Init(initflags) < 0) {
|
||||||
fprintf(stderr, "Couldn't initialize SDL: %s\n",
|
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||||
SDL_GetError());
|
exit(1);
|
||||||
exit(1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Set 640x480 video mode */
|
/* Set 640x480 video mode */
|
||||||
screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
|
screen = SDL_SetVideoMode(640, 480, video_bpp, videoflags);
|
||||||
if (screen == NULL) {
|
if (screen == NULL) {
|
||||||
fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
|
fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
|
||||||
video_bpp, SDL_GetError());
|
video_bpp, SDL_GetError());
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
done = 0;
|
done = 0;
|
||||||
while ( !done ) {
|
while (!done) {
|
||||||
|
|
||||||
/* Check for events */
|
/* Check for events */
|
||||||
while ( SDL_PollEvent(&event) ) {
|
while (SDL_PollEvent(&event)) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
/* Any keypress quits the app... */
|
/* Any keypress quits the app... */
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
done = 1;
|
done = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean up the SDL library */
|
/* Clean up the SDL library */
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,38 +9,34 @@
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import "SDL.h"
|
#import "SDL.h"
|
||||||
|
|
||||||
extern id gController; // instance of this class from nib
|
extern id gController; // instance of this class from nib
|
||||||
|
|
||||||
// Declare SDL_QuartzWindowDelegate (defined in SDL.framework)
|
// Declare SDL_QuartzWindowDelegate (defined in SDL.framework)
|
||||||
@interface SDL_QuartzWindowDelegate : NSObject
|
@interface SDL_QuartzWindowDelegate: NSObject @ end @ interface MyController:NSObject {
|
||||||
@end
|
|
||||||
|
|
||||||
@interface MyController : NSObject
|
|
||||||
{
|
|
||||||
// Interface Builder Outlets
|
// Interface Builder Outlets
|
||||||
IBOutlet id _framesPerSecond;
|
IBOutlet id _framesPerSecond;
|
||||||
IBOutlet id _numSprites;
|
IBOutlet id _numSprites;
|
||||||
IBOutlet id _window;
|
IBOutlet id _window;
|
||||||
IBOutlet id _view;
|
IBOutlet id _view;
|
||||||
|
|
||||||
// Private instance variables
|
|
||||||
int _nSprites;
|
|
||||||
int _max_speed;
|
|
||||||
int _doFlip;
|
|
||||||
Uint8* _mem;
|
|
||||||
|
|
||||||
SDL_Surface* _screen;
|
|
||||||
SDL_Surface* _sprite;
|
|
||||||
SDL_Rect* _sprite_rects;
|
|
||||||
SDL_Rect* _positions;
|
|
||||||
SDL_Rect* _velocities;
|
|
||||||
int _sprites_visible;
|
|
||||||
Uint16 _sprite_w, _sprite_h;
|
|
||||||
|
|
||||||
int _mouse_x, _mouse_y;
|
|
||||||
}
|
|
||||||
// Interface Builder Actions
|
|
||||||
- (IBAction)changeNumberOfSprites:(id)sender;
|
|
||||||
- (IBAction)selectUpdateMode:(id)sender;
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
// Private instance variables
|
||||||
|
int _nSprites;
|
||||||
|
int _max_speed;
|
||||||
|
int _doFlip;
|
||||||
|
Uint8 *_mem;
|
||||||
|
|
||||||
|
SDL_Surface *_screen;
|
||||||
|
SDL_Surface *_sprite;
|
||||||
|
SDL_Rect *_sprite_rects;
|
||||||
|
SDL_Rect *_positions;
|
||||||
|
SDL_Rect *_velocities;
|
||||||
|
int _sprites_visible;
|
||||||
|
Uint16 _sprite_w, _sprite_h;
|
||||||
|
|
||||||
|
int _mouse_x, _mouse_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interface Builder Actions
|
||||||
|
-(IBAction) changeNumberOfSprites:(id) sender;
|
||||||
|
-(IBAction) selectUpdateMode:(id) sender;
|
||||||
|
@end
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
#import <AppKit/AppKit.h>
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
|
||||||
@interface MyCustomView : NSQuickDrawView
|
@ interface MyCustomView:NSQuickDrawView {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -11,17 +11,11 @@
|
||||||
// Be a subclass of SDL_QuartzWindow so SDL will
|
// Be a subclass of SDL_QuartzWindow so SDL will
|
||||||
// handle the redraw problems when minimizing the window
|
// handle the redraw problems when minimizing the window
|
||||||
// This class is defined in SDL.framework
|
// This class is defined in SDL.framework
|
||||||
@interface SDL_QuartzWindow : NSWindow
|
@ interface SDL_QuartzWindow:NSWindow @ end
|
||||||
@end
|
|
||||||
|
|
||||||
// Also assign SDL_QuartzWindowDelegate to the window
|
// Also assign SDL_QuartzWindowDelegate to the window
|
||||||
// to perform other tasks. You can subclass this delegate
|
// to perform other tasks. You can subclass this delegate
|
||||||
// if you want to add your own delegation methods
|
// if you want to add your own delegation methods
|
||||||
// This class is defined in SDL.framework
|
// This class is defined in SDL.framework
|
||||||
@interface SDL_QuartzWindowDelegate : NSObject
|
@ interface SDL_QuartzWindowDelegate:NSObject @ end
|
||||||
@end
|
|
||||||
|
|
||||||
// Declare our custom class
|
// Declare our custom class
|
||||||
@interface MyCustomWindow : SDL_QuartzWindow
|
@ interface MyCustomWindow:SDL_QuartzWindow @ end
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface SDLMain : NSObject
|
@ interface SDLMain:NSObject {
|
||||||
{
|
|
||||||
IBOutlet id _controller;
|
IBOutlet id _controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -9,4 +9,3 @@
|
||||||
|
|
||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,4 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface SDLMain : NSObject
|
@ interface SDLMain:NSObject @ end
|
||||||
@end
|
|
||||||
|
|
|
@ -54,46 +54,49 @@ GLboolean Timing = GL_TRUE;
|
||||||
|
|
||||||
int w_win = 640;
|
int w_win = 640;
|
||||||
int h_win = 480;
|
int h_win = 480;
|
||||||
GLint count = 0;
|
GLint count = 0;
|
||||||
GLenum StrMode = GL_VENDOR;
|
GLenum StrMode = GL_VENDOR;
|
||||||
|
|
||||||
GLboolean moving;
|
GLboolean moving;
|
||||||
|
|
||||||
static double mtime(void)
|
static double
|
||||||
|
mtime(void)
|
||||||
{
|
{
|
||||||
struct timeval tk_time;
|
struct timeval tk_time;
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
|
|
||||||
gettimeofday(&tk_time, &tz);
|
gettimeofday(&tk_time, &tz);
|
||||||
|
|
||||||
return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec;
|
return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double filter(double in, double *save)
|
static double
|
||||||
|
filter(double in, double *save)
|
||||||
{
|
{
|
||||||
static double k1 = 0.9;
|
static double k1 = 0.9;
|
||||||
static double k2 = 0.05;
|
static double k2 = 0.05;
|
||||||
|
|
||||||
save[3] = in;
|
save[3] = in;
|
||||||
save[1] = save[0]*k1 + k2*(save[3] + save[2]);
|
save[1] = save[0] * k1 + k2 * (save[3] + save[2]);
|
||||||
|
|
||||||
save[0]=save[1];
|
save[0] = save[1];
|
||||||
save[2]=save[3];
|
save[2] = save[3];
|
||||||
|
|
||||||
return(save[1]);
|
return (save[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawStr(const char *str)
|
void
|
||||||
|
DrawStr(const char *str)
|
||||||
{
|
{
|
||||||
GLint i = 0;
|
GLint i = 0;
|
||||||
|
|
||||||
if(!str) return;
|
if (!str)
|
||||||
|
return;
|
||||||
while(str[i])
|
|
||||||
{
|
while (str[i]) {
|
||||||
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
|
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -134,18 +137,18 @@ InitFishs(void)
|
||||||
void
|
void
|
||||||
Atlantis_Init(void)
|
Atlantis_Init(void)
|
||||||
{
|
{
|
||||||
static float ambient[] = {0.2, 0.2, 0.2, 1.0};
|
static float ambient[] = { 0.2, 0.2, 0.2, 1.0 };
|
||||||
static float diffuse[] = {1.0, 1.0, 1.0, 1.0};
|
static float diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
|
||||||
static float position[] = {0.0, 1.0, 0.0, 0.0};
|
static float position[] = { 0.0, 1.0, 0.0, 0.0 };
|
||||||
static float mat_shininess[] = {90.0};
|
static float mat_shininess[] = { 90.0 };
|
||||||
static float mat_specular[] = {0.8, 0.8, 0.8, 1.0};
|
static float mat_specular[] = { 0.8, 0.8, 0.8, 1.0 };
|
||||||
static float mat_diffuse[] = {0.46, 0.66, 0.795, 1.0};
|
static float mat_diffuse[] = { 0.46, 0.66, 0.795, 1.0 };
|
||||||
static float mat_ambient[] = {0.3, 0.4, 0.5, 1.0};
|
static float mat_ambient[] = { 0.3, 0.4, 0.5, 1.0 };
|
||||||
static float lmodel_ambient[] = {0.4, 0.4, 0.4, 1.0};
|
static float lmodel_ambient[] = { 0.4, 0.4, 0.4, 1.0 };
|
||||||
static float lmodel_localviewer[] = {0.0};
|
static float lmodel_localviewer[] = { 0.0 };
|
||||||
//GLfloat map1[4] = {0.0, 0.0, 0.0, 0.0};
|
//GLfloat map1[4] = {0.0, 0.0, 0.0, 0.0};
|
||||||
//GLfloat map2[4] = {0.0, 0.0, 0.0, 0.0};
|
//GLfloat map2[4] = {0.0, 0.0, 0.0, 0.0};
|
||||||
static float fog_color[] = {0.0, 0.5, 0.9, 1.0};
|
static float fog_color[] = { 0.0, 0.5, 0.9, 1.0 };
|
||||||
|
|
||||||
glFrontFace(GL_CCW);
|
glFrontFace(GL_CCW);
|
||||||
|
|
||||||
|
@ -168,9 +171,9 @@ Atlantis_Init(void)
|
||||||
InitFishs();
|
InitFishs();
|
||||||
|
|
||||||
glEnable(GL_FOG);
|
glEnable(GL_FOG);
|
||||||
glFogi(GL_FOG_MODE, GL_EXP);
|
glFogi(GL_FOG_MODE, GL_EXP);
|
||||||
glFogf(GL_FOG_DENSITY, 0.0000025);
|
glFogf(GL_FOG_DENSITY, 0.0000025);
|
||||||
glFogfv(GL_FOG_COLOR, fog_color);
|
glFogfv(GL_FOG_COLOR, fog_color);
|
||||||
|
|
||||||
glClearColor(0.0, 0.5, 0.9, 1.0);
|
glClearColor(0.0, 0.5, 0.9, 1.0);
|
||||||
}
|
}
|
||||||
|
@ -178,14 +181,15 @@ Atlantis_Init(void)
|
||||||
void
|
void
|
||||||
Atlantis_Reshape(int width, int height)
|
Atlantis_Reshape(int width, int height)
|
||||||
{
|
{
|
||||||
w_win = width;
|
w_win = width;
|
||||||
h_win = height;
|
h_win = height;
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0, 300000.0);
|
gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0,
|
||||||
|
300000.0);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,42 +216,42 @@ Atlantis_Key(unsigned char key, int x, int y)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 't':
|
case 't':
|
||||||
Timing = !Timing;
|
Timing = !Timing;
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
switch(StrMode)
|
switch (StrMode) {
|
||||||
{
|
case GL_EXTENSIONS:
|
||||||
case GL_EXTENSIONS:
|
StrMode = GL_VENDOR;
|
||||||
StrMode = GL_VENDOR;
|
break;
|
||||||
break;
|
case GL_VENDOR:
|
||||||
case GL_VENDOR:
|
StrMode = GL_RENDERER;
|
||||||
StrMode = GL_RENDERER;
|
break;
|
||||||
break;
|
case GL_RENDERER:
|
||||||
case GL_RENDERER:
|
StrMode = GL_VERSION;
|
||||||
StrMode = GL_VERSION;
|
break;
|
||||||
break;
|
case GL_VERSION:
|
||||||
case GL_VERSION:
|
StrMode = GL_EXTENSIONS;
|
||||||
StrMode = GL_EXTENSIONS;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case 27: /* Esc will quit */
|
||||||
case 27: /* Esc will quit */
|
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
case 's': /* "s" start animation */
|
case 's': /* "s" start animation */
|
||||||
moving = GL_TRUE;
|
moving = GL_TRUE;
|
||||||
//glutIdleFunc(Animate);
|
//glutIdleFunc(Animate);
|
||||||
break;
|
break;
|
||||||
case 'a': /* "a" stop animation */
|
case 'a': /* "a" stop animation */
|
||||||
moving = GL_FALSE;
|
moving = GL_FALSE;
|
||||||
//glutIdleFunc(NULL);
|
//glutIdleFunc(NULL);
|
||||||
break;
|
break;
|
||||||
case '.': /* "." will advance frame */
|
case '.': /* "." will advance frame */
|
||||||
if (!moving) {
|
if (!moving) {
|
||||||
Atlantis_Animate();
|
Atlantis_Animate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void Display(void)
|
void Display(void)
|
||||||
{
|
{
|
||||||
|
@ -273,10 +277,10 @@ void
|
||||||
Atlantis_Display(void)
|
Atlantis_Display(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
static double th[4] = {0.0, 0.0, 0.0, 0.0};
|
static double th[4] = { 0.0, 0.0, 0.0, 0.0 };
|
||||||
static double t1 = 0.0, t2 = 0.0, t;
|
static double t1 = 0.0, t2 = 0.0, t;
|
||||||
char num_str[128];
|
char num_str[128];
|
||||||
|
|
||||||
t1 = t2;
|
t1 = t2;
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
@ -303,56 +307,59 @@ Atlantis_Display(void)
|
||||||
glScalef(0.45, 0.45, 0.3);
|
glScalef(0.45, 0.45, 0.3);
|
||||||
DrawWhale(&babyWhale);
|
DrawWhale(&babyWhale);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
if(Timing)
|
if (Timing) {
|
||||||
{
|
t2 = mtime();
|
||||||
t2 = mtime();
|
t = t2 - t1;
|
||||||
t = t2 - t1;
|
if (t > 0.0001)
|
||||||
if(t > 0.0001) t = 1.0 / t;
|
t = 1.0 / t;
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
//glDisable(GL_DEPTH_TEST);
|
//glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glColor3f(1.0, 0.0, 0.0);
|
glColor3f(1.0, 0.0, 0.0);
|
||||||
|
|
||||||
glMatrixMode (GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
|
glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
|
||||||
|
|
||||||
glRasterPos2f(5.0, 5.0);
|
glRasterPos2f(5.0, 5.0);
|
||||||
|
|
||||||
switch(StrMode)
|
switch (StrMode) {
|
||||||
{
|
case GL_VENDOR:
|
||||||
case GL_VENDOR:
|
sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th),
|
||||||
sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win);
|
w_win, h_win);
|
||||||
DrawStr(num_str);
|
DrawStr(num_str);
|
||||||
DrawStr(glGetString(GL_VENDOR));
|
DrawStr(glGetString(GL_VENDOR));
|
||||||
break;
|
break;
|
||||||
case GL_RENDERER:
|
case GL_RENDERER:
|
||||||
sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win);
|
sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th),
|
||||||
DrawStr(num_str);
|
w_win, h_win);
|
||||||
DrawStr(glGetString(GL_RENDERER));
|
DrawStr(num_str);
|
||||||
break;
|
DrawStr(glGetString(GL_RENDERER));
|
||||||
case GL_VERSION:
|
break;
|
||||||
sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win);
|
case GL_VERSION:
|
||||||
DrawStr(num_str);
|
sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th),
|
||||||
DrawStr(glGetString(GL_VERSION));
|
w_win, h_win);
|
||||||
break;
|
DrawStr(num_str);
|
||||||
case GL_EXTENSIONS:
|
DrawStr(glGetString(GL_VERSION));
|
||||||
sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win);
|
break;
|
||||||
DrawStr(num_str);
|
case GL_EXTENSIONS:
|
||||||
DrawStr(glGetString(GL_EXTENSIONS));
|
sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th),
|
||||||
break;
|
w_win, h_win);
|
||||||
}
|
DrawStr(num_str);
|
||||||
|
DrawStr(glGetString(GL_EXTENSIONS));
|
||||||
glPopMatrix();
|
break;
|
||||||
glMatrixMode(GL_MODELVIEW);
|
}
|
||||||
|
|
||||||
glEnable(GL_LIGHTING);
|
glPopMatrix();
|
||||||
//glEnable(GL_DEPTH_TEST);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
}
|
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
//glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
|
@ -456,4 +463,4 @@ glutIdleFunc(Animate);
|
||||||
glutMainLoop();
|
glutMainLoop();
|
||||||
return 0; // ANSI C requires main to return int.
|
return 0; // ANSI C requires main to return int.
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,7 +43,8 @@
|
||||||
|
|
||||||
#define WHALESPEED 250.0
|
#define WHALESPEED 250.0
|
||||||
|
|
||||||
typedef struct _fishRec {
|
typedef struct _fishRec
|
||||||
|
{
|
||||||
float x, y, z, phi, theta, psi, v;
|
float x, y, z, phi, theta, psi, v;
|
||||||
float xt, yt, zt;
|
float xt, yt, zt;
|
||||||
float htail, vtail;
|
float htail, vtail;
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||||
*/
|
*/
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h> /* For rand(). */
|
#include <stdlib.h> /* For rand(). */
|
||||||
#include <GLUT/glut.h>
|
#include <GLUT/glut.h>
|
||||||
#include "atlantis.h"
|
#include "atlantis.h"
|
||||||
|
|
||||||
|
@ -57,8 +57,10 @@ WhalePilot(fishRec * fish)
|
||||||
fish->theta = 0.0;
|
fish->theta = 0.0;
|
||||||
fish->psi -= 0.5;
|
fish->psi -= 0.5;
|
||||||
|
|
||||||
fish->x += WHALESPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
|
fish->x +=
|
||||||
fish->y += WHALESPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
|
WHALESPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
|
fish->y +=
|
||||||
|
WHALESPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
fish->z += WHALESPEED * fish->v * sin(fish->theta / RAD);
|
fish->z += WHALESPEED * fish->v * sin(fish->theta / RAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,8 +154,10 @@ SharkPilot(fishRec * fish)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fish->x += SHARKSPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
|
fish->x +=
|
||||||
fish->y += SHARKSPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
|
SHARKSPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
|
fish->y +=
|
||||||
|
SHARKSPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
fish->z += SHARKSPEED * fish->v * sin(fish->theta / RAD);
|
fish->z += SHARKSPEED * fish->v * sin(fish->theta / RAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Please see the SDL documentation for details on using the SDL API:
|
Please see the SDL documentation for details on using the SDL API:
|
||||||
/Developer/Documentation/SDL/docs.html
|
/Developer/Documentation/SDL/docs.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -12,168 +12,176 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
extern void Atlantis_Init ();
|
extern void Atlantis_Init();
|
||||||
extern void Atlantis_Reshape (int w, int h);
|
extern void Atlantis_Reshape(int w, int h);
|
||||||
extern void Atlantis_Animate ();
|
extern void Atlantis_Animate();
|
||||||
extern void Atlantis_Display ();
|
extern void Atlantis_Display();
|
||||||
|
|
||||||
static SDL_Surface *gScreen;
|
static SDL_Surface *gScreen;
|
||||||
|
|
||||||
static void initAttributes ()
|
static void
|
||||||
|
initAttributes()
|
||||||
{
|
{
|
||||||
// Setup attributes we want for the OpenGL context
|
// Setup attributes we want for the OpenGL context
|
||||||
|
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
// Don't set color bit sizes (SDL_GL_RED_SIZE, etc)
|
// Don't set color bit sizes (SDL_GL_RED_SIZE, etc)
|
||||||
// Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and
|
// Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and
|
||||||
// 5-5-5 RGB for 16-bit screens
|
// 5-5-5 RGB for 16-bit screens
|
||||||
|
|
||||||
// Request a 16-bit depth buffer (without this, there is no depth buffer)
|
// Request a 16-bit depth buffer (without this, there is no depth buffer)
|
||||||
value = 16;
|
value = 16;
|
||||||
SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, value);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, value);
|
||||||
|
|
||||||
|
|
||||||
// Request double-buffered OpenGL
|
// Request double-buffered OpenGL
|
||||||
// The fact that windows are double-buffered on Mac OS X has no effect
|
// The fact that windows are double-buffered on Mac OS X has no effect
|
||||||
// on OpenGL double buffering.
|
// on OpenGL double buffering.
|
||||||
value = 1;
|
value = 1;
|
||||||
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, value);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printAttributes ()
|
static void
|
||||||
|
printAttributes()
|
||||||
{
|
{
|
||||||
// Print out attributes of the context we created
|
// Print out attributes of the context we created
|
||||||
int nAttr;
|
int nAttr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
int attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE,
|
int attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE,
|
||||||
SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE };
|
SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE
|
||||||
|
};
|
||||||
char *desc[] = { "Red size: %d bits\n", "Blue size: %d bits\n", "Green size: %d bits\n",
|
|
||||||
"Alpha size: %d bits\n", "Color buffer size: %d bits\n",
|
char *desc[] =
|
||||||
"Depth bufer size: %d bits\n" };
|
{ "Red size: %d bits\n", "Blue size: %d bits\n",
|
||||||
|
"Green size: %d bits\n",
|
||||||
|
"Alpha size: %d bits\n", "Color buffer size: %d bits\n",
|
||||||
|
"Depth bufer size: %d bits\n"
|
||||||
|
};
|
||||||
|
|
||||||
nAttr = sizeof(attr) / sizeof(int);
|
nAttr = sizeof(attr) / sizeof(int);
|
||||||
|
|
||||||
for (i = 0; i < nAttr; i++) {
|
for (i = 0; i < nAttr; i++) {
|
||||||
|
|
||||||
int value;
|
int value;
|
||||||
SDL_GL_GetAttribute (attr[i], &value);
|
SDL_GL_GetAttribute(attr[i], &value);
|
||||||
printf (desc[i], value);
|
printf(desc[i], value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createSurface (int fullscreen)
|
static void
|
||||||
|
createSurface(int fullscreen)
|
||||||
{
|
{
|
||||||
Uint32 flags = 0;
|
Uint32 flags = 0;
|
||||||
|
|
||||||
flags = SDL_OPENGL;
|
flags = SDL_OPENGL;
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
flags |= SDL_FULLSCREEN;
|
flags |= SDL_FULLSCREEN;
|
||||||
|
|
||||||
// Create window
|
// Create window
|
||||||
gScreen = SDL_SetVideoMode (640, 480, 0, flags);
|
gScreen = SDL_SetVideoMode(640, 480, 0, flags);
|
||||||
if (gScreen == NULL) {
|
if (gScreen == NULL) {
|
||||||
|
|
||||||
fprintf (stderr, "Couldn't set 640x480 OpenGL video mode: %s\n",
|
fprintf(stderr, "Couldn't set 640x480 OpenGL video mode: %s\n",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initGL ()
|
static void
|
||||||
|
initGL()
|
||||||
{
|
{
|
||||||
Atlantis_Init ();
|
Atlantis_Init();
|
||||||
Atlantis_Reshape (gScreen->w, gScreen->h);
|
Atlantis_Reshape(gScreen->w, gScreen->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawGL ()
|
static void
|
||||||
|
drawGL()
|
||||||
{
|
{
|
||||||
Atlantis_Animate ();
|
Atlantis_Animate();
|
||||||
Atlantis_Display ();
|
Atlantis_Display();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mainLoop ()
|
static void
|
||||||
|
mainLoop()
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
int fps = 24;
|
int fps = 24;
|
||||||
int delay = 1000/fps;
|
int delay = 1000 / fps;
|
||||||
int thenTicks = -1;
|
int thenTicks = -1;
|
||||||
int nowTicks;
|
int nowTicks;
|
||||||
|
|
||||||
while ( !done ) {
|
|
||||||
|
|
||||||
/* Check for events */
|
while (!done) {
|
||||||
while ( SDL_PollEvent (&event) ) {
|
|
||||||
switch (event.type) {
|
/* Check for events */
|
||||||
|
while (SDL_PollEvent(&event)) {
|
||||||
|
switch (event.type) {
|
||||||
|
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
break;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
/* Any keypress quits the app... */
|
||||||
|
case SDL_QUIT:
|
||||||
|
done = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:
|
|
||||||
break;
|
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
|
||||||
break;
|
|
||||||
case SDL_KEYDOWN:
|
|
||||||
/* Any keypress quits the app... */
|
|
||||||
case SDL_QUIT:
|
|
||||||
done = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw at 24 hz
|
// Draw at 24 hz
|
||||||
// This approach is not normally recommended - it is better to
|
// This approach is not normally recommended - it is better to
|
||||||
// use time-based animation and run as fast as possible
|
// use time-based animation and run as fast as possible
|
||||||
drawGL ();
|
drawGL();
|
||||||
SDL_GL_SwapBuffers ();
|
SDL_GL_SwapBuffers();
|
||||||
|
|
||||||
// Time how long each draw-swap-delay cycle takes
|
// Time how long each draw-swap-delay cycle takes
|
||||||
// and adjust delay to get closer to target framerate
|
// and adjust delay to get closer to target framerate
|
||||||
if (thenTicks > 0) {
|
if (thenTicks > 0) {
|
||||||
nowTicks = SDL_GetTicks ();
|
nowTicks = SDL_GetTicks();
|
||||||
delay += (1000/fps - (nowTicks-thenTicks));
|
delay += (1000 / fps - (nowTicks - thenTicks));
|
||||||
thenTicks = nowTicks;
|
thenTicks = nowTicks;
|
||||||
if (delay < 0)
|
if (delay < 0)
|
||||||
delay = 1000/fps;
|
delay = 1000 / fps;
|
||||||
}
|
} else {
|
||||||
else {
|
thenTicks = SDL_GetTicks();
|
||||||
thenTicks = SDL_GetTicks ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Delay (delay);
|
SDL_Delay(delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Init SDL video subsystem
|
// Init SDL video subsystem
|
||||||
if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
|
|
||||||
fprintf(stderr, "Couldn't initialize SDL: %s\n",
|
|
||||||
SDL_GetError());
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
// Set GL context attributes
|
// Set GL context attributes
|
||||||
initAttributes ();
|
initAttributes();
|
||||||
|
|
||||||
// Create GL context
|
// Create GL context
|
||||||
createSurface (0);
|
createSurface(0);
|
||||||
|
|
||||||
// Get GL context attributes
|
// Get GL context attributes
|
||||||
printAttributes ();
|
printAttributes();
|
||||||
|
|
||||||
// Init GL state
|
// Init GL state
|
||||||
initGL ();
|
initGL();
|
||||||
|
|
||||||
// Draw, get events...
|
// Draw, get events...
|
||||||
mainLoop ();
|
mainLoop();
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,5 +7,4 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface SDLMain : NSObject
|
@ interface SDLMain:NSObject @ end
|
||||||
@end
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Please see the SDL documentation for details on using the SDL API:
|
Please see the SDL documentation for details on using the SDL API:
|
||||||
/Developer/Documentation/SDL/docs.html
|
/Developer/Documentation/SDL/docs.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -12,54 +12,54 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */
|
Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */
|
||||||
SDL_Surface *screen;
|
SDL_Surface *screen;
|
||||||
Uint8 video_bpp = 0;
|
Uint8 video_bpp = 0;
|
||||||
Uint32 videoflags = SDL_SWSURFACE;
|
Uint32 videoflags = SDL_SWSURFACE;
|
||||||
int done;
|
int done;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
/* Initialize the SDL library */
|
/* Initialize the SDL library */
|
||||||
if ( SDL_Init(initflags) < 0 ) {
|
if (SDL_Init(initflags) < 0) {
|
||||||
fprintf(stderr, "Couldn't initialize SDL: %s\n",
|
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||||
SDL_GetError());
|
exit(1);
|
||||||
exit(1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Set 640x480 video mode */
|
/* Set 640x480 video mode */
|
||||||
screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
|
screen = SDL_SetVideoMode(640, 480, video_bpp, videoflags);
|
||||||
if (screen == NULL) {
|
if (screen == NULL) {
|
||||||
fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
|
fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
|
||||||
video_bpp, SDL_GetError());
|
video_bpp, SDL_GetError());
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
done = 0;
|
done = 0;
|
||||||
while ( !done ) {
|
while (!done) {
|
||||||
|
|
||||||
/* Check for events */
|
/* Check for events */
|
||||||
while ( SDL_PollEvent(&event) ) {
|
while (SDL_PollEvent(&event)) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
/* Any keypress quits the app... */
|
/* Any keypress quits the app... */
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
done = 1;
|
done = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean up the SDL library */
|
/* Clean up the SDL library */
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,10 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface SDLMain : NSObject
|
@ interface SDLMain: NSObject - (IBAction) prefsMenu:(id) sender;
|
||||||
- (IBAction)prefsMenu:(id)sender;
|
-(IBAction) newGame:(id) sender;
|
||||||
- (IBAction)newGame:(id)sender;
|
-(IBAction) openGame:(id) sender;
|
||||||
- (IBAction)openGame:(id)sender;
|
-(IBAction) saveGame:(id) sender;
|
||||||
- (IBAction)saveGame:(id)sender;
|
-(IBAction) saveGameAs:(id) sender;
|
||||||
- (IBAction)saveGameAs:(id)sender;
|
-(IBAction) help:(id) sender;
|
||||||
- (IBAction)help:(id)sender;
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Please see the SDL documentation for details on using the SDL API:
|
Please see the SDL documentation for details on using the SDL API:
|
||||||
/Developer/Documentation/SDL/docs.html
|
/Developer/Documentation/SDL/docs.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -12,54 +12,54 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */
|
Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */
|
||||||
SDL_Surface *screen;
|
SDL_Surface *screen;
|
||||||
Uint8 video_bpp = 0;
|
Uint8 video_bpp = 0;
|
||||||
Uint32 videoflags = SDL_SWSURFACE;
|
Uint32 videoflags = SDL_SWSURFACE;
|
||||||
int done;
|
int done;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
/* Initialize the SDL library */
|
/* Initialize the SDL library */
|
||||||
if ( SDL_Init(initflags) < 0 ) {
|
if (SDL_Init(initflags) < 0) {
|
||||||
fprintf(stderr, "Couldn't initialize SDL: %s\n",
|
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||||
SDL_GetError());
|
exit(1);
|
||||||
exit(1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Set 640x480 video mode */
|
/* Set 640x480 video mode */
|
||||||
screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
|
screen = SDL_SetVideoMode(640, 480, video_bpp, videoflags);
|
||||||
if (screen == NULL) {
|
if (screen == NULL) {
|
||||||
fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
|
fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
|
||||||
video_bpp, SDL_GetError());
|
video_bpp, SDL_GetError());
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
done = 0;
|
done = 0;
|
||||||
while ( !done ) {
|
while (!done) {
|
||||||
|
|
||||||
/* Check for events */
|
/* Check for events */
|
||||||
while ( SDL_PollEvent(&event) ) {
|
while (SDL_PollEvent(&event)) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
/* Any keypress quits the app... */
|
/* Any keypress quits the app... */
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
done = 1;
|
done = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean up the SDL library */
|
/* Clean up the SDL library */
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,38 +9,34 @@
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import "SDL.h"
|
#import "SDL.h"
|
||||||
|
|
||||||
extern id gController; // instance of this class from nib
|
extern id gController; // instance of this class from nib
|
||||||
|
|
||||||
// Declare SDL_QuartzWindowDelegate (defined in SDL.framework)
|
// Declare SDL_QuartzWindowDelegate (defined in SDL.framework)
|
||||||
@interface SDL_QuartzWindowDelegate : NSObject
|
@interface SDL_QuartzWindowDelegate: NSObject @ end @ interface MyController:NSObject {
|
||||||
@end
|
|
||||||
|
|
||||||
@interface MyController : NSObject
|
|
||||||
{
|
|
||||||
// Interface Builder Outlets
|
// Interface Builder Outlets
|
||||||
IBOutlet id _framesPerSecond;
|
IBOutlet id _framesPerSecond;
|
||||||
IBOutlet id _numSprites;
|
IBOutlet id _numSprites;
|
||||||
IBOutlet id _window;
|
IBOutlet id _window;
|
||||||
IBOutlet id _view;
|
IBOutlet id _view;
|
||||||
|
|
||||||
// Private instance variables
|
|
||||||
int _nSprites;
|
|
||||||
int _max_speed;
|
|
||||||
int _doFlip;
|
|
||||||
Uint8* _mem;
|
|
||||||
|
|
||||||
SDL_Surface* _screen;
|
|
||||||
SDL_Surface* _sprite;
|
|
||||||
SDL_Rect* _sprite_rects;
|
|
||||||
SDL_Rect* _positions;
|
|
||||||
SDL_Rect* _velocities;
|
|
||||||
int _sprites_visible;
|
|
||||||
Uint16 _sprite_w, _sprite_h;
|
|
||||||
|
|
||||||
int _mouse_x, _mouse_y;
|
|
||||||
}
|
|
||||||
// Interface Builder Actions
|
|
||||||
- (IBAction)changeNumberOfSprites:(id)sender;
|
|
||||||
- (IBAction)selectUpdateMode:(id)sender;
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
// Private instance variables
|
||||||
|
int _nSprites;
|
||||||
|
int _max_speed;
|
||||||
|
int _doFlip;
|
||||||
|
Uint8 *_mem;
|
||||||
|
|
||||||
|
SDL_Surface *_screen;
|
||||||
|
SDL_Surface *_sprite;
|
||||||
|
SDL_Rect *_sprite_rects;
|
||||||
|
SDL_Rect *_positions;
|
||||||
|
SDL_Rect *_velocities;
|
||||||
|
int _sprites_visible;
|
||||||
|
Uint16 _sprite_w, _sprite_h;
|
||||||
|
|
||||||
|
int _mouse_x, _mouse_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interface Builder Actions
|
||||||
|
-(IBAction) changeNumberOfSprites:(id) sender;
|
||||||
|
-(IBAction) selectUpdateMode:(id) sender;
|
||||||
|
@end
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
#import <AppKit/AppKit.h>
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
|
||||||
@interface MyCustomView : NSQuickDrawView
|
@ interface MyCustomView:NSQuickDrawView {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -11,17 +11,11 @@
|
||||||
// Be a subclass of SDL_QuartzWindow so SDL will
|
// Be a subclass of SDL_QuartzWindow so SDL will
|
||||||
// handle the redraw problems when minimizing the window
|
// handle the redraw problems when minimizing the window
|
||||||
// This class is defined in SDL.framework
|
// This class is defined in SDL.framework
|
||||||
@interface SDL_QuartzWindow : NSWindow
|
@ interface SDL_QuartzWindow:NSWindow @ end
|
||||||
@end
|
|
||||||
|
|
||||||
// Also assign SDL_QuartzWindowDelegate to the window
|
// Also assign SDL_QuartzWindowDelegate to the window
|
||||||
// to perform other tasks. You can subclass this delegate
|
// to perform other tasks. You can subclass this delegate
|
||||||
// if you want to add your own delegation methods
|
// if you want to add your own delegation methods
|
||||||
// This class is defined in SDL.framework
|
// This class is defined in SDL.framework
|
||||||
@interface SDL_QuartzWindowDelegate : NSObject
|
@ interface SDL_QuartzWindowDelegate:NSObject @ end
|
||||||
@end
|
|
||||||
|
|
||||||
// Declare our custom class
|
// Declare our custom class
|
||||||
@interface MyCustomWindow : SDL_QuartzWindow
|
@ interface MyCustomWindow:SDL_QuartzWindow @ end
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface SDLMain : NSObject
|
@ interface SDLMain:NSObject {
|
||||||
{
|
|
||||||
IBOutlet id _controller;
|
IBOutlet id _controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -7,5 +7,4 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface SDLMain : NSObject
|
@ interface SDLMain:NSObject @ end
|
||||||
@end
|
|
||||||
|
|
|
@ -54,46 +54,49 @@ GLboolean Timing = GL_TRUE;
|
||||||
|
|
||||||
int w_win = 640;
|
int w_win = 640;
|
||||||
int h_win = 480;
|
int h_win = 480;
|
||||||
GLint count = 0;
|
GLint count = 0;
|
||||||
GLenum StrMode = GL_VENDOR;
|
GLenum StrMode = GL_VENDOR;
|
||||||
|
|
||||||
GLboolean moving;
|
GLboolean moving;
|
||||||
|
|
||||||
static double mtime(void)
|
static double
|
||||||
|
mtime(void)
|
||||||
{
|
{
|
||||||
struct timeval tk_time;
|
struct timeval tk_time;
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
|
|
||||||
gettimeofday(&tk_time, &tz);
|
gettimeofday(&tk_time, &tz);
|
||||||
|
|
||||||
return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec;
|
return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double filter(double in, double *save)
|
static double
|
||||||
|
filter(double in, double *save)
|
||||||
{
|
{
|
||||||
static double k1 = 0.9;
|
static double k1 = 0.9;
|
||||||
static double k2 = 0.05;
|
static double k2 = 0.05;
|
||||||
|
|
||||||
save[3] = in;
|
save[3] = in;
|
||||||
save[1] = save[0]*k1 + k2*(save[3] + save[2]);
|
save[1] = save[0] * k1 + k2 * (save[3] + save[2]);
|
||||||
|
|
||||||
save[0]=save[1];
|
save[0] = save[1];
|
||||||
save[2]=save[3];
|
save[2] = save[3];
|
||||||
|
|
||||||
return(save[1]);
|
return (save[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawStr(const char *str)
|
void
|
||||||
|
DrawStr(const char *str)
|
||||||
{
|
{
|
||||||
GLint i = 0;
|
GLint i = 0;
|
||||||
|
|
||||||
if(!str) return;
|
if (!str)
|
||||||
|
return;
|
||||||
while(str[i])
|
|
||||||
{
|
while (str[i]) {
|
||||||
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
|
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -134,18 +137,18 @@ InitFishs(void)
|
||||||
void
|
void
|
||||||
Atlantis_Init(void)
|
Atlantis_Init(void)
|
||||||
{
|
{
|
||||||
static float ambient[] = {0.2, 0.2, 0.2, 1.0};
|
static float ambient[] = { 0.2, 0.2, 0.2, 1.0 };
|
||||||
static float diffuse[] = {1.0, 1.0, 1.0, 1.0};
|
static float diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
|
||||||
static float position[] = {0.0, 1.0, 0.0, 0.0};
|
static float position[] = { 0.0, 1.0, 0.0, 0.0 };
|
||||||
static float mat_shininess[] = {90.0};
|
static float mat_shininess[] = { 90.0 };
|
||||||
static float mat_specular[] = {0.8, 0.8, 0.8, 1.0};
|
static float mat_specular[] = { 0.8, 0.8, 0.8, 1.0 };
|
||||||
static float mat_diffuse[] = {0.46, 0.66, 0.795, 1.0};
|
static float mat_diffuse[] = { 0.46, 0.66, 0.795, 1.0 };
|
||||||
static float mat_ambient[] = {0.3, 0.4, 0.5, 1.0};
|
static float mat_ambient[] = { 0.3, 0.4, 0.5, 1.0 };
|
||||||
static float lmodel_ambient[] = {0.4, 0.4, 0.4, 1.0};
|
static float lmodel_ambient[] = { 0.4, 0.4, 0.4, 1.0 };
|
||||||
static float lmodel_localviewer[] = {0.0};
|
static float lmodel_localviewer[] = { 0.0 };
|
||||||
//GLfloat map1[4] = {0.0, 0.0, 0.0, 0.0};
|
//GLfloat map1[4] = {0.0, 0.0, 0.0, 0.0};
|
||||||
//GLfloat map2[4] = {0.0, 0.0, 0.0, 0.0};
|
//GLfloat map2[4] = {0.0, 0.0, 0.0, 0.0};
|
||||||
static float fog_color[] = {0.0, 0.5, 0.9, 1.0};
|
static float fog_color[] = { 0.0, 0.5, 0.9, 1.0 };
|
||||||
|
|
||||||
glFrontFace(GL_CCW);
|
glFrontFace(GL_CCW);
|
||||||
|
|
||||||
|
@ -168,9 +171,9 @@ Atlantis_Init(void)
|
||||||
InitFishs();
|
InitFishs();
|
||||||
|
|
||||||
glEnable(GL_FOG);
|
glEnable(GL_FOG);
|
||||||
glFogi(GL_FOG_MODE, GL_EXP);
|
glFogi(GL_FOG_MODE, GL_EXP);
|
||||||
glFogf(GL_FOG_DENSITY, 0.0000025);
|
glFogf(GL_FOG_DENSITY, 0.0000025);
|
||||||
glFogfv(GL_FOG_COLOR, fog_color);
|
glFogfv(GL_FOG_COLOR, fog_color);
|
||||||
|
|
||||||
glClearColor(0.0, 0.5, 0.9, 1.0);
|
glClearColor(0.0, 0.5, 0.9, 1.0);
|
||||||
}
|
}
|
||||||
|
@ -178,14 +181,15 @@ Atlantis_Init(void)
|
||||||
void
|
void
|
||||||
Atlantis_Reshape(int width, int height)
|
Atlantis_Reshape(int width, int height)
|
||||||
{
|
{
|
||||||
w_win = width;
|
w_win = width;
|
||||||
h_win = height;
|
h_win = height;
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0, 300000.0);
|
gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0,
|
||||||
|
300000.0);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,42 +216,42 @@ Atlantis_Key(unsigned char key, int x, int y)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 't':
|
case 't':
|
||||||
Timing = !Timing;
|
Timing = !Timing;
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
switch(StrMode)
|
switch (StrMode) {
|
||||||
{
|
case GL_EXTENSIONS:
|
||||||
case GL_EXTENSIONS:
|
StrMode = GL_VENDOR;
|
||||||
StrMode = GL_VENDOR;
|
break;
|
||||||
break;
|
case GL_VENDOR:
|
||||||
case GL_VENDOR:
|
StrMode = GL_RENDERER;
|
||||||
StrMode = GL_RENDERER;
|
break;
|
||||||
break;
|
case GL_RENDERER:
|
||||||
case GL_RENDERER:
|
StrMode = GL_VERSION;
|
||||||
StrMode = GL_VERSION;
|
break;
|
||||||
break;
|
case GL_VERSION:
|
||||||
case GL_VERSION:
|
StrMode = GL_EXTENSIONS;
|
||||||
StrMode = GL_EXTENSIONS;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case 27: /* Esc will quit */
|
||||||
case 27: /* Esc will quit */
|
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
case 's': /* "s" start animation */
|
case 's': /* "s" start animation */
|
||||||
moving = GL_TRUE;
|
moving = GL_TRUE;
|
||||||
//glutIdleFunc(Animate);
|
//glutIdleFunc(Animate);
|
||||||
break;
|
break;
|
||||||
case 'a': /* "a" stop animation */
|
case 'a': /* "a" stop animation */
|
||||||
moving = GL_FALSE;
|
moving = GL_FALSE;
|
||||||
//glutIdleFunc(NULL);
|
//glutIdleFunc(NULL);
|
||||||
break;
|
break;
|
||||||
case '.': /* "." will advance frame */
|
case '.': /* "." will advance frame */
|
||||||
if (!moving) {
|
if (!moving) {
|
||||||
Atlantis_Animate();
|
Atlantis_Animate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void Display(void)
|
void Display(void)
|
||||||
{
|
{
|
||||||
|
@ -273,10 +277,10 @@ void
|
||||||
Atlantis_Display(void)
|
Atlantis_Display(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
static double th[4] = {0.0, 0.0, 0.0, 0.0};
|
static double th[4] = { 0.0, 0.0, 0.0, 0.0 };
|
||||||
static double t1 = 0.0, t2 = 0.0, t;
|
static double t1 = 0.0, t2 = 0.0, t;
|
||||||
char num_str[128];
|
char num_str[128];
|
||||||
|
|
||||||
t1 = t2;
|
t1 = t2;
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
@ -303,56 +307,59 @@ Atlantis_Display(void)
|
||||||
glScalef(0.45, 0.45, 0.3);
|
glScalef(0.45, 0.45, 0.3);
|
||||||
DrawWhale(&babyWhale);
|
DrawWhale(&babyWhale);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
if(Timing)
|
if (Timing) {
|
||||||
{
|
t2 = mtime();
|
||||||
t2 = mtime();
|
t = t2 - t1;
|
||||||
t = t2 - t1;
|
if (t > 0.0001)
|
||||||
if(t > 0.0001) t = 1.0 / t;
|
t = 1.0 / t;
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
//glDisable(GL_DEPTH_TEST);
|
//glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glColor3f(1.0, 0.0, 0.0);
|
glColor3f(1.0, 0.0, 0.0);
|
||||||
|
|
||||||
glMatrixMode (GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
|
glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
|
||||||
|
|
||||||
glRasterPos2f(5.0, 5.0);
|
glRasterPos2f(5.0, 5.0);
|
||||||
|
|
||||||
switch(StrMode)
|
switch (StrMode) {
|
||||||
{
|
case GL_VENDOR:
|
||||||
case GL_VENDOR:
|
sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th),
|
||||||
sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win);
|
w_win, h_win);
|
||||||
DrawStr(num_str);
|
DrawStr(num_str);
|
||||||
DrawStr(glGetString(GL_VENDOR));
|
DrawStr(glGetString(GL_VENDOR));
|
||||||
break;
|
break;
|
||||||
case GL_RENDERER:
|
case GL_RENDERER:
|
||||||
sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win);
|
sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th),
|
||||||
DrawStr(num_str);
|
w_win, h_win);
|
||||||
DrawStr(glGetString(GL_RENDERER));
|
DrawStr(num_str);
|
||||||
break;
|
DrawStr(glGetString(GL_RENDERER));
|
||||||
case GL_VERSION:
|
break;
|
||||||
sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win);
|
case GL_VERSION:
|
||||||
DrawStr(num_str);
|
sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th),
|
||||||
DrawStr(glGetString(GL_VERSION));
|
w_win, h_win);
|
||||||
break;
|
DrawStr(num_str);
|
||||||
case GL_EXTENSIONS:
|
DrawStr(glGetString(GL_VERSION));
|
||||||
sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win);
|
break;
|
||||||
DrawStr(num_str);
|
case GL_EXTENSIONS:
|
||||||
DrawStr(glGetString(GL_EXTENSIONS));
|
sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th),
|
||||||
break;
|
w_win, h_win);
|
||||||
}
|
DrawStr(num_str);
|
||||||
|
DrawStr(glGetString(GL_EXTENSIONS));
|
||||||
glPopMatrix();
|
break;
|
||||||
glMatrixMode(GL_MODELVIEW);
|
}
|
||||||
|
|
||||||
glEnable(GL_LIGHTING);
|
glPopMatrix();
|
||||||
//glEnable(GL_DEPTH_TEST);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
}
|
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
//glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
|
@ -456,4 +463,4 @@ glutIdleFunc(Animate);
|
||||||
glutMainLoop();
|
glutMainLoop();
|
||||||
return 0; // ANSI C requires main to return int.
|
return 0; // ANSI C requires main to return int.
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,7 +43,8 @@
|
||||||
|
|
||||||
#define WHALESPEED 250.0
|
#define WHALESPEED 250.0
|
||||||
|
|
||||||
typedef struct _fishRec {
|
typedef struct _fishRec
|
||||||
|
{
|
||||||
float x, y, z, phi, theta, psi, v;
|
float x, y, z, phi, theta, psi, v;
|
||||||
float xt, yt, zt;
|
float xt, yt, zt;
|
||||||
float htail, vtail;
|
float htail, vtail;
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||||
*/
|
*/
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h> /* For rand(). */
|
#include <stdlib.h> /* For rand(). */
|
||||||
#include <GLUT/glut.h>
|
#include <GLUT/glut.h>
|
||||||
#include "atlantis.h"
|
#include "atlantis.h"
|
||||||
|
|
||||||
|
@ -57,8 +57,10 @@ WhalePilot(fishRec * fish)
|
||||||
fish->theta = 0.0;
|
fish->theta = 0.0;
|
||||||
fish->psi -= 0.5;
|
fish->psi -= 0.5;
|
||||||
|
|
||||||
fish->x += WHALESPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
|
fish->x +=
|
||||||
fish->y += WHALESPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
|
WHALESPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
|
fish->y +=
|
||||||
|
WHALESPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
fish->z += WHALESPEED * fish->v * sin(fish->theta / RAD);
|
fish->z += WHALESPEED * fish->v * sin(fish->theta / RAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,8 +154,10 @@ SharkPilot(fishRec * fish)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fish->x += SHARKSPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
|
fish->x +=
|
||||||
fish->y += SHARKSPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
|
SHARKSPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
|
fish->y +=
|
||||||
|
SHARKSPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
fish->z += SHARKSPEED * fish->v * sin(fish->theta / RAD);
|
fish->z += SHARKSPEED * fish->v * sin(fish->theta / RAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Please see the SDL documentation for details on using the SDL API:
|
Please see the SDL documentation for details on using the SDL API:
|
||||||
/Developer/Documentation/SDL/docs.html
|
/Developer/Documentation/SDL/docs.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -12,168 +12,176 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
extern void Atlantis_Init ();
|
extern void Atlantis_Init();
|
||||||
extern void Atlantis_Reshape (int w, int h);
|
extern void Atlantis_Reshape(int w, int h);
|
||||||
extern void Atlantis_Animate ();
|
extern void Atlantis_Animate();
|
||||||
extern void Atlantis_Display ();
|
extern void Atlantis_Display();
|
||||||
|
|
||||||
static SDL_Surface *gScreen;
|
static SDL_Surface *gScreen;
|
||||||
|
|
||||||
static void initAttributes ()
|
static void
|
||||||
|
initAttributes()
|
||||||
{
|
{
|
||||||
// Setup attributes we want for the OpenGL context
|
// Setup attributes we want for the OpenGL context
|
||||||
|
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
// Don't set color bit sizes (SDL_GL_RED_SIZE, etc)
|
// Don't set color bit sizes (SDL_GL_RED_SIZE, etc)
|
||||||
// Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and
|
// Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and
|
||||||
// 5-5-5 RGB for 16-bit screens
|
// 5-5-5 RGB for 16-bit screens
|
||||||
|
|
||||||
// Request a 16-bit depth buffer (without this, there is no depth buffer)
|
// Request a 16-bit depth buffer (without this, there is no depth buffer)
|
||||||
value = 16;
|
value = 16;
|
||||||
SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, value);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, value);
|
||||||
|
|
||||||
|
|
||||||
// Request double-buffered OpenGL
|
// Request double-buffered OpenGL
|
||||||
// The fact that windows are double-buffered on Mac OS X has no effect
|
// The fact that windows are double-buffered on Mac OS X has no effect
|
||||||
// on OpenGL double buffering.
|
// on OpenGL double buffering.
|
||||||
value = 1;
|
value = 1;
|
||||||
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, value);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printAttributes ()
|
static void
|
||||||
|
printAttributes()
|
||||||
{
|
{
|
||||||
// Print out attributes of the context we created
|
// Print out attributes of the context we created
|
||||||
int nAttr;
|
int nAttr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
int attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE,
|
int attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE,
|
||||||
SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE };
|
SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE
|
||||||
|
};
|
||||||
char *desc[] = { "Red size: %d bits\n", "Blue size: %d bits\n", "Green size: %d bits\n",
|
|
||||||
"Alpha size: %d bits\n", "Color buffer size: %d bits\n",
|
char *desc[] =
|
||||||
"Depth bufer size: %d bits\n" };
|
{ "Red size: %d bits\n", "Blue size: %d bits\n",
|
||||||
|
"Green size: %d bits\n",
|
||||||
|
"Alpha size: %d bits\n", "Color buffer size: %d bits\n",
|
||||||
|
"Depth bufer size: %d bits\n"
|
||||||
|
};
|
||||||
|
|
||||||
nAttr = sizeof(attr) / sizeof(int);
|
nAttr = sizeof(attr) / sizeof(int);
|
||||||
|
|
||||||
for (i = 0; i < nAttr; i++) {
|
for (i = 0; i < nAttr; i++) {
|
||||||
|
|
||||||
int value;
|
int value;
|
||||||
SDL_GL_GetAttribute (attr[i], &value);
|
SDL_GL_GetAttribute(attr[i], &value);
|
||||||
printf (desc[i], value);
|
printf(desc[i], value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createSurface (int fullscreen)
|
static void
|
||||||
|
createSurface(int fullscreen)
|
||||||
{
|
{
|
||||||
Uint32 flags = 0;
|
Uint32 flags = 0;
|
||||||
|
|
||||||
flags = SDL_OPENGL;
|
flags = SDL_OPENGL;
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
flags |= SDL_FULLSCREEN;
|
flags |= SDL_FULLSCREEN;
|
||||||
|
|
||||||
// Create window
|
// Create window
|
||||||
gScreen = SDL_SetVideoMode (640, 480, 0, flags);
|
gScreen = SDL_SetVideoMode(640, 480, 0, flags);
|
||||||
if (gScreen == NULL) {
|
if (gScreen == NULL) {
|
||||||
|
|
||||||
fprintf (stderr, "Couldn't set 640x480 OpenGL video mode: %s\n",
|
fprintf(stderr, "Couldn't set 640x480 OpenGL video mode: %s\n",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initGL ()
|
static void
|
||||||
|
initGL()
|
||||||
{
|
{
|
||||||
Atlantis_Init ();
|
Atlantis_Init();
|
||||||
Atlantis_Reshape (gScreen->w, gScreen->h);
|
Atlantis_Reshape(gScreen->w, gScreen->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawGL ()
|
static void
|
||||||
|
drawGL()
|
||||||
{
|
{
|
||||||
Atlantis_Animate ();
|
Atlantis_Animate();
|
||||||
Atlantis_Display ();
|
Atlantis_Display();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mainLoop ()
|
static void
|
||||||
|
mainLoop()
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
int fps = 24;
|
int fps = 24;
|
||||||
int delay = 1000/fps;
|
int delay = 1000 / fps;
|
||||||
int thenTicks = -1;
|
int thenTicks = -1;
|
||||||
int nowTicks;
|
int nowTicks;
|
||||||
|
|
||||||
while ( !done ) {
|
|
||||||
|
|
||||||
/* Check for events */
|
while (!done) {
|
||||||
while ( SDL_PollEvent (&event) ) {
|
|
||||||
switch (event.type) {
|
/* Check for events */
|
||||||
|
while (SDL_PollEvent(&event)) {
|
||||||
|
switch (event.type) {
|
||||||
|
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
break;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
/* Any keypress quits the app... */
|
||||||
|
case SDL_QUIT:
|
||||||
|
done = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:
|
|
||||||
break;
|
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
|
||||||
break;
|
|
||||||
case SDL_KEYDOWN:
|
|
||||||
/* Any keypress quits the app... */
|
|
||||||
case SDL_QUIT:
|
|
||||||
done = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw at 24 hz
|
// Draw at 24 hz
|
||||||
// This approach is not normally recommended - it is better to
|
// This approach is not normally recommended - it is better to
|
||||||
// use time-based animation and run as fast as possible
|
// use time-based animation and run as fast as possible
|
||||||
drawGL ();
|
drawGL();
|
||||||
SDL_GL_SwapBuffers ();
|
SDL_GL_SwapBuffers();
|
||||||
|
|
||||||
// Time how long each draw-swap-delay cycle takes
|
// Time how long each draw-swap-delay cycle takes
|
||||||
// and adjust delay to get closer to target framerate
|
// and adjust delay to get closer to target framerate
|
||||||
if (thenTicks > 0) {
|
if (thenTicks > 0) {
|
||||||
nowTicks = SDL_GetTicks ();
|
nowTicks = SDL_GetTicks();
|
||||||
delay += (1000/fps - (nowTicks-thenTicks));
|
delay += (1000 / fps - (nowTicks - thenTicks));
|
||||||
thenTicks = nowTicks;
|
thenTicks = nowTicks;
|
||||||
if (delay < 0)
|
if (delay < 0)
|
||||||
delay = 1000/fps;
|
delay = 1000 / fps;
|
||||||
}
|
} else {
|
||||||
else {
|
thenTicks = SDL_GetTicks();
|
||||||
thenTicks = SDL_GetTicks ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Delay (delay);
|
SDL_Delay(delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Init SDL video subsystem
|
// Init SDL video subsystem
|
||||||
if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
|
|
||||||
fprintf(stderr, "Couldn't initialize SDL: %s\n",
|
|
||||||
SDL_GetError());
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
// Set GL context attributes
|
// Set GL context attributes
|
||||||
initAttributes ();
|
initAttributes();
|
||||||
|
|
||||||
// Create GL context
|
// Create GL context
|
||||||
createSurface (0);
|
createSurface(0);
|
||||||
|
|
||||||
// Get GL context attributes
|
// Get GL context attributes
|
||||||
printAttributes ();
|
printAttributes();
|
||||||
|
|
||||||
// Init GL state
|
// Init GL state
|
||||||
initGL ();
|
initGL();
|
||||||
|
|
||||||
// Draw, get events...
|
// Draw, get events...
|
||||||
mainLoop ();
|
mainLoop();
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,64 @@
|
||||||
#include "../SDL_sysvideo.h"
|
#include "../SDL_sysvideo.h"
|
||||||
#include "SDL_x11video.h"
|
#include "SDL_x11video.h"
|
||||||
|
|
||||||
|
static int numCmaps = 0;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Display *display;
|
||||||
|
int scrNum;
|
||||||
|
XStandardColormap cmap;
|
||||||
|
Visual visual;
|
||||||
|
} cmapTableEntry;
|
||||||
|
|
||||||
|
cmapTableEntry *cmapTable = NULL;
|
||||||
|
|
||||||
|
void
|
||||||
|
X11_TrackColormap(Display * display, int scrNum,
|
||||||
|
XStandardColormap * cmap, Visual * visual)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
cmapTableEntry *newTable = NULL;
|
||||||
|
|
||||||
|
/* only tracking DirectColor colormaps because they're the only ones
|
||||||
|
with gamma ramps */
|
||||||
|
if (DirectColor != visual->class) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* search the table to find out if we already have this one. We only
|
||||||
|
want one entry for each display, screen number, visualid
|
||||||
|
combination */
|
||||||
|
for (i = 0; i < numCmaps; i++) {
|
||||||
|
if (cmapTable[i].display == display &&
|
||||||
|
cmapTable[i].scrNum == scrNum &&
|
||||||
|
cmapTable[i].cmap.visualid == cmap->visualid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* increase the table by one entry. If the table is NULL create the
|
||||||
|
first entrty */
|
||||||
|
newTable = SDL_malloc((numCmaps + 1) * sizeof(cmapTableEntry));
|
||||||
|
if (NULL == newTable) {
|
||||||
|
SDL_SetError("Out of memory in X11_TrackColormap()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != cmapTable) {
|
||||||
|
SDL_memcpy(newTable, cmapTable, numCmaps * sizeof(cmapTableEntry));
|
||||||
|
SDL_free(cmapTable);
|
||||||
|
}
|
||||||
|
cmapTable = newTable;
|
||||||
|
|
||||||
|
cmapTable[numCmaps].display = display;
|
||||||
|
cmapTable[numCmaps].scrNum = scrNum;
|
||||||
|
SDL_memcpy(&cmapTable[numCmaps].cmap, cmap, sizeof(XStandardColormap));
|
||||||
|
SDL_memcpy(&cmapTable[numCmaps].visual, visual, sizeof(Visual));
|
||||||
|
|
||||||
|
numCmaps++;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
|
X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
#ifndef _SDL_x11gamma_h
|
#ifndef _SDL_x11gamma_h
|
||||||
#define _SDL_x11gamma_h
|
#define _SDL_x11gamma_h
|
||||||
|
|
||||||
|
extern void X11_TrackColormap(Display * display, int scrNum,
|
||||||
|
XStandardColormap * cmap, Visual * visual);
|
||||||
|
|
||||||
extern int X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
|
extern int X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
|
||||||
extern int X11_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
|
extern int X11_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
|
||||||
|
|
||||||
|
|
|
@ -184,22 +184,27 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||||
if (visual->class == DirectColor || visual->class == PseudoColor) {
|
if (visual->class == DirectColor || visual->class == PseudoColor) {
|
||||||
int nmaps;
|
int nmaps;
|
||||||
XStandardColormap *stdmaps;
|
XStandardColormap *stdmaps;
|
||||||
int i;
|
|
||||||
Bool found = False;
|
Bool found = False;
|
||||||
|
|
||||||
|
/* check to see if the colormap we need already exists */
|
||||||
if (0 != XGetRGBColormaps(data->display,
|
if (0 != XGetRGBColormaps(data->display,
|
||||||
RootWindow(data->display,
|
RootWindow(data->display,
|
||||||
displaydata->screen), &stdmaps,
|
displaydata->screen), &stdmaps,
|
||||||
&nmaps, XA_RGB_BEST_MAP)) {
|
&nmaps, XA_RGB_BEST_MAP)) {
|
||||||
|
int i;
|
||||||
for (i = 0; i < nmaps; i++) {
|
for (i = 0; i < nmaps; i++) {
|
||||||
if (stdmaps[i].visualid == visual->visualid) {
|
if (stdmaps[i].visualid == visual->visualid) {
|
||||||
xattr.colormap = stdmaps[i].colormap;
|
xattr.colormap = stdmaps[i].colormap;
|
||||||
|
X11_TrackColormap(data->display, displaydata->screen,
|
||||||
|
&stdmaps[i], visual);
|
||||||
found = True;
|
found = True;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFree(stdmaps);
|
XFree(stdmaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* it doesn't exist, so create it */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
int max = visual->map_entries - 1;
|
int max = visual->map_entries - 1;
|
||||||
XStandardColormap *cmap =
|
XStandardColormap *cmap =
|
||||||
|
@ -207,8 +212,10 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||||
visual->visualid, depth,
|
visual->visualid, depth,
|
||||||
XA_RGB_BEST_MAP, None,
|
XA_RGB_BEST_MAP, None,
|
||||||
max, max, max);
|
max, max, max);
|
||||||
if (cmap->visualid = visual->visualid) {
|
if (NULL != cmap && cmap->visualid == visual->visualid) {
|
||||||
xattr.colormap = cmap->colormap;
|
xattr.colormap = cmap->colormap;
|
||||||
|
X11_TrackColormap(data->display, displaydata->screen, cmap,
|
||||||
|
visual);
|
||||||
} else {
|
} else {
|
||||||
SDL_SetError
|
SDL_SetError
|
||||||
("Couldn't create window:XA_RGB_BEST_MAP not found");
|
("Couldn't create window:XA_RGB_BEST_MAP not found");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue