61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
#include "Environment.h"
|
|
|
|
#include "utils/Utils.h"
|
|
|
|
#ifdef __ANDROID__
|
|
#include <GLES2/gl2.h>
|
|
#include <GLES2/gl2ext.h>
|
|
#else
|
|
#include <GL/gl.h>
|
|
#endif
|
|
namespace ZL {
|
|
|
|
|
|
|
|
int Environment::windowHeaderHeight = 0;
|
|
int Environment::width = CONST_DEFAULT_WIDTH;
|
|
int Environment::height = CONST_DEFAULT_HEIGHT;
|
|
float Environment::zoom = DEFAULT_ZOOM;
|
|
|
|
|
|
SDL_Window* Environment::window = nullptr;
|
|
|
|
bool Environment::showMouse = false;
|
|
|
|
bool Environment::exitGameLoop = false;
|
|
|
|
Eigen::Matrix3f Environment::inverseShipMatrix = Eigen::Matrix3f::Identity();
|
|
|
|
|
|
bool Environment::tapDownHold = false;
|
|
Eigen::Vector2f Environment::tapDownStartPos = { 0, 0 };
|
|
Eigen::Vector2f Environment::tapDownCurrentPos = { 0, 0 };
|
|
|
|
ClientState Environment::shipState;
|
|
|
|
const float Environment::CONST_Z_NEAR = 5.f;
|
|
const float Environment::CONST_Z_FAR = 5000.f;
|
|
|
|
float Environment::projectionWidth = 1280.0f;
|
|
float Environment::projectionHeight = 720.0f;
|
|
|
|
void Environment::computeProjectionDimensions()
|
|
{
|
|
if (width <= 0 || height <= 0) return;
|
|
|
|
const float refShortSide = 720.0f;
|
|
float aspect = (float)width / (float)height;
|
|
|
|
if (width >= height) {
|
|
// Landscape: fix height to 720, scale width to preserve aspect
|
|
projectionHeight = refShortSide;
|
|
projectionWidth = refShortSide * aspect;
|
|
} else {
|
|
// Portrait: fix width to 720, scale height to preserve aspect
|
|
projectionWidth = refShortSide;
|
|
projectionHeight = refShortSide / aspect;
|
|
}
|
|
}
|
|
|
|
} // namespace ZL
|