Skip to content

Commit a68818e

Browse files
committed
Update to version 1.0.6
Check CHANGELOG for the list of changes in this release!
1 parent 0a71a92 commit a68818e

File tree

17 files changed

+654
-177
lines changed

17 files changed

+654
-177
lines changed

CHANGELOG

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
changelog
22
---------
33

4-
Current Release: raylib 1.0.4 (January 2014)
4+
Current Release: raylib 1.0.6 (March 2014)
55

66
NOTE: Only versions marked as 'Release' are available on release folder, updates are only available as source.
77
NOTE: Current Release includes all previous updates.
88

9+
-----------------------------------------------
10+
Release: raylib 1.0.6 (16 March 2014)
11+
-----------------------------------------------
12+
[core] Removed unused lighting-system code
13+
[core] Removed SetPerspective() function, calculated directly
14+
[core] Unload and reload default font on fullscreen toggle
15+
[core] Corrected bug gamepad buttons checking if no gamepad available
16+
[texture] DrawTextureV() - Added, to draw using Vector2 for position
17+
[texture] LoadTexture() - Redesigned, now uses LoadImage() + CreateTexture()
18+
[text] FormatText() - Corrected memory leak bug
19+
[models] Added Matrix struct and related functions
20+
[models] DrawBillboard() - Reviewed, now it works!
21+
[models] DrawBillboardRec() - Reviewed, now it works!
22+
[tests] Added folder with multiple tests for new functions
23+
924
-----------------------------------------------
1025
Update: raylib 1.0.5 (28 January 2014)
1126
-----------------------------------------------
1227
[audio] LoadSound() - Corrected a bug, WAV file was not closed!
1328
[core] GetMouseWheelMove() - Added, check mouse wheel Y movement
29+
[texture] CreateTexture2D() renamed to CreateTexture()
1430
[models] LoadHeightmap() - Added, Heightmap can be loaded as a Model
1531
[tool] rREM updated, now supports (partially) drag and drop of files
1632

release/win32-mingw/include/raylib.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*********************************************************************************************
22
*
3-
* raylib 1.0.4 (www.raylib.com)
3+
* raylib 1.0.6 (www.raylib.com)
44
*
55
* A simple and easy-to-use library to learn videogames programming
66
*
@@ -65,6 +65,7 @@
6565
#define KEY_SPACE 32
6666
#define KEY_ESCAPE 256
6767
#define KEY_ENTER 257
68+
#define KEY_BACKSPACE 259
6869
#define KEY_RIGHT 262
6970
#define KEY_LEFT 263
7071
#define KEY_DOWN 264
@@ -278,6 +279,7 @@ bool IsMouseButtonUp(int button); // Detect if a mouse but
278279
int GetMouseX(); // Returns mouse position X
279280
int GetMouseY(); // Returns mouse position Y
280281
Vector2 GetMousePosition(); // Returns mouse position XY
282+
int GetMouseWheelMove(); // Returns mouse wheel movement Y
281283

282284
bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
283285
Vector2 GetGamepadMovement(int gamepad); // Return axis movement vector for a gamepad
@@ -323,11 +325,12 @@ Image LoadImage(const char *fileName);
323325
Image LoadImageFromRES(const char *rresName, int resId); // Load an image from rRES file (raylib Resource)
324326
Texture2D LoadTexture(const char *fileName); // Load an image as texture into GPU memory
325327
Texture2D LoadTextureFromRES(const char *rresName, int resId); // Load an image as texture from rRES file (raylib Resource)
326-
Texture2D CreateTexture2D(Image image); // Create a Texture2D from Image data
328+
Texture2D CreateTexture(Image image); // Create a Texture2D from Image data
327329
void UnloadImage(Image image); // Unload image from CPU memory (RAM)
328330
void UnloadTexture(Texture2D texture); // Unload texture from GPU memory
329331

