Merge remote-tracking branch 'refs/remotes/raysan5/develop' into newaudio

This commit is contained in:
Joshua Reisenauer 2016-05-19 15:31:56 -07:00
commit 847944e240
44 changed files with 619 additions and 388 deletions

View file

@ -85,6 +85,8 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# add standard directories for GNU/Linux # add standard directories for GNU/Linux
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
INCLUDES = -I. -I../src -I/usr/local/include/raylib/ INCLUDES = -I. -I../src -I/usr/local/include/raylib/
else ifeq ($(PLATFORM_OS),OSX)
INCLUDES = -I. -I../src
else else
INCLUDES = -I. -I../../src -IC:/raylib/raylib/src INCLUDES = -I. -I../../src -IC:/raylib/raylib/src
# external libraries headers # external libraries headers
@ -103,6 +105,8 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# add standard directories for GNU/Linux # add standard directories for GNU/Linux
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
LFLAGS = -L. -L../../src LFLAGS = -L. -L../../src
else ifeq ($(PLATFORM_OS),OSX)
LFLAGS = -L. -L../src
else else
LFLAGS = -L. -L../../src -LC:/raylib/raylib/src LFLAGS = -L. -L../../src -LC:/raylib/raylib/src
# external libraries to link with # external libraries to link with
@ -129,7 +133,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libraries for OS X 10.9 desktop compiling # libraries for OS X 10.9 desktop compiling
# requires the following packages: # requires the following packages:
# libglfw3-dev libopenal-dev libegl1-mesa-dev # libglfw3-dev libopenal-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa LIBS = -lraylib -lglfw3 -framework OpenGL -framework OpenAl -framework Cocoa
else else
# libraries for Windows desktop compiling # libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed # NOTE: GLFW3 and OpenAL Soft libraries should be installed

View file

@ -33,5 +33,5 @@ void main()
else if (texelColor.r < 0.5) tc = sum*sum*0.009 + texelColor; else if (texelColor.r < 0.5) tc = sum*sum*0.009 + texelColor;
else tc = sum*sum*0.0075 + texelColor; else tc = sum*sum*0.0075 + texelColor;
finalColor = tc; gl_FragColor = tc;
} }

View file

@ -20,7 +20,7 @@ float angle = 0.8;
uniform vec2 center = vec2(200.0, 200.0); uniform vec2 center = vec2(200.0, 200.0);
void main (void) void main()
{ {
vec2 texSize = vec2(renderWidth, renderHeight); vec2 texSize = vec2(renderWidth, renderHeight);
vec2 tc = fragTexCoord*texSize; vec2 tc = fragTexCoord*texSize;

View file

@ -17,12 +17,12 @@ void main()
{ {
vec4 sum = vec4(0); vec4 sum = vec4(0);
vec4 tc = vec4(0); vec4 tc = vec4(0);
for (int i = -4; i < 4; i++) for (int i = -4; i < 4; i++)
{ {
for (int j = -3; j < 3; j++) for (int j = -3; j < 3; j++)
{ {
sum += texture2D(texture0, fragTexCoord + vec2(j, i)*0.004)*0.25; sum += texture(texture0, fragTexCoord + vec2(j, i)*0.004)*0.25;
} }
} }

View file

@ -29,6 +29,9 @@ uniform float matGlossiness = 50.0;
uniform vec3 lightPosition; uniform vec3 lightPosition;
uniform vec3 cameraPosition; uniform vec3 cameraPosition;
// Fragment shader output data
out vec4 fragColor;
// Calculate ambient lighting component // Calculate ambient lighting component
vec3 AmbientLighting() vec3 AmbientLighting()
{ {

View file

@ -21,7 +21,7 @@ float angle = 0.8;
uniform vec2 center = vec2(200.0, 200.0); uniform vec2 center = vec2(200.0, 200.0);
void main (void) void main()
{ {
vec2 texSize = vec2(renderWidth, renderHeight); vec2 texSize = vec2(renderWidth, renderHeight);
vec2 tc = fragTexCoord*texSize; vec2 tc = fragTexCoord*texSize;
@ -40,7 +40,7 @@ void main (void)
} }
tc += center; tc += center;
vec3 color = texture2D(texture0, tc/texSize).rgb; vec3 color = texture(texture0, tc/texSize).rgb;
finalColor = vec4(color, 1.0);; finalColor = vec4(color, 1.0);;
} }

View file

@ -1,20 +1,26 @@
#version 100 #version 100
// Input vertex attributes
attribute vec3 vertexPosition; attribute vec3 vertexPosition;
attribute vec2 vertexTexCoord; attribute vec2 vertexTexCoord;
attribute vec3 vertexNormal; attribute vec3 vertexNormal;
attribute vec4 vertexColor;
varying vec2 fragTexCoord; // Input uniform values
uniform mat4 mvpMatrix; uniform mat4 mvpMatrix;
// Output vertex attributes (to fragment shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
void main() void main()
{ {
vec3 normal = vertexNormal; // Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord; fragTexCoord = vertexTexCoord;
fragColor = vertexColor;
// Calculate final vertex position
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
} }

View file

@ -2,8 +2,11 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
@ -22,21 +25,13 @@ void main()
} }
} }
if (texture2D(texture0, fragTexCoord).r < 0.3) // Texel color fetching from texture sampler
{ vec4 texelColor = texture(texture0, fragTexCoord);
tc = sum*sum*0.012 + texture2D(texture0, fragTexCoord);
} // Calculate final fragment color
else if (texelColor.r < 0.3) tc = sum*sum*0.012 + texelColor;
{ else if (texelColor.r < 0.5) tc = sum*sum*0.009 + texelColor;
if (texture2D(texture0, fragTexCoord).r < 0.5) else tc = sum*sum*0.0075 + texelColor;
{
tc = sum*sum*0.009 + texture2D(texture0, fragTexCoord);
}
else
{
tc = sum*sum*0.0075 + texture2D(texture0, fragTexCoord);
}
}
gl_FragColor = tc; gl_FragColor = tc;
} }

View file

@ -2,7 +2,11 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
@ -16,6 +20,7 @@ float weight[3] = float[]( 0.2270270270, 0.3162162162, 0.0702702703 );
void main() void main()
{ {
// Texel color fetching from texture sampler
vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight[0]; vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight[0];
for (int i = 1; i < 3; i++) for (int i = 1; i < 3; i++)

View file

@ -2,12 +2,15 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
float hatchOffsetY = 5.0f; float hatchOffsetY = 5.0f;
float lumThreshold01 = 0.9f; float lumThreshold01 = 0.9f;

View file

@ -2,8 +2,11 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
@ -46,7 +49,7 @@ vec4 PostFX(sampler2D tex, vec2 uv)
return c; return c;
} }
void main(void) void main()
{ {
vec3 tc = PostFX(texture0, fragTexCoord).rgb; vec3 tc = PostFX(texture0, fragTexCoord).rgb;

View file

@ -2,8 +2,11 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;

View file

@ -2,12 +2,15 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
const float PI = 3.1415926535; const float PI = 3.1415926535;

View file

@ -2,8 +2,11 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
@ -11,10 +14,12 @@ uniform vec4 fragTintColor;
void main() void main()
{ {
vec4 base = texture2D(texture0, fragTexCoord)*fragTintColor; // Texel color fetching from texture sampler
vec4 texelColor = texture(texture0, fragTexCoord)*fragTintColor*fragColor;
// Convert to grayscale using NTSC conversion weights // Convert texel color to grayscale using NTSC conversion weights
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114)); float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114));
gl_FragColor = vec4(gray, gray, gray, fragTintColor.a); // Calculate final fragment color
gl_FragColor = vec4(gray, gray, gray, texelColor.a);
} }

