1
0
forked from 0ad/0ad

add/update win-specific code+header file comment

This was SVN commit r1841.
This commit is contained in:
janwas 2005-01-27 16:18:22 +00:00
parent f55107c114
commit 38d6f81d71
9 changed files with 155 additions and 49 deletions

View File

@ -1,3 +1,21 @@
// Windows-specific CPU related code
//
// 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/
#include "precompiled.h"
#include <stdlib.h> // for malloc, free

View File

@ -1,4 +1,4 @@
// stack trace, improved assert and exception handler
// stack trace, improved assert and exception handler for Win32
// Copyright (c) 2002-2005 Jan Wassenberg
//
// This program is free software; you can redistribute it and/or

View File

@ -1,3 +1,20 @@
// stack trace, improved assert and exception handler for Win32
// Copyright (c) 2002-2005 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 WDBG_H__
#define WDBG_H__

View File

@ -1,4 +1,4 @@
// Windows-specific code
// Windows-specific code and program entry point
// Copyright (c) 2003 Jan Wassenberg
//
// This program is free software; you can redistribute it and/or

View File

@ -1,5 +1,26 @@
#if !defined(__WIN_H__) && defined(_WIN32)
#define __WIN_H__
// compatibility fixes when compiling on Win32
// Copyright (c) 2002-2005 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 WIN_H__
#define WIN_H__
#ifndef _WIN32
#error "including win.h without _WIN32 defined"
#endif
#include <wchar.h>
@ -12,12 +33,11 @@
#include <stddef.h> // wchar_t
// libpng.h -> zlib.h -> zconf.h includes <windows.h>, which causes conflicts.
// inhibit this, and define what they actually need from windows.h
// incidentally, this requires all windows dependencies to include
// sysdep/win_internal.h
// prevent that, and define what they actually need from windows.h.
// incidentally, this requires all dependents of windows.h to include
// sysdep/win/win_internal.h instead.
#define _WINDOWS_ // windows.h include guard
#define WINAPI __stdcall
#define WINAPIV __cdecl
#endif // #ifndef __WIN_H__
#endif // #ifndef WIN_H__

View File

