mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Compare commits
3 Commits
720dd22491
...
13f9112d8c
| Author | SHA1 | Date | |
|---|---|---|---|
| 13f9112d8c | |||
| f16fb065ea | |||
| 66392fe0ae |
@ -679,6 +679,7 @@ void ClearWindowState(unsigned int flags)
|
|||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "ClearWindowState() - FLAG_WINDOW_TRANSPARENT is not supported on PLATFORM_DESKTOP_SDL");
|
TRACELOG(LOG_WARNING, "ClearWindowState() - FLAG_WINDOW_TRANSPARENT is not supported on PLATFORM_DESKTOP_SDL");
|
||||||
}
|
}
|
||||||
|
if (FLAG_IS_SET(flags, FLAG_WINDOW_HIGHDPI))
|
||||||
{
|
{
|
||||||
// NOTE: There also doesn't seem to be a feature to disable high DPI once enabled
|
// NOTE: There also doesn't seem to be a feature to disable high DPI once enabled
|
||||||
TRACELOG(LOG_WARNING, "ClearWindowState() - FLAG_WINDOW_HIGHDPI is not supported on PLATFORM_DESKTOP_SDL");
|
TRACELOG(LOG_WARNING, "ClearWindowState() - FLAG_WINDOW_HIGHDPI is not supported on PLATFORM_DESKTOP_SDL");
|
||||||
@ -1474,7 +1475,7 @@ void PollInputEvents(void)
|
|||||||
const int height = event.window.data2;
|
const int height = event.window.data2;
|
||||||
SetupViewport(width, height);
|
SetupViewport(width, height);
|
||||||
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
||||||
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||||
{
|
{
|
||||||
CORE.Window.screen.width = (int)(width/GetWindowScaleDPI().x);
|
CORE.Window.screen.width = (int)(width/GetWindowScaleDPI().x);
|
||||||
CORE.Window.screen.height = (int)(height/GetWindowScaleDPI().y);
|
CORE.Window.screen.height = (int)(height/GetWindowScaleDPI().y);
|
||||||
|
|||||||
@ -54,11 +54,6 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
// TODO: Define the platform specific variables required
|
// TODO: Define the platform specific variables required
|
||||||
|
|
||||||
// Display data
|
|
||||||
EGLDisplay device; // Native display device (physical screen connection)
|
|
||||||
EGLSurface surface; // Surface to draw on, framebuffers (connected to context)
|
|
||||||
EGLContext context; // Graphic context, mode in which drawing can be done
|
|
||||||
EGLConfig config; // Graphic config
|
|
||||||
} PlatformData;
|
} PlatformData;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
@ -346,10 +341,10 @@ void SwapScreenBuffer(void)
|
|||||||
double GetTime(void)
|
double GetTime(void)
|
||||||
{
|
{
|
||||||
double time = 0.0;
|
double time = 0.0;
|
||||||
|
|
||||||
struct timespec ts = { 0 };
|
struct timespec ts = { 0 };
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
|
unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
|
||||||
|
|
||||||
time = (double)(nanoSeconds - CORE.Time.base)*1e-9; // Elapsed time since InitTimer()
|
time = (double)(nanoSeconds - CORE.Time.base)*1e-9; // Elapsed time since InitTimer()
|
||||||
|
|
||||||
return time;
|
return time;
|
||||||
@ -366,7 +361,7 @@ void OpenURL(const char *url)
|
|||||||
if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character");
|
if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO: Load url using default browser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,86 +457,18 @@ int InitPlatform(void)
|
|||||||
CORE.Window.fullscreen = true;
|
CORE.Window.fullscreen = true;
|
||||||
FLAG_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
|
FLAG_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
|
||||||
|
|
||||||
EGLint samples = 0;
|
|
||||||
EGLint sampleBuffer = 0;
|
|
||||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
|
||||||
{
|
{
|
||||||
samples = 4;
|
// TODO: Enable MSAA
|
||||||
sampleBuffer = 1;
|
|
||||||
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4");
|
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4");
|
||||||
}
|
}
|
||||||
|
|
||||||
const EGLint framebufferAttribs[] =
|
// TODO: Init display and graphic device
|
||||||
{
|
|
||||||
EGL_RENDERABLE_TYPE, (rlGetVersion() == RL_OPENGL_ES_30)? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, // Type of context support
|
|
||||||
EGL_RED_SIZE, 8, // RED color bit depth (alternative: 5)
|
|
||||||
EGL_GREEN_SIZE, 8, // GREEN color bit depth (alternative: 6)
|
|
||||||
EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5)
|
|
||||||
//EGL_TRANSPARENT_TYPE, EGL_NONE, // Request transparent framebuffer (EGL_TRANSPARENT_RGB does not work on RPI)
|
|
||||||
EGL_DEPTH_SIZE, 16, // Depth buffer size (Required to use Depth testing!)
|
|
||||||
//EGL_STENCIL_SIZE, 8, // Stencil buffer size
|
|
||||||
EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA
|
|
||||||
EGL_SAMPLES, samples, // 4x Antialiasing if activated (Free on MALI GPUs)
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
const EGLint contextAttribs[] =
|
// TODO: Check display, device and context activation
|
||||||
{
|
bool result = true;
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
if (result)
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
EGLint numConfigs = 0;
|
|
||||||
|
|
||||||
// Get an EGL device connection
|
|
||||||
platform.device = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
|
||||||
if (platform.device == EGL_NO_DISPLAY)
|
|
||||||
{
|
|
||||||
TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the EGL device connection
|
|
||||||
if (eglInitialize(platform.device, NULL, NULL) == EGL_FALSE)
|
|
||||||
{
|
|
||||||
// If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred.
|
|
||||||
TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get an appropriate EGL framebuffer configuration
|
|
||||||
eglChooseConfig(platform.device, framebufferAttribs, &platform.config, 1, &numConfigs);
|
|
||||||
|
|
||||||
// Set rendering API
|
|
||||||
eglBindAPI(EGL_OPENGL_ES_API);
|
|
||||||
|
|
||||||
// Create an EGL rendering context
|
|
||||||
platform.context = eglCreateContext(platform.device, platform.config, EGL_NO_CONTEXT, contextAttribs);
|
|
||||||
if (platform.context == EGL_NO_CONTEXT)
|
|
||||||
{
|
|
||||||
TRACELOG(LOG_WARNING, "DISPLAY: Failed to create EGL context");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create an EGL window surface
|
|
||||||
EGLint displayFormat = 0;
|
|
||||||
|
|
||||||
// EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is guaranteed to be accepted by ANativeWindow_setBuffersGeometry()
|
|
||||||
// As soon as we picked a EGLConfig, we can safely reconfigure the ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID
|
|
||||||
eglGetConfigAttrib(platform.device, platform.config, EGL_NATIVE_VISUAL_ID, &displayFormat);
|
|
||||||
|
|
||||||
// Android specific call
|
|
||||||
ANativeWindow_setBuffersGeometry(platform.app->window, 0, 0, displayFormat); // Force use of native display size
|
|
||||||
|
|
||||||
platform.surface = eglCreateWindowSurface(platform.device, platform.config, platform.app->window, NULL);
|
|
||||||
|
|
||||||
// There must be at least one frame displayed before the buffers are swapped
|
|
||||||
eglSwapInterval(platform.device, 1);
|
|
||||||
|
|
||||||
EGLBoolean result = eglMakeCurrent(platform.device, platform.surface, platform.surface, platform.context);
|
|
||||||
|
|
||||||
// Check surface and context activation
|
|
||||||
if (result != EGL_FALSE)
|
|
||||||
{
|
{
|
||||||
CORE.Window.ready = true;
|
CORE.Window.ready = true;
|
||||||
|
|
||||||
|
|||||||
34
src/rlgl.h
34
src/rlgl.h
@ -5224,24 +5224,36 @@ static int rlGetPixelDataSize(int width, int height, int format)
|
|||||||
case RL_PIXELFORMAT_COMPRESSED_ETC1_RGB:
|
case RL_PIXELFORMAT_COMPRESSED_ETC1_RGB:
|
||||||
case RL_PIXELFORMAT_COMPRESSED_ETC2_RGB:
|
case RL_PIXELFORMAT_COMPRESSED_ETC2_RGB:
|
||||||
case RL_PIXELFORMAT_COMPRESSED_PVRT_RGB:
|
case RL_PIXELFORMAT_COMPRESSED_PVRT_RGB:
|
||||||
case RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA: bpp = 4; break;
|
case RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA: // 8 bytes per each 4x4 block
|
||||||
|
{
|
||||||
|
int blockWidth = (width + 3)/4;
|
||||||
|
int blockHeight = (height + 3)/4;
|
||||||
|
dataSize = blockWidth*blockHeight*8;
|
||||||
|
} break;
|
||||||
case RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA:
|
case RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA:
|
||||||
case RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA:
|
case RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA:
|
||||||
case RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA:
|
case RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA:
|
||||||
case RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA: bpp = 8; break;
|
case RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA: // 16 bytes per each 4x4 block
|
||||||
case RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA: bpp = 2; break;
|
{
|
||||||
|
int blockWidth = (width + 3)/4;
|
||||||
|
int blockHeight = (height + 3)/4;
|
||||||
|
dataSize = blockWidth*blockHeight*16;
|
||||||
|
} break;
|
||||||
|
case RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA: // 4 bytes per each 4x4 block
|
||||||
|
{
|
||||||
|
int blockWidth = (width + 3)/4;
|
||||||
|
int blockHeight = (height + 3)/4;
|
||||||
|
dataSize = blockWidth*blockHeight*4;
|
||||||
|
} break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
double bytesPerPixel = (double)bpp/8.0;
|
// Compute dataSize for uncompressed texture data (no blocks)
|
||||||
dataSize = (int)(bytesPerPixel*width*height); // Total data size in bytes
|
if ((format >= RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) &&
|
||||||
|
(format <= RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16))
|
||||||
// Most compressed formats works on 4x4 blocks,
|
|
||||||
// if texture is smaller, minimum dataSize is 8 or 16
|
|
||||||
if ((width <= 4) && (height <= 4))
|
|
||||||
{
|
{
|
||||||
if ((format >= RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) && (format < RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA)) dataSize = 8;
|
double bytesPerPixel = (double)bpp/8.0;
|
||||||
else if ((format >= RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA) && (format < RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA)) dataSize = 16;
|
dataSize = (int)(bytesPerPixel*width*height); // Total data size in bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataSize;
|
return dataSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user