aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPalaui <sucdepressec@gmail.com>2014-12-09 13:10:05 +0100
committerPalaui <sucdepressec@gmail.com>2014-12-09 13:10:05 +0100
commit29d8b48503f3064cdc1f3a87c01b4264e716a220 (patch)
tree31096a173fa4fb61fd9d912169abbf65fcf269c6 /src
parent63ed471ed24ed1b328cc90f03a88130511725e88 (diff)
downloadraylib-29d8b48503f3064cdc1f3a87c01b4264e716a220.tar.gz
raylib-29d8b48503f3064cdc1f3a87c01b4264e716a220.zip
Corrected some bugs...
[core] Added SetMousePosition() [models] LoadHeightmap() - Corrected textures bug [raymath] Functions renaming [WEB] Prepare environment for emscripten!
Diffstat (limited to 'src')
-rw-r--r--src/core.c11
-rw-r--r--src/makefile31
-rw-r--r--src/models.c2
-rw-r--r--src/raylib.h1
-rw-r--r--src/raymath.h4
-rw-r--r--src/rlgl.c8
6 files changed, 44 insertions, 13 deletions
diff --git a/src/core.c b/src/core.c
index dec08eeb..62ab5cbb 100644
--- a/src/core.c
+++ b/src/core.c
@@ -165,7 +165,7 @@ static const char *windowTitle; // Window text title...
static char configFlags = 0;
static bool customCursor = false; // Tracks if custom cursor has been set
-static bool cursorOnScreen = true; // Tracks if cursor is inside client area
+static bool cursorOnScreen = false; // Tracks if cursor is inside client area
static Texture2D cursor; // Cursor texture
static Vector2 mousePosition;
@@ -727,6 +727,15 @@ Vector2 GetMousePosition(void)
return mousePosition;
}
+// Set mouse position XY
+void SetMousePosition(Vector2 position)
+{
+ mousePosition = position;
+#if defined(PLATFORM_DESKTOP)
+ glfwSetCursorPos(window, position.x, position.y);
+#endif
+}
+
// Returns mouse wheel movement Y
int GetMouseWheelMove(void)
{
diff --git a/src/makefile b/src/makefile
index bb37748a..76984bbe 100644
--- a/src/makefile
+++ b/src/makefile
@@ -24,7 +24,7 @@
#**************************************************************************************************
# define raylib platform (by default, compile for RPI)
-# Other possible platforms: PLATFORM_DESKTOP PLATFORM_DESKTOP_LINUX
+# Other possible platforms: PLATFORM_DESKTOP_WIN PLATFORM_DESKTOP_LINUX PLATFORM_DESKTOP_MAC PLATFORM_WEB
PLATFORM ?= PLATFORM_RPI
# define raylib graphics api depending on selected platform
@@ -40,16 +40,26 @@ endif
# NOTE: makefiles targets require tab indentation
# define compiler: gcc for C program, define as g++ for C++
-CC = gcc
+ifeq ($(PLATFORM),PLATFORM_WEB)
+ # define emscripten compiler
+ CC = emcc
+else
+ # define default gcc compiler
+ CC = gcc
+endif
# define compiler flags:
# -O2 defines optimization level
# -Wall turns on most, but not all, compiler warnings
# -std=c99 use standard C from 1999 revision
+ifeq ($(PLATFORM),PLATFORM_WEB)
+ CFLAGS = -O3 -s USE_GLFW=3 -s LEGACY_GL_EMULATION=1
+else
ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline
else
- CFLAGS = -O2 -Wall -std=c99 -fgnu89-inline
+ CFLAGS = -O2 -Wall -std=c99
+endif
endif
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
@@ -69,11 +79,16 @@ default: raylib
# compile raylib library
raylib: $(OBJS)
+ifeq ($(PLATFORM),PLATFORM_WEB)
+ emcc $(OBJS) -o raylib.bc
+else
ar rcs libraylib.a $(OBJS)
+endif
# compile core module
+# emcc core.c -o core.bc -DPLATFORM_DESKTOP
core.o: core.c
- $(CC) -c core.c $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
+ $(CC) -c core.c $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(GRAPHICS)
# compile rlgl module
rlgl.o: rlgl.c
@@ -85,19 +100,19 @@ raymath.o: raymath.c
# compile shapes module
shapes.o: shapes.c
- $(CC) -c shapes.c $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
+ $(CC) -c shapes.c $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(GRAPHICS)
# compile textures module
textures.o: textures.c
- $(CC) -c textures.c $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
+ $(CC) -c textures.c $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(GRAPHICS)
# compile text module
text.o: text.c
- $(CC) -c text.c $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
+ $(CC) -c text.c $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(GRAPHICS)
# compile models module
models.o: models.c
- $(CC) -c models.c $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
+ $(CC) -c models.c $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(GRAPHICS)
# compile audio module
audio.o: audio.c
diff --git a/src/models.c b/src/models.c
index 2d2af038..f59a7b43 100644
--- a/src/models.c
+++ b/src/models.c
@@ -743,7 +743,7 @@ Model LoadHeightmap(Image heightmap, float maxHeight)
vData.texcoords[tcCounter + 7] = vData.texcoords[tcCounter + 5];
vData.texcoords[tcCounter + 8] = vData.texcoords[tcCounter + 2];
- vData.texcoords[tcCounter + 9] = vData.texcoords[tcCounter + 1];
+ vData.texcoords[tcCounter + 9] = vData.texcoords[tcCounter + 3];
vData.texcoords[tcCounter + 10] = (float)(x+1) / (mapX-1);
vData.texcoords[tcCounter + 11] = (float)(z+1) / (mapZ-1);
diff --git a/src/raylib.h b/src/raylib.h
index 9809d823..e7ef3217 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -340,6 +340,7 @@ bool IsMouseButtonUp(int button); // Detect if a mouse but
int GetMouseX(void); // Returns mouse position X
int GetMouseY(void); // Returns mouse position Y
Vector2 GetMousePosition(void); // Returns mouse position XY
+void SetMousePosition(Vector2 position); // Set mouse position XY
int GetMouseWheelMove(void); // Returns mouse wheel movement Y
bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
diff --git a/src/raymath.h b/src/raymath.h
index c396a347..334df4f3 100644
--- a/src/raymath.h
+++ b/src/raymath.h
@@ -108,8 +108,8 @@ Matrix MatrixAdd(Matrix left, Matrix right); // Add two matrices
Matrix MatrixSubstract(Matrix left, Matrix right); // Substract two matrices (left - right)
Matrix MatrixTranslate(float x, float y, float z); // Returns translation matrix
Matrix MatrixRotate(float angleX, float angleY, float angleZ); // Returns rotation matrix
-Matrix MatrixRotateAroundAxis(Vector3 axis, float angle); // Returns rotation matrix for an angle around an specified axis
-Matrix MatrixRotateAroundAxis2(Vector3 axis, float angle); // Returns rotation matrix for an angle around an specified axis (test another implemntation)
+Matrix MatrixFromAxisAngle(Vector3 axis, float angle); // Returns rotation matrix for an angle around an specified axis
+Matrix MatrixFromAxisAngle2(Vector3 axis, float angle); // Returns rotation matrix for an angle around an specified axis (test another implemntation)
Matrix MatrixFromQuaternion(Quaternion q); // Returns rotation matrix for a given quaternion
Matrix MatrixRotateX(float angle); // Returns x-rotation matrix (angle in radians)
Matrix MatrixRotateY(float angle); // Returns y-rotation matrix (angle in radians)
diff --git a/src/rlgl.c b/src/rlgl.c
index 5e51b2e2..ad6883e0 100644
--- a/src/rlgl.c
+++ b/src/rlgl.c
@@ -301,6 +301,10 @@ void rlRotatef(float angleDeg, float x, float y, float z)
if (x == 1) rot = MatrixRotateX(angleDeg*DEG2RAD);
else if (y == 1) rot = MatrixRotateY(angleDeg*DEG2RAD);
else if (z == 1) rot = MatrixRotateZ(angleDeg*DEG2RAD);
+
+ //Vector3 vec = (Vector3){ 0, 0, 1 };
+ //VectorNormalize(&vec);
+ //rot = MatrixFromAxisAngle(vec, angleDeg*DEG2RAD); // Working
MatrixTranspose(&rot);
@@ -1305,7 +1309,8 @@ unsigned int rlglLoadTexture(unsigned char *data, int width, int height, bool ge
#if defined(GRAPHICS_API_OPENGL_33)
// NOTE: We define internal (GPU) format as GL_RGBA8 (probably BGRA8 in practice, driver takes care)
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); // OpenGL
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); // WebGL
#elif defined(GRAPHICS_API_OPENGL_ES2)
// NOTE: On embedded systems, we let the driver choose the best internal format
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
@@ -1562,6 +1567,7 @@ static GLuint LoadDefaultShaders(void)
char fShaderStr[] = " #version 110 \n" // NOTE: Equivalent to version 100 on ES2
#elif defined(GRAPHICS_API_OPENGL_ES2)
char fShaderStr[] = " #version 100 \n" // NOTE: Must be defined this way! 110 doesn't work!
+ "precision mediump float; \n" // WebGL, required for PLATFORM_WEB
#endif
"uniform sampler2D texture0; \n"
"varying vec2 fragTexCoord; \n"