@ -1,3 +1,20 @@
// shared header for Win32-specific code
// Copyright (c) 2002-2005 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 WIN_INTERNAL_H
#define WIN_INTERNAL_H
@ -9,7 +26,7 @@
// Win32 socket decls aren't portable (e.g. problems with socklen_t)
// => skip winsock.h; lib.h should be used instead
// => skip winsock.h; wsock.h should be used instead
#define _WINSOCKAPI_
#define WIN32_LEAN_AND_MEAN
@ -292,15 +309,13 @@ enum BasicType
///////////////////////////////////////////////////////////////////////////////
/* Define _CRTIMP */
#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
#endif /* _CRTIMP */
# ifdef _DLL
# define _CRTIMP __declspec(dllimport)
# else
# define _CRTIMP
# endif
#endif
extern "C" {
_CRTIMP intptr_t _get_osfhandle(int);
@ -406,9 +421,10 @@ extern void win_unlock(uint idx);
// init and shutdown mechanism: register a function to be called at
// pre-main init or shutdown.
//
// the "segment name" determines when and in what order the functions are
// called: "LIB$W{type}{group}", where {type} is either I for
// (pre-main) initializers, or T for terminators (last of the atexit handlers).
// called: "LIB$W{type}{group}", where {type} is C for pre-libc init,
// I for pre-main init, or T for terminators (last of the atexit handlers).
// {group} is [B, Y]; groups are called in alphabetical order, but
// call order within the group itself is unspecified.
//

View File

@ -1,3 +1,21 @@
// partial pthread implementation for Win32
//
// Copyright (c) 2003-2005 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/
#include "precompiled.h"
#include <new>
@ -8,6 +26,7 @@
#include "win_internal.h"
#include "wpthread.h"
static HANDLE pthread_t_to_HANDLE(pthread_t p)
{
return (HANDLE)((char*)0 + p);

View File

@ -1,4 +1,4 @@
// POSIX asynchronous I/O for Win32
// partial pthread implementation for Win32
//
// Copyright (c) 2003-2005 Jan Wassenberg
//

View File

@ -1,11 +1,28 @@
#ifndef __WSDL_H__
#define __WSDL_H__
// 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__
#include "lib/types.h"
#include "SDL_keysym.h"
/* allow apps to override window name */
// allow apps to override window name
#ifndef APP_NAME
#define APP_NAME "ogl"
#endif
@ -16,7 +33,7 @@ extern "C" {
#define Uint32 u32
/* SDL_Init flags */
// SDL_Init flags
#define SDL_INIT_VIDEO 0
#define SDL_INIT_AUDIO 0
#define SDL_INIT_TIMER 0
@ -30,14 +47,14 @@ extern void SDL_Quit(void);
typedef enum
{
SDL_GL_DEPTH_SIZE,
SDL_GL_DOUBLEBUFFER /* ignored - always double buffered */
SDL_GL_DOUBLEBUFFER // ignored - always double buffered
}
SDL_GLattr;
extern int SDL_GL_SetAttribute(SDL_GLattr attr, int value);
/* SDL_SetVideoMode() flags */
// SDL_SetVideoMode() flags
#define SDL_OPENGL 0
#define SDL_FULLSCREEN 1
@ -62,9 +79,9 @@ SDL_VideoInfo;
extern SDL_VideoInfo* SDL_GetVideoInfo(void);
/*
* threads / sync
*/
//
// threads / sync
//
typedef void SDL_sem;
typedef void SDL_Thread;
@ -97,7 +114,7 @@ extern int SDL_ShowCursor(int toggle);
extern int SDL_SetGamma(float r, float g, float b);
/* macros */
// macros
#define SDL_GRAB_ON 0
#define SDL_WM_GrabInput(a)
@ -149,11 +166,10 @@ extern u64 SDL_Swap64(u64);
#define SDL_BYTE_ORDER SDL_LIL_ENDIAN
//////////////////////////////////////////////////////////////////////////////
/************************************************************************************************
* events
************************************************************************************************/
//
// events
//
//////////////////////////////////////////////////////////////////////////////
typedef struct
{
@ -174,7 +190,7 @@ typedef struct
}
SDL_MouseMotionEvent;
/* SDL_MouseButtonEvent.button */
// SDL_MouseButtonEvent.button
enum
{
// do not change order
@ -215,7 +231,7 @@ typedef struct
}
SDL_UserEvent;
/* SDL_Event.type */
// SDL_Event.type
enum
{
SDL_KEYDOWN,
@ -261,43 +277,43 @@ extern void SDL_WM_SetCaption(const char *title, const char *icon);
/* glutInitDisplayMode */
// glutInitDisplayMode
#define GLUT_RGB 0
#define GLUT_DOUBLE 0
#define GLUT_DEPTH 0
/* mouse buttons */
// mouse buttons
enum
{
GLUT_LEFT_BUTTON,
GLUT_RIGHT_BUTTON,
GLUT_MIDDLE_BUTTON /* also wheel, if avail */
GLUT_MIDDLE_BUTTON // also wheel, if avail
};
/* mouse button state */
// mouse button state
enum
{
GLUT_DOWN,
GLUT_UP
};
/* keys */
// keys
enum
{
GLUT_KEY_LEFT = 0x25, /* VK_* */
GLUT_KEY_LEFT = 0x25, // VK_*
GLUT_KEY_RIGHT = 0x27,
GLUT_KEY_UP = 0x26,
GLUT_KEY_DOWN = 0x28
};
/* glutSetCursor */
#define GLUT_CURSOR_INHERIT 32512 /* IDC_* */
// glutSetCursor
#define GLUT_CURSOR_INHERIT 32512 // IDC_*
#define GLUT_CURSOR_WAIT 32514
#define GLUT_CURSOR_DESTROY 32648
#define GLUT_CURSOR_NONE 0
/* glutGet */
// glutGet
enum
{
GLUT_ELAPSED_TIME,
@ -319,7 +335,7 @@ extern void glutSpecialFunc(void(*)(int, int, int));
extern void glutMouseFunc(void(*)(int, int, int, int));
#define glutInitDisplayMode(a) /* pixel format is hardwired */
#define glutInitDisplayMode(a) // pixel format is hardwired
extern int glutGameModeString(const char* str);
@ -344,4 +360,4 @@ extern void glutSetCursor(int);
}
#endif
#endif // #ifndef __WSDL_H__
#endif // #ifndef WSDL_H__