Merge branch 'master' of https://github.com/raysan5/raylib into raysan5-master

# Conflicts:
#	src/raylib.h
This commit is contained in:
Jak Barnes 2019-03-10 23:56:30 +00:00
commit 983d31c9d0
9 changed files with 1128 additions and 1194 deletions

View File

@ -273,6 +273,7 @@ static GLFWwindow *window; // Native window (graphic device
#endif
static bool windowReady = false; // Check if window has been initialized successfully
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 unsigned int displayWidth, displayHeight;// Display width and height (monitor, device-screen, LCD, ...)
@ -742,6 +743,16 @@ bool IsWindowMinimized(void)
#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
bool IsWindowHidden(void)
{
@ -990,6 +1001,8 @@ const char *GetClipboardText(void)
{
#if defined(PLATFORM_DESKTOP)
return glfwGetClipboardString(window);
#else
return NULL;
#endif
}
@ -3135,6 +3148,8 @@ static void PollInputEvents(void)
gamepadAxisCount = axisCount;
}
}
windowResized = false;
#if defined(SUPPORT_EVENTS_WAITING)
glfwWaitEvents();
@ -3412,6 +3427,8 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
currentHeight = height;
// NOTE: Postprocessing texture is not scaled to new size
windowResized = true;
}
// GLFW3 WindowIconify Callback, runs when window is minimized/restored
@ -4319,7 +4336,7 @@ static void *EventThread(void *arg)
// Button parsing
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;
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;
mal_uint32 subBufferSizeInFrames = audioBuffer->bufferSizeInFrames/2;
mal_uint32 subBufferSizeInFrames = (audioBuffer->bufferSizeInFrames > 1)? audioBuffer->bufferSizeInFrames/2 : audioBuffer->bufferSizeInFrames;
mal_uint32 currentSubBufferIndex = audioBuffer->frameCursorPos/subBufferSizeInFrames;
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 shaderId; // Shader 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 modelview; // Modelview matrix for this draw
} 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;
// 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)
@ -1802,7 +1804,7 @@ void rlLoadExtensions(void *loader)
#if defined(GRAPHICS_API_OPENGL_21)
if (GLAD_GL_VERSION_2_1) TraceLog(LOG_INFO, "OpenGL 2.1 profile supported");
#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");
#endif
#endif
@ -2725,18 +2727,18 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform)
// Unload mesh data from CPU and GPU
void rlUnloadMesh(Mesh *mesh)
{
if (mesh->vertices != NULL) free(mesh->vertices);
if (mesh->texcoords != NULL) free(mesh->texcoords);
if (mesh->normals != NULL) free(mesh->normals);
if (mesh->colors != NULL) free(mesh->colors);
if (mesh->tangents != NULL) free(mesh->tangents);
if (mesh->texcoords2 != NULL) free(mesh->texcoords2);
if (mesh->indices != NULL) free(mesh->indices);
free(mesh->vertices);
free(mesh->texcoords);
free(mesh->normals);
free(mesh->colors);
free(mesh->tangents);
free(mesh->texcoords2);
free(mesh->indices);
if (mesh->baseVertices != NULL) free(mesh->baseVertices);
if (mesh->baseNormals != NULL) free(mesh->baseNormals);
if (mesh->weightBias != NULL) free(mesh->weightBias);
if (mesh->weightId != NULL) free(mesh->weightId);
free(mesh->baseVertices);
free(mesh->baseNormals);
free(mesh->weightBias);
free(mesh->weightId);
rlDeleteBuffers(mesh->vboId[0]); // vertex
rlDeleteBuffers(mesh->vboId[1]); // texcoords
@ -4093,7 +4095,7 @@ static void UpdateBuffersDefault(void)
// Another option: map the buffer object into client's memory
// Probably this code could be moved somewhere else...
// vertexData[currentBuffer].vertices = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
// if(vertexData[currentBuffer].vertices)
// if (vertexData[currentBuffer].vertices)
// {
// Update vertex data
// }
@ -4132,9 +4134,13 @@ static void DrawBuffersDefault(void)
glUniformMatrix4fv(currentShader.locs[LOC_MATRIX_MVP], 1, false, MatrixToFloat(matMVP));
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)
// 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: Additional map textures not considered for default buffers drawing
// NOTE: Right now additional map textures not considered for default buffers drawing
int vertexOffset = 0;
@ -4164,6 +4170,10 @@ static void DrawBuffersDefault(void)
for (int i = 0; i < drawsCounter; i++)
{
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);
else

View File

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

View File

@ -1,6 +1,6 @@
/**********************************************************************************************
*
* sysnet - Provides cross-platform network defines, macros etc
* rnet - Provides cross-platform network defines, macros etc
*
* DEPENDENCIES:
* <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(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;
}

View File

@ -688,8 +688,7 @@ void UnloadFont(Font font)
{
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);
free(font.chars);
@ -1327,13 +1326,11 @@ int TextToInteger(const char *text)
return result;
}
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// Module specific Functions Definition
//----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_FNT)
// Load a BMFont file (AngelCode font file)
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);
if (image.data != NULL) free(image.data);
free(image.data);
}
else
{
@ -414,10 +414,7 @@ RenderTexture2D LoadRenderTexture(int width, int height)
// Unload image from CPU memory (RAM)
void UnloadImage(Image image)
{
if (image.data != NULL) free(image.data);
// NOTE: It becomes anoying every time a texture is loaded
//TraceLog(LOG_INFO, "Unloaded image data");
free(image.data);
}
// Unload texture from GPU memory (VRAM)