Merge branch 'raysan5:master' into master
This commit is contained in:
commit
8b2f1350b0
|
|
@ -27,6 +27,12 @@ if (${PLATFORM} MATCHES "Desktop")
|
|||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
find_package(OpenGL QUIET)
|
||||
set(LIBS_PRIVATE ${OPENGL_LIBRARIES} winmm)
|
||||
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "QNX")
|
||||
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
||||
find_library(GLESV2 GLESv2)
|
||||
find_library(EGL EGL)
|
||||
set(LIBS_PUBLIC m)
|
||||
set(LIBS_PRIVATE ${GLESV2} ${EGL} atomic pthread dl)
|
||||
elseif (UNIX)
|
||||
find_library(pthread NAMES pthread)
|
||||
find_package(OpenGL QUIET)
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ int main(void)
|
|||
.tapbackPos = 0.01f
|
||||
};
|
||||
|
||||
size_t wavCursor = 0;
|
||||
int wavCursor = 0;
|
||||
const short *wavPCM16 = wav.data;
|
||||
|
||||
short chunkSamples[AUDIO_STREAM_RING_BUFFER_SIZE] = { 0 };
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
|
@ -84,14 +84,13 @@ int main(void)
|
|||
for (int y = playerCellY - 1; y <= playerCellY + 1; y++)
|
||||
{
|
||||
// Avoid map accessing out of bounds
|
||||
if ((y < 0) || (y >= cubicmap.height)) continue;
|
||||
|
||||
if ((y >= 0) && (y < cubicmap.height))
|
||||
{
|
||||
for (int x = playerCellX - 1; x <= playerCellX + 1; x++)
|
||||
{
|
||||
// Avoid map accessing out of bounds
|
||||
if ((x < 0) || (x >= cubicmap.width)) continue;
|
||||
|
||||
if ((mapPixels[y*cubicmap.width + x].r == 255) && // Collision: white pixel, only check R channel
|
||||
// NOTE: Collision: Only checking R channel for white pixel
|
||||
if (((x >= 0) && (x < cubicmap.width)) &&
|
||||
(mapPixels[y*cubicmap.width + x].r == 255) &&
|
||||
(CheckCollisionCircleRec(playerPos, playerRadius,
|
||||
(Rectangle){ mapPosition.x - 0.5f + x*1.0f, mapPosition.z - 0.5f + y*1.0f, 1.0f, 1.0f })))
|
||||
{
|
||||
|
|
@ -100,6 +99,7 @@ int main(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_DESKTOP_SDL)
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
#define GLAD_GLES2_IMPLEMENTATION
|
||||
#include "glad_gles2.h" // Required for: OpenGL functionality
|
||||
#define glGenVertexArrays glGenVertexArraysOES
|
||||
#define glBindVertexArray glBindVertexArrayOES
|
||||
|
|
|
|||
|
|
@ -1161,7 +1161,8 @@ int InitPlatform(void)
|
|||
platform.fd = open("/dev/dri/by-path/platform-gpu-card", O_RDWR); // VideoCore VI (Raspberry Pi 4)
|
||||
if (platform.fd != -1) TRACELOG(LOG_INFO, "DISPLAY: platform-gpu-card opened successfully");
|
||||
|
||||
if ((platform.fd == -1) || (drmModeGetResources(platform.fd) == NULL))
|
||||
drmModeRes *res = NULL;
|
||||
if ((platform.fd == -1) || ((res = drmModeGetResources(platform.fd)) == NULL))
|
||||
{
|
||||
if (platform.fd != -1) close(platform.fd);
|
||||
TRACELOG(LOG_WARNING, "DISPLAY: Failed to open platform-gpu-card, trying card1");
|
||||
|
|
@ -1169,7 +1170,7 @@ int InitPlatform(void)
|
|||
if (platform.fd != -1) TRACELOG(LOG_INFO, "DISPLAY: card1 opened successfully");
|
||||
}
|
||||
|
||||
if ((platform.fd == -1) || (drmModeGetResources(platform.fd) == NULL))
|
||||
if ((platform.fd == -1) || ((res = drmModeGetResources(platform.fd)) == NULL))
|
||||
{
|
||||
if (platform.fd != -1) close(platform.fd);
|
||||
TRACELOG(LOG_WARNING, "DISPLAY: Failed to open graphic card1, trying card0");
|
||||
|
|
@ -1177,7 +1178,7 @@ int InitPlatform(void)
|
|||
if (platform.fd != -1) TRACELOG(LOG_INFO, "DISPLAY: card0 opened successfully");
|
||||
}
|
||||
|
||||
if ((platform.fd == -1) || (drmModeGetResources(platform.fd) == NULL))
|
||||
if ((platform.fd == -1) || ((res = drmModeGetResources(platform.fd)) == NULL))
|
||||
{
|
||||
if (platform.fd != -1) close(platform.fd);
|
||||
TRACELOG(LOG_WARNING, "DISPLAY: Failed to open graphic card0, trying card2");
|
||||
|
|
@ -1192,7 +1193,6 @@ int InitPlatform(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
drmModeRes *res = drmModeGetResources(platform.fd);
|
||||
if (!res)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "DISPLAY: Failed get DRM resources");
|
||||
|
|
|
|||
|
|
@ -2738,6 +2738,10 @@ const char *GetApplicationDirectory(void)
|
|||
appDir[0] = '.';
|
||||
appDir[1] = '/';
|
||||
}
|
||||
|
||||
#elif defined(__wasm__)
|
||||
|
||||
appDir[0] = '/';
|
||||
#endif
|
||||
|
||||
return appDir;
|
||||
|
|
|
|||
37
src/rtext.c
37
src/rtext.c
|
|
@ -1044,15 +1044,26 @@ bool ExportFontAsCode(Font font, const char *fileName)
|
|||
#define TEXT_BYTES_PER_LINE 20
|
||||
#endif
|
||||
|
||||
#define MAX_FONT_DATA_SIZE 1024*1024 // 1 MB
|
||||
|
||||
// Get file name from path
|
||||
char fileNamePascal[256] = { 0 };
|
||||
strncpy(fileNamePascal, TextToPascal(GetFileNameWithoutExt(fileName)), 256 - 1);
|
||||
|
||||
// NOTE: Text data buffer size is estimated considering image data size in bytes
|
||||
// and requiring 6 char bytes for every byte: "0x00, "
|
||||
char *txtData = (char *)RL_CALLOC(MAX_FONT_DATA_SIZE, sizeof(char));
|
||||
// Get font atlas image and size, required to estimate code file size
|
||||
// NOTE: This mechanism is highly coupled to raylib
|
||||
Image image = LoadImageFromTexture(font.texture);
|
||||
if (image.format != PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) TRACELOG(LOG_WARNING, "Font export as code: Font image format is not GRAY+ALPHA!");
|
||||
int imageDataSize = GetPixelDataSize(image.width, image.height, image.format);
|
||||
|
||||
// Image data is usually GRAYSCALE + ALPHA and can be reduced to GRAYSCALE
|
||||
//ImageFormat(&image, PIXELFORMAT_UNCOMPRESSED_GRAYSCALE);
|
||||
|
||||
// Estimate text code size
|
||||
// - Image data is stored as "0x%02x", so it requires at least 4 char per byte, let's use 6
|
||||
// - font.recs[] data is stored as "{ %1.0f, %1.0f, %1.0f , %1.0f }", let's reserve 64 per rec
|
||||
// - font.glyphs[] data is stored as "{ %i, %i, %i, %i, { 0 }},\n", let's reserve 64 per glyph
|
||||
// - Comments and additional code, let's reserve 32KB
|
||||
int txtDataSize = imageDataSize*6 + font.glyphCount*64 + font.glyphCount*64 + 32768;
|
||||
char *txtData = (char *)RL_CALLOC(txtDataSize, sizeof(char));
|
||||
|
||||
int byteCount = 0;
|
||||
byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n");
|
||||
|
|
@ -1074,15 +1085,6 @@ bool ExportFontAsCode(Font font, const char *fileName)
|
|||
byteCount += sprintf(txtData + byteCount, "// //\n");
|
||||
byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n");
|
||||
|
||||
// Support font export and initialization
|
||||
// NOTE: This mechanism is highly coupled to raylib
|
||||
Image image = LoadImageFromTexture(font.texture);
|
||||
if (image.format != PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) TRACELOG(LOG_WARNING, "Font export as code: Font image format is not GRAY+ALPHA!");
|
||||
int imageDataSize = GetPixelDataSize(image.width, image.height, image.format);
|
||||
|
||||
// Image data is usually GRAYSCALE + ALPHA and can be reduced to GRAYSCALE
|
||||
//ImageFormat(&image, PIXELFORMAT_UNCOMPRESSED_GRAYSCALE);
|
||||
|
||||
#define SUPPORT_COMPRESSED_FONT_ATLAS
|
||||
#if defined(SUPPORT_COMPRESSED_FONT_ATLAS)
|
||||
// WARNING: Data is compressed using raylib CompressData() DEFLATE,
|
||||
|
|
@ -1120,8 +1122,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
|
|||
byteCount += sprintf(txtData + byteCount, "};\n\n");
|
||||
|
||||
// Save font glyphs data
|
||||
// NOTE: Glyphs image data not saved (grayscale pixels),
|
||||
// it could be generated from image and recs
|
||||
// NOTE: Glyphs image data not saved (grayscale pixels), it could be generated from image and recs
|
||||
byteCount += sprintf(txtData + byteCount, "// Font glyphs info data\n");
|
||||
byteCount += sprintf(txtData + byteCount, "// NOTE: No glyphs.image data provided\n");
|
||||
byteCount += sprintf(txtData + byteCount, "static GlyphInfo fontGlyphs_%s[%i] = {\n", fileNamePascal, font.glyphCount);
|
||||
|
|
@ -1152,8 +1153,8 @@ bool ExportFontAsCode(Font font, const char *fileName)
|
|||
#if defined(SUPPORT_COMPRESSED_FONT_ATLAS)
|
||||
byteCount += sprintf(txtData + byteCount, " UnloadImage(imFont); // Uncompressed data can be unloaded from memory\n\n");
|
||||
#endif
|
||||
// We have two possible mechanisms to assign font.recs and font.glyphs data,
|
||||
// that data is already available as global arrays, we two options to assign that data:
|
||||
// There are two possible mechanisms to assign font.recs and font.glyphs data,
|
||||
// that data is already available as global arrays, two options to assign that data:
|
||||
// - 1. Data copy. This option consumes more memory and Font MUST be unloaded by user, requiring additional code
|
||||
// - 2. Data assignment. This option consumes less memory and Font MUST NOT be unloaded by user because data is on protected DATA segment
|
||||
//#define SUPPORT_FONT_DATA_COPY
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user