Moved eeWindowContext definitiion to windowcontext.hpp

Moved eeWindowHandle definition to windowhandle.hpp ( and changed the name from eeWindowHandler )
In windows eeWindowContex and eeWindowHandler are forward declared.
Still need to see how to implement this in linux ( os x shouldn't be a problem ).
HaikuTTF doesn't expose window.h or pthread.h anymore.
Added TryLock to cMutex.
This commit is contained in:
spartanj@gmail.com
2012-12-06 01:55:32 -03:00
parent 9f49dbce0d
commit 183b923531
46 changed files with 522 additions and 410 deletions

View File

@@ -24,8 +24,7 @@
/**
@TODO Add PVRTC and ETC support.
@TODO Check for endianness problems, and make EEPP endianness agnostic.
@TODO Support for Android ( work in progress, it's working ) and iOS.
@TODO Add Scripting support ( squirrel or angel script ).
@TODO Add Scripting support ( squirrel or angel script or lua ).
*/
// General includes and declarations

View File

@@ -13,6 +13,9 @@
#include <eepp/window/cwindow.hpp>
using namespace EE::Window;
#include <eepp/graphics/ctexture.hpp>
using namespace EE::Graphics;
namespace EE { namespace Gaming {
#define EE_MAP_LAYER_UNKNOWN 0xFFFFFFFF

View File

@@ -1,8 +1,8 @@
#ifndef EEPP_GRAPHICS_HPP
#define EEPP_GRAPHICS_HPP
#include <eepp/graphics/blendmode.hpp>
#include <eepp/graphics/renderer/cgl.hpp>
#include <eepp/graphics/blendmode.hpp>
#include <eepp/graphics/renderer/crenderergl.hpp>
#include <eepp/graphics/renderer/crenderergl3.hpp>
#include <eepp/graphics/renders.hpp>

View File

@@ -2,12 +2,13 @@
#define EE_GRAPHICSCCONSOLE_H
#include <eepp/graphics/base.hpp>
#include <eepp/window/cwindow.hpp>
#include <eepp/window/cinputtextbuffer.hpp>
#include <eepp/graphics/cprimitives.hpp>
#include <eepp/graphics/cfont.hpp>
#include <deque>
namespace EE { namespace Window { class cWindow; class cInputTextBuffer; class InputEvent; } }
using namespace EE::Window;
namespace EE { namespace Graphics {
@@ -148,7 +149,7 @@ class EE_API cConsole{
Uint32 mMaxLogLines;
eeInt mLastLogPos;
cInputTextBuffer mTBuf;
cInputTextBuffer * mTBuf;
cFont * mFont;

View File

@@ -19,6 +19,9 @@ class EE_API cMutex {
/** Unlock the mutex */
void Unlock();
/** Tries to lock de mutex */
int TryLock();
private:
Platform::cMutexImpl * mMutexImpl;
};

View File

@@ -18,62 +18,8 @@ using namespace EE::System;
#include <eepp/graphics/opengl.hpp>
using namespace EE::Graphics;
#if EE_PLATFORM == EE_PLATFORM_WIN
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#undef GetDiskFreeSpace
inline BOOL WIN_ShowWindow( HWND hWnd, int nCmdShow ) {
return ShowWindow( hWnd, nCmdShow );
}
typedef UINT eeScrapType;
typedef HWND eeWindowHandler;
#ifdef CreateWindow
#undef CreateWindow
#endif
#elif defined( EE_X11_PLATFORM )
#include <X11/Xlib.h>
#include <X11/Xcursor/Xcursor.h>
#include <X11/cursorfont.h>
#include <X11/Xatom.h>
typedef Atom eeScrapType;
typedef Window X11Window;
typedef Display * eeWindowHandler;
typedef Cursor X11Cursor;
#undef Window
#undef Display
#undef Cursor
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
typedef unsigned int eeScrapType;
typedef void * eeWindowHandler; // NSWindow *
#else
typedef unsigned int eeWindowHandler; //! Fallback
typedef unsigned int eeScrapType;
#endif
#ifdef EE_GLEW_AVAILABLE
#if EE_PLATFORM == EE_PLATFORM_WIN
#include <eepp/helper/glew/wglew.h>
typedef HGLRC eeWindowContex;
#elif defined( EE_X11_PLATFORM )
#include <eepp/helper/glew/glxew.h>
typedef GLXContext eeWindowContex;
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
#include <AGL/agl.h>
typedef AGLContext eeWindowContex;
#endif
#else
typedef unsigned int eeWindowContex; //! Fallback
#endif
#include <eepp/window/windowhandle.hpp>
#include <eepp/window/windowcontext.hpp>
#include <eepp/window/keycodes.hpp>
#endif

View File

@@ -3,10 +3,11 @@
#include <eepp/window/base.hpp>
#include <eepp/window/cview.hpp>
#include <eepp/window/cplatformimpl.hpp>
namespace EE { namespace Window {
namespace Platform { class cPlatformImpl; }
class cClipboard;
class cInput;
class cCursorManager;
@@ -191,7 +192,7 @@ class EE_API cWindow {
virtual eeWindowContex GetContext() const;
/** @return The window handler */
virtual eeWindowHandler GetWindowHandler() = 0;
virtual eeWindowHandle GetWindowHandler() = 0;
/** Clear the current window
This function is usually called once every frame, to clear the previous frame content.

View File

@@ -0,0 +1,29 @@
#ifndef EE_WINDOWCONTEXT_HPP
#define EE_WINDOWCONTEXT_HPP
#include <eepp/declares.hpp>
#ifdef EE_GLEW_AVAILABLE
#if EE_PLATFORM == EE_PLATFORM_WIN
typedef void * eeWindowContex;
#elif defined( EE_X11_PLATFORM )
#include <eepp/helper/glew/glxew.h>
#undef Window
#undef Display
#undef Cursor
typedef GLXContext eeWindowContex;
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
#include <AGL/agl.h>
typedef AGLContext eeWindowContex;
#endif
#else
typedef unsigned int eeWindowContex; //! Fallback
#endif
#endif

View File

@@ -0,0 +1,33 @@
#ifndef EE_WINDOWHANDLE_HPP
#define EE_WINDOWHANDLE_HPP
#include <eepp/declares.hpp>
#if EE_PLATFORM == EE_PLATFORM_WIN
struct HWND__;
typedef HWND__* eeWindowHandle;
#elif defined( EE_X11_PLATFORM )
#include <X11/Xlib.h>
#include <X11/Xcursor/Xcursor.h>
#include <X11/cursorfont.h>
#undef Window
#undef Display
#undef Cursor
typedef unsigned long X11Window;
typedef unsigned long X11Cursor;
typedef Display * eeWindowHandle;
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
typedef void * eeWindowHandle; // NSWindow *
#else
typedef unsigned int eeWindowHandle; //! Fallback
#endif
#endif

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by Qt Creator 2.6.0, 2012-12-05T03:03:15. -->
<!-- Written by Qt Creator 2.6.0, 2012-12-06T01:52:52. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -57,7 +57,7 @@
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets"/>
<value type="bool" key="GenericProjectManager.GenericMakeStep.Clean">false</value>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments">-j4 -e DEBUGBUILD=yes SHARED_BACKEND=yes BACKENDS_ALL=yes test</value>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments">-j4 -e DEBUGBUILD=yes BACKEND_SDL=yes test</value>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand">make</value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName"></value>

View File

@@ -4,6 +4,7 @@
#include <eepp/window/cinput.hpp>
#include <eepp/window/cengine.hpp>
#include <eepp/window/ccursormanager.hpp>
#include <eepp/window/cwindow.hpp>
#include <algorithm>
#include <cstdarg>
@@ -27,6 +28,7 @@ cConsole::cConsole( Window::cWindow * window ) :
mVidCb(0),
mMaxLogLines(1024),
mLastLogPos(0),
mTBuf( eeNew( cInputTextBuffer, () ) ),
mFont(NULL),
mTexId(0),
mCurAlpha(0),
@@ -57,6 +59,8 @@ cConsole::~cConsole() {
mWindow->GetInput()->PopCallback( mMyCallback );
mWindow->PopResizeCallback( mVidCb );
}
eeSAFE_DELETE( mTBuf );
}
void cConsole::Create( cFont* Font, const bool& MakeDefaultCommands, const eeUint& MaxLogLines, const Uint32& TextureId ) {
@@ -93,10 +97,10 @@ void cConsole::Create( cFont* Font, const bool& MakeDefaultCommands, const eeUin
mVidCb = mWindow->PushResizeCallback( cb::Make0( this, &cConsole::PrivVideoResize ) );
}
mTBuf.SetReturnCallback( cb::Make0( this, &cConsole::ProcessLine ) );
mTBuf.Start();
mTBuf.SupportNewLine( false );
mTBuf.Active( false );
mTBuf->SetReturnCallback( cb::Make0( this, &cConsole::ProcessLine ) );
mTBuf->Start();
mTBuf->SupportNewLine( false );
mTBuf->Active( false );
IgnoreCharOnPrompt( KEY_TAB );
mCon.ConModif = 0;
@@ -159,17 +163,17 @@ void cConsole::Draw() {
CurY = mTempY + mY + mCurHeight - mFontSize - 1;
mFont->Color( eeColorA ( mFontLineColor.R(), mFontLineColor.G(), mFontLineColor.B(), static_cast<Uint8>(mA) ) );
mFont->SetText( "> " + mTBuf.Buffer() );
mFont->SetText( "> " + mTBuf->Buffer() );
mFont->Draw( mFontSize, CurY );
mFont->Color( eeColorA ( mFontLineColor.R(), mFontLineColor.G(), mFontLineColor.B(), static_cast<Uint8>(mCurAlpha) ) );
mFont->Color( OldColor );
if ( (eeUint)mTBuf.CurPos() == mTBuf.Buffer().size() ) {
if ( (eeUint)mTBuf->CurPos() == mTBuf->Buffer().size() ) {
mFont->Draw( "_", mFontSize + mFont->GetTextWidth() , CurY );
} else {
mFont->SetText( "> " + mTBuf.Buffer().substr( 0, mTBuf.CurPos() ) );
mFont->SetText( "> " + mTBuf->Buffer().substr( 0, mTBuf->CurPos() ) );
mFont->Draw( "_", mFontSize + mFont->GetTextWidth() , CurY );
}
}
@@ -190,7 +194,7 @@ void cConsole::FadeIn() {
mFadeIn = true;
mVisible = true;
mY = 0.0f;
mTBuf.Active( true );
mTBuf->Active( true );
}
}
@@ -199,12 +203,12 @@ void cConsole::FadeOut() {
mFading = true;
mFadeOut = true;
mVisible = false;
mTBuf.Active( false );
mTBuf->Active( false );
}
}
void cConsole::ProcessLine() {
String str = mTBuf.Buffer();
String str = mTBuf->Buffer();
std::vector < String > params = String::SplitString( str, ' ' );
mLastCommands.push_back( str );
@@ -222,7 +226,7 @@ void cConsole::ProcessLine() {
PushText( "Unknown Command: '" + params[0] + "'" );
}
}
mTBuf.Clear();
mTBuf->Clear();
}
void cConsole::PrivPushText( const String& str ) {
@@ -332,7 +336,7 @@ void cConsole::PrintCommandsStartingWith( const String& start ) {
}
if ( cmds.size() > 1 ) {
PushText( "> " + mTBuf.Buffer() );
PushText( "> " + mTBuf->Buffer() );
std::list<String>::iterator ite;
@@ -340,8 +344,8 @@ void cConsole::PrintCommandsStartingWith( const String& start ) {
PushText( (*ite) );
} else if ( cmds.size() ) {
mTBuf.Buffer( cmds.front() );
mTBuf.CursorToEnd();
mTBuf->Buffer( cmds.front() );
mTBuf->CursorToEnd();
}
}
@@ -367,8 +371,8 @@ void cConsole::PrivInputCallback( InputEvent * Event ) {
Uint32 Button = Event->button.button;
if ( InputEvent::KeyDown == etype ) {
if ( ( KeyCode == KEY_TAB ) && (eeUint)mTBuf.CurPos() == mTBuf.Buffer().size() ) {
PrintCommandsStartingWith( mTBuf.Buffer() );
if ( ( KeyCode == KEY_TAB ) && (eeUint)mTBuf->CurPos() == mTBuf->Buffer().size() ) {
PrintCommandsStartingWith( mTBuf->Buffer() );
}
if ( mLastCommands.size() > 0 ) {
@@ -382,10 +386,10 @@ void cConsole::PrivInputCallback( InputEvent * Event ) {
if ( KeyCode == KEY_UP || KeyCode == KEY_DOWN ) {
if ( mLastLogPos == static_cast<eeInt>( mLastCommands.size() ) ) {
mTBuf.Buffer( "" );
mTBuf->Buffer( "" );
} else {
mTBuf.Buffer( mLastCommands[mLastLogPos] );
mTBuf.CursorToEnd();
mTBuf->Buffer( mLastCommands[mLastLogPos] );
mTBuf->CursorToEnd();
}
}
}
@@ -661,7 +665,7 @@ void cConsole::CmdShowFps( const std::vector < String >& params ) {
}
void cConsole::IgnoreCharOnPrompt( const Uint32& ch ) {
mTBuf.PushIgnoredChar( ch );
mTBuf->PushIgnoredChar( ch );
}
const bool& cConsole::IsShowingFps() const {

View File

@@ -64,21 +64,21 @@ cFrameBufferPBuffer::~cFrameBufferPBuffer() {
#if EE_PLATFORM == EE_PLATFORM_WIN
if ( mContext )
wglDeleteContext( mContext );
wglDeleteContext( (HGLRC)mContext );
if ( mPBuffer && mDeviceContext ) {
wglReleasePbufferDCARB( mPBuffer, mDeviceContext );
wglDestroyPbufferARB( mPBuffer );
wglReleasePbufferDCARB( (HPBUFFERARB)mPBuffer, (HDC)mDeviceContext );
wglDestroyPbufferARB( (HPBUFFERARB)mPBuffer );
}
#elif defined( EE_X11_PLATFORM )
if ( mContext )
glXDestroyContext( mDisplay, mContext );
glXDestroyContext( (Display*)mDisplay, (GLXContext)mContext );
if ( mPBuffer )
glXDestroyGLXPbufferSGIX( mDisplay, mPBuffer );
glXDestroyGLXPbufferSGIX( (Display*)mDisplay, mPBuffer );
if ( mDisplay )
XCloseDisplay( mDisplay );
XCloseDisplay( (Display*)mDisplay );
#endif
#endif
@@ -145,15 +145,15 @@ bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height, boo
return false;
mPBuffer = wglCreatePbufferARB( currentDC, pixelFormat, Width, Height, NULL );
mDeviceContext = wglGetPbufferDCARB( mPBuffer );
mContext = wglCreateContext( mDeviceContext );
mDeviceContext = wglGetPbufferDCARB( (HPBUFFERARB)mPBuffer );
mContext = wglCreateContext( (HDC)mDeviceContext );
if ( !mPBuffer || !mDeviceContext || !mContext )
return false;
int actualWidth, actualHeight;
wglQueryPbufferARB( mPBuffer, WGL_PBUFFER_WIDTH_ARB, &actualWidth );
wglQueryPbufferARB( mPBuffer, WGL_PBUFFER_HEIGHT_ARB, &actualHeight );
wglQueryPbufferARB( (HPBUFFERARB)mPBuffer, WGL_PBUFFER_WIDTH_ARB, &actualWidth );
wglQueryPbufferARB( (HPBUFFERARB)mPBuffer, WGL_PBUFFER_HEIGHT_ARB, &actualHeight );
if ( ( actualWidth != static_cast<int>(Width) ) || ( actualHeight != static_cast<int>(Height) ) )
return false;
@@ -161,7 +161,7 @@ bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height, boo
HGLRC currentContext = wglGetCurrentContext();
if (currentContext) {
wglMakeCurrent( NULL, NULL );
wglShareLists( currentContext, mContext );
wglShareLists( currentContext, (HGLRC)mContext );
wglMakeCurrent( currentDC, currentContext );
}
#elif defined( EE_X11_PLATFORM )
@@ -185,12 +185,12 @@ bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height, boo
};
int nbConfigs = 0;
GLXFBConfig* configs = glXChooseFBConfigSGIX( mDisplay, DefaultScreen( mDisplay ), visualAttributes, &nbConfigs );
GLXFBConfig* configs = glXChooseFBConfigSGIX( (Display*)mDisplay, DefaultScreen( (Display*)mDisplay ), visualAttributes, &nbConfigs );
if (!configs || !nbConfigs)
return false;
mPBuffer = glXCreateGLXPbufferSGIX( mDisplay, configs[0], Width, Height, PBufferAttributes );
mPBuffer = glXCreateGLXPbufferSGIX( (Display*)mDisplay, configs[0], Width, Height, PBufferAttributes );
if ( !mPBuffer ) {
XFree(configs);
@@ -198,8 +198,8 @@ bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height, boo
}
unsigned int actualWidth, actualHeight;
glXQueryGLXPbufferSGIX( mDisplay, mPBuffer, GLX_WIDTH_SGIX, &actualWidth);
glXQueryGLXPbufferSGIX( mDisplay, mPBuffer, GLX_HEIGHT_SGIX, &actualHeight);
glXQueryGLXPbufferSGIX( (Display*)mDisplay, mPBuffer, GLX_WIDTH_SGIX, &actualWidth);
glXQueryGLXPbufferSGIX( (Display*)mDisplay, mPBuffer, GLX_HEIGHT_SGIX, &actualHeight);
if ( ( actualWidth != Width ) || ( actualHeight != Height ) ) {
XFree(configs);
@@ -210,10 +210,10 @@ bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height, boo
GLXContext currentContext = glXGetCurrentContext();
if ( currentContext )
glXMakeCurrent( mDisplay, 0, NULL );
glXMakeCurrent( (Display*)mDisplay, 0, NULL );
XVisualInfo* visual = glXGetVisualFromFBConfig( mDisplay, configs[0] );
mContext = glXCreateContext( mDisplay, visual, currentContext, true );
XVisualInfo* visual = glXGetVisualFromFBConfig( (Display*)mDisplay, configs[0] );
mContext = glXCreateContext( (Display*)mDisplay, visual, currentContext, true );
if ( !mContext ) {
XFree(configs);
@@ -222,7 +222,7 @@ bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height, boo
}
if ( currentContext )
glXMakeCurrent( mDisplay, currentDrawable, currentContext );
glXMakeCurrent( (Display*)mDisplay, currentDrawable, currentContext );
XFree(configs);
XFree(visual);
@@ -252,14 +252,14 @@ void cFrameBufferPBuffer::Bind() {
if ( mDeviceContext && mContext ) {
if ( wglGetCurrentContext() != mContext ) {
ChangeContext = true;
wglMakeCurrent( mDeviceContext, mContext );
wglMakeCurrent( (HDC)mDeviceContext, (HGLRC)mContext );
}
}
#elif defined( EE_X11_PLATFORM )
if ( mPBuffer && mContext ) {
if ( glXGetCurrentContext() != mContext ) {
ChangeContext = true;
glXMakeCurrent( mDisplay, mPBuffer, mContext );
glXMakeCurrent( (Display*)mDisplay, mPBuffer, (GLXContext)mContext );
}
}
#endif

View File

@@ -54,13 +54,13 @@ class EE_API cFrameBufferPBuffer : public cFrameBuffer {
#ifdef EE_GLEW_AVAILABLE
#if EE_PLATFORM == EE_PLATFORM_WIN
HDC mDeviceContext;
HPBUFFERARB mPBuffer;
HGLRC mContext;
void * mDeviceContext;
void * mPBuffer;
void * mContext;
#elif defined( EE_X11_PLATFORM )
::Display * mDisplay;
GLXPbuffer mPBuffer;
GLXContext mContext;
void * mDisplay;
unsigned long mPBuffer;
void * mContext;
#endif
#endif

View File

@@ -39,15 +39,6 @@ typedef SOPHIST_uint32 u32;
#define HK_PLATFORM_POSIX
#endif
#if HK_PLATFORM == HK_PLATFORM_WIN
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#elif defined( HK_PLATFORM_POSIX )
#include <pthread.h>
#endif
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_OUTLINE_H

View File

@@ -2,36 +2,75 @@
namespace HaikuTTF {
hkMutex::hkMutex() {
#if HK_PLATFORM == HK_PLATFORM_WIN
InitializeCriticalSection(&mMutex);
#elif defined( HK_PLATFORM_POSIX )
pthread_mutex_init(&mMutex, NULL);
#endif
#if HK_PLATFORM == HK_PLATFORM_WIN
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
class hkMutexImpl {
public:
hkMutexImpl() {
InitializeCriticalSection(&mMutex);
}
~hkMutexImpl() {
DeleteCriticalSection(&mMutex);
}
void Lock() {
EnterCriticalSection(&mMutex);
}
void Unlock() {
LeaveCriticalSection(&mMutex);
}
protected:
CRITICAL_SECTION mMutex;
};
#elif defined( HK_PLATFORM_POSIX )
#include <pthread.h>
class hkMutexImpl {
public:
hkMutexImpl() {
pthread_mutex_init(&mMutex, NULL);
}
~hkMutexImpl() {
pthread_mutex_destroy(&mMutex);
}
void Lock() {
pthread_mutex_lock(&mMutex);
}
void Unlock() {
pthread_mutex_unlock(&mMutex);
}
protected:
pthread_mutex_t mMutex;
};
#endif
hkMutex::hkMutex() :
mImpl( hkNew( hkMutexImpl, () ) )
{
}
hkMutex::~hkMutex() {
#if HK_PLATFORM == HK_PLATFORM_WIN
DeleteCriticalSection(&mMutex);
#elif defined( HK_PLATFORM_POSIX )
pthread_mutex_destroy(&mMutex);
#endif
hkSAFE_DELETE( mImpl )
}
void hkMutex::Lock() {
#if HK_PLATFORM == HK_PLATFORM_WIN
EnterCriticalSection(&mMutex);
#elif defined( HK_PLATFORM_POSIX )
pthread_mutex_lock(&mMutex);
#endif
mImpl->Lock();
}
void hkMutex::Unlock() {
#if HK_PLATFORM == HK_PLATFORM_WIN
LeaveCriticalSection(&mMutex);
#elif defined( HK_PLATFORM_POSIX )
pthread_mutex_unlock(&mMutex);
#endif
mImpl->Unlock();
}
}

View File

@@ -5,6 +5,8 @@
namespace HaikuTTF {
class hkMutexImpl;
class hkMutex {
public:
hkMutex();
@@ -15,11 +17,7 @@ class hkMutex {
void Unlock();
protected:
#if HK_PLATFORM == HK_PLATFORM_WIN
CRITICAL_SECTION mMutex;
#elif defined( HK_PLATFORM_POSIX )
pthread_mutex_t mMutex;
#endif
hkMutexImpl * mImpl;
};
}

View File

@@ -90,7 +90,7 @@ void cLog::openfs() {
std::string str = mFilePath + "log.log";
mFS = eeNew( cIOStreamFile, ( str, std::ios::app | std::ios::out | std::ios::binary ) );
}
}
}
void cLog::closefs() {
@@ -173,7 +173,7 @@ const bool& cLog::LiveWrite() const {
}
void cLog::LiveWrite( const bool& lw ) {
mLiveWrite = lw;
mLiveWrite = lw;
}
}}

View File

@@ -20,4 +20,8 @@ void cMutex::Unlock() {
mMutexImpl->Unlock();
}
int cMutex::TryLock() {
return mMutexImpl->TryLock();
}
}}

View File

@@ -23,6 +23,10 @@ void cMutexImpl::Unlock() {
pthread_mutex_unlock(&mMutex);
}
int cMutexImpl::TryLock() {
return pthread_mutex_trylock(&mMutex);
}
}}}
#endif

View File

@@ -18,6 +18,8 @@ class cMutexImpl {
void Lock();
void Unlock();
int TryLock();
private:
pthread_mutex_t mMutex;
};
@@ -27,4 +29,4 @@ class cMutexImpl {
#endif
#endif

View File

@@ -20,6 +20,10 @@ void cMutexImpl::Unlock() {
LeaveCriticalSection(&mMutex);
}
int cMutexImpl::TryLock() {
return TryEnterCriticalSection(&mMutex);
}
}}}
#endif

View File

@@ -21,6 +21,8 @@ class cMutexImpl {
void Lock();
void Unlock();
int TryLock();
private:
CRITICAL_SECTION mMutex;
};

View File

@@ -6,6 +6,20 @@
#include <climits>
#include <SDL/SDL.h>
#if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_MACOSX || defined( EE_X11_PLATFORM )
#include <SDL/SDL_syswm.h>
#endif
#if EE_PLATFORM == EE_PLATFORM_WIN
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#elif defined( EE_X11_PLATFORM )
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#endif
namespace EE { namespace Window { namespace Backend { namespace SDL {
#define T(A, B, C, D) (int)((A<<24)|(B<<16)|(C<<8)|(D<<0))
@@ -103,7 +117,7 @@ void cClipboardSDL::Init() {
void cClipboardSDL::SetText( const std::string& Text ) {
#if defined( EE_X11_PLATFORM )
eeWindowHandler display = mInfo->info.x11.display;
eeWindowHandle display = mInfo->info.x11.display;
X11Window window = mInfo->info.x11.wmwindow;
Atom format = TEXT_FORMAT;

View File

@@ -10,12 +10,18 @@
class SDL_SysWMinfo;
#if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_MACOSX || defined( EE_X11_PLATFORM )
#include <SDL/SDL_syswm.h>
#endif
namespace EE { namespace Window { namespace Backend { namespace SDL {
#if EE_PLATFORM == EE_PLATFORM_WIN
typedef unsigned int eeScrapType;
#elif defined( EE_X11_PLATFORM )
typedef unsigned long eeScrapType;
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
typedef unsigned int eeScrapType;
#else
typedef unsigned int eeScrapType;
#endif
class EE_API cClipboardSDL : public cClipboard {
public:
virtual ~cClipboardSDL();
@@ -38,7 +44,7 @@ class EE_API cClipboardSDL : public cClipboard {
void * mInfo;
#endif
eeScrapType clipboard_convert_format(int type);
eeScrapType clipboard_convert_format( int type );
int clipboard_convert_scrap(int type, char *dst, char *src, int srclen);

View File

@@ -3,6 +3,7 @@
#ifdef EE_BACKEND_SDL_1_2
#include <eepp/window/cplatformimpl.hpp>
#include <SDL/SDL.h>
namespace EE { namespace Window { namespace Backend { namespace SDL {

View File

@@ -27,13 +27,13 @@ namespace EE { namespace Window { namespace Backend { namespace SDL {
cWindowSDL::cWindowSDL( WindowSettings Settings, ContextSettings Context ) :
cWindow( Settings, Context, eeNew( cClipboardSDL, ( this ) ), eeNew( cInputSDL, ( this ) ), eeNew( cCursorManagerSDL, ( this ) ) ),
mSurface( NULL ),
mWMinfo( (SDL_SysWMinfo*)eeMalloc( sizeof( mWMinfo ) ) )
mWMinfo( eeNew( SDL_SysWMinfo, () ) )
{
Create( Settings, Context );
}
cWindowSDL::~cWindowSDL() {
eeSAFE_FREE( mWMinfo );
eeSAFE_DELETE( mWMinfo );
}
bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) {
@@ -382,7 +382,7 @@ void cWindowSDL::SetGamma( eeFloat Red, eeFloat Green, eeFloat Blue ) {
SDL_SetGamma( Red, Green, Blue );
}
eeWindowHandler cWindowSDL::GetWindowHandler() {
eeWindowHandle cWindowSDL::GetWindowHandler() {
#if EE_PLATFORM == EE_PLATFORM_WIN
return mWMinfo->window;
#elif defined( EE_X11_PLATFORM )

View File

@@ -37,7 +37,7 @@ class EE_API cWindowSDL : public cWindow {
void SetGamma( eeFloat Red, eeFloat Green, eeFloat Blue );
eeWindowHandler GetWindowHandler();
eeWindowHandle GetWindowHandler();
protected:
friend class cClipboardSDL;

View File

@@ -1,5 +1,6 @@
#include <eepp/window/backend/SDL2/ccursormanagersdl2.hpp>
#include <eepp/window/backend/SDL2/ccursorsdl2.hpp>
#include <eepp/window/cplatformimpl.hpp>
#ifdef EE_BACKEND_SDL2

View File

@@ -380,7 +380,7 @@ void cWindowSDL::SetGamma( eeFloat Red, eeFloat Green, eeFloat Blue ) {
SDL_SetWindowGammaRamp( mSDLWindow, red_ramp, green_ramp, blue_ramp );
}
eeWindowHandler cWindowSDL::GetWindowHandler() {
eeWindowHandle cWindowSDL::GetWindowHandler() {
#if EE_PLATFORM == EE_PLATFORM_WIN
return mWMinfo.info.win.window;
#elif defined( EE_X11_PLATFORM )

View File

@@ -38,7 +38,7 @@ class EE_API cWindowSDL : public cWindow {
void SetGamma( eeFloat Red, eeFloat Green, eeFloat Blue );
eeWindowHandler GetWindowHandler();
eeWindowHandle GetWindowHandler();
virtual void Minimize();

View File

@@ -8,7 +8,7 @@
#undef None
#endif
#include <SFML/Window.hpp>
#include <eepp/window/cplatformimpl.hpp>
namespace EE { namespace Window { namespace Backend { namespace SFML {

View File

@@ -198,7 +198,7 @@ eeWindowContex cWindowSFML::GetContext() const {
void cWindowSFML::GetMainContext() {
}
eeWindowHandler cWindowSFML::GetWindowHandler() {
eeWindowHandle cWindowSFML::GetWindowHandler() {
#if defined( EE_X11_PLATFORM )
if ( 0 == mWinHandler ) {
#ifdef EE_SUPPORT_EXCEPTIONS
@@ -214,9 +214,9 @@ eeWindowHandler cWindowSFML::GetWindowHandler() {
return mWinHandler;
#elif EE_PLATFORM == EE_PLATFORM_WIN
return (eeWindowHandler)mSFMLWindow.getSystemHandle();
return (eeWindowHandle)mSFMLWindow.getSystemHandle();
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
return (eeWindowHandler)mSFMLWindow.getSystemHandle();
return (eeWindowHandle)mSFMLWindow.getSystemHandle();
#else
return 0;
#endif

View File

@@ -46,7 +46,7 @@ class EE_API cWindowSFML : public cWindow {
eeWindowContex GetContext() const;
eeWindowHandler GetWindowHandler();
eeWindowHandle GetWindowHandler();
void SetDefaultContext();
@@ -57,7 +57,7 @@ class EE_API cWindowSFML : public cWindow {
sf::Window mSFMLWindow;
eeWindowHandler mWinHandler;
eeWindowHandle mWinHandler;
bool mVisible;

View File

@@ -28,7 +28,7 @@ String cClipboardAl::GetWideText() {
/** Not sure if activate this, sometimes freeze the application because of the notification delay. */
/**
cWindowAl * win = reinterpret_cast<cWindowAl*> ( mWindow );
eeWindowHandler mDisplay = win->GetWindowHandler();
eeWindowHandle mDisplay = win->GetWindowHandler();
X11Window mWin = win->GetX11Window();
Atom clipboard = XInternAtom(mDisplay, "CLIPBOARD", True);

View File

@@ -388,7 +388,7 @@ std::vector< std::pair<unsigned int, unsigned int> > cWindowAl::GetPossibleResol
void cWindowAl::SetGamma( eeFloat Red, eeFloat Green, eeFloat Blue ) {
}
eeWindowHandler cWindowAl::GetWindowHandler() {
eeWindowHandle cWindowAl::GetWindowHandler() {
#if EE_PLATFORM == EE_PLATFORM_WIN
return al_get_win_window_handle( mDisplay );
#elif defined( EE_X11_PLATFORM )

View File

@@ -38,7 +38,7 @@ class EE_API cWindowAl : public cWindow {
void SetGamma( eeFloat Red, eeFloat Green, eeFloat Blue );
eeWindowHandler GetWindowHandler();
eeWindowHandle GetWindowHandler();
#if defined( EE_X11_PLATFORM )
X11Window GetX11Window();

View File

@@ -82,7 +82,7 @@ eeWindowContex cWindowNull::GetContext() const {
void cWindowNull::GetMainContext() {
}
eeWindowHandler cWindowNull::GetWindowHandler() {
eeWindowHandle cWindowNull::GetWindowHandler() {
return 0;
}

View File

@@ -47,7 +47,7 @@ class EE_API cWindowNull : public cWindow {
eeWindowContex GetContext() const;
eeWindowHandler GetWindowHandler();
eeWindowHandle GetWindowHandler();
void SetDefaultContext();
protected:

View File

@@ -3,6 +3,7 @@
#include <eepp/window/cinput.hpp>
#include <eepp/window/ccursormanager.hpp>
#include <eepp/window/platform/null/cnullimpl.hpp>
#include <eepp/window/cplatformimpl.hpp>
#include <eepp/graphics/renderer/cgl.hpp>
#include <eepp/graphics/ctexturefactory.hpp>
@@ -12,6 +13,17 @@
#include <eepp/helper/SOIL2/src/SOIL2/SOIL2.h>
#ifdef EE_GLEW_AVAILABLE
#if EE_PLATFORM == EE_PLATFORM_WIN
#include <eepp/helper/glew/wglew.h>
#undef GetDiskFreeSpace
#elif defined( EE_X11_PLATFORM )
#include <eepp/helper/glew/glxew.h>
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
#include <AGL/agl.h>
#endif
#endif
#ifdef EE_GLES1_LATE_INCLUDE
#if EE_PLATFORM == EE_PLATFORM_IOS
#include <OpenGLES/ES1/gl.h>

View File

@@ -2,10 +2,11 @@
#define EE_WINDOWCOSXIMPL_HPP
#include <eepp/window/base.hpp>
#include <eepp/window/cplatformimpl.hpp>
#if EE_PLATFORM == EE_PLATFORM_MACOSX
#include <eepp/window/cplatformimpl.hpp>
namespace EE { namespace Window { namespace Platform {
using namespace EE::Window;

View File

@@ -1,215 +1,217 @@
#include <eepp/window/platform/win/ccursorwin.hpp>
#if EE_PLATFORM == EE_PLATFORM_WIN
#include <eepp/window/platform/win/cwinimpl.hpp>
#define WINDOWS_RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
#include <windows.h>
#include <eepp/window/platform/win/cwinimpl.hpp>
#define WINDOWS_RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
namespace EE { namespace Window { namespace Platform {
cCursorWin::cCursorWin( cTexture * tex, const eeVector2i& hotspot, const std::string& name, cWindow * window ) :
cCursor( tex, hotspot, name, window )
{
{
Create();
}
cCursorWin::cCursorWin( cImage * img, const eeVector2i& hotspot, const std::string& name, cWindow * window ) :
cCursor( img, hotspot, name, window )
{
{
Create();
}
cCursorWin::cCursorWin( const std::string& path, const eeVector2i& hotspot, const std::string& name, cWindow * window ) :
cCursor( path, hotspot, name, window )
{
{
Create();
}
cCursorWin::~cCursorWin() {
if ( NULL != mCursor )
DestroyIcon( mCursor );
}
static BITMAPINFO *get_bitmap_info( cImage * bitmap ) {
BITMAPINFO *bi;
int i;
bi = (BITMAPINFO *) eeMalloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD) * 256);
ZeroMemory(&bi->bmiHeader, sizeof(BITMAPINFOHEADER));
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi->bmiHeader.biBitCount = 32;
bi->bmiHeader.biPlanes = 1;
bi->bmiHeader.biWidth = (int)bitmap->Width();
bi->bmiHeader.biHeight = -((int)bitmap->Height());
bi->bmiHeader.biClrUsed = 256;
bi->bmiHeader.biCompression = BI_RGB;
for (i = 0; i < 256; i++) {
bi->bmiColors[i].rgbRed = 0;
bi->bmiColors[i].rgbGreen = 0;
bi->bmiColors[i].rgbBlue = 0;
bi->bmiColors[i].rgbReserved = 0;
}
return bi;
}
static BYTE *get_dib_from_bitmap_32(cImage *bitmap) {
int w, h;
int x, y;
int pitch;
BYTE *pixels;
BYTE *dst;
w = (int)bitmap->Width();
h = (int)bitmap->Height();
pitch = w * 4;
pixels = (BYTE *) eeMalloc(h * pitch);
if (!pixels)
return NULL;
for (y = 0; y < h; y++) {
dst = pixels + y * pitch;
for (x = 0; x < w; x++) {
eeColorA C = bitmap->GetPixel( x, y );
/* BGR */
dst[0] = C.B();
dst[1] = C.G();
dst[2] = C.R();
dst[3] = C.A();
dst += 4;
}
}
return pixels;
}
static void local_stretch_blit_to_hdc( cImage *bitmap, HDC dc, int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y, int dest_w, int dest_h) {
const int bitmap_h = (const int)bitmap->Height();
const int bottom_up_src_y = bitmap_h - src_y - src_h;
BYTE *pixels;
BITMAPINFO *bi;
bi = get_bitmap_info(bitmap);
pixels = get_dib_from_bitmap_32(bitmap);
/* Windows treats all source bitmaps as bottom-up when using StretchDIBits
* unless the source (x,y) is (0,0). To work around this buggy behavior, we
* can use negative heights to reverse the direction of the blits.
*
* See <http://wiki.allegro.cc/StretchDIBits> for a detailed explanation.
*/
if (bottom_up_src_y == 0 && src_x == 0 && src_h != bitmap_h) {
StretchDIBits( dc, dest_x, dest_h+dest_y-1, dest_w, -dest_h, src_x, bitmap_h - src_y + 1, src_w, -src_h, pixels, bi, DIB_RGB_COLORS, SRCCOPY );
}
else {
StretchDIBits( dc, dest_x, dest_y, dest_w, dest_h, src_x, bottom_up_src_y, src_w, src_h, pixels, bi, DIB_RGB_COLORS, SRCCOPY );
}
eeFree(pixels);
eeFree(bi);
}
static void local_draw_to_hdc( HDC dc, cImage * bitmap, int x, int y ) {
int w = bitmap->Width();
int h = bitmap->Height();
local_stretch_blit_to_hdc(bitmap, dc, 0, 0, w, h, x, y, w, h);
}
void cCursorWin::Create() {
if ( NULL == mImage && mImage->Size() )
return;
int x, y;
int sys_sm_cx, sys_sm_cy;
HDC h_dc;
HDC h_and_dc;
HDC h_xor_dc;
ICONINFO iconinfo;
HBITMAP and_mask;
HBITMAP xor_mask;
HBITMAP hOldAndMaskBitmap;
HBITMAP hOldXorMaskBitmap;
HICON icon;
/* Get allowed cursor size - Windows can't make cursors of arbitrary size */
sys_sm_cx = GetSystemMetrics(SM_CXCURSOR);
sys_sm_cy = GetSystemMetrics(SM_CYCURSOR);
if ( ( (int)mImage->Width() > sys_sm_cx ) || ( (int)mImage->Height() > sys_sm_cy ) ) {
return;
}
/* Create bitmap */
h_dc = GetDC( GetPlatform()->GetHandler() );
h_xor_dc = CreateCompatibleDC(h_dc);
h_and_dc = CreateCompatibleDC(h_dc);
/* Prepare AND (monochrome) and XOR (colour) mask */
and_mask = CreateBitmap(sys_sm_cx, sys_sm_cy, 1, 1, NULL);
xor_mask = CreateCompatibleBitmap(h_dc, sys_sm_cx, sys_sm_cy);
hOldAndMaskBitmap = (HBITMAP) SelectObject(h_and_dc, and_mask);
hOldXorMaskBitmap = (HBITMAP) SelectObject(h_xor_dc, xor_mask);
/* Create transparent cursor */
for (y = 0; y < sys_sm_cy; y++) {
for (x = 0; x < sys_sm_cx; x++) {
SetPixel(h_and_dc, x, y, WINDOWS_RGB(255, 255, 255));
SetPixel(h_xor_dc, x, y, WINDOWS_RGB(0, 0, 0));
}
}
local_draw_to_hdc( h_xor_dc, mImage, 0, 0 );
/* Make cursor background transparent */
for (y = 0; y < (int)mImage->Height(); y++) {
for (x = 0; x < (int)mImage->Width(); x++) {
eeColorA C = mImage->GetPixel( x, y );
if ( C.A() != 0 ) {
/* Don't touch XOR value */
SetPixel( h_and_dc, x, y, 0 );
} else {
/* No need to touch AND value */
SetPixel( h_xor_dc, x, y, WINDOWS_RGB( 0, 0, 0 ) );
}
}
}
SelectObject(h_and_dc, hOldAndMaskBitmap);
SelectObject(h_xor_dc, hOldXorMaskBitmap);
DeleteDC(h_and_dc);
DeleteDC(h_xor_dc);
ReleaseDC( GetPlatform()->GetHandler() , h_dc );
iconinfo.fIcon = false;
iconinfo.xHotspot = mHotSpot.x;
iconinfo.yHotspot = mHotSpot.y;
iconinfo.hbmMask = and_mask;
iconinfo.hbmColor = xor_mask;
icon = CreateIconIndirect(&iconinfo);
DeleteObject(and_mask);
DeleteObject(xor_mask);
mCursor = (HCURSOR)icon;
}
cWinImpl * cCursorWin::GetPlatform() {
return reinterpret_cast<cWinImpl*>( mWindow->GetPlatform() );
}
HCURSOR cCursorWin::GetCursor() const {
return mCursor;
}
cCursorWin::~cCursorWin() {
if ( NULL != mCursor )
DestroyIcon( (HCURSOR)mCursor );
}
static BITMAPINFO *get_bitmap_info( cImage * bitmap ) {
BITMAPINFO *bi;
int i;
bi = (BITMAPINFO *) eeMalloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD) * 256);
ZeroMemory(&bi->bmiHeader, sizeof(BITMAPINFOHEADER));
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi->bmiHeader.biBitCount = 32;
bi->bmiHeader.biPlanes = 1;
bi->bmiHeader.biWidth = (int)bitmap->Width();
bi->bmiHeader.biHeight = -((int)bitmap->Height());
bi->bmiHeader.biClrUsed = 256;
bi->bmiHeader.biCompression = BI_RGB;
for (i = 0; i < 256; i++) {
bi->bmiColors[i].rgbRed = 0;
bi->bmiColors[i].rgbGreen = 0;
bi->bmiColors[i].rgbBlue = 0;
bi->bmiColors[i].rgbReserved = 0;
}
return bi;
}
static BYTE *get_dib_from_bitmap_32(cImage *bitmap) {
int w, h;
int x, y;
int pitch;
BYTE *pixels;
BYTE *dst;
w = (int)bitmap->Width();
h = (int)bitmap->Height();
pitch = w * 4;
pixels = (BYTE *) eeMalloc(h * pitch);
if (!pixels)
return NULL;
for (y = 0; y < h; y++) {
dst = pixels + y * pitch;
for (x = 0; x < w; x++) {
eeColorA C = bitmap->GetPixel( x, y );
/* BGR */
dst[0] = C.B();
dst[1] = C.G();
dst[2] = C.R();
dst[3] = C.A();
dst += 4;
}
}
return pixels;
}
static void local_stretch_blit_to_hdc( cImage *bitmap, HDC dc, int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y, int dest_w, int dest_h) {
const int bitmap_h = (const int)bitmap->Height();
const int bottom_up_src_y = bitmap_h - src_y - src_h;
BYTE *pixels;
BITMAPINFO *bi;
bi = get_bitmap_info(bitmap);
pixels = get_dib_from_bitmap_32(bitmap);
/* Windows treats all source bitmaps as bottom-up when using StretchDIBits
* unless the source (x,y) is (0,0). To work around this buggy behavior, we
* can use negative heights to reverse the direction of the blits.
*
* See <http://wiki.allegro.cc/StretchDIBits> for a detailed explanation.
*/
if (bottom_up_src_y == 0 && src_x == 0 && src_h != bitmap_h) {
StretchDIBits( dc, dest_x, dest_h+dest_y-1, dest_w, -dest_h, src_x, bitmap_h - src_y + 1, src_w, -src_h, pixels, bi, DIB_RGB_COLORS, SRCCOPY );
}
else {
StretchDIBits( dc, dest_x, dest_y, dest_w, dest_h, src_x, bottom_up_src_y, src_w, src_h, pixels, bi, DIB_RGB_COLORS, SRCCOPY );
}
eeFree(pixels);
eeFree(bi);
}
static void local_draw_to_hdc( HDC dc, cImage * bitmap, int x, int y ) {
int w = bitmap->Width();
int h = bitmap->Height();
local_stretch_blit_to_hdc(bitmap, dc, 0, 0, w, h, x, y, w, h);
}
void cCursorWin::Create() {
if ( NULL == mImage && mImage->Size() )
return;
int x, y;
int sys_sm_cx, sys_sm_cy;
HDC h_dc;
HDC h_and_dc;
HDC h_xor_dc;
ICONINFO iconinfo;
HBITMAP and_mask;
HBITMAP xor_mask;
HBITMAP hOldAndMaskBitmap;
HBITMAP hOldXorMaskBitmap;
HICON icon;
/* Get allowed cursor size - Windows can't make cursors of arbitrary size */
sys_sm_cx = GetSystemMetrics(SM_CXCURSOR);
sys_sm_cy = GetSystemMetrics(SM_CYCURSOR);
if ( ( (int)mImage->Width() > sys_sm_cx ) || ( (int)mImage->Height() > sys_sm_cy ) ) {
return;
}
/* Create bitmap */
h_dc = GetDC( GetPlatform()->GetHandler() );
h_xor_dc = CreateCompatibleDC(h_dc);
h_and_dc = CreateCompatibleDC(h_dc);
/* Prepare AND (monochrome) and XOR (colour) mask */
and_mask = CreateBitmap(sys_sm_cx, sys_sm_cy, 1, 1, NULL);
xor_mask = CreateCompatibleBitmap(h_dc, sys_sm_cx, sys_sm_cy);
hOldAndMaskBitmap = (HBITMAP) SelectObject(h_and_dc, and_mask);
hOldXorMaskBitmap = (HBITMAP) SelectObject(h_xor_dc, xor_mask);
/* Create transparent cursor */
for (y = 0; y < sys_sm_cy; y++) {
for (x = 0; x < sys_sm_cx; x++) {
SetPixel(h_and_dc, x, y, WINDOWS_RGB(255, 255, 255));
SetPixel(h_xor_dc, x, y, WINDOWS_RGB(0, 0, 0));
}
}
local_draw_to_hdc( h_xor_dc, mImage, 0, 0 );
/* Make cursor background transparent */
for (y = 0; y < (int)mImage->Height(); y++) {
for (x = 0; x < (int)mImage->Width(); x++) {
eeColorA C = mImage->GetPixel( x, y );
if ( C.A() != 0 ) {
/* Don't touch XOR value */
SetPixel( h_and_dc, x, y, 0 );
} else {
/* No need to touch AND value */
SetPixel( h_xor_dc, x, y, WINDOWS_RGB( 0, 0, 0 ) );
}
}
}
SelectObject(h_and_dc, hOldAndMaskBitmap);
SelectObject(h_xor_dc, hOldXorMaskBitmap);
DeleteDC(h_and_dc);
DeleteDC(h_xor_dc);
ReleaseDC( GetPlatform()->GetHandler() , h_dc );
iconinfo.fIcon = false;
iconinfo.xHotspot = mHotSpot.x;
iconinfo.yHotspot = mHotSpot.y;
iconinfo.hbmMask = and_mask;
iconinfo.hbmColor = xor_mask;
icon = CreateIconIndirect(&iconinfo);
DeleteObject(and_mask);
DeleteObject(xor_mask);
mCursor = (void*)icon;
}
cWinImpl * cCursorWin::GetPlatform() {
return reinterpret_cast<cWinImpl*>( mWindow->GetPlatform() );
}
void * cCursorWin::GetCursor() const {
return mCursor;
}
}}}

View File

@@ -8,27 +8,27 @@
using namespace EE::Window;
namespace EE { namespace Window { namespace Platform {
class cWinImpl;
class cCursorWin : public cCursor {
public:
HCURSOR GetCursor() const;
class cWinImpl;
class cCursorWin : public cCursor {
public:
void * GetCursor() const;
protected:
friend class cWinImpl;
HCURSOR mCursor;
friend class cWinImpl;
void * mCursor;
cCursorWin( cTexture * tex, const eeVector2i& hotspot, const std::string& name, cWindow * window );
cCursorWin( cImage * img, const eeVector2i& hotspot, const std::string& name, cWindow * window );
cCursorWin( const std::string& path, const eeVector2i& hotspot, const std::string& name, cWindow * window );
cCursorWin( const std::string& path, const eeVector2i& hotspot, const std::string& name, cWindow * window );
~cCursorWin();
void Create();
void Create();
cWinImpl * GetPlatform();
};

View File

@@ -1,16 +1,26 @@
#include <eepp/window/platform/win/cwinimpl.hpp>
#include <eepp/declares.hpp>
#if EE_PLATFORM == EE_PLATFORM_WIN
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#undef CreateWindow
static BOOL WIN_ShowWindow( HWND hWnd, int nCmdShow ) {
return ShowWindow( hWnd, nCmdShow );
}
#include <eepp/window/platform/win/cwinimpl.hpp>
#include <eepp/window/cwindow.hpp>
#include <eepp/window/platform/win/ccursorwin.hpp>
using namespace EE::Window::Cursor;
#include <eepp/window/platform/win/ccursorwin.hpp>
using namespace EE::Window::Cursor;
namespace EE { namespace Window { namespace Platform {
cWinImpl::cWinImpl( cWindow * window, eeWindowHandler handler ) :
cWinImpl::cWinImpl( cWindow * window, eeWindowHandle handler ) :
cPlatformImpl( window ),
mHandler( handler ),
mCursorCurrent( NULL ),
@@ -53,7 +63,7 @@ void cWinImpl::MoveWindow( int left, int top ) {
}
void cWinImpl::SetContext( eeWindowContex Context ) {
wglMakeCurrent( GetDC( mHandler ), Context );
wglMakeCurrent( (HDC)GetDC( mHandler ), (HGLRC)Context );
}
eeVector2i cWinImpl::Position() {
@@ -62,16 +72,16 @@ eeVector2i cWinImpl::Position() {
return eeVector2i( r.left, r.top );
}
void cWinImpl::ShowMouseCursor() {
mCursorHidden = false;
void cWinImpl::ShowMouseCursor() {
mCursorHidden = false;
if ( !mCursorCurrent ) {
SetSystemMouseCursor( Cursor::SYS_CURSOR_DEFAULT );
} else {
SetCursor( mCursorCurrent );
SetCursor( (HCURSOR)mCursorCurrent );
POINT p;
GetCursorPos( &p );
SetCursorPos( p.x, p.y );
SetCursorPos( p.x, p.y );
}
}
@@ -96,11 +106,11 @@ cCursor * cWinImpl::CreateMouseCursor( const std::string& path, const eeVector2i
return eeNew( cCursorWin, ( path, hotspot, name, mWindow ) );
}
void cWinImpl::SetMouseCursor( cCursor * cursor ) {
mCursorCurrent = reinterpret_cast<cCursorWin*> ( cursor )->GetCursor();
void cWinImpl::SetMouseCursor( cCursor * cursor ) {
mCursorCurrent = reinterpret_cast<cCursorWin*> ( cursor )->GetCursor();
if ( !mCursorHidden ) {
SetCursor( mCursorCurrent );
SetCursor( (HCURSOR)mCursorCurrent );
POINT p;
GetCursorPos( &p );
SetCursorPos( p.x, p.y );
@@ -146,8 +156,8 @@ void cWinImpl::SetSystemMouseCursor( Cursor::EE_SYSTEM_CURSOR syscursor ) {
mc = LoadCursor(NULL, IDC_NO); break;
default:
return;
mCursorCurrent = mc;
mCursorCurrent = mc;
if ( !mCursorHidden ) {
SetCursor( mc );
@@ -158,16 +168,16 @@ void cWinImpl::SetSystemMouseCursor( Cursor::EE_SYSTEM_CURSOR syscursor ) {
}
}
void cWinImpl::RestoreCursor() {
void cWinImpl::RestoreCursor() {
if ( !mCursorHidden ) {
ShowMouseCursor();
} else {
HideMouseCursor();
}
}
eeWindowHandler cWinImpl::GetHandler() const {
return mHandler;
eeWindowHandle cWinImpl::GetHandler() const {
return mHandler;
}
}}}

View File

@@ -2,17 +2,18 @@
#define EE_WINDOWCWINIMPL_HPP
#include <eepp/window/base.hpp>
#include <eepp/window/cplatformimpl.hpp>
#if EE_PLATFORM == EE_PLATFORM_WIN
#include <eepp/window/cplatformimpl.hpp>
namespace EE { namespace Window { namespace Platform {
using namespace EE::Window;
class cWinImpl : public cPlatformImpl {
public:
cWinImpl( Window::cWindow * window, eeWindowHandler handler );
cWinImpl( Window::cWindow * window, eeWindowHandle handler );
~cWinImpl();
@@ -48,10 +49,10 @@ class cWinImpl : public cPlatformImpl {
void RestoreCursor();
eeWindowHandler GetHandler() const;
eeWindowHandle GetHandler() const;
protected:
eeWindowHandler mHandler;
HCURSOR mCursorCurrent;
eeWindowHandle mHandler;
void * mCursorCurrent;
bool mCursorHidden;
};

View File

@@ -7,7 +7,7 @@ using namespace EE::Window::Cursor;
namespace EE { namespace Window { namespace Platform {
cX11Impl::cX11Impl( cWindow * window, eeWindowHandler display, X11Window xwindow, X11Window mainwindow, LockFunc lock, UnlockFunc unlock ) :
cX11Impl::cX11Impl( cWindow * window, eeWindowHandle display, X11Window xwindow, X11Window mainwindow, LockFunc lock, UnlockFunc unlock ) :
cPlatformImpl( window ),
mDisplay( display ),
mX11Window( xwindow ),
@@ -279,7 +279,7 @@ void cX11Impl::SetSystemMouseCursor( Cursor::EE_SYSTEM_CURSOR syscursor ) {
Unlock();
}
eeWindowHandler cX11Impl::GetDisplay() const {
eeWindowHandle cX11Impl::GetDisplay() const {
return mDisplay;
}

View File

@@ -2,10 +2,11 @@
#define EE_WINDOWCX11IMPL_HPP
#include <eepp/window/base.hpp>
#include <eepp/window/cplatformimpl.hpp>
#if defined( EE_X11_PLATFORM )
#include <eepp/window/cplatformimpl.hpp>
namespace EE { namespace Window { namespace Platform {
using namespace EE::Window;
@@ -15,7 +16,7 @@ class cX11Impl : public cPlatformImpl {
typedef void (*LockFunc)(void);
typedef void (*UnlockFunc)(void);
cX11Impl( Window::cWindow * window, eeWindowHandler display, X11Window xwindow, X11Window mainwindow, LockFunc lock, UnlockFunc unlock );
cX11Impl( Window::cWindow * window, eeWindowHandle display, X11Window xwindow, X11Window mainwindow, LockFunc lock, UnlockFunc unlock );
~cX11Impl();
@@ -51,13 +52,13 @@ class cX11Impl : public cPlatformImpl {
void RestoreCursor();
eeWindowHandler GetDisplay() const;
eeWindowHandle GetDisplay() const;
void Lock();
void Unlock();
protected:
eeWindowHandler mDisplay;
eeWindowHandle mDisplay;
X11Window mX11Window;
X11Window mMainWindow;
LockFunc mLock;