Quellcode durchsuchen

Merge branch 'raysan5:master' into master

pull/4796/head
Jon Daniel vor 1 Woche
committed von GitHub
Ursprung
Commit
e46afa295e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden GPG-Schlüssel-ID: B5690EEEBB952194
6 geänderte Dateien mit 24 neuen und 23 gelöschten Zeilen
  1. +3
    -1
      examples/core/core_2d_camera.c
  2. +7
    -7
      examples/core/core_2d_camera_mouse_zoom.c
  3. +8
    -4
      src/platforms/rcore_desktop_glfw.c
  4. +2
    -1
      src/rcore.c
  5. +1
    -7
      src/rlgl.h
  6. +3
    -3
      src/rshapes.c

+ 3
- 1
examples/core/core_2d_camera.c Datei anzeigen

@ -14,6 +14,7 @@
********************************************************************************************/
#include "raylib.h"
#include <math.h>
#define MAX_BUILDINGS 100
@ -81,7 +82,8 @@ int main(void)
else if (camera.rotation < -40) camera.rotation = -40;
// Camera zoom controls
camera.zoom += ((float)GetMouseWheelMove()*0.05f);
// Uses log scaling to provide consistent zoom speed
camera.zoom = expf(logf(camera.zoom) + ((float)GetMouseWheelMove()*0.1f));
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
else if (camera.zoom < 0.1f) camera.zoom = 0.1f;

+ 7
- 7
examples/core/core_2d_camera_mouse_zoom.c Datei anzeigen

@ -73,9 +73,9 @@ int main ()
camera.target = mouseWorldPos;
// Zoom increment
kt">float scaleFactor = 1.0f + (0.25f*fabsf(wheel));
">if (wheel < 0) scaleFactor = 1.0f/scaleFactor;
camera.zoom = Clamp(camera.zoomo">*scaleFactor, 0.125f, 64.0f);
o">// Uses log scaling to provide consistent zoom speed
t">float scale = 0.2f*wheel;
camera.zoom = Clamp(expf(logf(camera.zoomp">)+scale), 0.125f, 64.0f);
}
}
else
@ -96,10 +96,10 @@ int main ()
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
{
// Zoom increment
// Uses log scaling to provide consistent zoom speed
float deltaX = GetMouseDelta().x;
float scaleFactor = 1.0f + (0.01f*fabsf(deltaX));
if (deltaX < 0) scaleFactor = 1.0f/scaleFactor;
camera.zoom = Clamp(camera.zoom*scaleFactor, 0.125f, 64.0f);
float scale = 0.005f*deltaX;
camera.zoom = Clamp(expf(logf(camera.zoom)+scale), 0.125f, 64.0f);
}
}
//----------------------------------------------------------------------------------
@ -143,4 +143,4 @@ int main ()
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
}

+ 8
- 4
src/platforms/rcore_desktop_glfw.c Datei anzeigen

@ -1741,7 +1741,7 @@ static void ErrorCallback(int error, const char *description)
}
// GLFW3 WindowSize Callback, runs when window is resizedLastFrame
// NOTE: Window resizing not allowed by default
// NOTE: Window resizing not enabled by default, use SetConfigFlags()
static void WindowSizeCallback(GLFWwindow *window, int width, int height)
{
// Reset viewport and projection matrix for new size
@ -1756,15 +1756,19 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
if (IsWindowState(FLAG_WINDOW_HIGHDPI))
{
width = (int)(width / GetWindowScaleDPI().x);
height = (int)(height / GetWindowScaleDPI().y);
width = (int)(width/GetWindowScaleDPI().x);
height = (int)(height/GetWindowScaleDPI().y);
}
// Set render size
CORE.Window.render.width = width;
CORE.Window.render.height = height;
// Set current screen size
CORE.Window.screen.width = width;
CORE.Window.screen.height = height;
// NOTE: Postprocessing texture is not scaled to new size
// WARNING: If using a render texture, it is not scaled to new size
}
static void WindowPosCallback(GLFWwindow* window, int x, int y)
{

+ 2
- 1
src/rcore.c Datei anzeigen

@ -1119,7 +1119,7 @@ void BeginTextureMode(RenderTexture2D target)
//rlScalef(0.0f, -1.0f, 0.0f); // Flip Y-drawing (?)
// Setup current width/height for proper aspect ratio
// calculation when using BeginMode3D()
// calculation when using BeginTextureMode()
CORE.Window.currentFbo.width = target.texture.width;
CORE.Window.currentFbo.height = target.texture.height;
CORE.Window.usingFbo = true;
@ -2354,6 +2354,7 @@ bool ChangeDirectory(const char *dir)
bool result = CHDIR(dir);
if (result != 0) TRACELOG(LOG_WARNING, "SYSTEM: Failed to change to directory: %s", dir);
else TRACELOG(LOG_INFO, "SYSTEM: Working Directory: %s", dir);
return (result == 0);
}

+ 1
- 7
src/rlgl.h Datei anzeigen

@ -1459,9 +1459,6 @@ void rlBegin(int mode)
// NOTE: In all three cases, vertex are accumulated over default internal vertex buffer
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode != mode)
{
// Get current binded texture to preserve it between draw modes change (QUADS <--> TRIANGLES)
int currentTexture = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId;
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0)
{
// Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4,
@ -1484,16 +1481,13 @@ void rlBegin(int mode)
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode;
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0;
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = currentTexture; // Preserve active texture
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.defaultTextureId;
}
}
// Finish vertex providing
void rlEnd(void)
{
// Reset texture to default
rlSetTexture(RLGL.State.defaultTextureId);
// NOTE: Depth increment is dependant on rlOrtho(): z-near and z-far values,
// as well as depth buffer bit-depth (16bit or 24bit or 32bit)
// Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits)

+ 3
- 3
src/rshapes.c Datei anzeigen

@ -2239,7 +2239,7 @@ bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2
// NOTE: Based on http://jeffreythompson.org/collision-detection/poly-point.php
bool CheckCollisionPointPoly(Vector2 point, const Vector2 *points, int pointCount)
{
bool inside = false;
bool collision = false;
if (pointCount > 2)
{
@ -2248,12 +2248,12 @@ bool CheckCollisionPointPoly(Vector2 point, const Vector2 *points, int pointCoun
if ((points[i].y > point.y) != (points[j].y > point.y) &&
(point.x < (points[j].x - points[i].x)*(point.y - points[i].y)/(points[j].y - points[i].y) + points[i].x))
{
inside = !inside;
collision = !collision;
}
}
}
return inside;
return collision;
}
// Check collision between two rectangles

Laden…
Abbrechen
Speichern