2005-01-27 17:18:22 +01:00
|
|
|
// emulation of a subset of SDL and GLUT for Win32
|
|
|
|
//
|
|
|
|
// Copyright (c) 2003 Jan Wassenberg
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// Contact info:
|
|
|
|
// Jan.Wassenberg@stud.uni-karlsruhe.de
|
|
|
|
// http://www.stud.uni-karlsruhe.de/~urkt/
|
|
|
|
|
|
|
|
#ifndef WSDL_H__
|
|
|
|
#define WSDL_H__
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2005-01-23 18:48:32 +01:00
|
|
|
#include "lib/types.h"
|
2004-06-19 16:29:40 +02:00
|
|
|
#include "SDL_keysym.h"
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
// allow apps to override window name
|
2004-03-03 00:56:51 +01:00
|
|
|
#ifndef APP_NAME
|
|
|
|
#define APP_NAME "ogl"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-10-12 06:27:55 +02:00
|
|
|
typedef u8 Uint8;
|
|
|
|
typedef u16 Uint16;
|
|
|
|
typedef u32 Uint32;
|
|
|
|
|
2004-05-16 05:31:29 +02:00
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
// SDL_Init flags
|
2004-03-03 00:56:51 +01:00
|
|
|
#define SDL_INIT_VIDEO 0
|
|
|
|
#define SDL_INIT_AUDIO 0
|
|
|
|
#define SDL_INIT_TIMER 0
|
|
|
|
#define SDL_INIT_NOPARACHUTE 0
|
|
|
|
|
2004-05-16 05:31:29 +02:00
|
|
|
extern int SDL_Init(Uint32 flags);
|
|
|
|
|
2005-01-23 18:48:32 +01:00
|
|
|
extern void SDL_Quit(void);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2005-10-31 02:15:49 +01:00
|
|
|
extern Uint8 SDL_GetAppState();
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SDL_GL_DEPTH_SIZE,
|
2005-01-27 17:18:22 +01:00
|
|
|
SDL_GL_DOUBLEBUFFER // ignored - always double buffered
|
2004-03-03 00:56:51 +01:00
|
|
|
}
|
|
|
|
SDL_GLattr;
|
|
|
|
|
|
|
|
extern int SDL_GL_SetAttribute(SDL_GLattr attr, int value);
|
|
|
|
|
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
// SDL_SetVideoMode() flags
|
2004-03-03 00:56:51 +01:00
|
|
|
#define SDL_OPENGL 0
|
|
|
|
#define SDL_FULLSCREEN 1
|
|
|
|
|
|
|
|
extern int SDL_SetVideoMode(int w, int h, int bpp, unsigned long flags);
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
}
|
|
|
|
SDL_Surface;
|
|
|
|
|
2005-01-23 18:48:32 +01:00
|
|
|
extern SDL_Surface* SDL_GetVideoSurface(void);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int video_mem;
|
|
|
|
}
|
|
|
|
SDL_VideoInfo;
|
|
|
|
|
2005-01-23 18:48:32 +01:00
|
|
|
extern SDL_VideoInfo* SDL_GetVideoInfo(void);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
//
|
|
|
|
// threads / sync
|
|
|
|
//
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
typedef void SDL_sem;
|
|
|
|
typedef void SDL_Thread;
|
|
|
|
|
|
|
|
extern void* SDL_GL_GetProcAddress(const char*);
|
|
|
|
|
2005-01-23 18:48:32 +01:00
|
|
|
extern void SDL_GL_SwapBuffers(void);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2005-01-23 18:48:32 +01:00
|
|
|
extern u32 SDL_GetTicks(void);
|
2005-01-07 02:25:10 +01:00
|
|
|
extern void SDL_Delay(u32 ms);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
extern SDL_sem* SDL_CreateSemaphore(int cnt);
|
2005-01-07 02:25:10 +01:00
|
|
|
extern void SDL_DestroySemaphore(SDL_sem*);
|
2004-03-03 00:56:51 +01:00
|
|
|
extern int SDL_SemPost(SDL_sem*);
|
|
|
|
extern int SDL_SemWait(SDL_sem* sem);
|
|
|
|
|
|
|
|
extern SDL_Thread* SDL_CreateThread(int(*)(void*), void*);
|
|
|
|
extern int SDL_KillThread(SDL_Thread*);
|
|
|
|
|
2005-01-07 02:25:10 +01:00
|
|
|
extern int SDL_WarpMouse(int, int);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2005-01-09 15:23:59 +01:00
|
|
|
enum ShowCursorToggle
|
|
|
|
{
|
|
|
|
SDL_DISABLE = 0,
|
|
|
|
SDL_ENABLE = 1,
|
|
|
|
SDL_QUERY = 2
|
|
|
|
};
|
|
|
|
extern int SDL_ShowCursor(int toggle);
|
|
|
|
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2004-05-24 22:25:48 +02:00
|
|
|
extern int SDL_SetGamma(float r, float g, float b);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
// macros
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
#define SDL_GRAB_ON 0
|
|
|
|
#define SDL_WM_GrabInput(a)
|
|
|
|
#define SDL_GetError() ""
|
|
|
|
|
|
|
|
|
2004-05-31 14:21:14 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef linux
|
|
|
|
# include <asm/byteorder.h>
|
|
|
|
# ifdef __arch__swab16
|
|
|
|
# define SDL_Swap16 __arch__swab16
|
|
|
|
# endif
|
|
|
|
# ifdef __arch__swab32
|
|
|
|
# define SDL_Swap32 __arch__swab32
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2005-01-13 01:17:31 +01:00
|
|
|
// Debug-mode ICC doesn't like the intrinsics, so only use them
|
|
|
|
// for MSVC and non-debug ICC.
|
2005-08-09 18:23:19 +02:00
|
|
|
#if MSC_VERSION && !( defined(__INTEL_COMPILER) && !defined(NDEBUG) )
|
2005-01-27 16:40:23 +01:00
|
|
|
extern unsigned short _byteswap_ushort(unsigned short);
|
|
|
|
extern unsigned long _byteswap_ulong(unsigned long);
|
|
|
|
extern unsigned __int64 _byteswap_uint64(unsigned __int64);
|
2005-01-09 15:23:59 +01:00
|
|
|
#pragma intrinsic(_byteswap_ushort)
|
|
|
|
#pragma intrinsic(_byteswap_ulong)
|
|
|
|
#pragma intrinsic(_byteswap_uint64)
|
2004-05-31 14:21:14 +02:00
|
|
|
# define SDL_Swap16 _byteswap_ushort
|
|
|
|
# define SDL_Swap32 _byteswap_ulong
|
|
|
|
# define SDL_Swap64 _byteswap_uint64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SDL_Swap16
|
|
|
|
extern u16 SDL_Swap16(u16);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SDL_Swap32
|
|
|
|
extern u32 SDL_Swap32(u32);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SDL_Swap64
|
|
|
|
extern u64 SDL_Swap64(u64);
|
|
|
|
#endif
|
|
|
|
|
2004-06-02 19:40:43 +02:00
|
|
|
#define SDL_LIL_ENDIAN 1234
|
|
|
|
#define SDL_BIG_ENDIAN 4321
|
|
|
|
|
|
|
|
#define SDL_BYTE_ORDER SDL_LIL_ENDIAN
|
2004-05-31 14:21:14 +02:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2005-01-27 17:18:22 +01:00
|
|
|
//
|
|
|
|
// events
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2005-10-12 06:27:55 +02:00
|
|
|
Uint8 type;
|
2004-03-03 00:56:51 +01:00
|
|
|
SDLKey sym;
|
|
|
|
u16 unicode;
|
|
|
|
}
|
|
|
|
SDL_keysym;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2005-10-12 06:27:55 +02:00
|
|
|
Uint8 type;
|
2004-03-03 00:56:51 +01:00
|
|
|
SDL_keysym keysym;
|
|
|
|
}
|
|
|
|
SDL_KeyboardEvent;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2005-10-12 06:27:55 +02:00
|
|
|
Uint8 type;
|
2004-03-03 00:56:51 +01:00
|
|
|
u16 x, y;
|
|
|
|
}
|
|
|
|
SDL_MouseMotionEvent;
|
|
|
|
|
2005-10-12 06:27:55 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Uint8 type;
|
|
|
|
}
|
|
|
|
SDL_QuitEvent;
|
|
|
|
|
2005-10-13 20:05:55 +02:00
|
|
|
enum SDL_MouseButtonEvent_button
|
2004-03-03 00:56:51 +01:00
|
|
|
{
|
2005-10-24 02:06:08 +02:00
|
|
|
// to remain compatible with regular SDL, these values must not change!
|
|
|
|
SDL_BUTTON_LEFT = 1,
|
|
|
|
SDL_BUTTON_MIDDLE = 2,
|
|
|
|
SDL_BUTTON_RIGHT = 3,
|
|
|
|
SDL_BUTTON_WHEELUP = 4,
|
|
|
|
SDL_BUTTON_WHEELDOWN = 5
|
2004-03-03 00:56:51 +01:00
|
|
|
};
|
|
|
|
|
2005-10-13 20:05:55 +02:00
|
|
|
enum SDL_MouseButtonEvent_state
|
|
|
|
{
|
|
|
|
SDL_RELEASED = 0,
|
|
|
|
SDL_PRESSED = 1
|
|
|
|
};
|
|
|
|
|
2004-03-03 00:56:51 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2005-10-12 06:27:55 +02:00
|
|
|
Uint8 type;
|
2004-03-03 00:56:51 +01:00
|
|
|
u8 button;
|
|
|
|
u8 state;
|
|
|
|
u16 x, y;
|
|
|
|
}
|
|
|
|
SDL_MouseButtonEvent;
|
|
|
|
|
2005-10-13 20:05:55 +02:00
|
|
|
enum SDL_ActiveEvent_state
|
2004-06-21 15:59:58 +02:00
|
|
|
{
|
|
|
|
SDL_APPACTIVE = 1,
|
|
|
|
SDL_APPMOUSEFOCUS = 2,
|
|
|
|
SDL_APPINPUTFOCUS = 4
|
|
|
|
};
|
|
|
|
|
2004-03-03 00:56:51 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2005-10-12 06:27:55 +02:00
|
|
|
Uint8 type;
|
2004-03-03 00:56:51 +01:00
|
|
|
u8 gain;
|
|
|
|
u8 state;
|
|
|
|
}
|
|
|
|
SDL_ActiveEvent;
|
|
|
|
|
2004-07-21 18:34:07 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2005-10-12 06:27:55 +02:00
|
|
|
Uint8 type;
|
2005-10-13 21:11:22 +02:00
|
|
|
int code;
|
|
|
|
void* data1;
|
2004-07-21 18:34:07 +02:00
|
|
|
}
|
|
|
|
SDL_UserEvent;
|
|
|
|
|
2005-10-13 20:05:55 +02:00
|
|
|
enum SDL_Event_type
|
2004-03-03 00:56:51 +01:00
|
|
|
{
|
|
|
|
SDL_KEYDOWN,
|
|
|
|
SDL_KEYUP,
|
|
|
|
SDL_MOUSEMOTION,
|
|
|
|
SDL_MOUSEBUTTONDOWN,
|
|
|
|
SDL_MOUSEBUTTONUP,
|
2004-07-21 18:34:07 +02:00
|
|
|
SDL_ACTIVEEVENT,
|
2005-10-12 06:27:55 +02:00
|
|
|
SDL_QUIT,
|
|
|
|
SDL_USEREVENT
|
2004-03-03 00:56:51 +01:00
|
|
|
};
|
|
|
|
|
2005-10-12 06:27:55 +02:00
|
|
|
typedef union
|
2004-03-03 00:56:51 +01:00
|
|
|
{
|
2005-10-12 06:27:55 +02:00
|
|
|
Uint8 type;
|
|
|
|
SDL_KeyboardEvent key;
|
|
|
|
SDL_MouseMotionEvent motion;
|
|
|
|
SDL_MouseButtonEvent button;
|
|
|
|
SDL_ActiveEvent active;
|
|
|
|
SDL_UserEvent user;
|
2004-03-03 00:56:51 +01:00
|
|
|
}
|
|
|
|
SDL_Event;
|
|
|
|
|
|
|
|
|
|
|
|
extern int SDL_EnableUNICODE(int enable);
|
2004-06-21 15:59:58 +02:00
|
|
|
extern int SDL_WaitEvent(SDL_Event*);
|
2004-03-03 00:56:51 +01:00
|
|
|
extern int SDL_PollEvent(SDL_Event* ev);
|
2004-07-21 18:34:07 +02:00
|
|
|
extern int SDL_PushEvent(SDL_Event* ev);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
extern void SDL_WM_SetCaption(const char *title, const char *icon);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
// glutInitDisplayMode
|
2004-03-03 00:56:51 +01:00
|
|
|
#define GLUT_RGB 0
|
|
|
|
#define GLUT_DOUBLE 0
|
|
|
|
#define GLUT_DEPTH 0
|
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
// mouse buttons
|
2004-03-03 00:56:51 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
GLUT_LEFT_BUTTON,
|
|
|
|
GLUT_RIGHT_BUTTON,
|
2005-01-27 17:18:22 +01:00
|
|
|
GLUT_MIDDLE_BUTTON // also wheel, if avail
|
2004-03-03 00:56:51 +01:00
|
|
|
};
|
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
// mouse button state
|
2004-03-03 00:56:51 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
GLUT_DOWN,
|
|
|
|
GLUT_UP
|
|
|
|
};
|
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
// keys
|
2004-03-03 00:56:51 +01:00
|
|
|
enum
|
|
|
|
{
|
2005-01-27 17:18:22 +01:00
|
|
|
GLUT_KEY_LEFT = 0x25, // VK_*
|
2004-03-03 00:56:51 +01:00
|
|
|
GLUT_KEY_RIGHT = 0x27,
|
|
|
|
GLUT_KEY_UP = 0x26,
|
|
|
|
GLUT_KEY_DOWN = 0x28
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
// glutSetCursor
|
|
|
|
#define GLUT_CURSOR_INHERIT 32512 // IDC_*
|
2004-03-03 00:56:51 +01:00
|
|
|
#define GLUT_CURSOR_WAIT 32514
|
|
|
|
#define GLUT_CURSOR_DESTROY 32648
|
|
|
|
#define GLUT_CURSOR_NONE 0
|
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
// glutGet
|
2004-03-03 00:56:51 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
GLUT_ELAPSED_TIME,
|
|
|
|
GLUT_SCREEN_WIDTH,
|
|
|
|
GLUT_SCREEN_HEIGHT,
|
|
|
|
|
|
|
|
GLUT_GAME_MODE_WIDTH,
|
|
|
|
GLUT_GAME_MODE_HEIGHT,
|
|
|
|
GLUT_GAME_MODE_PIXEL_DEPTH,
|
|
|
|
GLUT_GAME_MODE_REFRESH_RATE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern void glutIdleFunc(void(*)());
|
|
|
|
extern void glutDisplayFunc(void(*)());
|
|
|
|
extern void glutKeyboardFunc(void(*)(int, int, int));
|
|
|
|
extern void glutSpecialFunc(void(*)(int, int, int));
|
|
|
|
extern void glutMouseFunc(void(*)(int, int, int, int));
|
|
|
|
|
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
#define glutInitDisplayMode(a) // pixel format is hardwired
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
extern int glutGameModeString(const char* str);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern void glutInit(int* argc, char* argv[]);
|
|
|
|
extern int glutGet(int arg);
|
2005-01-23 18:48:32 +01:00
|
|
|
extern int glutEnterGameMode(void);
|
|
|
|
extern void glutMainLoop(void);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2005-01-23 18:48:32 +01:00
|
|
|
extern void glutPostRedisplay(void);
|
2004-03-03 00:56:51 +01:00
|
|
|
|
|
|
|
extern void glutSetCursor(int);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define glutSwapBuffers SDL_GL_SwapBuffers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-01-27 17:18:22 +01:00
|
|
|
#endif // #ifndef WSDL_H__
|