mirror of
https://github.com/glest/glest-source.git
synced 2025-08-08 09:26:27 +02:00
Code Restructuring to make mega-glest more standard
This commit is contained in:
@@ -1,111 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_SOCKET_H_
|
||||
#define _SHARED_PLATFORM_SOCKET_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <fcntl.h>
|
||||
#include <map>
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
// =====================================================
|
||||
// class IP
|
||||
// =====================================================
|
||||
|
||||
class Ip{
|
||||
private:
|
||||
unsigned char bytes[4];
|
||||
|
||||
public:
|
||||
Ip();
|
||||
Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3);
|
||||
Ip(const string& ipString);
|
||||
|
||||
unsigned char getByte(int byteIndex) {return bytes[byteIndex];}
|
||||
string getString() const;
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Socket
|
||||
// =====================================================
|
||||
|
||||
class Socket {
|
||||
protected:
|
||||
int sock;
|
||||
long lastDebugEvent;
|
||||
|
||||
public:
|
||||
Socket(int sock);
|
||||
Socket();
|
||||
~Socket();
|
||||
|
||||
static bool enableDebugText;
|
||||
|
||||
// Int lookup is socket fd while bool result is whether or not that socket was signalled for reading
|
||||
static bool hasDataToRead(std::map<int,bool> &socketTriggeredList);
|
||||
static bool hasDataToRead(int socket);
|
||||
bool hasDataToRead();
|
||||
void disconnectSocket();
|
||||
|
||||
int getSocketId() const { return sock; }
|
||||
|
||||
int getDataToRead();
|
||||
int send(const void *data, int dataSize);
|
||||
int receive(void *data, int dataSize);
|
||||
int peek(void *data, int dataSize);
|
||||
|
||||
void setBlock(bool block);
|
||||
bool isReadable();
|
||||
bool isWritable(bool waitOnDelayedResponse);
|
||||
bool isConnected();
|
||||
|
||||
string getHostName() const;
|
||||
string getIp() const;
|
||||
|
||||
protected:
|
||||
static void throwException(const string &str);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class ClientSocket
|
||||
// =====================================================
|
||||
|
||||
class ClientSocket: public Socket{
|
||||
public:
|
||||
void connect(const Ip &ip, int port);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class ServerSocket
|
||||
// =====================================================
|
||||
|
||||
class ServerSocket: public Socket{
|
||||
public:
|
||||
void bind(int port);
|
||||
void listen(int connectionQueueSize= SOMAXCONN);
|
||||
Socket *accept();
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,55 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_FACTORYREPOSITORY_H_
|
||||
#define _SHARED_PLATFORM_FACTORYREPOSITORY_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "graphics_factory.h"
|
||||
#include "sound_factory.h"
|
||||
|
||||
#include "graphics_factory_gl.h"
|
||||
#include "sound_factory_openal.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
using Shared::Graphics::GraphicsFactory;
|
||||
using Shared::Sound::SoundFactory;
|
||||
using Shared::Graphics::Gl::GraphicsFactoryGl;
|
||||
using Shared::Sound::OpenAL::SoundFactoryOpenAL;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
// =====================================================
|
||||
// class FactoryRepository
|
||||
// =====================================================
|
||||
|
||||
class FactoryRepository{
|
||||
private:
|
||||
FactoryRepository(){};
|
||||
FactoryRepository(const FactoryRepository& );
|
||||
void operator=(const FactoryRepository& );
|
||||
|
||||
private:
|
||||
GraphicsFactoryGl graphicsFactoryGl;
|
||||
SoundFactoryOpenAL soundFactoryOpenAL;
|
||||
|
||||
public:
|
||||
static FactoryRepository &getInstance();
|
||||
|
||||
GraphicsFactory *getGraphicsFactory(const string &name);
|
||||
SoundFactory *getSoundFactory(const string &name);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,57 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
#ifndef _SHARED_PLATFORM_GLWRAP_H_
|
||||
#define _SHARED_PLATFORM_GLWRAP_H_
|
||||
|
||||
#include <SDL.h>
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <SDL_opengl.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "font.h"
|
||||
#include "types.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
using Shared::Graphics::FontMetrics;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
// =====================================================
|
||||
// class PlatformContextGl
|
||||
// =====================================================
|
||||
|
||||
class PlatformContextGl {
|
||||
public:
|
||||
virtual ~PlatformContextGl() {}
|
||||
|
||||
virtual void init(int colorBits, int depthBits, int stencilBits);
|
||||
virtual void end();
|
||||
|
||||
virtual void makeCurrent();
|
||||
virtual void swapBuffers();
|
||||
|
||||
DeviceContextHandle getHandle() const { return 0; }
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// Global Fcs
|
||||
// =====================================================
|
||||
|
||||
void createGlFontBitmaps(uint32 &base, const string &type, int size, int width, int charCount, FontMetrics &metrics);
|
||||
void createGlFontOutlines(uint32 &base, const string &type, int width, float depth, int charCount, FontMetrics &metrics);
|
||||
const char *getPlatformExtensions(const PlatformContextGl *pcgl);
|
||||
void* getGlProcAddress(const char *procName);
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,7 +0,0 @@
|
||||
#ifndef _NOIMPL_H_
|
||||
#define _NOIMPL_H_
|
||||
|
||||
#define NOIMPL std::cerr << __PRETTY_FUNCTION__ << " not implemented.\n";
|
||||
|
||||
#endif
|
||||
|
@@ -1,29 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
#ifndef _SHARED_PLATFORM_MAIN_H_
|
||||
#define _SHARED_PLATFORM_MAIN_H_
|
||||
|
||||
#include <SDL.h>
|
||||
#include <iostream>
|
||||
|
||||
#define MAIN_FUNCTION(X) int main(int argc, char **argv) \
|
||||
{ \
|
||||
if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { \
|
||||
std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n"; \
|
||||
return 1; \
|
||||
} \
|
||||
SDL_EnableUNICODE(1); \
|
||||
int result = X(argc, argv); \
|
||||
SDL_Quit(); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,115 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
#ifndef _SHARED_PLATFORM_PLATFORMUTIL_H_
|
||||
#define _SHARED_PLATFORM_PLATFORMUTIL_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "checksum.h"
|
||||
#include <utility>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::exception;
|
||||
|
||||
using Shared::Platform::int64;
|
||||
|
||||
using Shared::Util::Checksum;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
// =====================================================
|
||||
// class PerformanceTimer
|
||||
// =====================================================
|
||||
|
||||
class PerformanceTimer{
|
||||
private:
|
||||
Uint32 lastTicks;
|
||||
Uint32 updateTicks;
|
||||
|
||||
int times; // number of consecutive times
|
||||
int maxTimes; // maximum number consecutive times
|
||||
|
||||
public:
|
||||
void init(float fps, int maxTimes= -1);
|
||||
|
||||
bool isTime();
|
||||
void reset();
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Chrono
|
||||
// =====================================================
|
||||
|
||||
class Chrono {
|
||||
private:
|
||||
Uint32 startCount;
|
||||
Uint32 accumCount;
|
||||
Uint32 freq;
|
||||
bool stopped;
|
||||
|
||||
public:
|
||||
Chrono();
|
||||
void start();
|
||||
void stop();
|
||||
int64 getMicros() const;
|
||||
int64 getMillis() const;
|
||||
int64 getSeconds() const;
|
||||
|
||||
private:
|
||||
int64 queryCounter(int multiplier) const;
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class PlatformExceptionHandler
|
||||
// =====================================================
|
||||
|
||||
class PlatformExceptionHandler {
|
||||
public:
|
||||
virtual ~PlatformExceptionHandler() {}
|
||||
void install(string dumpFileName) {}
|
||||
virtual void handle()=0;
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// Misc
|
||||
// =====================================================
|
||||
|
||||
void findAll(const string &path, vector<string> &results, bool cutExtension=false, bool errorOnNotFound=true);
|
||||
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum);
|
||||
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(const string &path, const string &filterFileExt, vector<std::pair<string,int32> > *recursiveMap);
|
||||
void createDirectoryPaths(string Path);
|
||||
string extractDirectoryPathFromFile(string filename);
|
||||
|
||||
bool changeVideoMode(int resH, int resW, int colorBits, int refreshFrequency);
|
||||
void restoreVideoMode();
|
||||
|
||||
void message(string message);
|
||||
bool ask(string message);
|
||||
void exceptionMessage(const exception &excp);
|
||||
|
||||
int getScreenW();
|
||||
int getScreenH();
|
||||
|
||||
void sleep(int millis);
|
||||
|
||||
void showCursor(bool b);
|
||||
bool isKeyDown(int virtualKey);
|
||||
string getCommandLine();
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,26 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
#ifndef _SHARED_PLATFORM_SDL_GLOBALS_H_
|
||||
#define _SHARED_PLATFORM_SDL_GLOBALS_H_
|
||||
|
||||
// This header contains things that should not be used outside the platform/sdl
|
||||
// directory
|
||||
|
||||
namespace Shared{ namespace Platform{ namespace Private{
|
||||
|
||||
extern bool shouldBeFullscreen;
|
||||
extern int ScreenWidth;
|
||||
extern int ScreenHeight;
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
@@ -1,67 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_THREAD_H_
|
||||
#define _SHARED_PLATFORM_THREAD_H_
|
||||
|
||||
#include <SDL_thread.h>
|
||||
#include <SDL_mutex.h>
|
||||
|
||||
// =====================================================
|
||||
// class Thread
|
||||
// =====================================================
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
class Thread{
|
||||
public:
|
||||
enum Priority {
|
||||
pIdle = 0,
|
||||
pLow = 1,
|
||||
pNormal = 2,
|
||||
pHigh = 3,
|
||||
pRealTime = 4
|
||||
};
|
||||
|
||||
private:
|
||||
SDL_Thread* thread;
|
||||
|
||||
public:
|
||||
virtual ~Thread() {}
|
||||
|
||||
void start();
|
||||
virtual void execute()=0;
|
||||
void setPriority(Thread::Priority threadPriority);
|
||||
void suspend();
|
||||
void resume();
|
||||
|
||||
private:
|
||||
static int beginExecution(void *param);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Mutex
|
||||
// =====================================================
|
||||
|
||||
class Mutex{
|
||||
private:
|
||||
SDL_mutex* mutex;
|
||||
|
||||
public:
|
||||
Mutex();
|
||||
~Mutex();
|
||||
void p();
|
||||
void v();
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,37 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
#ifndef _SHARED_PLATFORM_TYPES_H_
|
||||
#define _SHARED_PLATFORM_TYPES_H_
|
||||
|
||||
#include <SDL_types.h>
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
// These don't have a real meaning in the SDL port
|
||||
typedef void* WindowHandle;
|
||||
typedef void* DeviceContextHandle;
|
||||
typedef void* GlContextHandle;
|
||||
|
||||
typedef float float32;
|
||||
typedef double float64;
|
||||
// don't use Sint8 here because that is defined as signed char
|
||||
// and some parts of the code do std::string str = (int8*) var;
|
||||
typedef char int8;
|
||||
typedef Uint8 uint8;
|
||||
typedef Sint16 int16;
|
||||
typedef Uint16 uint16;
|
||||
typedef Sint32 int32;
|
||||
typedef Uint32 uint32;
|
||||
typedef Sint64 int64;
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,144 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_WINDOW_H_
|
||||
#define _SHARED_PLATFORM_WINDOW_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <SDL.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
using std::map;
|
||||
using std::string;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
class Timer;
|
||||
class PlatformContextGl;
|
||||
|
||||
enum MouseButton{
|
||||
mbLeft,
|
||||
mbRight,
|
||||
mbCenter
|
||||
};
|
||||
|
||||
enum SizeState{
|
||||
ssMaximized,
|
||||
ssMinimized,
|
||||
ssRestored
|
||||
};
|
||||
|
||||
// keycode constants (unfortunately designed after DirectInput and therefore not
|
||||
// very specific)
|
||||
// They also have to fit into a char. The positive numbers seem to be equal
|
||||
// to ascii, for the rest we have to find sensefull mappings from SDL (which is
|
||||
// alot more fine grained like left/right control instead of just control...)
|
||||
const char vkAdd = -1;
|
||||
const char vkSubtract = -2;
|
||||
const char vkAlt = -3;
|
||||
const char vkControl = -4;
|
||||
const char vkShift = -5;
|
||||
const char vkEscape = -6;
|
||||
const char vkUp = -7;
|
||||
const char vkLeft = -8;
|
||||
const char vkRight = -9;
|
||||
const char vkDown = -10;
|
||||
const char vkReturn = -11;
|
||||
const char vkBack = -12;
|
||||
|
||||
struct MouseState{
|
||||
bool leftMouse;
|
||||
bool rightMouse;
|
||||
bool centerMouse;
|
||||
};
|
||||
|
||||
enum WindowStyle{
|
||||
wsFullscreen,
|
||||
wsWindowedFixed,
|
||||
wsWindowedResizable
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Window
|
||||
// =====================================================
|
||||
|
||||
class Window {
|
||||
private:
|
||||
Uint32 lastMouseDown[3];
|
||||
int lastMouseX[3];
|
||||
int lastMouseY[3];
|
||||
|
||||
protected:
|
||||
int w, h;
|
||||
|
||||
public:
|
||||
static bool handleEvent();
|
||||
|
||||
Window();
|
||||
virtual ~Window();
|
||||
|
||||
WindowHandle getHandle() {return 0;}
|
||||
string getText();
|
||||
int getX() { return 0; }
|
||||
int getY() { return 0; }
|
||||
int getW() { return w; }
|
||||
int getH() { return h; }
|
||||
|
||||
//component state
|
||||
int getClientW() { return getW(); }
|
||||
int getClientH() { return getH(); }
|
||||
float getAspect();
|
||||
|
||||
//object state
|
||||
void setText(string text);
|
||||
void setStyle(WindowStyle windowStyle);
|
||||
void setSize(int w, int h);
|
||||
void setPos(int x, int y);
|
||||
void setEnabled(bool enabled);
|
||||
void setVisible(bool visible);
|
||||
|
||||
//misc
|
||||
void create();
|
||||
void destroy();
|
||||
void minimize();
|
||||
|
||||
protected:
|
||||
virtual void eventCreate(){}
|
||||
virtual void eventMouseDown(int x, int y, MouseButton mouseButton){}
|
||||
virtual void eventMouseUp(int x, int y, MouseButton mouseButton){}
|
||||
virtual void eventMouseMove(int x, int y, const MouseState* mouseState){}
|
||||
virtual void eventMouseDoubleClick(int x, int y, MouseButton mouseButton){}
|
||||
virtual void eventKeyDown(char key){}
|
||||
virtual void eventKeyUp(char key){}
|
||||
virtual void eventKeyPress(char c){}
|
||||
virtual void eventResize(){};
|
||||
virtual void eventPaint(){}
|
||||
virtual void eventTimer(int timerId){}
|
||||
virtual void eventActivate(bool activated){};
|
||||
virtual void eventResize(SizeState sizeState){};
|
||||
virtual void eventMenu(int menuId){}
|
||||
virtual void eventClose(){};
|
||||
virtual void eventDestroy(){};
|
||||
|
||||
private:
|
||||
/// needed to detect double clicks
|
||||
void handleMouseDown(SDL_Event event);
|
||||
|
||||
static MouseButton getMouseButton(int sdlButton);
|
||||
static char getKey(SDL_keysym keysym);
|
||||
static void toggleFullscreen();
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,38 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_WINDOWGL_H_
|
||||
#define _SHARED_PLATFORM_WINDOWGL_H_
|
||||
|
||||
#include "context_gl.h"
|
||||
#include "window.h"
|
||||
|
||||
using Shared::Graphics::Gl::ContextGl;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
// =====================================================
|
||||
// class WindowGl
|
||||
// =====================================================
|
||||
|
||||
class WindowGl: public Window{
|
||||
private:
|
||||
ContextGl context;
|
||||
|
||||
public:
|
||||
void initGl(int colorBits, int depthBits, int stencilBits);
|
||||
void makeCurrentGl();
|
||||
void swapBuffersGl();
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,58 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_FACTORYREPOSITORY_H_
|
||||
#define _SHARED_PLATFORM_FACTORYREPOSITORY_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "graphics_factory.h"
|
||||
#include "sound_factory.h"
|
||||
|
||||
#include "graphics_factory_gl.h"
|
||||
#include "graphics_factory_gl2.h"
|
||||
#include "sound_factory_ds8.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
using Shared::Graphics::GraphicsFactory;
|
||||
using Shared::Sound::SoundFactory;
|
||||
using Shared::Graphics::Gl::GraphicsFactoryGl;
|
||||
using Shared::Graphics::Gl::GraphicsFactoryGl2;
|
||||
using Shared::Sound::Ds8::SoundFactoryDs8;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
// =====================================================
|
||||
// class FactoryRepository
|
||||
// =====================================================
|
||||
|
||||
class FactoryRepository{
|
||||
private:
|
||||
FactoryRepository(){};
|
||||
FactoryRepository(FactoryRepository &);
|
||||
void operator=(FactoryRepository &);
|
||||
|
||||
private:
|
||||
GraphicsFactoryGl graphicsFactoryGl;
|
||||
GraphicsFactoryGl2 graphicsFactoryGl2;
|
||||
SoundFactoryDs8 soundFactoryDs8;
|
||||
|
||||
public:
|
||||
static FactoryRepository &getInstance();
|
||||
|
||||
GraphicsFactory *getGraphicsFactory(const string &name);
|
||||
SoundFactory *getSoundFactory(const string &name);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,65 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_GLWRAP_H_
|
||||
#define _SHARED_PLATFORM_GLWRAP_H_
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <GL\gl.h>
|
||||
#include <GL\glu.h>
|
||||
#include <glprocs.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "font.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
#define GLEST_GLPROC(X, Y) inline X( static a= wglGetProcAddress(a); return a;)
|
||||
|
||||
using std::string;
|
||||
|
||||
using Shared::Graphics::FontMetrics;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
// =====================================================
|
||||
// class PlatformContextGl
|
||||
// =====================================================
|
||||
|
||||
class PlatformContextGl{
|
||||
protected:
|
||||
DeviceContextHandle dch;
|
||||
GlContextHandle glch;
|
||||
|
||||
public:
|
||||
virtual void init(int colorBits, int depthBits, int stencilBits);
|
||||
virtual void end();
|
||||
|
||||
virtual void makeCurrent();
|
||||
virtual void swapBuffers();
|
||||
|
||||
DeviceContextHandle getHandle() const {return dch;}
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// Global Fcs
|
||||
// =====================================================
|
||||
|
||||
void createGlFontBitmaps(uint32 &base, const string &type, int size, int width, int charCount, FontMetrics &metrics);
|
||||
void createGlFontOutlines(uint32 &base, const string &type, int width, float depth, int charCount, FontMetrics &metrics);
|
||||
const char *getPlatformExtensions(const PlatformContextGl *pcgl);
|
||||
PROC getGlProcAddress(const char *procName);
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,23 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_DEFINITIONS_H_
|
||||
#define _SHARED_PLATFORM_DEFINITIONS_H_
|
||||
|
||||
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,19 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_MAIN_H_
|
||||
#define _SHARED_PLATFORM_MAIN_H_
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define MAIN_FUNCTION(X) int main(int argc, char *argv[]){return X(argc, argv);}
|
||||
|
||||
#endif
|
@@ -1,90 +0,0 @@
|
||||
#ifndef _SHARED_PLATFORM_POPUPMENU_H_
|
||||
#define _SHARED_PLATFORM_POPUPMENU_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
class Menu;
|
||||
|
||||
// =====================================================
|
||||
// class MenuBase
|
||||
// =====================================================
|
||||
|
||||
class MenuBase{
|
||||
private:
|
||||
static int nextId;
|
||||
|
||||
protected:
|
||||
int id;
|
||||
string text;
|
||||
HMENU handle;
|
||||
|
||||
public:
|
||||
void init(const string &text="");
|
||||
virtual ~MenuBase(){};
|
||||
|
||||
virtual void create(Menu *parent)= 0;
|
||||
virtual void destroy(){};
|
||||
|
||||
int getId() const {return id;}
|
||||
const string &getText() const {return text;}
|
||||
HMENU getHandle() const {return handle;}
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Menu
|
||||
// =====================================================
|
||||
|
||||
class Menu: public MenuBase{
|
||||
private:
|
||||
typedef vector<MenuBase*> MenuChildren;
|
||||
|
||||
private:
|
||||
MenuChildren children;
|
||||
|
||||
public:
|
||||
virtual void create(Menu *parent= NULL);
|
||||
virtual void destroy();
|
||||
|
||||
int getChildCount() const {return children.size();}
|
||||
MenuBase *getChild(int i) const {return children[i];}
|
||||
|
||||
void addChild(MenuBase *menu) {children.push_back(menu);}
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class MenuItem
|
||||
// =====================================================
|
||||
|
||||
class MenuItem: public MenuBase{
|
||||
private:
|
||||
bool isChecked;
|
||||
Menu *parent;
|
||||
|
||||
public:
|
||||
virtual void create(Menu *parent);
|
||||
|
||||
void setChecked(bool checked);
|
||||
|
||||
Menu *getParent() const {return parent;}
|
||||
bool getChecked() const {return isChecked;}
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class MenuSeparator
|
||||
// =====================================================
|
||||
|
||||
class MenuSeparator: public MenuBase{
|
||||
public:
|
||||
virtual void create(Menu *parent);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,125 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_PLATFORMUTIL_H_
|
||||
#define _SHARED_PLATFORM_PLATFORMUTIL_H_
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "types.h"
|
||||
#include "checksum.h"
|
||||
#include <utility>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::exception;
|
||||
|
||||
using Shared::Platform::int64;
|
||||
using Shared::Util::Checksum;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
// =====================================================
|
||||
// class PerformanceTimer
|
||||
// =====================================================
|
||||
|
||||
class PerformanceTimer{
|
||||
private:
|
||||
int64 thisTicks;
|
||||
int64 lastTicks;
|
||||
int64 updateTicks;
|
||||
|
||||
int times; // number of consecutive times
|
||||
int maxTimes; // maximum number consecutive times
|
||||
|
||||
public:
|
||||
void init(int fps, int maxTimes= -1);
|
||||
|
||||
bool isTime();
|
||||
void reset();
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Chrono
|
||||
// =====================================================
|
||||
|
||||
class Chrono{
|
||||
private:
|
||||
int64 startCount;
|
||||
int64 accumCount;
|
||||
int64 freq;
|
||||
bool stopped;
|
||||
|
||||
public:
|
||||
Chrono();
|
||||
void start();
|
||||
void stop();
|
||||
int64 getMicros() const;
|
||||
int64 getMillis() const;
|
||||
int64 getSeconds() const;
|
||||
|
||||
private:
|
||||
int64 queryCounter(int multiplier) const;
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class PlatformExceptionHandler
|
||||
// =====================================================
|
||||
|
||||
LONG WINAPI UnhandledExceptionFilter2(struct _EXCEPTION_POINTERS *ExceptionInfo);
|
||||
|
||||
class PlatformExceptionHandler{
|
||||
private:
|
||||
static PlatformExceptionHandler *thisPointer;
|
||||
|
||||
private:
|
||||
static LONG WINAPI handler(LPEXCEPTION_POINTERS pointers);
|
||||
string dumpFileName;
|
||||
|
||||
public:
|
||||
void install(string dumpFileName);
|
||||
virtual void handle()=0;
|
||||
static string codeToStr(DWORD code);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// Misc
|
||||
// =====================================================
|
||||
|
||||
void findAll(const string &path, vector<string> &results, bool cutExtension=false, bool errorOnNotFound=true);
|
||||
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum);
|
||||
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(const string &path, const string &filterFileExt, vector<std::pair<string,int32> > *recursiveMap);
|
||||
void createDirectoryPaths(string Path);
|
||||
string extractDirectoryPathFromFile(string filename);
|
||||
|
||||
bool changeVideoMode(int resH, int resW, int colorBits, int refreshFrequency);
|
||||
void restoreVideoMode();
|
||||
|
||||
void message(string message);
|
||||
bool ask(string message);
|
||||
void exceptionMessage(const exception &excp);
|
||||
|
||||
int getScreenW();
|
||||
int getScreenH();
|
||||
|
||||
void sleep(int millis);
|
||||
|
||||
void showCursor(bool b);
|
||||
bool isKeyDown(int virtualKey);
|
||||
string getCommandLine();
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,113 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_SOCKET_H_
|
||||
#define _SHARED_PLATFORM_SOCKET_H_
|
||||
|
||||
#include <string>
|
||||
#include <winsock.h>
|
||||
#include <map>
|
||||
|
||||
using std::string;
|
||||
|
||||
const char* WSAGetLastErrorMessage(const char* pcMessagePrefix,int nErrorID = 0);
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
// =====================================================
|
||||
// class IP
|
||||
// =====================================================
|
||||
|
||||
class Ip{
|
||||
private:
|
||||
unsigned char bytes[4];
|
||||
|
||||
public:
|
||||
Ip();
|
||||
Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3);
|
||||
Ip(const string& ipString);
|
||||
|
||||
unsigned char getByte(int byteIndex) {return bytes[byteIndex];}
|
||||
string getString() const;
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Socket
|
||||
// =====================================================
|
||||
|
||||
class Socket{
|
||||
private:
|
||||
class SocketManager{
|
||||
public:
|
||||
SocketManager();
|
||||
~SocketManager();
|
||||
};
|
||||
|
||||
protected:
|
||||
static SocketManager socketManager;
|
||||
SOCKET sock;
|
||||
|
||||
public:
|
||||
Socket(SOCKET sock);
|
||||
Socket();
|
||||
~Socket();
|
||||
|
||||
static bool enableDebugText;
|
||||
|
||||
// Int lookup is socket fd while bool result is whether or not that socket was signalled for reading
|
||||
static bool hasDataToRead(std::map<int,bool> &socketTriggeredList);
|
||||
static bool hasDataToRead(int socket);
|
||||
bool hasDataToRead();
|
||||
void disconnectSocket();
|
||||
|
||||
int getSocketId() const { return sock; }
|
||||
|
||||
int getDataToRead();
|
||||
int send(const void *data, int dataSize);
|
||||
int receive(void *data, int dataSize);
|
||||
int peek(void *data, int dataSize);
|
||||
|
||||
void setBlock(bool block);
|
||||
bool isReadable();
|
||||
bool isWritable(bool waitOnDelayedResponse);
|
||||
bool isConnected();
|
||||
|
||||
string getHostName() const;
|
||||
string getIp() const;
|
||||
|
||||
protected:
|
||||
static void throwException(const string &str);
|
||||
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class ClientSocket
|
||||
// =====================================================
|
||||
|
||||
class ClientSocket: public Socket{
|
||||
public:
|
||||
void connect(const Ip &ip, int port);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class ServerSocket
|
||||
// =====================================================
|
||||
|
||||
class ServerSocket: public Socket{
|
||||
public:
|
||||
void bind(int port);
|
||||
void listen(int connectionQueueSize= SOMAXCONN);
|
||||
Socket *accept();
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,69 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_THREAD_H_
|
||||
#define _SHARED_PLATFORM_THREAD_H_
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// =====================================================
|
||||
// class Thread
|
||||
// =====================================================
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
typedef LPTHREAD_START_ROUTINE ThreadFunction;
|
||||
typedef DWORD ThreadId;
|
||||
|
||||
class Thread{
|
||||
public:
|
||||
enum Priority{
|
||||
pIdle= THREAD_PRIORITY_IDLE,
|
||||
pLow= THREAD_PRIORITY_BELOW_NORMAL,
|
||||
pNormal= THREAD_PRIORITY_NORMAL,
|
||||
pHigh= THREAD_PRIORITY_ABOVE_NORMAL,
|
||||
pRealTime= THREAD_PRIORITY_TIME_CRITICAL
|
||||
};
|
||||
|
||||
private:
|
||||
HANDLE threadHandle;
|
||||
static const ThreadId threadIdBase= 1000;
|
||||
static ThreadId nextThreadId;
|
||||
|
||||
public:
|
||||
void start();
|
||||
virtual void execute()=0;
|
||||
void setPriority(Thread::Priority threadPriority);
|
||||
void suspend();
|
||||
void resume();
|
||||
|
||||
private:
|
||||
static DWORD WINAPI beginExecution(void *param);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Mutex
|
||||
// =====================================================
|
||||
|
||||
class Mutex{
|
||||
private:
|
||||
CRITICAL_SECTION mutex;
|
||||
|
||||
public:
|
||||
Mutex();
|
||||
~Mutex();
|
||||
void p();
|
||||
void v();
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,35 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_TYPES_H_
|
||||
#define _SHARED_PLATFORM_TYPES_H_
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
typedef HWND WindowHandle;
|
||||
typedef HDC DeviceContextHandle;
|
||||
typedef HGLRC GlContextHandle;
|
||||
|
||||
typedef float float32;
|
||||
typedef double float64;
|
||||
typedef char int8;
|
||||
typedef unsigned char uint8;
|
||||
typedef short int int16;
|
||||
typedef unsigned short int uint16;
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
typedef long long int64;
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,158 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_WINDOW_H_
|
||||
#define _SHARED_PLATFORM_WINDOW_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "types.h"
|
||||
#include "platform_menu.h"
|
||||
|
||||
using std::map;
|
||||
using std::string;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
class Timer;
|
||||
class PlatformContextGl;
|
||||
|
||||
enum MouseButton{
|
||||
mbLeft,
|
||||
mbRight,
|
||||
mbCenter
|
||||
};
|
||||
|
||||
enum SizeState{
|
||||
ssMaximized,
|
||||
ssMinimized,
|
||||
ssRestored
|
||||
};
|
||||
|
||||
const int vkAdd= VK_ADD;
|
||||
const int vkSubtract= VK_SUBTRACT;
|
||||
const int vkAlt= VK_MENU;
|
||||
const int vkControl= VK_CONTROL;
|
||||
const int vkShift= VK_SHIFT;
|
||||
const int vkEscape= VK_ESCAPE;
|
||||
const int vkUp= VK_UP;
|
||||
const int vkLeft= VK_LEFT;
|
||||
const int vkRight= VK_RIGHT;
|
||||
const int vkDown= VK_DOWN;
|
||||
const int vkReturn= VK_RETURN;
|
||||
const int vkBack= VK_BACK;
|
||||
const int vkDelete= VK_DELETE;
|
||||
const int vkF1= VK_F1;
|
||||
|
||||
struct MouseState{
|
||||
bool leftMouse;
|
||||
bool rightMouse;
|
||||
bool centerMouse;
|
||||
};
|
||||
|
||||
enum WindowStyle{
|
||||
wsFullscreen,
|
||||
wsWindowedFixed,
|
||||
wsWindowedResizeable
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Window
|
||||
// =====================================================
|
||||
|
||||
class Window{
|
||||
private:
|
||||
typedef map<WindowHandle, Window*> WindowMap;
|
||||
|
||||
private:
|
||||
static const DWORD fullscreenStyle;
|
||||
static const DWORD windowedFixedStyle;
|
||||
static const DWORD windowedResizeableStyle;
|
||||
|
||||
static int nextClassName;
|
||||
static WindowMap createdWindows;
|
||||
|
||||
protected:
|
||||
WindowHandle handle;
|
||||
WindowStyle windowStyle;
|
||||
string text;
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
string className;
|
||||
DWORD style;
|
||||
DWORD exStyle;
|
||||
bool ownDc;
|
||||
|
||||
public:
|
||||
static bool handleEvent();
|
||||
|
||||
//contructor & destructor
|
||||
Window();
|
||||
virtual ~Window();
|
||||
|
||||
WindowHandle getHandle() {return handle;}
|
||||
string getText();
|
||||
int getX() {return x;}
|
||||
int getY() {return y;}
|
||||
int getW() {return w;}
|
||||
int getH() {return h;}
|
||||
|
||||
//component state
|
||||
int getClientW();
|
||||
int getClientH();
|
||||
float getAspect();
|
||||
|
||||
//object state
|
||||
void setText(string text);
|
||||
void setStyle(WindowStyle windowStyle);
|
||||
void setSize(int w, int h);
|
||||
void setPos(int x, int y);
|
||||
void setEnabled(bool enabled);
|
||||
void setVisible(bool visible);
|
||||
|
||||
//misc
|
||||
void create();
|
||||
void minimize();
|
||||
void maximize();
|
||||
void restore();
|
||||
void showPopupMenu(Menu *menu, int x, int y);
|
||||
void destroy();
|
||||
|
||||
protected:
|
||||
virtual void eventCreate(){}
|
||||
virtual void eventMouseDown(int x, int y, MouseButton mouseButton){}
|
||||
virtual void eventMouseUp(int x, int y, MouseButton mouseButton){}
|
||||
virtual void eventMouseMove(int x, int y, const MouseState *mouseState){}
|
||||
virtual void eventMouseDoubleClick(int x, int y, MouseButton mouseButton){}
|
||||
virtual void eventKeyDown(char key){}
|
||||
virtual void eventKeyUp(char key){}
|
||||
virtual void eventKeyPress(char c){};
|
||||
virtual void eventResize(){};
|
||||
virtual void eventPaint(){}
|
||||
virtual void eventActivate(bool activated){};
|
||||
virtual void eventResize(SizeState sizeState){};
|
||||
virtual void eventMenu(int menuId){}
|
||||
virtual void eventClose(){};
|
||||
virtual void eventDestroy(){};
|
||||
|
||||
private:
|
||||
static LRESULT CALLBACK eventRouter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
static int getNextClassName();
|
||||
void registerWindow(WNDPROC wndProc= NULL);
|
||||
void createWindow(LPVOID creationData= NULL);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,38 +0,0 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#ifndef _SHARED_PLATFORM_WINDOWGL_H_
|
||||
#define _SHARED_PLATFORM_WINDOWGL_H_
|
||||
|
||||
#include "context_gl.h"
|
||||
#include "window.h"
|
||||
|
||||
using Shared::Graphics::Gl::ContextGl;
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
// =====================================================
|
||||
// class WindowGl
|
||||
// =====================================================
|
||||
|
||||
class WindowGl: public Window{
|
||||
protected:
|
||||
ContextGl context;
|
||||
|
||||
public:
|
||||
void initGl(int colorBits, int depthBits, int stencilBits);
|
||||
void makeCurrentGl();
|
||||
void swapBuffersGl();
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user