330332
void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D
333+
void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2
331334
void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters
332335
void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle
333336
void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, // Draw a part of a texture defined by a rectangle with 'pro' parameters
@@ -370,17 +373,13 @@ void DrawGizmo(Vector3 position, bool orbits);
370373
//------------------------------------------------------------------------------------
371374
Model LoadModel(const char *fileName); // Load a 3d model (.OBJ)
372375
//Model LoadModelFromRES(const char *rresName, int resId); // TODO: Load a 3d model from rRES file (raylib Resource)
376+
Model LoadHeightmap(Image heightmap, float maxHeight); // Load a heightmap image as a 3d model
373377
void UnloadModel(Model model); // Unload 3d model from memory
374378
void DrawModel(Model model, Vector3 position, float scale, Color color); // Draw a model
375379
void DrawModelEx(Model model, Texture2D texture, Vector3 position, float scale, Color tint); // Draw a textured model
376380
void DrawModelWires(Model model, Vector3 position, float scale, Color color); // Draw a model wires
377-
378-
// NOTE: The following functions work but are incomplete or require some revision
379-
// DrawHeightmap is extremely inefficient and can impact performance up to 60%
380-
void DrawBillboard(Camera camera, Texture2D texture, Vector3 basePos, float size, Color tint); // REVIEW: Draw a billboard (raylib 1.x)
381-
void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 basePos, float size, Color tint); // REVIEW: Draw a billboard (raylib 1.x)
382-
void DrawHeightmap(Image heightmap, Vector3 centerPos, Vector3 scale, Color color); // REVIEW: Draw heightmap using image map (raylib 1.x)
383-
void DrawHeightmapEx(Image heightmap, Texture2D texture, Vector3 centerPos, Vector3 scale, Color tint); // REVIEW: Draw textured heightmap (raylib 1.x)
381+
void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
382+
void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
384383

385384
//------------------------------------------------------------------------------------
386385
// Audio Loading and Playing Functions (Module: audio)
3.98 KB
Binary file not shown.

src/core.c

Lines changed: 14 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <stdio.h> // Standard input / output lib
3434
#include <stdlib.h> // Declares malloc() and free() for memory management, rand()
3535
#include <time.h> // Useful to initialize random seed
36-
#include <math.h> // Math related functions, tan() on SetPerspective
36+
#include <math.h> // Math related functions, tan() used to set perspective
3737
#include "vector3.h" // Basic Vector3 functions
3838
#include "utils.h" // WritePNG() function
3939

@@ -96,7 +96,6 @@ static void ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
9696
static void CursorEnterCallback(GLFWwindow* window, int enter); // GLFW3 Cursor Enter Callback, cursor enters client area
9797
static void WindowSizeCallback(GLFWwindow* window, int width, int height); // GLFW3 WindowSize Callback, runs when window is resized
9898
static void CameraLookAt(Vector3 position, Vector3 target, Vector3 up); // Setup camera view (updates MODELVIEW matrix)
99-
static void SetPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); // Setup view projection (updates PROJECTION matrix)
10099
static void TakeScreenshot(); // Takes a bitmap (BMP) screenshot and saves it in the same folder as executable
101100

102101
//----------------------------------------------------------------------------------
@@ -147,14 +146,7 @@ void InitWindowEx(int width, int height, const char* title, bool resizable, cons
147146

148147
LoadDefaultFont();
149148

150-
if (cursorImage != NULL)
151-
{
152-
// Load image as texture
153-
cursor = LoadTexture(cursorImage);
154-
155-
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
156-
customCursor = true;
157-
}
149+
if (cursorImage != NULL) SetCustomCursor(cursorImage);
158150

159151
srand(time(NULL)); // Initialize random seed
160152
}
@@ -199,6 +191,8 @@ void ToggleFullscreen()
199191
{
200192
fullscreen = !fullscreen; // Toggle fullscreen flag
201193

194+
UnloadDefaultFont();
195+
202196
glfwDestroyWindow(window); // Destroy the current window (we will recreate it!)
203197

204198
// TODO: WARNING! All loaded resources are lost, we loose Context!
@@ -217,6 +211,8 @@ void ToggleFullscreen()
217211
glfwSetKeyCallback(window, KeyCallback);
218212

219213
InitGraphicsDevice();
214+
215+
LoadDefaultFont();
220216
}
221217
}
222218