View file

@ -2,8 +2,11 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;

View file

@ -2,8 +2,11 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;

View file

@ -2,8 +2,11 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;

View file

@ -2,8 +2,11 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
@ -14,7 +17,7 @@ float frequency = 720/3.0;
uniform float time; uniform float time;
void main (void) void main()
{ {
/* /*
// Scanlines method 1 // Scanlines method 1

View file

@ -2,28 +2,32 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
const float renderWidth = 1280; const float renderWidth = 800.0; // HARDCODED for example!
const float renderHeight = 720; const float renderHeight = 480.0; // Use uniforms instead...
float radius = 250.0; float radius = 250.0;
float angle = 0.8; float angle = 0.8;
uniform vec2 center = vec2(200, 200); uniform vec2 center = vec2(200.0, 200.0);
void main (void) void main()
{ {
vec2 texSize = vec2(renderWidth, renderHeight); vec2 texSize = vec2(renderWidth, renderHeight);
vec2 tc = fragTexCoord*texSize; vec2 tc = fragTexCoord*texSize;
tc -= center; tc -= center;
float dist = length(tc);
float dist = length(tc);
if (dist < radius) if (dist < radius)
{ {
float percent = (radius - dist)/radius; float percent = (radius - dist)/radius;
@ -33,7 +37,7 @@ void main (void)
tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c))); tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
} }
tc += center; tc += center;
vec3 color = texture2D(texture0, tc/texSize).rgb; vec3 color = texture2D(texture0, tc/texSize).rgb;

View file

@ -2,8 +2,11 @@
precision mediump float; precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
@ -11,6 +14,7 @@ uniform vec4 fragTintColor;
void main() void main()
{ {
// Texel color fetching from texture sampler
vec4 texelColor = texture2D(texture0, fragTexCoord); vec4 texelColor = texture2D(texture0, fragTexCoord);
// NOTE: Implement here your fragment shader code // NOTE: Implement here your fragment shader code

View file

@ -1,18 +1,26 @@
#version 330 #version 330
// Input vertex attributes
in vec3 vertexPosition; in vec3 vertexPosition;
in vec2 vertexTexCoord; in vec2 vertexTexCoord;
in vec3 vertexNormal; in vec3 vertexNormal;
in vec4 vertexColor;
out vec2 fragTexCoord; // Input uniform values
uniform mat4 mvpMatrix; uniform mat4 mvpMatrix;
// Output vertex attributes (to fragment shader)
out vec2 fragTexCoord;
out vec4 fragColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
void main() void main()
{ {
// Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord; fragTexCoord = vertexTexCoord;
fragColor = vertexColor;
// Calculate final vertex position
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
} }

View file

@ -1,12 +1,16 @@
#version 330 #version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 fragColor; // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
void main() void main()
@ -18,25 +22,17 @@ void main()
{ {
for (int j = -3; j < 3; j++) for (int j = -3; j < 3; j++)
{ {
sum += texture(texture0, fragTexCoord + vec2(j, i)*0.004) * 0.25; sum += texture(texture0, fragTexCoord + vec2(j, i)*0.004)*0.25;
} }
} }
if (texture(texture0, fragTexCoord).r < 0.3) // Texel color fetching from texture sampler
{ vec4 texelColor = texture(texture0, fragTexCoord);
tc = sum*sum*0.012 + texture(texture0, fragTexCoord);
}
else
{
if (texture(texture0, fragTexCoord).r < 0.5)
{
tc = sum*sum*0.009 + texture(texture0, fragTexCoord);
}
else
{
tc = sum*sum*0.0075 + texture(texture0, fragTexCoord);
}
}
fragColor = tc; // Calculate final fragment color
if (texelColor.r < 0.3) tc = sum*sum*0.012 + texelColor;
else if (texelColor.r < 0.5) tc = sum*sum*0.009 + texelColor;
else tc = sum*sum*0.0075 + texelColor;
finalColor = tc;
} }

View file

@ -1,12 +1,16 @@
#version 330 #version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 fragColor; // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
const float renderWidth = 1280.0; const float renderWidth = 1280.0;
@ -17,13 +21,14 @@ float weight[3] = float[](0.2270270270, 0.3162162162, 0.0702702703);
void main() void main()
{ {
vec3 tc = texture(texture0, fragTexCoord).rgb*weight[0]; // Texel color fetching from texture sampler
vec3 texelColor = texture(texture0, fragTexCoord).rgb*weight[0];
for (int i = 1; i < 3; i++) for (int i = 1; i < 3; i++)
{ {
tc += texture(texture0, fragTexCoord + vec2(offset[i])/renderWidth, 0.0).rgb*weight[i]; texelColor += texture(texture0, fragTexCoord + vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
tc += texture(texture0, fragTexCoord - vec2(offset[i])/renderWidth, 0.0).rgb*weight[i]; texelColor += texture(texture0, fragTexCoord - vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
} }
fragColor = vec4(tc, 1.0); finalColor = vec4(texelColor, 1.0);
} }

View file

@ -1,13 +1,17 @@
#version 330 #version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 fragColor; // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// NOTE: Add here your custom variables // Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables
float hatchOffsetY = 5.0; float hatchOffsetY = 5.0;
float lumThreshold01 = 0.9; float lumThreshold01 = 0.9;
@ -27,18 +31,18 @@ void main()
if (lum < lumThreshold02) if (lum < lumThreshold02)
{ {
if (mod(gl_FragCoord .x - gl_FragCoord .y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
} }
if (lum < lumThreshold03) if (lum < lumThreshold03)
{ {
if (mod(gl_FragCoord .x + gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); if (mod(gl_FragCoord.x + gl_FragCoord.y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
} }
if (lum < lumThreshold04) if (lum < lumThreshold04)
{ {
if (mod(gl_FragCoord .x - gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); if (mod(gl_FragCoord.x - gl_FragCoord.y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
} }
fragColor = vec4(tc, 1.0); finalColor = vec4(tc, 1.0);
} }

View file

@ -1,12 +1,16 @@
#version 330 #version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 fragColor; // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
const float renderWidth = 1280.0; const float renderWidth = 1280.0;
@ -46,9 +50,9 @@ vec4 PostFX(sampler2D tex, vec2 uv)
return c; return c;
} }
void main(void) void main()
{ {
vec3 tc = PostFX(texture0, fragTexCoord).rgb; vec3 tc = PostFX(texture0, fragTexCoord).rgb;
fragColor = vec4(tc, 1.0); finalColor = vec4(tc, 1.0);
} }

27
shaders/glsl330/depth.fs Normal file
View file

@ -0,0 +1,27 @@
#version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
in vec4 fragColor;
// Input uniform values
uniform sampler2D texture0; // Depth texture
uniform vec4 fragTintColor;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables
void main()
{
float zNear = 0.01; // camera z near
float zFar = 10.0; // camera z far
float z = texture(texture0, fragTexCoord).x;
// Linearize depth value
float depth = (2.0*zNear)/(zFar + zNear - z*(zFar - zNear));
// Calculate final fragment color
finalColor = vec4(depth, depth, depth, 1.0f);
}

View file

@ -1,20 +1,26 @@
#version 330 #version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 fragColor; // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
void main() void main()
{ {
vec4 base = texture(texture0, fragTexCoord)*fragTintColor; // Texel color fetching from texture sampler
vec4 texelColor = texture(texture0, fragTexCoord)*fragTintColor*fragColor;
// Convert to grayscale using NTSC conversion weights // Convert texel color to grayscale using NTSC conversion weights
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114)); float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114));
fragColor = vec4(gray, gray, gray, fragTintColor.a); // Calculate final fragment color
finalColor = vec4(gray, gray, gray, texelColor.a);
} }

View file

@ -1,76 +1,85 @@
#version 330 #version 330
// Vertex shader input data // Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec3 fragNormal; in vec3 fragNormal;
// Diffuse data // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// Light attributes // Output fragment color
uniform vec3 light_ambientColor = vec3(0.6, 0.3, 0); out vec4 finalColor;
uniform vec3 light_diffuseColor = vec3(1, 0.5, 0);
uniform vec3 light_specularColor = vec3(0, 1, 0);
uniform float light_intensity = 1;
uniform float light_specIntensity = 1;
// Material attributes // NOTE: Add here your custom variables
uniform vec3 mat_ambientColor = vec3(1, 1, 1);
uniform vec3 mat_specularColor = vec3(1, 1, 1);
uniform float mat_glossiness = 50;
// World attributes // Light uniform values
uniform vec3 lightPos; uniform vec3 lightAmbientColor = vec3(0.6, 0.3, 0.0);
uniform vec3 cameraPos; uniform vec3 lightDiffuseColor = vec3(1.0, 0.5, 0.0);
uniform vec3 lightSpecularColor = vec3(0.0, 1.0, 0.0);
uniform float lightIntensity = 1.0;
uniform float lightSpecIntensity = 1.0;
// Material uniform values
uniform vec3 matAmbientColor = vec3(1.0, 1.0, 1.0);
uniform vec3 matSpecularColor = vec3(1.0, 1.0, 1.0);
uniform float matGlossiness = 50.0;
// World uniform values
uniform vec3 lightPosition;
uniform vec3 cameraPosition;
// Fragment shader output data // Fragment shader output data
out vec4 fragColor; out vec4 fragColor;
// Calculate ambient lighting component
vec3 AmbientLighting() vec3 AmbientLighting()
{ {
return mat_ambientColor * light_ambientColor; return (matAmbientColor*lightAmbientColor);
} }
// Calculate diffuse lighting component
vec3 DiffuseLighting(in vec3 N, in vec3 L) vec3 DiffuseLighting(in vec3 N, in vec3 L)
{ {
// Lambertian reflection calculation // Lambertian reflection calculation
float diffuse = clamp(dot(N, L), 0, 1); float diffuse = clamp(dot(N, L), 0, 1);
return tintColor.xyz * light_diffuseColor * light_intensity * diffuse; return (fragTintColor.xyz*lightDiffuseColor*lightIntensity*diffuse);
} }
// Calculate specular lighting component
vec3 SpecularLighting(in vec3 N, in vec3 L, in vec3 V) vec3 SpecularLighting(in vec3 N, in vec3 L, in vec3 V)
{ {
float specular = 0; float specular = 0.0;
// Calculate specular reflection only if the surface is oriented to the light source // Calculate specular reflection only if the surface is oriented to the light source
if(dot(N, L) > 0) if (dot(N, L) > 0)
{ {
// Calculate half vector // Calculate half vector
vec3 H = normalize(L + V); vec3 H = normalize(L + V);
// Calculate specular intensity // Calculate specular intensity
specular = pow(dot(N, H), 3 + mat_glossiness); specular = pow(dot(N, H), 3 + matGlossiness);
} }
return mat_specularColor * light_specularColor * light_specIntensity * specular; return (matSpecularColor*lightSpecularColor*lightSpecIntensity*specular);
} }
void main() void main()
{ {
// Normalize input vectors // Normalize input vectors
vec3 L = normalize(lightPos); vec3 L = normalize(lightPosition);
vec3 V = normalize(cameraPos); vec3 V = normalize(cameraPosition);
vec3 N = normalize(fragNormal); vec3 N = normalize(fragNormal);
// Calculate lighting components
vec3 ambient = AmbientLighting(); vec3 ambient = AmbientLighting();
vec3 diffuse = DiffuseLighting(N, L); vec3 diffuse = DiffuseLighting(N, L);
vec3 specular = SpecularLighting(N, L, V); vec3 specular = SpecularLighting(N, L, V);
// Get base color from texture // Texel color fetching from texture sampler
vec4 textureColor = texture(texture0, fragTexCoord); vec4 texelColor = texture(texture0, fragTexCoord);
vec3 finalColor = textureColor.rgb;
// Calculate final fragment color
fragColor = vec4(finalColor * (ambient + diffuse + specular), textureColor.a); finalColor = vec4(texelColor.rgb*(ambient + diffuse + specular), texelColor.a);
} }

View file

@ -1,23 +1,25 @@
#version 330 #version 330
// Vertex input data // Input vertex attributes
in vec3 vertexPosition; in vec3 vertexPosition;
in vec2 vertexTexCoord; in vec2 vertexTexCoord;
in vec3 vertexNormal; in vec3 vertexNormal;
// Projection and model data // Input uniform values
uniform mat4 mvpMatrix; uniform mat4 mvpMatrix;
uniform mat4 modelMatrix;
// Attributes to fragment shader // Output vertex attributes (to fragment shader)
out vec2 fragTexCoord; out vec2 fragTexCoord;
out vec3 fragNormal; out vec3 fragNormal;
// NOTE: Add here your custom variables
uniform mat4 modelMatrix;
void main() void main()
{ {
// Send texture coord to fragment shader // Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord; fragTexCoord = vertexTexCoord;
// Calculate view vector normal from model // Calculate view vector normal from model
mat3 normalMatrix = transpose(inverse(mat3(modelMatrix))); mat3 normalMatrix = transpose(inverse(mat3(modelMatrix)));
fragNormal = normalize(normalMatrix*vertexNormal); fragNormal = normalize(normalMatrix*vertexNormal);

View file

@ -1,13 +1,17 @@
#version 330 #version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 fragColor; // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// NOTE: Add here your custom variables // Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables
const float renderWidth = 1280.0; const float renderWidth = 1280.0;
const float renderHeight = 720.0; const float renderHeight = 720.0;
@ -24,5 +28,5 @@ void main()
vec3 tc = texture(texture0, coord).rgb; vec3 tc = texture(texture0, coord).rgb;
fragColor = vec4(tc, 1.0); finalColor = vec4(tc, 1.0);
} }

View file

@ -1,12 +1,16 @@
#version 330 #version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 fragColor; // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
float gamma = 0.6; float gamma = 0.6;
@ -14,13 +18,14 @@ float numColors = 8.0;
void main() void main()
{ {
vec3 color = texture(texture0, fragTexCoord.xy).rgb; // Texel color fetching from texture sampler
vec3 texelColor = texture(texture0, fragTexCoord.xy).rgb;
color = pow(color, vec3(gamma, gamma, gamma)); texelColor = pow(texelColor, vec3(gamma, gamma, gamma));
color = color*numColors; texelColor = texelColor*numColors;
color = floor(color); texelColor = floor(texelColor);
color = color/numColors; texelColor = texelColor/numColors;
color = pow(color, vec3(1.0/gamma)); texelColor = pow(texelColor, vec3(1.0/gamma));
fragColor = vec4(color, 1.0); finalColor = vec4(texelColor, 1.0);
} }

View file

@ -1,27 +1,32 @@
#version 330 #version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 fragColor; // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
void main() void main()
{ {
vec3 color = texture(texture0, fragTexCoord).rgb; // Texel color fetching from texture sampler
vec3 texelColor = texture(texture0, fragTexCoord).rgb;
vec3 colors[3]; vec3 colors[3];
colors[0] = vec3(0.0, 0.0, 1.0); colors[0] = vec3(0.0, 0.0, 1.0);
colors[1] = vec3(1.0, 1.0, 0.0); colors[1] = vec3(1.0, 1.0, 0.0);
colors[2] = vec3(1.0, 0.0, 0.0); colors[2] = vec3(1.0, 0.0, 0.0);
float lum = (color.r + color.g + color.b)/3.0; float lum = (texelColor.r + texelColor.g + texelColor.b)/3.0;
int ix = (lum < 0.5)? 0:1; int ix = (lum < 0.5)? 0:1;
vec3 tc = mix(colors[ix], colors[ix + 1], (lum - float(ix)*0.5)/0.5); vec3 tc = mix(colors[ix], colors[ix + 1], (lum - float(ix)*0.5)/0.5);
fragColor = vec4(tc, 1.0); finalColor = vec4(tc, 1.0);
} }

View file

@ -1,12 +1,16 @@
#version 330 #version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 fragColor; // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
float offset = 0.0; float offset = 0.0;
@ -14,7 +18,7 @@ float frequency = 720.0/3.0;
uniform float time; uniform float time;
void main (void) void main()
{ {
/* /*
// Scanlines method 1 // Scanlines method 1
@ -35,7 +39,8 @@ void main (void)
float globalPos = (fragTexCoord.y + offset) * frequency; float globalPos = (fragTexCoord.y + offset) * frequency;
float wavePos = cos((fract(globalPos) - 0.5)*3.14); float wavePos = cos((fract(globalPos) - 0.5)*3.14);
vec4 color = texture(texture0, fragTexCoord); // Texel color fetching from texture sampler
vec4 texelColor = texture(texture0, fragTexCoord);
fragColor = mix(vec4(0.0, 0.3, 0.0, 0.0), color, wavePos); finalColor = mix(vec4(0.0, 0.3, 0.0, 0.0), texelColor, wavePos);
} }

View file

@ -1,27 +1,32 @@
#version 330 #version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 fragColor; // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
const float renderWidth = 1280.0; const float renderWidth = 800.0; // HARDCODED for example!
const float renderHeight = 720.0; const float renderHeight = 480.0; // Use uniforms instead...
float radius = 250.0; float radius = 250.0;
float angle = 0.8; float angle = 0.8;
uniform vec2 center = vec2(200.0, 200.0); uniform vec2 center = vec2(200.0, 200.0);
void main (void) void main()
{ {
vec2 texSize = vec2(renderWidth, renderHeight); vec2 texSize = vec2(renderWidth, renderHeight);
vec2 tc = fragTexCoord*texSize; vec2 tc = fragTexCoord*texSize;
tc -= center; tc -= center;
float dist = length(tc); float dist = length(tc);
if (dist < radius) if (dist < radius)
@ -37,5 +42,5 @@ void main (void)
tc += center; tc += center;
vec3 color = texture(texture0, tc/texSize).rgb; vec3 color = texture(texture0, tc/texSize).rgb;
fragColor = vec4(color, 1.0);; finalColor = vec4(color, 1.0);;
} }

View file

@ -1,19 +1,24 @@
#version 330 #version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 fragColor; // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 fragTintColor; uniform vec4 fragTintColor;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables // NOTE: Add here your custom variables
void main() void main()
{ {
// Texel color fetching from texture sampler
vec4 texelColor = texture(texture0, fragTexCoord); vec4 texelColor = texture(texture0, fragTexCoord);
// NOTE: Implement here your fragment shader code // NOTE: Implement here your fragment shader code
fragColor = texelColor*fragTintColor; finalColor = texelColor*fragTintColor;
} }

View file

@ -1447,7 +1447,11 @@ static void InitDisplay(int width, int height)
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // Profiles Hint: Only 3.3 and above! glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // Profiles Hint: Only 3.3 and above!
// Other values: GLFW_OPENGL_ANY_PROFILE, GLFW_OPENGL_COMPAT_PROFILE // Other values: GLFW_OPENGL_ANY_PROFILE, GLFW_OPENGL_COMPAT_PROFILE
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // OSX Requires
#else
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE); // Fordward Compatibility Hint: Only 3.3 and above! glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE); // Fordward Compatibility Hint: Only 3.3 and above!
#endif
//glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); //glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
} }

View file

@ -691,31 +691,14 @@ Model LoadCubicmap(Image cubicmap)
return model; return model;
} }
// Unload 3d model from memory // Unload 3d model from memory (mesh and material)
void UnloadModel(Model model) void UnloadModel(Model model)
{ {
// Unload mesh data rlglUnloadMesh(&model.mesh);
if (model.mesh.vertices != NULL) free(model.mesh.vertices);
if (model.mesh.texcoords != NULL) free(model.mesh.texcoords);
if (model.mesh.normals != NULL) free(model.mesh.normals);
if (model.mesh.colors != NULL) free(model.mesh.colors);
if (model.mesh.tangents != NULL) free(model.mesh.tangents);
if (model.mesh.texcoords2 != NULL) free(model.mesh.texcoords2);
if (model.mesh.indices != NULL) free(model.mesh.indices);
TraceLog(INFO, "Unloaded model data from RAM (CPU)");
rlDeleteBuffers(model.mesh.vboId[0]); // vertex
rlDeleteBuffers(model.mesh.vboId[1]); // texcoords
rlDeleteBuffers(model.mesh.vboId[2]); // normals
rlDeleteBuffers(model.mesh.vboId[3]); // colors
rlDeleteBuffers(model.mesh.vboId[4]); // tangents
rlDeleteBuffers(model.mesh.vboId[5]); // texcoords2
rlDeleteBuffers(model.mesh.vboId[6]); // indices
rlDeleteVertexArrays(model.mesh.vaoId);
UnloadMaterial(model.material); UnloadMaterial(model.material);
TraceLog(INFO, "Unloaded model data from RAM and VRAM");
} }
// Load material data (from file) // Load material data (from file)
@ -1247,40 +1230,27 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota
model.transform = MatrixMultiply(MatrixMultiply(matScale, matRotation), matTranslation); model.transform = MatrixMultiply(MatrixMultiply(matScale, matRotation), matTranslation);
model.material.colDiffuse = tint; model.material.colDiffuse = tint;
rlglDrawEx(model.mesh, model.material, model.transform, false); rlglDrawMesh(model.mesh, model.material, model.transform);
} }
// Draw a model wires (with texture if set) // Draw a model wires (with texture if set)
void DrawModelWires(Model model, Vector3 position, float scale, Color tint) void DrawModelWires(Model model, Vector3 position, float scale, Color tint)
{ {
Vector3 vScale = { scale, scale, scale }; rlEnableWireMode();
Vector3 rotationAxis = { 0.0f, 0.0f, 0.0f };
// Calculate transformation matrix from function parameters
// Get transform matrix (rotation -> scale -> translation)
Matrix matRotation = MatrixRotate(rotationAxis, 0.0f);
Matrix matScale = MatrixScale(vScale.x, vScale.y, vScale.z);
Matrix matTranslation = MatrixTranslate(position.x, position.y, position.z);
model.transform = MatrixMultiply(MatrixMultiply(matScale, matRotation), matTranslation); DrawModel(model, position, scale, tint);
model.material.colDiffuse = tint;
rlglDrawEx(model.mesh, model.material, model.transform, true); rlDisableWireMode();
} }
// Draw a model wires (with texture if set) with extended parameters // Draw a model wires (with texture if set) with extended parameters
void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint) void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint)
{ {
// Calculate transformation matrix from function parameters rlEnableWireMode();
// Get transform matrix (rotation -> scale -> translation)
Matrix matRotation = MatrixRotate(rotationAxis, rotationAngle*DEG2RAD);
Matrix matScale = MatrixScale(scale.x, scale.y, scale.z);
Matrix matTranslation = MatrixTranslate(position.x, position.y, position.z);
model.transform = MatrixMultiply(MatrixMultiply(matScale, matRotation), matTranslation); DrawModelEx(model, position, rotationAxis, rotationAngle, scale, tint);
model.material.colDiffuse = tint;
rlglDrawEx(model.mesh, model.material, model.transform, true); rlDisableWireMode();
} }
// Draw a billboard // Draw a billboard

View file

@ -740,6 +740,24 @@ void rlDisableDepthTest(void)
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
} }
// Enable wire mode
void rlEnableWireMode(void)
{
#if defined (GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
// NOTE: glPolygonMode() not available on OpenGL ES
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
#endif
}
// Disable wire mode
void rlDisableWireMode(void)
{
#if defined (GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
// NOTE: glPolygonMode() not available on OpenGL ES
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
#endif
}
// Unload texture from GPU memory // Unload texture from GPU memory
void rlDeleteTextures(unsigned int id) void rlDeleteTextures(unsigned int id)
{ {
@ -1033,178 +1051,18 @@ void rlglClose(void)
void rlglDraw(void) void rlglDraw(void)
{ {
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
/*
for (int i = 0; i < modelsCount; i++)
{
rlglDrawMesh(models[i]->mesh, models[i]->material, models[i]->transform);
}
*/
// NOTE: Default buffers always drawn at the end
UpdateDefaultBuffers(); UpdateDefaultBuffers();
DrawDefaultBuffers(); DrawDefaultBuffers();
#endif #endif
} }
// Draw a 3d mesh with material and transform
void rlglDrawEx(Mesh mesh, Material material, Matrix transform, bool wires)
{
#if defined (GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
// NOTE: glPolygonMode() not available on OpenGL ES
if (wires) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
#endif
#if defined(GRAPHICS_API_OPENGL_11)
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, material.texDiffuse.id);
// NOTE: On OpenGL 1.1 we use Vertex Arrays to draw model
glEnableClientState(GL_VERTEX_ARRAY); // Enable vertex array
glEnableClientState(GL_TEXTURE_COORD_ARRAY); // Enable texture coords array
if (mesh.normals != NULL) glEnableClientState(GL_NORMAL_ARRAY); // Enable normals array
if (mesh.colors != NULL) glEnableClientState(GL_COLOR_ARRAY); // Enable colors array
glVertexPointer(3, GL_FLOAT, 0, mesh.vertices); // Pointer to vertex coords array
glTexCoordPointer(2, GL_FLOAT, 0, mesh.texcoords); // Pointer to texture coords array
if (mesh.normals != NULL) glNormalPointer(GL_FLOAT, 0, mesh.normals); // Pointer to normals array
if (mesh.colors != NULL) glColorPointer(4, GL_UNSIGNED_BYTE, 0, mesh.colors); // Pointer to colors array
rlPushMatrix();
rlMultMatrixf(MatrixToFloat(transform));
rlColor4ub(material.colDiffuse.r, material.colDiffuse.g, material.colDiffuse.b, material.colDiffuse.a);
if (mesh.indices != NULL) glDrawElements(GL_TRIANGLES, mesh.triangleCount*3, GL_UNSIGNED_SHORT, mesh.indices);
else glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount);
rlPopMatrix();
glDisableClientState(GL_VERTEX_ARRAY); // Disable vertex array
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // Disable texture coords array
if (mesh.normals != NULL) glDisableClientState(GL_NORMAL_ARRAY); // Disable normals array
if (mesh.colors != NULL) glDisableClientState(GL_NORMAL_ARRAY); // Disable colors array
glDisable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
#endif
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
glUseProgram(material.shader.id);
// At this point the modelview matrix just contains the view matrix (camera)
// That's because Begin3dMode() sets it an no model-drawing function modifies it, all use rlPushMatrix() and rlPopMatrix()
Matrix matView = modelview; // View matrix (camera)
Matrix matProjection = projection; // Projection matrix (perspective)
// Calculate model-view matrix combining matModel and matView
Matrix matModelView = MatrixMultiply(transform, matView); // Transform to camera-space coordinates
// Calculate model-view-projection matrix (MVP)
Matrix matMVP = MatrixMultiply(matModelView, matProjection); // Transform to screen-space coordinates
// Send combined model-view-projection matrix to shader
glUniformMatrix4fv(material.shader.mvpLoc, 1, false, MatrixToFloat(matMVP));
// Apply color tinting (material.colDiffuse)
// NOTE: Just update one uniform on fragment shader
float vColor[4] = { (float)material.colDiffuse.r/255, (float)material.colDiffuse.g/255, (float)material.colDiffuse.b/255, (float)material.colDiffuse.a/255 };
glUniform4fv(material.shader.tintColorLoc, 1, vColor);
// Set shader textures (diffuse, normal, specular)
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, material.texDiffuse.id);
glUniform1i(material.shader.mapDiffuseLoc, 0); // Texture fits in active texture unit 0
if ((material.texNormal.id != 0) && (material.shader.mapNormalLoc != -1))
{
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, material.texNormal.id);
glUniform1i(material.shader.mapNormalLoc, 1); // Texture fits in active texture unit 1
}
if ((material.texSpecular.id != 0) && (material.shader.mapSpecularLoc != -1))
{
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, material.texSpecular.id);
glUniform1i(material.shader.mapSpecularLoc, 2); // Texture fits in active texture unit 2
}
if (vaoSupported)
{
glBindVertexArray(mesh.vaoId);
}
else
{
// Bind mesh VBO data: vertex position (shader-location = 0)
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[0]);
glVertexAttribPointer(material.shader.vertexLoc, 3, GL_FLOAT, 0, 0, 0);
glEnableVertexAttribArray(material.shader.vertexLoc);
// Bind mesh VBO data: vertex texcoords (shader-location = 1)
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[1]);
glVertexAttribPointer(material.shader.texcoordLoc, 2, GL_FLOAT, 0, 0, 0);
glEnableVertexAttribArray(material.shader.texcoordLoc);
// Bind mesh VBO data: vertex normals (shader-location = 2, if available)
if (material.shader.normalLoc != -1)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[2]);
glVertexAttribPointer(material.shader.normalLoc, 3, GL_FLOAT, 0, 0, 0);
glEnableVertexAttribArray(material.shader.normalLoc);
}
// Bind mesh VBO data: vertex colors (shader-location = 3, if available) , tangents, texcoords2 (if available)
if (material.shader.colorLoc != -1)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[3]);
glVertexAttribPointer(material.shader.colorLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
glEnableVertexAttribArray(material.shader.colorLoc);
}
// Bind mesh VBO data: vertex tangents (shader-location = 4, if available)
if (material.shader.tangentLoc != -1)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[4]);
glVertexAttribPointer(material.shader.tangentLoc, 3, GL_FLOAT, 0, 0, 0);
glEnableVertexAttribArray(material.shader.tangentLoc);
}
// Bind mesh VBO data: vertex texcoords2 (shader-location = 5, if available)
if (material.shader.texcoord2Loc != -1)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[5]);
glVertexAttribPointer(material.shader.texcoord2Loc, 2, GL_FLOAT, 0, 0, 0);
glEnableVertexAttribArray(material.shader.texcoord2Loc);
}
if (mesh.indices != NULL) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quads.vboId[3]);
}
// Draw call!
if (mesh.indices != NULL) glDrawElements(GL_TRIANGLES, mesh.triangleCount*3, GL_UNSIGNED_SHORT, 0); // Indexed vertices draw
else glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount);
if (material.texNormal.id != 0)
{
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
}
if (material.texSpecular.id != 0)
{
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, 0);
}
glActiveTexture(GL_TEXTURE0); // Set shader active texture to default 0
glBindTexture(GL_TEXTURE_2D, 0); // Unbind textures
if (vaoSupported) glBindVertexArray(0); // Unbind VAO
else
{
glBindBuffer(GL_ARRAY_BUFFER, 0); // Unbind VBOs
if (mesh.indices != NULL) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
glUseProgram(0); // Unbind shader program
#endif
#if defined (GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
// NOTE: glPolygonMode() not available on OpenGL ES
if (wires) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
#endif
}
// Initialize Graphics Device (OpenGL stuff) // Initialize Graphics Device (OpenGL stuff)
// NOTE: Stores global variables screenWidth and screenHeight // NOTE: Stores global variables screenWidth and screenHeight
void rlglInitGraphics(int offsetX, int offsetY, int width, int height) void rlglInitGraphics(int offsetX, int offsetY, int width, int height)
@ -1776,6 +1634,245 @@ void rlglLoadMesh(Mesh *mesh)
#endif #endif
} }
// Update vertex data on GPU (upload new data to one buffer)
void rlglUpdateMesh(Mesh mesh, int buffer, int numVertex)
{
// Activate mesh VAO
if (vaoSupported) glBindVertexArray(mesh.vaoId);
switch (buffer)
{
case 0: // Update vertices (vertex position)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[0]);
if (numVertex >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*numVertex, mesh.vertices, GL_DYNAMIC_DRAW);
else glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(float)*3*numVertex, mesh.vertices);
} break;
case 1: // Update texcoords (vertex texture coordinates)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[1]);
if (numVertex >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*numVertex, mesh.texcoords, GL_DYNAMIC_DRAW);
else glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(float)*2*numVertex, mesh.texcoords);
} break;
case 2: // Update normals (vertex normals)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[0]);
if (numVertex >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*numVertex, mesh.normals, GL_DYNAMIC_DRAW);
else glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(float)*3*numVertex, mesh.normals);
} break;
case 3: // Update colors (vertex colors)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[2]);
if (numVertex >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, sizeof(float)*4*numVertex, mesh.colors, GL_DYNAMIC_DRAW);
else glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(unsigned char)*4*numVertex, mesh.colors);
} break;
case 4: // Update tangents (vertex tangents)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[0]);
if (numVertex >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*numVertex, mesh.tangents, GL_DYNAMIC_DRAW);
else glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(float)*3*numVertex, mesh.tangents);
} break;
case 5: // Update texcoords2 (vertex second texture coordinates)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[1]);
if (numVertex >= mesh.vertexCount) glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*numVertex, mesh.texcoords2, GL_DYNAMIC_DRAW);
else glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(float)*2*numVertex, mesh.texcoords2);
} break;
default: break;
}
// Unbind the current VAO
if (vaoSupported) glBindVertexArray(0);
// Another option would be using buffer mapping...
//mesh.vertices = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
// Now we can modify vertices
//glUnmapBuffer(GL_ARRAY_BUFFER);
}
// Draw a 3d mesh with material and transform
void rlglDrawMesh(Mesh mesh, Material material, Matrix transform)
{
#if defined(GRAPHICS_API_OPENGL_11)
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, material.texDiffuse.id);
// NOTE: On OpenGL 1.1 we use Vertex Arrays to draw model
glEnableClientState(GL_VERTEX_ARRAY); // Enable vertex array
glEnableClientState(GL_TEXTURE_COORD_ARRAY); // Enable texture coords array
if (mesh.normals != NULL) glEnableClientState(GL_NORMAL_ARRAY); // Enable normals array
if (mesh.colors != NULL) glEnableClientState(GL_COLOR_ARRAY); // Enable colors array
glVertexPointer(3, GL_FLOAT, 0, mesh.vertices); // Pointer to vertex coords array
glTexCoordPointer(2, GL_FLOAT, 0, mesh.texcoords); // Pointer to texture coords array
if (mesh.normals != NULL) glNormalPointer(GL_FLOAT, 0, mesh.normals); // Pointer to normals array
if (mesh.colors != NULL) glColorPointer(4, GL_UNSIGNED_BYTE, 0, mesh.colors); // Pointer to colors array
rlPushMatrix();
rlMultMatrixf(MatrixToFloat(transform));
rlColor4ub(material.colDiffuse.r, material.colDiffuse.g, material.colDiffuse.b, material.colDiffuse.a);
if (mesh.indices != NULL) glDrawElements(GL_TRIANGLES, mesh.triangleCount*3, GL_UNSIGNED_SHORT, mesh.indices);
else glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount);
rlPopMatrix();
glDisableClientState(GL_VERTEX_ARRAY); // Disable vertex array
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // Disable texture coords array
if (mesh.normals != NULL) glDisableClientState(GL_NORMAL_ARRAY); // Disable normals array
if (mesh.colors != NULL) glDisableClientState(GL_NORMAL_ARRAY); // Disable colors array
glDisable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
#endif
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
glUseProgram(material.shader.id);
// At this point the modelview matrix just contains the view matrix (camera)
// That's because Begin3dMode() sets it an no model-drawing function modifies it, all use rlPushMatrix() and rlPopMatrix()
Matrix matView = modelview; // View matrix (camera)
Matrix matProjection = projection; // Projection matrix (perspective)
// Calculate model-view matrix combining matModel and matView
Matrix matModelView = MatrixMultiply(transform, matView); // Transform to camera-space coordinates
// Calculate model-view-projection matrix (MVP)
Matrix matMVP = MatrixMultiply(matModelView, matProjection); // Transform to screen-space coordinates
// Send combined model-view-projection matrix to shader
glUniformMatrix4fv(material.shader.mvpLoc, 1, false, MatrixToFloat(matMVP));
// Apply color tinting (material.colDiffuse)
// NOTE: Just update one uniform on fragment shader
float vColor[4] = { (float)material.colDiffuse.r/255, (float)material.colDiffuse.g/255, (float)material.colDiffuse.b/255, (float)material.colDiffuse.a/255 };
glUniform4fv(material.shader.tintColorLoc, 1, vColor);
// Set shader textures (diffuse, normal, specular)
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, material.texDiffuse.id);
glUniform1i(material.shader.mapDiffuseLoc, 0); // Texture fits in active texture unit 0
if ((material.texNormal.id != 0) && (material.shader.mapNormalLoc != -1))
{
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, material.texNormal.id);
glUniform1i(material.shader.mapNormalLoc, 1); // Texture fits in active texture unit 1
}
if ((material.texSpecular.id != 0) && (material.shader.mapSpecularLoc != -1))
{
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, material.texSpecular.id);
glUniform1i(material.shader.mapSpecularLoc, 2); // Texture fits in active texture unit 2
}
if (vaoSupported)
{
glBindVertexArray(mesh.vaoId);
}
else
{
// Bind mesh VBO data: vertex position (shader-location = 0)
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[0]);
glVertexAttribPointer(material.shader.vertexLoc, 3, GL_FLOAT, 0, 0, 0);
glEnableVertexAttribArray(material.shader.vertexLoc);
// Bind mesh VBO data: vertex texcoords (shader-location = 1)
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[1]);
glVertexAttribPointer(material.shader.texcoordLoc, 2, GL_FLOAT, 0, 0, 0);
glEnableVertexAttribArray(material.shader.texcoordLoc);
// Bind mesh VBO data: vertex normals (shader-location = 2, if available)
if (material.shader.normalLoc != -1)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[2]);
glVertexAttribPointer(material.shader.normalLoc, 3, GL_FLOAT, 0, 0, 0);
glEnableVertexAttribArray(material.shader.normalLoc);
}
// Bind mesh VBO data: vertex colors (shader-location = 3, if available) , tangents, texcoords2 (if available)
if (material.shader.colorLoc != -1)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[3]);
glVertexAttribPointer(material.shader.colorLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
glEnableVertexAttribArray(material.shader.colorLoc);
}
// Bind mesh VBO data: vertex tangents (shader-location = 4, if available)
if (material.shader.tangentLoc != -1)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[4]);
glVertexAttribPointer(material.shader.tangentLoc, 3, GL_FLOAT, 0, 0, 0);
glEnableVertexAttribArray(material.shader.tangentLoc);
}
// Bind mesh VBO data: vertex texcoords2 (shader-location = 5, if available)
if (material.shader.texcoord2Loc != -1)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh.vboId[5]);
glVertexAttribPointer(material.shader.texcoord2Loc, 2, GL_FLOAT, 0, 0, 0);
glEnableVertexAttribArray(material.shader.texcoord2Loc);
}
if (mesh.indices != NULL) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quads.vboId[3]);
}
// Draw call!
if (mesh.indices != NULL) glDrawElements(GL_TRIANGLES, mesh.triangleCount*3, GL_UNSIGNED_SHORT, 0); // Indexed vertices draw
else glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount);
if (material.texNormal.id != 0)
{
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
}
if (material.texSpecular.id != 0)
{
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, 0);
}
glActiveTexture(GL_TEXTURE0); // Set shader active texture to default 0
glBindTexture(GL_TEXTURE_2D, 0); // Unbind textures
if (vaoSupported) glBindVertexArray(0); // Unbind VAO
else
{
glBindBuffer(GL_ARRAY_BUFFER, 0); // Unbind VBOs
if (mesh.indices != NULL) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
glUseProgram(0); // Unbind shader program
#endif
}
// Unload mesh data from CPU and GPU
void rlglUnloadMesh(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);
rlDeleteBuffers(mesh->vboId[0]); // vertex
rlDeleteBuffers(mesh->vboId[1]); // texcoords
rlDeleteBuffers(mesh->vboId[2]); // normals
rlDeleteBuffers(mesh->vboId[3]); // colors
rlDeleteBuffers(mesh->vboId[4]); // tangents
rlDeleteBuffers(mesh->vboId[5]); // texcoords2
rlDeleteBuffers(mesh->vboId[6]); // indices
rlDeleteVertexArrays(mesh->vaoId);
}
// Read screen pixel data (color buffer) // Read screen pixel data (color buffer)
unsigned char *rlglReadScreenPixels(int width, int height) unsigned char *rlglReadScreenPixels(int width, int height)
{ {
@ -2328,12 +2425,12 @@ static void LoadDefaultShaderLocations(Shader *shader)
// vertex texcoord2 location = 5 // vertex texcoord2 location = 5
// Get handles to GLSL input attibute locations // Get handles to GLSL input attibute locations
shader->vertexLoc = glGetAttribLocation(shader->id, "vertexPosition"); shader->vertexLoc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_POSITION_NAME);
shader->texcoordLoc = glGetAttribLocation(shader->id, "vertexTexCoord"); shader->texcoordLoc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_TEXCOORD_NAME);
shader->normalLoc = glGetAttribLocation(shader->id, "vertexNormal"); shader->normalLoc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_NORMAL_NAME);
shader->colorLoc = glGetAttribLocation(shader->id, "vertexColor"); shader->colorLoc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_COLOR_NAME);
shader->tangentLoc = glGetAttribLocation(shader->id, "vertexTangent"); shader->tangentLoc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_TANGENT_NAME);
shader->texcoord2Loc = glGetAttribLocation(shader->id, "vertexTexCoord2"); shader->texcoord2Loc = glGetAttribLocation(shader->id, DEFAULT_ATTRIB_TEXCOORD2_NAME);
// Get handles to GLSL uniform locations (vertex shader) // Get handles to GLSL uniform locations (vertex shader)
shader->mvpLoc = glGetUniformLocation(shader->id, "mvpMatrix"); shader->mvpLoc = glGetUniformLocation(shader->id, "mvpMatrix");
@ -2350,8 +2447,8 @@ static void UnloadDefaultShader(void)
{ {
glUseProgram(0); glUseProgram(0);
//glDetachShader(defaultShaderProgram, vertexShader); //glDetachShader(defaultShader, vertexShader);
//glDetachShader(defaultShaderProgram, fragmentShader); //glDetachShader(defaultShader, fragmentShader);
//glDeleteShader(vertexShader); // Already deleted on shader compilation //glDeleteShader(vertexShader); // Already deleted on shader compilation
//glDeleteShader(fragmentShader); // Already deleted on sahder compilation //glDeleteShader(fragmentShader); // Already deleted on sahder compilation
glDeleteProgram(defaultShader.id); glDeleteProgram(defaultShader.id);

View file

@ -256,6 +256,8 @@ void rlEnableRenderTexture(unsigned int id); // Enable render texture (fbo)
void rlDisableRenderTexture(void); // Disable render texture (fbo), return to default framebuffer void rlDisableRenderTexture(void); // Disable render texture (fbo), return to default framebuffer
void rlEnableDepthTest(void); // Enable depth test void rlEnableDepthTest(void); // Enable depth test
void rlDisableDepthTest(void); // Disable depth test void rlDisableDepthTest(void); // Disable depth test
void rlEnableWireMode(void); // Enable wire mode
void rlDisableWireMode(void); // Disable wire mode
void rlDeleteTextures(unsigned int id); // Delete OpenGL texture from GPU void rlDeleteTextures(unsigned int id); // Delete OpenGL texture from GPU
void rlDeleteRenderTextures(RenderTexture2D target); // Delete render textures (fbo) from GPU void rlDeleteRenderTextures(RenderTexture2D target); // Delete render textures (fbo) from GPU
void rlDeleteShader(unsigned int id); // Delete OpenGL shader program from GPU void rlDeleteShader(unsigned int id); // Delete OpenGL shader program from GPU
@ -277,8 +279,11 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int textureForma
RenderTexture2D rlglLoadRenderTexture(int width, int height); // Load a texture to be used for rendering (fbo with color and depth attachments) RenderTexture2D rlglLoadRenderTexture(int width, int height); // Load a texture to be used for rendering (fbo with color and depth attachments)
void rlglUpdateTexture(unsigned int id, int width, int height, int format, void *data); // Update GPU texture with new data void rlglUpdateTexture(unsigned int id, int width, int height, int format, void *data); // Update GPU texture with new data
void rlglGenerateMipmaps(Texture2D texture); // Generate mipmap data for selected texture void rlglGenerateMipmaps(Texture2D texture); // Generate mipmap data for selected texture
void rlglLoadMesh(Mesh *mesh); // Upload vertex data into GPU and provided VAO/VBO ids
void rlglDrawEx(Mesh mesh, Material material, Matrix transform, bool wires); void rlglLoadMesh(Mesh *mesh); // Upload vertex data into GPU and provided VAO/VBO ids
void rlglUpdateMesh(Mesh mesh, int buffer, int numVertex); // Update vertex data on GPU (upload new data to one buffer)
void rlglDrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform
void rlglUnloadMesh(Mesh *mesh); // Unload mesh data from CPU and GPU
Vector3 rlglUnproject(Vector3 source, Matrix proj, Matrix view); // Get world coordinates from screen coordinates Vector3 rlglUnproject(Vector3 source, Matrix proj, Matrix view); // Get world coordinates from screen coordinates

View file

@ -109,7 +109,10 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
LFLAGS = -L. -L../../src LFLAGS = -L. -L../../src
else else
LFLAGS = -L. -L../../src -LC:/raylib/raylib/src LFLAGS = -L. -L../../src
ifeq ($(PLATFORM_OS),WINDOWS)
LFLAGS += -LC:/raylib/raylib/src
endif
# external libraries to link with # external libraries to link with
# GLFW3 # GLFW3
LFLAGS += -L../../external/glfw3/lib/$(LIBPATH) LFLAGS += -L../../external/glfw3/lib/$(LIBPATH)
@ -134,7 +137,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libraries for OS X 10.9 desktop compiling # libraries for OS X 10.9 desktop compiling
# requires the following packages: # requires the following packages:
# libglfw3-dev libopenal-dev libegl1-mesa-dev # libglfw3-dev libopenal-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa LIBS = -lraylib -lglfw3 -framework OpenGL -framework OpenAl -framework Cocoa
else else
# libraries for Windows desktop compiling # libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed # NOTE: GLFW3 and OpenAL Soft libraries should be installed

View file

@ -109,7 +109,10 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
LFLAGS = -L. -L../../src LFLAGS = -L. -L../../src
else else
LFLAGS = -L. -L../../src -LC:/raylib/raylib/src LFLAGS = -L. -L../../src
ifeq ($(PLATFORM_OS),WINDOWS)
LFLAGS += -LC:/raylib/raylib/src
endif
# external libraries to link with # external libraries to link with
# GLFW3 # GLFW3
LFLAGS += -L../../external/glfw3/lib/$(LIBPATH) LFLAGS += -L../../external/glfw3/lib/$(LIBPATH)

View file

@ -108,7 +108,10 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
LFLAGS = -L. -L../../src LFLAGS = -L. -L../../src
else else
LFLAGS = -L. -L../../src -LC:/raylib/raylib/src LFLAGS = -L. -L../../src
ifeq ($(PLATFORM_OS),WINDOWS)
LFLAGS += -LC:/raylib/raylib/src
endif
# external libraries to link with # external libraries to link with
# GLFW3 # GLFW3
LFLAGS += -L../../external/glfw3/lib/$(LIBPATH) LFLAGS += -L../../external/glfw3/lib/$(LIBPATH)
@ -133,7 +136,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libraries for OS X 10.9 desktop compiling # libraries for OS X 10.9 desktop compiling
# requires the following packages: # requires the following packages:
# libglfw3-dev libopenal-dev libegl1-mesa-dev # libglfw3-dev libopenal-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa LIBS = -lraylib -lglfw3 -framework OpenGL -framework OpenAl -framework Cocoa
else else
# libraries for Windows desktop compiling # libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed # NOTE: GLFW3 and OpenAL Soft libraries should be installed

View file

@ -109,7 +109,10 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
LFLAGS = -L. -L../../src LFLAGS = -L. -L../../src
else else
LFLAGS = -L. -L../../src -LC:/raylib/raylib/src LFLAGS = -L. -L../../src
ifeq ($(PLATFORM_OS),WINDOWS)
LFLAGS += -LC:/raylib/raylib/src
endif
# external libraries to link with # external libraries to link with
# GLFW3 # GLFW3
LFLAGS += -L../../external/glfw3/lib/$(LIBPATH) LFLAGS += -L../../external/glfw3/lib/$(LIBPATH)
@ -134,7 +137,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libraries for OS X 10.9 desktop compiling # libraries for OS X 10.9 desktop compiling
# requires the following packages: # requires the following packages:
# libglfw3-dev libopenal-dev libegl1-mesa-dev # libglfw3-dev libopenal-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa LIBS = -lraylib -lglfw3 -framework OpenGL -framework OpenAl -framework Cocoa
else else
# libraries for Windows desktop compiling # libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed # NOTE: GLFW3 and OpenAL Soft libraries should be installed

View file

@ -109,7 +109,10 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
LFLAGS = -L. -L../../src LFLAGS = -L. -L../../src
else else
LFLAGS = -L. -L../../src -LC:/raylib/raylib/src LFLAGS = -L. -L../../src
ifeq ($(PLATFORM_OS),WINDOWS)
LFLAGS += -LC:/raylib/raylib/src
endif
# external libraries to link with # external libraries to link with
# GLFW3 # GLFW3
LFLAGS += -L../../external/glfw3/lib/$(LIBPATH) LFLAGS += -L../../external/glfw3/lib/$(LIBPATH)
@ -134,7 +137,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libraries for OS X 10.9 desktop compiling # libraries for OS X 10.9 desktop compiling
# requires the following packages: # requires the following packages:
# libglfw3-dev libopenal-dev libegl1-mesa-dev # libglfw3-dev libopenal-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa LIBS = -lraylib -lglfw3 -framework OpenGL -framework OpenAl -framework Cocoa
else else
# libraries for Windows desktop compiling # libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed # NOTE: GLFW3 and OpenAL Soft libraries should be installed