Merge pull request #375 from OpenMW/master

Add OpenMW commits up to 29 Jan 2018
pull/376/head
David Cernat 7 years ago committed by GitHub
commit 78df8c5ebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,7 +1,9 @@
int stderr = 0; // Hack: fix linker error int stderr = 0; // Hack: fix linker error
#ifdef __ANDROID__
#include "SDL_main.h" #include "SDL_main.h"
#include <SDL_gamecontroller.h>
#include <SDL_mouse.h>
#include <SDL_events.h>
/******************************************************************************* /*******************************************************************************
Functions called by JNI Functions called by JNI
@ -15,6 +17,25 @@ extern int argcData;
extern const char **argvData; extern const char **argvData;
void releaseArgv(); void releaseArgv();
int Java_org_libsdl_app_SDLActivity_getMouseX(JNIEnv *env, jclass cls, jobject obj) {
int ret = 0;
SDL_GetMouseState(&ret, NULL);
return ret;
}
int Java_org_libsdl_app_SDLActivity_getMouseY(JNIEnv *env, jclass cls, jobject obj) {
int ret = 0;
SDL_GetMouseState(NULL, &ret);
return ret;
}
int Java_org_libsdl_app_SDLActivity_isMouseShown(JNIEnv *env, jclass cls, jobject obj) {
return SDL_ShowCursor(SDL_QUERY);
}
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
jobject obj) { jobject obj) {
@ -24,6 +45,9 @@ int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
SDL_SetMainReady(); SDL_SetMainReady();
// On Android, we use a virtual controller with guid="Virtual"
SDL_GameControllerAddMapping("5669727475616c000000000000000000,Virtual,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4");
/* Run the application code! */ /* Run the application code! */
int status; int status;
@ -36,5 +60,3 @@ int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
return status; return status;
} }
#endif /* __ANDROID__ */

@ -13,11 +13,6 @@ namespace ESM
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
/// \brief File header record
struct Header
{
static const int CurrentFormat = 0; // most recent known format
struct Data struct Data
{ {
/* File format version. This is actually a float, the supported /* File format version. This is actually a float, the supported
@ -31,14 +26,6 @@ namespace ESM
int records; // Number of records int records; // Number of records
}; };
// Defines another files (esm or esp) that this file depends upon.
struct MasterData
{
std::string name;
uint64_t size;
int index; // Position of the parent file in the global list of loaded files
};
struct GMDT struct GMDT
{ {
float mCurrentHealth; float mCurrentHealth;
@ -49,6 +36,22 @@ namespace ESM
unsigned char unknown2[4]; unsigned char unknown2[4];
NAME32 mPlayerName; NAME32 mPlayerName;
}; };
#pragma pack(pop)
/// \brief File header record
struct Header
{
static const int CurrentFormat = 0; // most recent known format
// Defines another files (esm or esp) that this file depends upon.
struct MasterData
{
std::string name;
uint64_t size;
int index; // Position of the parent file in the global list of loaded files
};
GMDT mGameData; // Used in .ess savegames only GMDT mGameData; // Used in .ess savegames only
std::vector<unsigned char> mSCRD; // Used in .ess savegames only, unknown std::vector<unsigned char> mSCRD; // Used in .ess savegames only, unknown
std::vector<unsigned char> mSCRS; // Used in .ess savegames only, screenshot std::vector<unsigned char> mSCRS; // Used in .ess savegames only, screenshot
@ -62,7 +65,6 @@ namespace ESM
void load (ESMReader &esm); void load (ESMReader &esm);
void save (ESMWriter &esm); void save (ESMWriter &esm);
}; };
#pragma pack(pop)
} }

@ -203,19 +203,14 @@ namespace SDLUtil
void SDLCursorManager::cursorChanged(const std::string& name) void SDLCursorManager::cursorChanged(const std::string& name)
{ {
mCurrentCursor = name; mCurrentCursor = name;
CursorMap::const_iterator curs_iter = mCursorMap.find(name);
if(curs_iter != mCursorMap.end())
{
//we have this cursor
_setGUICursor(name); _setGUICursor(name);
} }
}
void SDLCursorManager::_setGUICursor(const std::string &name) void SDLCursorManager::_setGUICursor(const std::string &name)
{ {
SDL_SetCursor(mCursorMap.find(name)->second); auto it = mCursorMap.find(name);
if (it != mCursorMap.end())
SDL_SetCursor(it->second);
} }
void SDLCursorManager::createCursor(const std::string& name, int rotDegrees, osg::Image* image, Uint8 hotspot_x, Uint8 hotspot_y) void SDLCursorManager::createCursor(const std::string& name, int rotDegrees, osg::Image* image, Uint8 hotspot_x, Uint8 hotspot_y)

@ -92,9 +92,18 @@ void GraphicsWindowSDL2::init()
SDL_GLContext oldCtx = SDL_GL_GetCurrentContext(); SDL_GLContext oldCtx = SDL_GL_GetCurrentContext();
#if defined(OPENGL_ES) || defined(ANDROID) #if defined(OPENGL_ES) || defined(ANDROID)
int major = 1;
int minor = 1;
char *ver = getenv("OPENMW_GLES_VERSION");
if (ver && strcmp(ver, "2") == 0) {
major = 2;
minor = 0;
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor);
#endif #endif
mContext = SDL_GL_CreateContext(mWindow); mContext = SDL_GL_CreateContext(mWindow);

@ -315,9 +315,9 @@ int VideoState::queue_picture(AVFrame *pFrame, double pts)
vp->pts = pts; vp->pts = pts;
vp->data.resize((*this->video_st)->codec->width * (*this->video_st)->codec->height * 4); vp->data.resize((*this->video_st)->codec->width * (*this->video_st)->codec->height * 4);
uint8_t *dst = &vp->data[0]; uint8_t *dst[4] = { &vp->data[0], nullptr, nullptr, nullptr };
sws_scale(this->sws_context, pFrame->data, pFrame->linesize, sws_scale(this->sws_context, pFrame->data, pFrame->linesize,
0, (*this->video_st)->codec->height, &dst, this->rgbaFrame->linesize); 0, (*this->video_st)->codec->height, dst, this->rgbaFrame->linesize);
// now we inform our display thread that we have a pic ready // now we inform our display thread that we have a pic ready
this->pictq_windex = (this->pictq_windex+1) % VIDEO_PICTURE_ARRAY_SIZE; this->pictq_windex = (this->pictq_windex+1) % VIDEO_PICTURE_ARRAY_SIZE;

Loading…
Cancel
Save