@@ -275,15 +271,18 @@ void EndDrawing()
275271
// Initializes 3D mode for drawing (Camera setup)
276272
void Begin3dMode(Camera camera)
277273
{
278-
//glEnable(GL_LIGHTING); // TODO: Setup proper lighting system (raylib 1.x)
279-
280274
glMatrixMode(GL_PROJECTION); // Switch to projection matrix
281275

282276
glPushMatrix(); // Save previous matrix, which contains the settings for the 2d ortho projection
283277
glLoadIdentity(); // Reset current matrix (PROJECTION)
284278

285-
SetPerspective(45.0f, (GLfloat)windowWidth/(GLfloat)windowHeight, 0.1f, 100.0f); // Setup perspective projection
279+
// Setup perspective projection
280+
float aspect = (GLfloat)windowWidth/(GLfloat)windowHeight;
281+
double top = 0.1f*tan(45.0f*PI / 360.0);
282+
double right = top*aspect;
286283

284+
glFrustum(-right, right, -top, top, 0.1f, 100.0f);
285+
287286
glMatrixMode(GL_MODELVIEW); // Switch back to modelview matrix
288287
glLoadIdentity(); // Reset current matrix (MODELVIEW)
289288

@@ -300,8 +299,6 @@ void End3dMode()
300299
glLoadIdentity(); // Reset current matrix (MODELVIEW)
301300

302301
glTranslatef(0.375, 0.375, 0); // HACK to ensure pixel-perfect drawing on OpenGL (after exiting 3D mode)
303-
304-
//glDisable(GL_LIGHTING); // TODO: Setup proper lighting system (raylib 1.x)
305302
}
306303

307304
// Set target FPS for the game
@@ -570,7 +567,7 @@ bool IsGamepadButtonDown(int gamepad, int button)
570567

571568
buttons = glfwGetJoystickButtons(gamepad, &buttonsCount);
572569

573-
if (buttons[button] == GLFW_PRESS)
570+
if ((buttons != NULL) && (buttons[button] == GLFW_PRESS))
574571
{
575572
return true;
576573
}
@@ -601,7 +598,7 @@ bool IsGamepadButtonUp(int gamepad, int button)
601598

602599
buttons = glfwGetJoystickButtons(gamepad, &buttonsCount);
603600

604-
if (buttons[button] == GLFW_RELEASE)
601+
if ((buttons != NULL) && (buttons[button] == GLFW_RELEASE))
605602
{
606603
return true;
607604
}
@@ -685,19 +682,6 @@ static void InitGraphicsDevice()
685682
glMatrixMode(GL_MODELVIEW); // Switch back to MODELVIEW matrix
686683
glLoadIdentity(); // Reset current matrix (MODELVIEW)
687684

688-
// TODO: Create an efficient Lighting System with proper functions (raylib 1.x)
689-
/*
690-
glEnable(GL_COLOR_MATERIAL); // Enable materials, causes some glMaterial atributes to track the current color (glColor)...
691-
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); // Material types and where to apply them
692-
// NOTE: ONLY works with lighting; defines how light interacts with material
693-
694-
glLightfv(GL_LIGHT1, GL_AMBIENT, lightAmbient); // Define ambient light color property
695-
glLightfv(GL_LIGHT1, GL_DIFFUSE, lightDiffuse); // Define diffuse light color property
696-
glLightfv(GL_LIGHT1, GL_POSITION, lightPosition); // Define light position
697-
698-
glEnable(GL_LIGHTING);
699-
glEnable(GL_LIGHT1); // Enable light one (8 lights available at the same time)
700-
*/
701685
// TODO: Review all shapes/models are drawn CCW and enable backface culling
702686

703687
//glEnable(GL_CULL_FACE); // Enable backface culling (Disabled by default)
@@ -746,19 +730,6 @@ static void CameraLookAt(Vector3 position, Vector3 target, Vector3 up)
746730
glTranslatef(-position.x, -position.y, -position.z); // Translate eye to position
747731
}
748732

749-
// Setup view projection (updates PROJECTION matrix)
750-
static void SetPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
751-
{
752-
double xmin, xmax, ymin, ymax;
753-
754-
ymax = zNear * tan(fovy * PI / 360.0);
755-
ymin = -ymax;
756-
xmin = ymin * aspect;
757-
xmax = ymax * aspect;
758-
759-
glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
760-
}
761-
762733
// Takes a bitmap (BMP) screenshot and saves it in the same folder as executable
763734
static void TakeScreenshot()
764735
{

0 commit comments

Comments
 (0)