added support for msys2 mingwtoolchains and fix x64 cocos/audio on windows platform for MSVC and Mingw. Also fixed a few very bad type casts very important for future Arm64 bit processors

This commit is contained in:
martell 2013-12-05 03:37:27 +00:00
parent 4214ad231e
commit e5ada6f377
7 changed files with 112 additions and 15 deletions

View File

@ -1,3 +1,28 @@
#/****************************************************************************
# Copyright (c) 2013 cocos2d-x.org
# Copyright (c) 2012-2013 martell malone
#
# http://www.cocos2d-x.org
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# ****************************************************************************/
cmake_minimum_required(VERSION 2.8)
project (Cocos2dx)

View File

@ -0,0 +1,62 @@
#!/bin/bash
# msys2 Pacman Manager for cocos2d-x
#/****************************************************************************
# Copyright (c) 2012-2013 Martell Malone
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# ****************************************************************************/
set -e
THISDIR="$(dirname $0)"
test "$THISDIR" = "." && THISDIR=${PWD}
OSTYPE=${OSTYPE//[0-9.]/}
HOST_ARCH=$(uname -m)
if [ "${HOST_ARCH}" = "i686" ]; then
BITS=32
elif [ "${HOST_ARCH}" = "x86_64" ]; then
BITS=64
fi
if [ "${OSTYPE}" = "msys" ]; then
CC=${HOST_ARCH}-w64-mingw32-gcc
CXX=${HOST_ARCH}-w64-mingw32-g++
PP=mingw-w64-${HOST_ARCH}
MINGW_PACKAGES=(glfw glew libwebp libjpeg-turbo libpng freetype libiconv zlib curl
make gcc binutils headers cmake libxml2)
MINGW_PACKAGES=(${MINGW_PACKAGES[@]/#/${PP}-})
pacman -S --force --noconfirm --needed ${MINGW_PACKAGES[@]}
mkdir -p mingw${BITS} && cd mingw${BITS}
export PATH=/mingw${BITS}/bin:${PATH}
cmake -G"MinGW Makefiles" -DCMAKE_MAKE_PROGRAM="mingw32-make" \
-DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" ../..
mingw32-make
fi

View File

@ -613,7 +613,7 @@ void Sprite::draw(void)
long offset = 0;
setGLBufferData(&_quad, 4 * kQuadSize, 0);
#else
long offset = (long)&_quad;
size_t offset = (size_t)&_quad;
#endif // EMSCRIPTEN
// vertex

View File

@ -439,7 +439,7 @@ int ZipUtils::inflateCCZBuffer(const unsigned char *buffer, long bufferLen, unsi
}
unsigned long destlen = len;
unsigned long source = (unsigned long) buffer + sizeof(*header);
size_t source = (size_t) buffer + sizeof(*header);
int ret = uncompress(*out, &destlen, (Bytef*)source, bufferLen - sizeof(*header) );
if( ret != Z_OK )

View File

@ -52,6 +52,12 @@ THE SOFTWARE.
#include <stdlib.h>
#include <time.h>
#ifndef M_PI
#define M_PI 3.14159265358
#endif
#ifndef M_PI_2
#define M_PI_2 1.57079632679
#endif
// for MIN MAX and sys/time.h on win32 platform
#ifdef __MINGW32__
#include <sys/time.h>
@ -73,7 +79,9 @@ THE SOFTWARE.
#endif
#define _WINSOCKAPI_
#define NOMINMAX
#ifndef NOMINMAX
#define NOMINMAX
#endif
// Structure timeval has define in winsock.h, include windows.h for it.
#include <Windows.h>

View File

@ -8,11 +8,11 @@ namespace CocosDenshion {
static HINSTANCE s_hInstance;
static MCIERROR s_mciError;
static LRESULT WINAPI _SoundPlayProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
LRESULT WINAPI _SoundPlayProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
MciPlayer::MciPlayer()
: _wnd(NULL)
, _dev(NULL)
, _dev(0L)
, _soundID(0)
, _times(0)
, _playing(false)
@ -56,7 +56,7 @@ MciPlayer::MciPlayer()
NULL );
if (_wnd)
{
SetWindowLong(_wnd, GWL_USERDATA, (LONG)this);
SetWindowLongPtr(_wnd, GWLP_USERDATA, (LONG_PTR)this);
}
}
@ -85,7 +85,7 @@ void MciPlayer::Open(const char* pFileName, UINT uId)
mciOpen.lpstrDeviceType = (LPCTSTR)MCI_ALL_DEVICE_ID;
mciOpen.lpstrElementName = pFileName;
mciError = mciSendCommand(0,MCI_OPEN, MCI_OPEN_ELEMENT, (DWORD)&mciOpen);
mciError = mciSendCommand(0,MCI_OPEN, MCI_OPEN_ELEMENT, reinterpret_cast<DWORD_PTR>(&mciOpen));
BREAK_IF(mciError);
_dev = mciOpen.wDeviceID;
@ -101,8 +101,8 @@ void MciPlayer::Play(UINT uTimes /* = 1 */)
return;
}
MCI_PLAY_PARMS mciPlay = {0};
mciPlay.dwCallback = (DWORD_PTR)_wnd;
s_mciError = mciSendCommand(_dev,MCI_PLAY, MCI_FROM|MCI_NOTIFY,(DWORD)&mciPlay);
mciPlay.dwCallback = reinterpret_cast<DWORD_PTR>(_wnd);
s_mciError = mciSendCommand(_dev,MCI_PLAY, MCI_FROM|MCI_NOTIFY,reinterpret_cast<DWORD_PTR>(&mciPlay));
if (! s_mciError)
{
_playing = true;
@ -149,8 +149,8 @@ void MciPlayer::Rewind()
mciSendCommand(_dev, MCI_SEEK, MCI_SEEK_TO_START, 0);
MCI_PLAY_PARMS mciPlay = {0};
mciPlay.dwCallback = (DWORD)_wnd;
_playing = mciSendCommand(_dev, MCI_PLAY, MCI_NOTIFY,(DWORD)&mciPlay) ? false : true;
mciPlay.dwCallback = reinterpret_cast<DWORD_PTR>(_wnd);
_playing = mciSendCommand(_dev, MCI_PLAY, MCI_NOTIFY,reinterpret_cast<DWORD_PTR>(&mciPlay)) ? false : true;
}
bool MciPlayer::IsPlaying()
@ -185,7 +185,7 @@ LRESULT WINAPI _SoundPlayProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
MciPlayer * pPlayer = NULL;
if (MM_MCINOTIFY == Msg
&& MCI_NOTIFY_SUCCESSFUL == wParam
&&(pPlayer = (MciPlayer *)GetWindowLong(hWnd, GWL_USERDATA)))
&&(pPlayer = (MciPlayer *)GetWindowLongPtr(hWnd, GWLP_USERDATA)))
{
if (pPlayer->_times)
{
@ -197,8 +197,8 @@ LRESULT WINAPI _SoundPlayProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
mciSendCommand(lParam, MCI_SEEK, MCI_SEEK_TO_START, 0);
MCI_PLAY_PARMS mciPlay = {0};
mciPlay.dwCallback = (DWORD)hWnd;
mciSendCommand(lParam, MCI_PLAY, MCI_NOTIFY,(DWORD)&mciPlay);
mciPlay.dwCallback = reinterpret_cast<DWORD_PTR>(hWnd);
mciSendCommand(lParam, MCI_PLAY, MCI_NOTIFY,reinterpret_cast<DWORD_PTR>(&mciPlay));
}
else
{

View File

@ -133,7 +133,9 @@ Config of cocos2d-x project, per target platform.
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#pragma warning (disable:4127)
#ifndef __MINGW32__
#pragma warning (disable:4127)
#endif
#endif // CC_PLATFORM_WIN32
#endif // __CC_PLATFORM_CONFIG_H__