Merge branch 'raysan5-master'

Updated to the latest changes on raysan5-master
Reverted some "trigger-format-finger" code in raylib.h
Minor API changes
This commit is contained in:
Jak Barnes 2019-03-10 23:57:16 +00:00
commit 22249b72cf
9 changed files with 1128 additions and 1194 deletions

View File

@ -273,6 +273,7 @@ static GLFWwindow *window; // Native window (graphic device
#endif #endif
static bool windowReady = false; // Check if window has been initialized successfully static bool windowReady = false; // Check if window has been initialized successfully
static bool windowMinimized = false; // Check if window has been minimized static bool windowMinimized = false; // Check if window has been minimized
static bool windowResized = false; // Check if window has been resized
static const char *windowTitle = NULL; // Window text title... static const char *windowTitle = NULL; // Window text title...
static unsigned int displayWidth, displayHeight;// Display width and height (monitor, device-screen, LCD, ...) static unsigned int displayWidth, displayHeight;// Display width and height (monitor, device-screen, LCD, ...)
@ -742,6 +743,16 @@ bool IsWindowMinimized(void)
#endif #endif
} }
// Check if window has been resized
bool IsWindowResized(void)
{
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP)
return windowResized;
#else
return false;
#endif
}
// Check if window is currently hidden // Check if window is currently hidden
bool IsWindowHidden(void) bool IsWindowHidden(void)
{ {
@ -990,6 +1001,8 @@ const char *GetClipboardText(void)
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
return glfwGetClipboardString(window); return glfwGetClipboardString(window);
#else
return NULL;
#endif #endif
} }
@ -3136,6 +3149,8 @@ static void PollInputEvents(void)
} }
} }
windowResized = false;
#if defined(SUPPORT_EVENTS_WAITING) #if defined(SUPPORT_EVENTS_WAITING)
glfwWaitEvents(); glfwWaitEvents();
#else #else
@ -3412,6 +3427,8 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
currentHeight = height; currentHeight = height;
// NOTE: Postprocessing texture is not scaled to new size // NOTE: Postprocessing texture is not scaled to new size
windowResized = true;
} }
// GLFW3 WindowIconify Callback, runs when window is minimized/restored // GLFW3 WindowIconify Callback, runs when window is minimized/restored
@ -4319,7 +4336,7 @@ static void *EventThread(void *arg)
// Button parsing // Button parsing
if (event.type == EV_KEY) if (event.type == EV_KEY)
{ {
if((event.code == BTN_TOUCH) || (event.code == BTN_LEFT)) if ((event.code == BTN_TOUCH) || (event.code == BTN_LEFT))
{ {
currentMouseStateEvdev[MOUSE_LEFT_BUTTON] = event.value; currentMouseStateEvdev[MOUSE_LEFT_BUTTON] = event.value;
if (event.value > 0) gestureEvent.touchAction = TOUCH_DOWN; if (event.value > 0) gestureEvent.touchAction = TOUCH_DOWN;

View File

@ -367,7 +367,7 @@ static mal_uint32 OnAudioBufferDSPRead(mal_dsp *pDSP, mal_uint32 frameCount, voi
{ {
AudioBuffer *audioBuffer = (AudioBuffer *)pUserData; AudioBuffer *audioBuffer = (AudioBuffer *)pUserData;
mal_uint32 subBufferSizeInFrames = audioBuffer->bufferSizeInFrames/2; mal_uint32 subBufferSizeInFrames = (audioBuffer->bufferSizeInFrames > 1)? audioBuffer->bufferSizeInFrames/2 : audioBuffer->bufferSizeInFrames;
mal_uint32 currentSubBufferIndex = audioBuffer->frameCursorPos/subBufferSizeInFrames; mal_uint32 currentSubBufferIndex = audioBuffer->frameCursorPos/subBufferSizeInFrames;
if (currentSubBufferIndex > 1) if (currentSubBufferIndex > 1)

File diff suppressed because it is too large Load Diff

View File

@ -728,6 +728,8 @@ typedef struct DrawCall {
//unsigned int vaoId; // Vertex Array id to be used on the draw //unsigned int vaoId; // Vertex Array id to be used on the draw
//unsigned int shaderId; // Shader id to be used on the draw //unsigned int shaderId; // Shader id to be used on the draw
unsigned int textureId; // Texture id to be used on the draw unsigned int textureId; // Texture id to be used on the draw
// TODO: Support additional texture units?
//Matrix projection; // Projection matrix for this draw //Matrix projection; // Projection matrix for this draw
//Matrix modelview; // Modelview matrix for this draw //Matrix modelview; // Modelview matrix for this draw
} DrawCall; } DrawCall;
@ -1622,7 +1624,7 @@ void rlglInit(int width, int height)
if (strcmp(extList[i], (const char *)"GL_EXT_texture_mirror_clamp") == 0) texMirrorClampSupported = true; if (strcmp(extList[i], (const char *)"GL_EXT_texture_mirror_clamp") == 0) texMirrorClampSupported = true;
// Debug marker support // Debug marker support
if(strcmp(extList[i], (const char *)"GL_EXT_debug_marker") == 0) debugMarkerSupported = true; if (strcmp(extList[i], (const char *)"GL_EXT_debug_marker") == 0) debugMarkerSupported = true;
} }
#if defined(_WIN32) && defined(_MSC_VER) #if defined(_WIN32) && defined(_MSC_VER)
@ -1802,7 +1804,7 @@ void rlLoadExtensions(void *loader)
#if defined(GRAPHICS_API_OPENGL_21) #if defined(GRAPHICS_API_OPENGL_21)
if (GLAD_GL_VERSION_2_1) TraceLog(LOG_INFO, "OpenGL 2.1 profile supported"); if (GLAD_GL_VERSION_2_1) TraceLog(LOG_INFO, "OpenGL 2.1 profile supported");
#elif defined(GRAPHICS_API_OPENGL_33) #elif defined(GRAPHICS_API_OPENGL_33)
if(GLAD_GL_VERSION_3_3) TraceLog(LOG_INFO, "OpenGL 3.3 Core profile supported"); if (GLAD_GL_VERSION_3_3) TraceLog(LOG_INFO, "OpenGL 3.3 Core profile supported");
else TraceLog(LOG_ERROR, "OpenGL 3.3 Core profile not supported"); else TraceLog(LOG_ERROR, "OpenGL 3.3 Core profile not supported");
#endif #endif
#endif #endif
@ -2725,18 +2727,18 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform)
// Unload mesh data from CPU and GPU // Unload mesh data from CPU and GPU
void rlUnloadMesh(Mesh *mesh) void rlUnloadMesh(Mesh *mesh)
{ {
if (mesh->vertices != NULL) free(mesh->vertices); free(mesh->vertices);
if (mesh->texcoords != NULL) free(mesh->texcoords); free(mesh->texcoords);
if (mesh->normals != NULL) free(mesh->normals); free(mesh->normals);
if (mesh->colors != NULL) free(mesh->colors); free(mesh->colors);
if (mesh->tangents != NULL) free(mesh->tangents); free(mesh->tangents);
if (mesh->texcoords2 != NULL) free(mesh->texcoords2); free(mesh->texcoords2);
if (mesh->indices != NULL) free(mesh->indices); free(mesh->indices);
if (mesh->baseVertices != NULL) free(mesh->baseVertices); free(mesh->baseVertices);
if (mesh->baseNormals != NULL) free(mesh->baseNormals); free(mesh->baseNormals);
if (mesh->weightBias != NULL) free(mesh->weightBias); free(mesh->weightBias);
if (mesh->weightId != NULL) free(mesh->weightId); free(mesh->weightId);
rlDeleteBuffers(mesh->vboId[0]); // vertex rlDeleteBuffers(mesh->vboId[0]); // vertex
rlDeleteBuffers(mesh->vboId[1]); // texcoords rlDeleteBuffers(mesh->vboId[1]); // texcoords
@ -4093,7 +4095,7 @@ static void UpdateBuffersDefault(void)
// Another option: map the buffer object into client's memory // Another option: map the buffer object into client's memory
// Probably this code could be moved somewhere else... // Probably this code could be moved somewhere else...
// vertexData[currentBuffer].vertices = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); // vertexData[currentBuffer].vertices = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
// if(vertexData[currentBuffer].vertices) // if (vertexData[currentBuffer].vertices)
// { // {
// Update vertex data // Update vertex data
// } // }
@ -4132,9 +4134,13 @@ static void DrawBuffersDefault(void)
glUniformMatrix4fv(currentShader.locs[LOC_MATRIX_MVP], 1, false, MatrixToFloat(matMVP)); glUniformMatrix4fv(currentShader.locs[LOC_MATRIX_MVP], 1, false, MatrixToFloat(matMVP));
glUniform4f(currentShader.locs[LOC_COLOR_DIFFUSE], 1.0f, 1.0f, 1.0f, 1.0f); glUniform4f(currentShader.locs[LOC_COLOR_DIFFUSE], 1.0f, 1.0f, 1.0f, 1.0f);
glUniform1i(currentShader.locs[LOC_MAP_DIFFUSE], 0); glUniform1i(currentShader.locs[LOC_MAP_DIFFUSE], 0); // Provided value refers to the texture unit (active)
// NOTE: Additional map textures not considered for default buffers drawing // TODO: Support additional texture units on custom shader
//if (currentShader->locs[LOC_MAP_SPECULAR] > 0) glUniform1i(currentShader.locs[LOC_MAP_SPECULAR], 1);
//if (currentShader->locs[LOC_MAP_NORMAL] > 0) glUniform1i(currentShader.locs[LOC_MAP_NORMAL], 2);
// NOTE: Right now additional map textures not considered for default buffers drawing
int vertexOffset = 0; int vertexOffset = 0;
@ -4165,6 +4171,10 @@ static void DrawBuffersDefault(void)
{ {
glBindTexture(GL_TEXTURE_2D, draws[i].textureId); glBindTexture(GL_TEXTURE_2D, draws[i].textureId);
// TODO: Find some way to bind additional textures --> Use global texture IDs? Register them on draw[i]?
//if (currentShader->locs[LOC_MAP_SPECULAR] > 0) { glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textureUnit1_id); }
//if (currentShader->locs[LOC_MAP_SPECULAR] > 0) { glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, textureUnit2_id); }
if ((draws[i].mode == RL_LINES) || (draws[i].mode == RL_TRIANGLES)) glDrawArrays(draws[i].mode, vertexOffset, draws[i].vertexCount); if ((draws[i].mode == RL_LINES) || (draws[i].mode == RL_TRIANGLES)) glDrawArrays(draws[i].mode, vertexOffset, draws[i].vertexCount);
else else
{ {

View File

@ -7,7 +7,7 @@
* *
* DEPENDENCIES: * DEPENDENCIES:
* raylib.h - TraceLog * raylib.h - TraceLog
* sysnet.h - platform-specific network includes * rnet.h - platform-specific network includes
* *
* CONTRIBUTORS: * CONTRIBUTORS:
* Jak Barnes (github: @syphonx) (Feb. 2019): * Jak Barnes (github: @syphonx) (Feb. 2019):
@ -44,7 +44,7 @@
# include <stdarg.h> # include <stdarg.h>
#else #else
# include "raylib.h" # include "raylib.h"
# include "sysnet.h" # include "rnet.h"
# if !defined(EXTERNAL_CONFIG_FLAGS) # if !defined(EXTERNAL_CONFIG_FLAGS)
# include "config.h" // Defines module configuration flags # include "config.h" // Defines module configuration flags
# endif # endif

View File

@ -1,6 +1,6 @@
/********************************************************************************************** /**********************************************************************************************
* *
* sysnet - Provides cross-platform network defines, macros etc * rnet - Provides cross-platform network defines, macros etc
* *
* DEPENDENCIES: * DEPENDENCIES:
* <limits.h> - Used for cross-platform type specifiers * <limits.h> - Used for cross-platform type specifiers

View File

@ -400,7 +400,7 @@ void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color)
{ {
if (lineThick > rec.width || lineThick > rec.height) if (lineThick > rec.width || lineThick > rec.height)
{ {
if(rec.width > rec.height) lineThick = (int)rec.height/2; if (rec.width > rec.height) lineThick = (int)rec.height/2;
else if (rec.width < rec.height) lineThick = (int)rec.width/2; else if (rec.width < rec.height) lineThick = (int)rec.width/2;
} }

View File

@ -688,8 +688,7 @@ void UnloadFont(Font font)
{ {
for (int i = 0; i < font.charsCount; i++) for (int i = 0; i < font.charsCount; i++)
{ {
if(font.chars[i].data != NULL) free(font.chars[i].data);
free(font.chars[i].data);
} }
UnloadTexture(font.texture); UnloadTexture(font.texture);
free(font.chars); free(font.chars);
@ -1327,13 +1326,11 @@ int TextToInteger(const char *text)
return result; return result;
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module specific Functions Definition // Module specific Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_FNT) #if defined(SUPPORT_FILEFORMAT_FNT)
// Load a BMFont file (AngelCode font file) // Load a BMFont file (AngelCode font file)
static Font LoadBMFont(const char *fileName) static Font LoadBMFont(const char *fileName)

View File

@ -353,7 +353,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
{ {
TraceLog(LOG_WARNING, "[%s] RAW image data can not be read, wrong requested format or size", fileName); TraceLog(LOG_WARNING, "[%s] RAW image data can not be read, wrong requested format or size", fileName);
if (image.data != NULL) free(image.data); free(image.data);
} }
else else
{ {
@ -414,10 +414,7 @@ RenderTexture2D LoadRenderTexture(int width, int height)
// Unload image from CPU memory (RAM) // Unload image from CPU memory (RAM)
void UnloadImage(Image image) void UnloadImage(Image image)
{ {
if (image.data != NULL) free(image.data); free(image.data);
// NOTE: It becomes anoying every time a texture is loaded
//TraceLog(LOG_INFO, "Unloaded image data");
} }
// Unload texture from GPU memory (VRAM) // Unload texture from GPU memory (VRAM)