Merge pull request #282 from raysan5/develop

Integrate Develop branch
This commit is contained in:
Ray 2017-05-09 09:35:58 +02:00 committed by GitHub
commit 0ca874c710
56 changed files with 353040 additions and 289533 deletions

View file

@ -88,6 +88,9 @@ void UpdateDrawFrame(void)
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); // Update camera and player position UpdateCamera(&camera); // Update camera and player position
// Lock mouse cursor if mouse click on canvas
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) DisableCursor();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

File diff suppressed because one or more lines are too long

View file

@ -58,6 +58,17 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.9
CLANG_VERSION=e1.37.9_64bit
PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_64bit
export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif
# define compiler: gcc for C program, define as g++ for C++ # define compiler: gcc for C program, define as g++ for C++
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# define emscripten compiler # define emscripten compiler

View file

@ -57,7 +57,7 @@
div.emscripten_border { border: 1px solid black; } div.emscripten_border { border: 1px solid black; }
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */ /* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten { border: 0px none; } canvas.emscripten { border: 0px none; background: black; }
#emscripten_logo { #emscripten_logo {
display: inline-block; display: inline-block;
@ -144,7 +144,7 @@
<div class="emscripten" id="status">Downloading...</div> <div class="emscripten" id="status">Downloading...</div>
<span id='controls'> <span id='controls'>
<span><input type="button" value="Fullscreen" onclick="Module.requestFullScreen(false, false)"></span> <span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(false, false)"></span>
</span> </span>
<div class="emscripten"> <div class="emscripten">

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View file

@ -4,28 +4,31 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>raylib GGJ15 game: Just Do</title> <title>raylib HTML5 GAME</title>
<meta name="title" content="raylib game: Just Do"> <meta name="title" content="raylib HTML5 GAME">
<meta name="description" content="Just Do is a logic/puzzle videogame developed for GGJ15 using raylib. Try it!"> <meta name="description" content="New HTML5 videogame, developed using raylib videogames library">
<meta name="keywords" content="raylib, logic, puzzle videogames, programming, C, learn, study, simple, easy, free, open source, raysan"> <meta name="keywords" content="raylib, games, html5, programming, C, C++, library, learn, videogames">
<meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=device-width">
<!-- Facebook metatags for sharing -->
<meta property="og:title" content="raylib HTML5 GAME">
<meta property="og:image:type" content="image/png">
<meta property="og:image" content="http://www.raylib.com/img/raylib_logo.png">
<meta property="og:image" content="http://www.raylib.com/img/raylib_logo.png">
<meta property="og:url" content="http://www.raylib.com/games">
<meta property="og:site_name" content="raylib.com">
<meta property="og:description" content="New hmtl5 videogame, developed using raylib videogames library">
<!-- Open Graph data: Facebook/LinkedIn metatags for sharing --> <meta name="twitter:card" content="summary">
<meta property="og:title" content="raylib game: Just Do"/> <meta name="twitter:site" content="@emegemegames">
<meta property="og:image:type" content="image/png" /> <meta name="twitter:title" content="raylib HTML5 GAME">
<meta property="og:image" content="http://www.raylib.com/img/just_do.png"/> <meta name="twitter:description" content="New HTML5 videogame, developed using raylib videogames library">
<meta property="og:url" content="http://www.raylib.com/just_do.html" /> <meta name="twitter:image" content="http://www.raylib.com/img/raylib_logo.png">
<meta property="og:site_name" content="raylib game: Just Do"/> <meta name="twitter:url" content="http://www.raylib.com/img/raylib_logo.png">
<meta property="og:description" content="Just Do is a logic/puzzle videogame developed for GGJ15 using raylib. Try it!"/>
<!--<link rel="stylesheet" href="./Koala Seasons by emegeme_files/main.css">-->
<!-- Twitter Card --> <link rel="shortcut icon" href="http://www.raylib.com/favicon.ico">
<meta name="twitter:card" content="summary"/>
<meta name="twitter:site" content="@raysan5"/>
<meta name="twitter:title" content="raylib game: Just Do"/>
<meta name="twitter:description" content="Just Do is a logic/puzzle videogame developed for GGJ15 using raylib. Try it!"/>
<meta name="twitter:image" content="http://www.raylib.com/img/just_do.png"/>
<meta name="twitter:url" content="http://www.raylib.com/just_do.html"/>
<style> <style>
body { body {
@ -33,18 +36,34 @@
margin: 0; margin: 0;
padding: none; padding: none;
} }
.emscripten { padding-right: 0; display: block; } #header_part {
width: 100%;
height: 80px;
background-color: #888888;
}
#logo {
width:64px;
height:64px;
float:left;
position:relative;
margin:10px;
background-image:url(http://www.raylib.com/common/img/raylib_logo_64x64.png);
}
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
div.emscripten { text-align: center; } div.emscripten { text-align: center; }
div.emscripten_border { border: 1px solid black; margin-top: 50px; } div.emscripten_border { border: 1px solid black; }
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */ /* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten { border: 0px none; } canvas.emscripten { border: 0px none; background: black; }
#emscripten_logo { #emscripten_logo {
display: inline-block; display: inline-block;
margin: 0; margin: 0;
} }
.spinner { .spinner {
height: 30px; height: 30px;
width: 30px; width: 30px;
@ -53,21 +72,18 @@
margin-left: 20px; margin-left: 20px;
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
-webkit-animation: rotation .8s linear infinite; -webkit-animation: rotation .8s linear infinite;
-moz-animation: rotation .8s linear infinite; -moz-animation: rotation .8s linear infinite;
-o-animation: rotation .8s linear infinite; -o-animation: rotation .8s linear infinite;
animation: rotation 0.8s linear infinite; animation: rotation 0.8s linear infinite;
border-left: 5px solid black;
border-left: 5px solid rgb(235, 235, 235); border-right: 5px solid black;
border-right: 5px solid rgb(235, 235, 235); border-bottom: 5px solid black;
border-bottom: 5px solid rgb(235, 235, 235); border-top: 5px solid red;
border-top: 5px solid rgb(120, 120, 120);
border-radius: 100%; border-radius: 100%;
background-color: rgb(189, 215, 46); background-color: rgb(245, 245, 245);
} }
@-webkit-keyframes rotation { @-webkit-keyframes rotation {
from {-webkit-transform: rotate(0deg);} from {-webkit-transform: rotate(0deg);}
to {-webkit-transform: rotate(360deg);} to {-webkit-transform: rotate(360deg);}
@ -84,21 +100,21 @@
from {transform: rotate(0deg);} from {transform: rotate(0deg);}
to {transform: rotate(360deg);} to {transform: rotate(360deg);}
} }
#status { #status {
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
margin-top: 30px; margin-top: 30px;
margin-left: 20px; margin-left: 20px;
font-weight: bold; font-weight: bold;
color: rgb(120, 120, 120); color: rgb(40, 40, 40);
} }
#progress { #progress {
height: 20px; height: 20px;
width: 30px; width: 30px;
} }
#controls { #controls {
display: inline-block; display: inline-block;
float: right; float: right;
@ -106,7 +122,7 @@
margin-top: 30px; margin-top: 30px;
margin-right: 20px; margin-right: 20px;
} }
#output { #output {
width: 100%; width: 100%;
height: 140px; height: 140px;
@ -118,40 +134,34 @@
font-family: 'Lucida Console', Monaco, monospace; font-family: 'Lucida Console', Monaco, monospace;
outline: none; outline: none;
} }
svg#Layer_1 {margin-top: 5px;}
#logo{width:64px; height:64px; float:left; position:relative; margin:10px; background-image:url(http://www.raylib.com/common/img/raylib_logo_64x64.png);}
</style> </style>
</head> </head>
<body> <body>
<a id="logo" href="index.htm"></a> <div id="header_part">
<a id="logo" href="http://www.raylib.com"></a>
<div class="spinner" id='spinner'></div>
<div class="emscripten" id="status">Downloading...</div>
<div class="spinner" id='spinner'></div> <span id='controls'>
<div class="emscripten" id="status">Downloading...</div> <span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(false, false)"></span>
</span>
<span id='controls'> <div class="emscripten">
<span><input type="checkbox" id="resize">Resize canvas</span> <progress value="0" max="100" id="progress" hidden=1></progress>
<span><input type="checkbox" id="pointerLock">Lock/hide mouse pointer &nbsp;&nbsp;&nbsp;</span> </div>
<span><input type="button" value="Fullscreen" onclick="Module.requestFullScreen(document.getElementById('pointerLock').checked,
document.getElementById('resize').checked)">
</span>
</span>
<div class="emscripten">
<progress value="0" max="100" id="progress" hidden=1></progress>
</div> </div>
<div class="emscripten_border"> <div class="emscripten_border">
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas> <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
</div> </div>
<textarea id="output" rows="8"></textarea> <textarea id="output" rows="8"></textarea>
<script type='text/javascript'> <script type='text/javascript'>
var statusElement = document.getElementById('status'); var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress'); var progressElement = document.getElementById('progress');
var spinnerElement = document.getElementById('spinner'); var spinnerElement = document.getElementById('spinner');
var Module = { var Module = {
preRun: [], preRun: [],
postRun: [], postRun: [],
@ -159,7 +169,7 @@
var element = document.getElementById('output'); var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache if (element) element.value = ''; // clear browser cache
return function(text) { return function(text) {
text = Array.prototype.slice.call(arguments).join(' '); if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML // These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&amp;"); //text = text.replace(/&/g, "&amp;");
//text = text.replace(/</g, "&lt;"); //text = text.replace(/</g, "&lt;");
@ -173,7 +183,7 @@
}; };
})(), })(),
printErr: function(text) { printErr: function(text) {
text = Array.prototype.slice.call(arguments).join(' '); if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
if (0) { // XXX disabled for safety typeof dump == 'function') { if (0) { // XXX disabled for safety typeof dump == 'function') {
dump(text + '\n'); // fast, straight to the real console dump(text + '\n'); // fast, straight to the real console
} else { } else {
@ -182,12 +192,10 @@
}, },
canvas: (function() { canvas: (function() {
var canvas = document.getElementById('canvas'); var canvas = document.getElementById('canvas');
// As a default initial behavior, pop up an alert when webgl context is lost. To make your // As a default initial behavior, pop up an alert when webgl context is lost. To make your
// application robust, you may want to override this behavior before shipping! // application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false); canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
return canvas; return canvas;
})(), })(),
setStatus: function(text) { setStatus: function(text) {
@ -227,17 +235,5 @@
}; };
</script> </script>
<script async type="text/javascript" src="just_do.js"></script> <script async type="text/javascript" src="just_do.js"></script>
<!-- Google Analytics tracking code -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','http://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-45733555-1', 'raylib.com');
ga('require', 'linkid', 'linkid.js');
ga('send', 'pageview');
</script>
</body> </body>
</html> </html>

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -57,7 +57,7 @@
div.emscripten_border { border: 1px solid black; } div.emscripten_border { border: 1px solid black; }
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */ /* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten { border: 0px none; } canvas.emscripten { border: 0px none; background: black; }
#emscripten_logo { #emscripten_logo {
display: inline-block; display: inline-block;
@ -144,7 +144,7 @@
<div class="emscripten" id="status">Downloading...</div> <div class="emscripten" id="status">Downloading...</div>
<span id='controls'> <span id='controls'>
<span><input type="button" value="Fullscreen" onclick="Module.requestFullScreen(false, false)"></span> <span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(false, false)"></span>
</span> </span>
<div class="emscripten"> <div class="emscripten">
@ -234,6 +234,6 @@
}; };
}; };
</script> </script>
<script async type="text/javascript" src="illogic.js"></script> <script async type="text/javascript" src="koala_seasons.js"></script>
</body> </body>
</html> </html>

87700
docs/games/koala_seasons.js Normal file

File diff suppressed because one or more lines are too long

View file

@ -144,7 +144,7 @@
<div class="emscripten" id="status">Downloading...</div> <div class="emscripten" id="status">Downloading...</div>
<span id='controls'> <span id='controls'>
<span><input type="button" value="Fullscreen" onclick="Module.requestFullScreen(false, false)"></span> <span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(false, false)"></span>
</span> </span>
<div class="emscripten"> <div class="emscripten">

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,238 +0,0 @@
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>raylib running on web</title>
<meta name="title" content="raylib runing on web">
<meta name="description" content="raylib is a simple and easy-to-use library to learn videogames programming.">
<meta name="keywords" content="raylib, videogames, programming, C, C++, library, learn, study, simple, easy, free, open source, raysan">
<meta name="viewport" content="width=device-width">
<!-- Facebook metatags for sharing -->
<meta property="og:title" content="raylib"/>
<meta property="og:image:type" content="image/png" />
<meta property="og:image" content="http://www.raylib.com/img/ln_raylib_logo.png"/>
<meta property="og:image" content="http://www.raylib.com/img/fb_raylib_logo.png"/>
<meta property="og:url" content="http://www.raylib.com" />
<meta property="og:site_name" content="raylib"/>
<meta property="og:description" content="raylib is a simple and easy-to-use library to learn videogames programming. "/>
<style>
body {
font-family: arial;
margin: 0;
padding: none;
}
.emscripten { padding-right: 0; display: block; }
div.emscripten { text-align: center; }
div.emscripten_border { border: 1px solid black; margin-top: 50px; }
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten { border: 0px none; }
#emscripten_logo {
display: inline-block;
margin: 0;
}
.spinner {
height: 30px;
width: 30px;
margin: 0;
margin-top: 20px;
margin-left: 20px;
display: inline-block;
vertical-align: top;
-webkit-animation: rotation .8s linear infinite;
-moz-animation: rotation .8s linear infinite;
-o-animation: rotation .8s linear infinite;
animation: rotation 0.8s linear infinite;
border-left: 5px solid rgb(235, 235, 235);
border-right: 5px solid rgb(235, 235, 235);
border-bottom: 5px solid rgb(235, 235, 235);
border-top: 5px solid rgb(120, 120, 120);
border-radius: 100%;
background-color: rgb(189, 215, 46);
}
@-webkit-keyframes rotation {
from {-webkit-transform: rotate(0deg);}
to {-webkit-transform: rotate(360deg);}
}
@-moz-keyframes rotation {
from {-moz-transform: rotate(0deg);}
to {-moz-transform: rotate(360deg);}
}
@-o-keyframes rotation {
from {-o-transform: rotate(0deg);}
to {-o-transform: rotate(360deg);}
}
@keyframes rotation {
from {transform: rotate(0deg);}
to {transform: rotate(360deg);}
}
#status {
display: inline-block;
vertical-align: top;
margin-top: 30px;
margin-left: 20px;
font-weight: bold;
color: rgb(120, 120, 120);
}
#progress {
height: 20px;
width: 30px;
}
#controls {
display: inline-block;
float: right;
vertical-align: top;
margin-top: 30px;
margin-right: 20px;
}
#output {
width: 100%;
height: 140px;
margin: 0 auto;
margin-top: 10px;
display: block;
background-color: black;
color: rgb(37, 174, 38);
font-family: 'Lucida Console', Monaco, monospace;
outline: none;
}
svg#Layer_1 {margin-top: 5px;}
#logo{width:64px; height:64px; float:left; position:relative; margin:10px; background-image:url(http://www.raylib.com/common/img/raylib_logo_64x64.png);}
</style>
</head>
<body>
<a id="logo" href="index.html"></a>
<div class="spinner" id='spinner'></div>
<div class="emscripten" id="status">Downloading...</div>
<span id='controls'>
<span><input type="checkbox" id="resize">Resize canvas</span>
<span><input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer &nbsp;&nbsp;&nbsp;</span>
<span><input type="button" value="Fullscreen" onclick="Module.requestFullScreen(document.getElementById('pointerLock').checked,
document.getElementById('resize').checked)">
</span>
</span>
<div class="emscripten">
<progress value="0" max="100" id="progress" hidden=1></progress>
</div>
<div class="emscripten_border">
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
</div>
<textarea id="output" rows="8"></textarea>
<script type='text/javascript'>
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');
var spinnerElement = document.getElementById('spinner');
var Module = {
preRun: [],
postRun: [],
print: (function() {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
return function(text) {
text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&amp;");
//text = text.replace(/</g, "&lt;");
//text = text.replace(/>/g, "&gt;");
//text = text.replace('\n', '<br>', 'g');
console.log(text);
if (element) {
element.value += text + "\n";
element.scrollTop = element.scrollHeight; // focus on bottom
}
};
})(),
printErr: function(text) {
text = Array.prototype.slice.call(arguments).join(' ');
if (0) { // XXX disabled for safety typeof dump == 'function') {
dump(text + '\n'); // fast, straight to the real console
} else {
console.error(text);
}
},
canvas: (function() {
var canvas = document.getElementById('canvas');
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
// application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
return canvas;
})(),
setStatus: function(text) {
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
if (m && now - Date.now() < 30) return; // if this is a progress update, skip it if too soon
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
spinnerElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
if (!text) spinnerElement.style.display = 'none';
}
statusElement.innerHTML = text;
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading...');
window.onerror = function(event) {
// TODO: do not warn on ok events like simulating an infinite loop or exitStatus
Module.setStatus('Exception thrown, see JavaScript console');
spinnerElement.style.display = 'none';
Module.setStatus = function(text) {
if (text) Module.printErr('[post-exception status] ' + text);
};
};
</script>
<!-- raylib demo code -->
<script async type="text/javascript" src="raylib_demo.js"></script>
<!-- Google Analytics tracking code -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','http://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-45733555-1', 'raylib.com');
ga('require', 'linkid', 'linkid.js');
ga('send', 'pageview');
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -4,26 +4,26 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>King GameJam - Skully Escape</title> <title>raylib HTML5 GAME</title>
<meta name="title" content="Skully Escape"> <meta name="title" content="raylib HTML5 GAME">
<meta name="description" content="Skully Escape, new raylib videogame, developed during the King GameJam in Barcelona"> <meta name="description" content="New HTML5 videogame, developed using raylib videogames library">
<meta name="keywords" content="skully, raylib, gamejam, King, programming, C, C++, library, learn, videogames"> <meta name="keywords" content="raylib, games, html5, programming, C, C++, library, learn, videogames">
<meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=device-width">
<!-- Facebook metatags for sharing --> <!-- Facebook metatags for sharing -->
<meta property="og:title" content="Skully Escape"> <meta property="og:title" content="raylib HTML5 GAME">
<meta property="og:image:type" content="image/png"> <meta property="og:image:type" content="image/png">
<meta property="og:image" content="http://www.raylib.com/img/raylib_logo.png"> <meta property="og:image" content="http://www.raylib.com/img/raylib_logo.png">
<meta property="og:image" content="http://www.raylib.com/img/raylib_logo.png"> <meta property="og:image" content="http://www.raylib.com/img/raylib_logo.png">
<meta property="og:url" content="http://www.raylib.com/games/skully_escape.png"> <meta property="og:url" content="http://www.raylib.com/games">
<meta property="og:site_name" content="raylib.com"> <meta property="og:site_name" content="raylib.com">
<meta property="og:description" content="Skully Escape, new raylib videogame, developed during the King GameJam in Barcelona"> <meta property="og:description" content="New hmtl5 videogame, developed using raylib videogames library">
<meta name="twitter:card" content="summary"> <meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@emegemegames"> <meta name="twitter:site" content="@emegemegames">
<meta name="twitter:title" content="Koala Seasons"> <meta name="twitter:title" content="raylib HTML5 GAME">
<meta name="twitter:description" content="Skully Escape, new raylib videogame, developed during the King GameJam in Barcelona"> <meta name="twitter:description" content="New HTML5 videogame, developed using raylib videogames library">
<meta name="twitter:image" content="http://www.raylib.com/img/raylib_logo.png"> <meta name="twitter:image" content="http://www.raylib.com/img/raylib_logo.png">
<meta name="twitter:url" content="http://www.raylib.com/img/raylib_logo.png"> <meta name="twitter:url" content="http://www.raylib.com/img/raylib_logo.png">
@ -51,18 +51,19 @@
margin:10px; margin:10px;
background-image:url(http://www.raylib.com/common/img/raylib_logo_64x64.png); background-image:url(http://www.raylib.com/common/img/raylib_logo_64x64.png);
} }
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; } .emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
div.emscripten { text-align: center; } div.emscripten { text-align: center; }
div.emscripten_border { border: 1px solid black; } div.emscripten_border { border: 1px solid black; }
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */ /* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten { border: 0px none; } canvas.emscripten { border: 0px none; background: black; }
#emscripten_logo { #emscripten_logo {
display: inline-block; display: inline-block;
margin: 0; margin: 0;
} }
.spinner { .spinner {
height: 30px; height: 30px;
width: 30px; width: 30px;
@ -71,21 +72,18 @@
margin-left: 20px; margin-left: 20px;
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
-webkit-animation: rotation .8s linear infinite; -webkit-animation: rotation .8s linear infinite;
-moz-animation: rotation .8s linear infinite; -moz-animation: rotation .8s linear infinite;
-o-animation: rotation .8s linear infinite; -o-animation: rotation .8s linear infinite;
animation: rotation 0.8s linear infinite; animation: rotation 0.8s linear infinite;
border-left: 5px solid black;
border-left: 5px solid rgb(235, 235, 235); border-right: 5px solid black;
border-right: 5px solid rgb(235, 235, 235); border-bottom: 5px solid black;
border-bottom: 5px solid rgb(235, 235, 235); border-top: 5px solid red;
border-top: 5px solid rgb(120, 120, 120);
border-radius: 100%; border-radius: 100%;
background-color: rgb(189, 215, 46); background-color: rgb(245, 245, 245);
} }
@-webkit-keyframes rotation { @-webkit-keyframes rotation {
from {-webkit-transform: rotate(0deg);} from {-webkit-transform: rotate(0deg);}
to {-webkit-transform: rotate(360deg);} to {-webkit-transform: rotate(360deg);}
@ -102,21 +100,21 @@
from {transform: rotate(0deg);} from {transform: rotate(0deg);}
to {transform: rotate(360deg);} to {transform: rotate(360deg);}
} }
#status { #status {
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
margin-top: 30px; margin-top: 30px;
margin-left: 20px; margin-left: 20px;
font-weight: bold; font-weight: bold;
color: rgb(120, 120, 120); color: rgb(40, 40, 40);
} }
#progress { #progress {
height: 20px; height: 20px;
width: 30px; width: 30px;
} }
#controls { #controls {
display: inline-block; display: inline-block;
float: right; float: right;
@ -124,15 +122,15 @@
margin-top: 30px; margin-top: 30px;
margin-right: 20px; margin-right: 20px;
} }
#output { #output {
width: 100%; width: 100%;
height: 200px; height: 140px;
margin: 0 auto; margin: 0 auto;
margin-top: 10px; margin-top: 10px;
display: block; display: block;
background-color: black; background-color: black;
color: white; color: rgb(37, 174, 38);
font-family: 'Lucida Console', Monaco, monospace; font-family: 'Lucida Console', Monaco, monospace;
outline: none; outline: none;
} }
@ -146,7 +144,7 @@
<div class="emscripten" id="status">Downloading...</div> <div class="emscripten" id="status">Downloading...</div>
<span id='controls'> <span id='controls'>
<span><input type="button" value="Fullscreen" onclick="Module.requestFullScreen(false, false)"></span> <span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(false, false)"></span>
</span> </span>
<div class="emscripten"> <div class="emscripten">
@ -164,7 +162,6 @@
var statusElement = document.getElementById('status'); var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress'); var progressElement = document.getElementById('progress');
var spinnerElement = document.getElementById('spinner'); var spinnerElement = document.getElementById('spinner');
var Module = { var Module = {
preRun: [], preRun: [],
postRun: [], postRun: [],
@ -195,12 +192,10 @@
}, },
canvas: (function() { canvas: (function() {
var canvas = document.getElementById('canvas'); var canvas = document.getElementById('canvas');
// As a default initial behavior, pop up an alert when webgl context is lost. To make your // As a default initial behavior, pop up an alert when webgl context is lost. To make your
// application robust, you may want to override this behavior before shipping! // application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false); canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
return canvas; return canvas;
})(), })(),
setStatus: function(text) { setStatus: function(text) {
@ -240,17 +235,5 @@
}; };
</script> </script>
<script async type="text/javascript" src="skully_escape.js"></script> <script async type="text/javascript" src="skully_escape.js"></script>
<!-- Google Analytics tracking code -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','http://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-45733555-1', 'raylib.com');
ga('require', 'linkid', 'linkid.js');
ga('send', 'pageview');
</script>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

14030
docs/games/wave_collector.data Normal file

File diff suppressed because one or more lines are too long

View file

@ -57,7 +57,7 @@
div.emscripten_border { border: 1px solid black; } div.emscripten_border { border: 1px solid black; }
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */ /* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten { border: 0px none; } canvas.emscripten { border: 0px none; background: black; }
#emscripten_logo { #emscripten_logo {
display: inline-block; display: inline-block;
@ -144,7 +144,7 @@
<div class="emscripten" id="status">Downloading...</div> <div class="emscripten" id="status">Downloading...</div>
<span id='controls'> <span id='controls'>
<span><input type="button" value="Fullscreen" onclick="Module.requestFullScreen(false, false)"></span> <span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(false, false)"></span>
</span> </span>
<div class="emscripten"> <div class="emscripten">
@ -234,6 +234,6 @@
}; };
}; };
</script> </script>
<script async type="text/javascript" src="raylib_zerouno.js"></script> <script async type="text/javascript" src="wave_collector.js"></script>
</body> </body>
</html> </html>

70971
docs/games/wave_collector.js Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,20 @@

This game sources are licensed under an unmodified zlib/libpng license,
which is an OSI-certified, BSD-like license:
Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
This software is provided "as-is", without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you
wrote the original software. If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented
as being the original software.
3. This notice may not be removed or altered from any source distribution.

View file

@ -94,7 +94,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --profiling --preload-file resources CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=33554432 --profiling --preload-file resources
# -O2 # if used, also set --memory-init-file 0 # -O2 # if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing

20
games/just_do/LICENSE.txt Normal file
View file

@ -0,0 +1,20 @@

This game sources are licensed under an unmodified zlib/libpng license,
which is an OSI-certified, BSD-like license:
Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
This software is provided "as-is", without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you
wrote the original software. If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented
as being the original software.
3. This notice may not be removed or altered from any source distribution.

View file

@ -94,7 +94,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s --profiling --preload-file resources CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources
# -O2 # if used, also set --memory-init-file 0 # -O2 # if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing

View file

@ -154,17 +154,4 @@ void UnloadLevel02Screen(void)
int FinishLevel02Screen(void) int FinishLevel02Screen(void)
{ {
return finishScreen; return finishScreen;
}
// Calculate distance between two points
float Vector2Distance(Vector2 v1, Vector2 v2)
{
float result;
float dx = v2.x - v1.x;
float dy = v2.y - v1.y;
result = sqrt(dx*dx + dy*dy);
return result;
} }

View file

@ -0,0 +1,20 @@

This game sources are licensed under an unmodified zlib/libpng license,
which is an OSI-certified, BSD-like license:
Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
This software is provided "as-is", without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you
wrote the original software. If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented
as being the original software.
3. This notice may not be removed or altered from any source distribution.

View file

@ -94,7 +94,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources -s ALLOW_MEMORY_GROWTH=1 CFLAGS = -O1 -Wall -std=c99 -DPLATFORM_WEB -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=67108864 --profiling --preload-file resources
# -O2 # if used, also set --memory-init-file 0 # -O2 # if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing

View file

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

View file

@ -490,7 +490,7 @@ void UpdateGameplayScreen(void)
if (monthTimer >= monthChange) if (monthTimer >= monthChange)
{ {
if ((currentMonth == 10)) if (currentMonth == 10)
{ {
clockInitRotation = 225; clockInitRotation = 225;
clockFinalRotation = clockInitRotation + 90; clockFinalRotation = clockInitRotation + 90;

View file

@ -0,0 +1,20 @@

This game sources are licensed under an unmodified zlib/libpng license,
which is an OSI-certified, BSD-like license:
Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
This software is provided "as-is", without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you
wrote the original software. If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented
as being the original software.
3. This notice may not be removed or altered from any source distribution.

View file

@ -94,7 +94,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources -s ALLOW_MEMORY_GROWTH=1 CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources -s TOTAL_MEMORY=33554432
# -O2 # if used, also set --memory-init-file 0 # -O2 # if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing

View file

@ -0,0 +1,20 @@

This game sources are licensed under an unmodified zlib/libpng license,
which is an OSI-certified, BSD-like license:
Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
This software is provided "as-is", without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you
wrote the original software. If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented
as being the original software.
3. This notice may not be removed or altered from any source distribution.

View file

@ -94,7 +94,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources -s ALLOW_MEMORY_GROWTH=1 CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=67108864 --profiling --preload-file resources
# -O2 # if used, also set --memory-init-file 0 # -O2 # if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing

View file

@ -0,0 +1,20 @@

This game sources are licensed under an unmodified zlib/libpng license,
which is an OSI-certified, BSD-like license:
Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
This software is provided "as-is", without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you
wrote the original software. If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented
as being the original software.
3. This notice may not be removed or altered from any source distribution.

View file

@ -94,7 +94,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --profiling --preload-file resources CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 -s TOTAL_MEMORY=67108864 --profiling --preload-file resources
# -O2 # if used, also set --memory-init-file 0 # -O2 # if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing

View file

@ -1,10 +1,19 @@
#****************************************************************************** #******************************************************************************
# #
# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten) # raylib makefile
# #
# Many Thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline. # Platforms supported:
# PLATFORM_DESKTOP: Windows (win32/Win64)
# PLATFORM_DESKTOP: Linux
# PLATFORM_DESKTOP: OSX (Mac)
# PLATFORM_ANDROID: Android (ARM or ARM64)
# PLATFORM_RPI: Raspberry Pi (Raspbian)
# PLATFORM_WEB: HTML5 (Chrome, Firefox)
# #
# Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) # Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline.
# Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline.
#
# Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
# #
# This software is provided "as-is", without any express or implied warranty. # This software is provided "as-is", without any express or implied warranty.
# In no event will the authors be held liable for any damages arising from # In no event will the authors be held liable for any damages arising from
@ -29,7 +38,7 @@
# Please read the wiki to know how to compile raylib, because there are # Please read the wiki to know how to compile raylib, because there are
# different methods. # different methods.
.PHONY: all clean install unistall .PHONY: all clean install uninstall
# define raylib platform to compile for # define raylib platform to compile for
# possible platforms: PLATFORM_DESKTOP PLATFORM_ANDROID PLATFORM_RPI PLATFORM_WEB # possible platforms: PLATFORM_DESKTOP PLATFORM_ANDROID PLATFORM_RPI PLATFORM_WEB
@ -38,12 +47,16 @@ PLATFORM ?= PLATFORM_DESKTOP
# define YES if you want shared/dynamic version of library instead of static (default) # define YES if you want shared/dynamic version of library instead of static (default)
SHARED ?= NO SHARED ?= NO
# define NO to use OpenAL Soft as static library (or shared by default) # use OpenAL Soft as shared library (.so / .dll)
SHARED_OPENAL ?= YES # NOTE: If defined NO, static OpenAL Soft library should be provided
SHARED_OPENAL ?= NO
# on PLATFORM_WEB force OpenAL Soft shared library # on PLATFORM_WEB force OpenAL Soft shared library
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
SHARED_OPENAL ?= YES SHARED_OPENAL = YES
endif
ifeq ($(PLATFORM),PLATFORM_ANDROID)
SHARED_OPENAL = YES
endif endif
# determine if the file has root access (only for installing raylib) # determine if the file has root access (only for installing raylib)
@ -69,48 +82,67 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_WEB)
# path to Android NDK # Emscripten required variables
ANDROID_NDK = $(ANDROID_NDK_HOME) EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.37.9
CLANG_VERSION=e1.37.9_64bit
PYTHON_VERSION=2.7.5.3_64bit
NODE_VERSION=4.1.1_64bit
export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif
# possible Android architectures: ARM ARM64 ifeq ($(PLATFORM),PLATFORM_ANDROID)
# Android NDK path
# NOTE: Required for standalone toolchain generation
ANDROID_NDK = $(ANDROID_NDK_HOME)
# Android standalone toolchain path
# NOTE: This path is also used if toolchain generation
#ANDROID_TOOLCHAIN = $(CURDIR)/toolchain
ANDROID_TOOLCHAIN = C:/raylib/android-standalone-toolchain
# Android architecture: ARM or ARM64
ANDROID_ARCH ?= ARM ANDROID_ARCH ?= ARM
# define YES to use clang instead of gcc # Android compiler: gcc or clang
# NOTE: Define YES to use clang instead of gcc
ANDROID_LLVM ?= NO ANDROID_LLVM ?= NO
# standalone Android toolchain install dir
ANDROID_TOOLCHAIN = $(CURDIR)/toolchain
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# RPI cross-compiler
CROSS_COMPILE ?= NO CROSS_COMPILE ?= NO
endif endif
# define raylib graphics api depending on selected platform # define raylib graphics api depending on selected platform
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
GRAPHICS = GRAPHICS_API_OPENGL_ES2 # by default use OpenGL 3.3 on desktop platforms
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# define raylib graphics api to use (on RPI, OpenGL ES 2.0 must be used)
GRAPHICS = GRAPHICS_API_OPENGL_ES2
else
# define raylib graphics api to use (OpenGL 3.3 by default)
GRAPHICS ?= GRAPHICS_API_OPENGL_33 GRAPHICS ?= GRAPHICS_API_OPENGL_33
#GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1 #GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
#GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1 #GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI)
# on RPI OpenGL ES 2.0 must be used
GRAPHICS = GRAPHICS_API_OPENGL_ES2
endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# on HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0
GRAPHICS = GRAPHICS_API_OPENGL_ES2
endif
ifeq ($(PLATFORM),PLATFORM_ANDROID)
# by default use OpenGL ES 2.0 on Android
GRAPHICS = GRAPHICS_API_OPENGL_ES2 GRAPHICS = GRAPHICS_API_OPENGL_ES2
endif endif
# NOTE: makefiles targets require tab indentation # NOTE: makefiles targets require tab indentation
# NOTE: define compiler: gcc for C program, define as g++ for C++
# define compiler: gcc for C program, define as g++ for C++
# default gcc compiler # default gcc compiler
CC = gcc CC = gcc
# Android toolchain compiler
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_ANDROID)
ifeq ($(ANDROID_ARCH),ARM) ifeq ($(ANDROID_ARCH),ARM)
ifeq ($(ANDROID_LLVM),YES) ifeq ($(ANDROID_LLVM),YES)
@ -128,6 +160,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
endif endif
endif endif
# RPI cross-compiler
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
ifeq ($(CROSS_COMPILE),YES) ifeq ($(CROSS_COMPILE),YES)
# rpi compiler # rpi compiler
@ -135,13 +168,15 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
endif endif
endif endif
# HTML5 emscripten compiler
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# emscripten compiler
CC = emcc CC = emcc
endif endif
# default archiver program to pack libraries
AR = ar AR = ar
# Android archiver
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_ANDROID)
ifeq ($(ANDROID_ARCH),ARM) ifeq ($(ANDROID_ARCH),ARM)
AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar
@ -159,29 +194,17 @@ endif
# -std=gnu99 defines C language mode (GNU C from 1999 revision) # -std=gnu99 defines C language mode (GNU C from 1999 revision)
# -fgnu89-inline declaring inline functions support (GCC optimized) # -fgnu89-inline declaring inline functions support (GCC optimized)
# -Wno-missing-braces ignore invalid warning (GCC bug 53119) # -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB # -D_DEFAULT_SOURCE use with -std=c99
ifeq ($(PLATFORM),PLATFORM_DESKTOP) CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces
ifeq ($(PLATFORM_OS),WINDOWS)
CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces
endif
ifeq ($(PLATFORM_OS),LINUX)
CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE
endif
ifeq ($(PLATFORM_OS),OSX)
CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces
endif
endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources
# -O2 # if used, also set --memory-init-file 0 # -O2 # if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support # -s USE_PTHREADS=1 # multithreading support
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS = -O1 -Wall -std=gnu99 -fgnu89-inline -Wno-missing-braces
endif
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
@ -205,32 +228,32 @@ endif
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes #CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
# external required libraries (stb and others)
INCLUDES = -I. -Iexternal
# OpenAL Soft library
INCLUDES += -Iexternal/openal_soft/include
# define any directories containing required header files # define any directories containing required header files
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# STB libraries and others # GLFW3 library
INCLUDES = -I. -Iexternal
# OpenAL Soft library
INCLUDES += -Iexternal/openal_soft/include
# Android includes
INCLUDES += -I$(ANDROID_TOOLCHAIN)/sysroot/usr/include
INCLUDES += -I$(ANDROID_NDK)/sources/android/native_app_glue
else
# STB libraries and others
INCLUDES = -I. -Iexternal
# GLFW3 library
INCLUDES += -Iexternal/glfw3/include INCLUDES += -Iexternal/glfw3/include
# OpenAL Soft library
INCLUDES += -Iexternal/openal_soft/include
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI) ifeq ($(PLATFORM),PLATFORM_RPI)
# STB libraries and others # RPI requried libraries
INCLUDES = -I. -Iexternal
# RPi libraries
INCLUDES += -I/opt/vc/include INCLUDES += -I/opt/vc/include
INCLUDES += -I/opt/vc/include/interface/vmcs_host/linux INCLUDES += -I/opt/vc/include/interface/vmcs_host/linux
INCLUDES += -I/opt/vc/include/interface/vcos/pthreads INCLUDES += -I/opt/vc/include/interface/vcos/pthreads
# OpenAL Soft library endif
INCLUDES += -Iexternal/openal_soft/include ifeq ($(PLATFORM),PLATFORM_WEB)
# GLFW3 library
INCLUDES += -Iexternal/glfw3/include
endif
ifeq ($(PLATFORM),PLATFORM_ANDROID)
# Android required libraries
INCLUDES += -I$(ANDROID_TOOLCHAIN)/sysroot/usr/include
# Include android_native_app_glue.h
INCLUDES += -Iandroid/jni/include
#INCLUDES += -I$(ANDROID_NDK)/sources/android/native_app_glue
endif endif
# define output directory for compiled library # define output directory for compiled library
@ -245,6 +268,12 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
OUTPUT_PATH = ../release/osx OUTPUT_PATH = ../release/osx
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_RPI)
OUTPUT_PATH = ../release/rpi
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
OUTPUT_PATH = ../release/html5
endif
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_ANDROID)
ifeq ($(ANDROID_ARCH),ARM) ifeq ($(ANDROID_ARCH),ARM)
OUTPUT_PATH = ../release/android/armeabi-v7a OUTPUT_PATH = ../release/android/armeabi-v7a
@ -253,12 +282,6 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
OUTPUT_PATH = ../release/android/arm64-v8a OUTPUT_PATH = ../release/android/arm64-v8a
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB)
OUTPUT_PATH = ../release/html5
endif
ifeq ($(PLATFORM),PLATFORM_RPI)
OUTPUT_PATH = ../release/rpi
endif
# define all object files required with a wildcard # define all object files required with a wildcard
# The wildcard takes all files that finish with ".c", then it replaces the # The wildcard takes all files that finish with ".c", then it replaces the
@ -268,9 +291,10 @@ OBJS += external/stb_vorbis.o
# typing 'make' will invoke the default target entry called 'all', # typing 'make' will invoke the default target entry called 'all',
# in this case, the 'default' target entry is raylib # in this case, the 'default' target entry is raylib
all: toolchain raylib all: raylib
# make standalone Android toolchain # generate standalone Android toolchain
# NOTE: Android toolchain could already be provided
toolchain: toolchain:
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_ANDROID)
ifeq ($(ANDROID_ARCH),ARM) ifeq ($(ANDROID_ARCH),ARM)
@ -304,7 +328,7 @@ else
@echo "raylib shared library (libraylib.so) generated!" @echo "raylib shared library (libraylib.so) generated!"
endif endif
else else
# compile raylib static library. # compile raylib static library.
$(AR) rcs $(OUTPUT_PATH)/libraylib.a $(OBJS) $(AR) rcs $(OUTPUT_PATH)/libraylib.a $(OBJS)
@echo "libraylib.a generated (static library)!" @echo "libraylib.a generated (static library)!"
ifeq ($(SHARED_OPENAL),NO) ifeq ($(SHARED_OPENAL),NO)
@ -353,6 +377,7 @@ external/stb_vorbis.o: external/stb_vorbis.c external/stb_vorbis.h
utils.o : utils.c utils.h utils.o : utils.c utils.h
$(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(SHAREDFLAG) $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(SHAREDFLAG)
# It installs generated and needed files to compile projects using raylib. # It installs generated and needed files to compile projects using raylib.
# The installation works manually. # The installation works manually.
# TODO: add other platforms. # TODO: add other platforms.
@ -379,7 +404,7 @@ endif
# it removes raylib dev files installed on the system. # it removes raylib dev files installed on the system.
# TODO: see 'install' target. # TODO: see 'install' target.
unistall : uninstall :
ifeq ($(ROOT),root) ifeq ($(ROOT),root)
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
rm --force /usr/local/include/raylib.h rm --force /usr/local/include/raylib.h

View file

@ -79,7 +79,7 @@
#include "utils.h" // Required for: fopen() Android mapping #include "utils.h" // Required for: fopen() Android mapping
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__)
#include "OpenAL/al.h" // OpenAL basic header #include "OpenAL/al.h" // OpenAL basic header
#include "OpenAL/alc.h" // OpenAL context header (like OpenGL, OpenAL requires a context to work) #include "OpenAL/alc.h" // OpenAL context header (like OpenGL, OpenAL requires a context to work)
#else #else
@ -570,7 +570,7 @@ void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels)
// NOTE: Only supported mono <--> stereo // NOTE: Only supported mono <--> stereo
if (wave->channels != channels) if (wave->channels != channels)
{ {
void *data = malloc(wave->sampleCount*channels*wave->sampleSize/8); void *data = malloc(wave->sampleCount*wave->sampleSize/8*channels);
if ((wave->channels == 1) && (channels == 2)) // mono ---> stereo (duplicate mono information) if ((wave->channels == 1) && (channels == 2)) // mono ---> stereo (duplicate mono information)
{ {
@ -607,7 +607,7 @@ Wave WaveCopy(Wave wave)
{ {
Wave newWave = { 0 }; Wave newWave = { 0 };
newWave.data = malloc(wave.sampleCount*wave.channels*wave.sampleSize/8); newWave.data = malloc(wave.sampleCount*wave.sampleSize/8*wave.channels);
if (newWave.data != NULL) if (newWave.data != NULL)
{ {
@ -632,7 +632,7 @@ void WaveCrop(Wave *wave, int initSample, int finalSample)
{ {
int sampleCount = finalSample - initSample; int sampleCount = finalSample - initSample;
void *data = malloc(sampleCount*wave->channels*wave->sampleSize/8); void *data = malloc(sampleCount*wave->sampleSize/8*wave->channels);
memcpy(data, (unsigned char*)wave->data + (initSample*wave->channels*wave->sampleSize/8), sampleCount*wave->channels*wave->sampleSize/8); memcpy(data, (unsigned char*)wave->data + (initSample*wave->channels*wave->sampleSize/8), sampleCount*wave->channels*wave->sampleSize/8);
@ -810,7 +810,8 @@ void StopMusicStream(Music music)
for (int i = 0; i < MAX_STREAM_BUFFERS; i++) for (int i = 0; i < MAX_STREAM_BUFFERS; i++)
{ {
alBufferData(music->stream.buffers[i], music->stream.format, pcm, AUDIO_BUFFER_SIZE*music->stream.sampleSize/8*music->stream.channels, music->stream.sampleRate); UpdateAudioStream(music->stream, pcm, AUDIO_BUFFER_SIZE);
//alBufferData(music->stream.buffers[i], music->stream.format, pcm, AUDIO_BUFFER_SIZE*music->stream.sampleSize/8*music->stream.channels, music->stream.sampleRate);
} }
free(pcm); free(pcm);
@ -849,11 +850,11 @@ void UpdateMusicStream(Music music)
bool active = true; bool active = true;
// NOTE: Using dynamic allocation because it could require more than 16KB // NOTE: Using dynamic allocation because it could require more than 16KB
void *pcm = calloc(AUDIO_BUFFER_SIZE*music->stream.channels*music->stream.sampleSize/8, 1); void *pcm = calloc(AUDIO_BUFFER_SIZE*music->stream.sampleSize/8*music->stream.channels, 1);
int numBuffersToProcess = processed; int numBuffersToProcess = processed;
int samplesCount = 0; // Total size of data steamed in L+R samples for xm floats, int samplesCount = 0; // Total size of data steamed in L+R samples for xm floats,
//individual L or R for ogg shorts // individual L or R for ogg shorts
for (int i = 0; i < numBuffersToProcess; i++) for (int i = 0; i < numBuffersToProcess; i++)
{ {
@ -1245,23 +1246,19 @@ static Wave LoadWAV(const char *fileName)
// NOTE: Using stb_vorbis library // NOTE: Using stb_vorbis library
static Wave LoadOGG(const char *fileName) static Wave LoadOGG(const char *fileName)
{ {
Wave wave; Wave wave = { 0 };
stb_vorbis *oggFile = stb_vorbis_open_filename(fileName, NULL, NULL); stb_vorbis *oggFile = stb_vorbis_open_filename(fileName, NULL, NULL);
if (oggFile == NULL) if (oggFile == NULL) TraceLog(WARNING, "[%s] OGG file could not be opened", fileName);
{
TraceLog(WARNING, "[%s] OGG file could not be opened", fileName);
wave.data = NULL;
}
else else
{ {
stb_vorbis_info info = stb_vorbis_get_info(oggFile); stb_vorbis_info info = stb_vorbis_get_info(oggFile);
wave.sampleRate = info.sample_rate; wave.sampleRate = info.sample_rate;
wave.sampleSize = 16; // 16 bit per sample (short) wave.sampleSize = 16; // 16 bit per sample (short)
wave.channels = info.channels; wave.channels = info.channels;
wave.sampleCount = (int)stb_vorbis_stream_length_in_samples(oggFile); wave.sampleCount = (int)stb_vorbis_stream_length_in_samples(oggFile); // Independent by channel
float totalSeconds = stb_vorbis_stream_length_in_seconds(oggFile); float totalSeconds = stb_vorbis_stream_length_in_seconds(oggFile);
if (totalSeconds > 10) TraceLog(WARNING, "[%s] Ogg audio length is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds); if (totalSeconds > 10) TraceLog(WARNING, "[%s] Ogg audio length is larger than 10 seconds (%f), that's a big file in memory, consider music streaming", fileName, totalSeconds);
@ -1329,7 +1326,7 @@ void TraceLog(int msgType, const char *text, ...)
va_list args; va_list args;
int traceDebugMsgs = 0; int traceDebugMsgs = 0;
#ifdef DO_NOT_TRACE_DEBUG_MSGS #if defined(DO_NOT_TRACE_DEBUG_MSGS)
traceDebugMsgs = 0; traceDebugMsgs = 0;
#endif #endif

View file

@ -181,7 +181,14 @@ void SetCameraMoveControls(int frontKey, int backKey,
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Camera move modes (first person and third person cameras) // Camera move modes (first person and third person cameras)
typedef enum { MOVE_FRONT = 0, MOVE_BACK, MOVE_RIGHT, MOVE_LEFT, MOVE_UP, MOVE_DOWN } CameraMove; typedef enum {
MOVE_FRONT = 0,
MOVE_BACK,
MOVE_RIGHT,
MOVE_LEFT,
MOVE_UP,
MOVE_DOWN
} CameraMove;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition
@ -203,15 +210,14 @@ static int cameraMode = CAMERA_CUSTOM; // Current camera mode
#if defined(CAMERA_STANDALONE) #if defined(CAMERA_STANDALONE)
// NOTE: Camera controls depend on some raylib input functions // NOTE: Camera controls depend on some raylib input functions
// TODO: Set your own input functions (used in UpdateCamera()) // TODO: Set your own input functions (used in UpdateCamera())
static Vector2 GetMousePosition() { return (Vector2){ 0.0f, 0.0f }; } static void EnableCursor() {} // Unlock cursor
static void SetMousePosition(Vector2 pos) {} static void DisableCursor() {} // Lock cursor
static int IsKeyDown(int key) { return 0; }
static int IsMouseButtonDown(int button) { return 0;} static int IsMouseButtonDown(int button) { return 0;}
static int GetMouseWheelMove() { return 0; } static int GetMouseWheelMove() { return 0; }
static int GetScreenWidth() { return 1280; } static Vector2 GetMousePosition() { return (Vector2){ 0.0f, 0.0f }; }
static int GetScreenHeight() { return 720; }
static void ShowCursor() {}
static void HideCursor() {}
static int IsKeyDown(int key) { return 0; }
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -242,18 +248,23 @@ void SetCameraMode(Camera camera, int mode)
cameraAngle.y = -asinf(fabsf(dy)/distance.y); // Camera angle in plane XY (0 aligned with X, move positive CW) cameraAngle.y = -asinf(fabsf(dy)/distance.y); // Camera angle in plane XY (0 aligned with X, move positive CW)
// NOTE: Just testing what cameraAngle means // NOTE: Just testing what cameraAngle means
//cameraAngle.x = 0.0f*DEG2RAD; // Camera angle in plane XZ (0 aligned with Z, move positive CCW) //cameraAngle.x = 0.0f*DEG2RAD; // Camera angle in plane XZ (0 aligned with Z, move positive CCW)
//cameraAngle.y = -60.0f*DEG2RAD; // Camera angle in plane XY (0 aligned with X, move positive CW) //cameraAngle.y = -60.0f*DEG2RAD; // Camera angle in plane XY (0 aligned with X, move positive CW)
playerEyesPosition = camera.position.y; playerEyesPosition = camera.position.y;
// Lock cursor for first person and third person cameras
if ((mode == CAMERA_FIRST_PERSON) ||
(mode == CAMERA_THIRD_PERSON)) DisableCursor();
else EnableCursor();
cameraMode = mode; cameraMode = mode;
} }
// Update camera depending on selected mode // Update camera depending on selected mode
// NOTE: Camera controls depend on some raylib functions: // NOTE: Camera controls depend on some raylib functions:
// Mouse: GetMousePosition(), SetMousePosition(), IsMouseButtonDown(), GetMouseWheelMove() // System: EnableCursor(), DisableCursor()
// System: GetScreenWidth(), GetScreenHeight(), ShowCursor(), HideCursor() // Mouse: IsMouseButtonDown(), GetMousePosition(), GetMouseWheelMove()
// Keys: IsKeyDown() // Keys: IsKeyDown()
// TODO: Port to quaternion-based camera // TODO: Port to quaternion-based camera
void UpdateCamera(Camera *camera) void UpdateCamera(Camera *camera)
@ -284,36 +295,10 @@ void UpdateCamera(Camera *camera)
if (cameraMode != CAMERA_CUSTOM) if (cameraMode != CAMERA_CUSTOM)
{ {
// Get screen size mousePositionDelta.x = mousePosition.x - previousMousePosition.x;
int screenWidth = GetScreenWidth(); mousePositionDelta.y = mousePosition.y - previousMousePosition.y;
int screenHeight = GetScreenHeight();
if ((cameraMode == CAMERA_FIRST_PERSON) ||
(cameraMode == CAMERA_THIRD_PERSON))
{
HideCursor();
if (mousePosition.x < (float)screenHeight/3.0f) SetMousePosition((Vector2){ screenWidth - screenHeight/3, mousePosition.y }); previousMousePosition = mousePosition;
else if (mousePosition.y < (float)screenHeight/3.0f) SetMousePosition((Vector2){ mousePosition.x, screenHeight - screenHeight/3 });
else if (mousePosition.x > (screenWidth - (float)screenHeight/3.0f)) SetMousePosition((Vector2){ screenHeight/3, mousePosition.y });
else if (mousePosition.y > (screenHeight - (float)screenHeight/3.0f)) SetMousePosition((Vector2){ mousePosition.x, screenHeight/3 });
else
{
mousePositionDelta.x = mousePosition.x - previousMousePosition.x;
mousePositionDelta.y = mousePosition.y - previousMousePosition.y;
}
}
else // CAMERA_FREE, CAMERA_ORBITAL
{
ShowCursor();
mousePositionDelta.x = mousePosition.x - previousMousePosition.x;
mousePositionDelta.y = mousePosition.y - previousMousePosition.y;
}
// NOTE: We GetMousePosition() again because it can be modified by a previous SetMousePosition() call
// If using directly mousePosition variable we have problems on CAMERA_FIRST_PERSON and CAMERA_THIRD_PERSON
previousMousePosition = GetMousePosition();
} }
// Support for multiple automatic camera modes // Support for multiple automatic camera modes

View file

@ -5,11 +5,10 @@
* PLATFORMS SUPPORTED: * PLATFORMS SUPPORTED:
* - Windows (win32/Win64) * - Windows (win32/Win64)
* - Linux (tested on Ubuntu) * - Linux (tested on Ubuntu)
* - Mac (OSX) * - OSX (Mac)
* - Android (API Level 9 or greater) * - Android (ARM or ARM64)
* - Raspberry Pi (Raspbian) * - Raspberry Pi (Raspbian)
* - HTML5 (Chrome, Firefox) * - HTML5 (Chrome, Firefox)
* - Oculus Rift CV1
* *
* CONFIGURATION: * CONFIGURATION:
* *
@ -42,6 +41,9 @@
* #define SUPPORT_MOUSE_GESTURES * #define SUPPORT_MOUSE_GESTURES
* Mouse gestures are directly mapped like touches and processed by gestures system. * Mouse gestures are directly mapped like touches and processed by gestures system.
* *
* #define SUPPORT_BUSY_WAIT_LOOP
* Use busy wait loop for timming sync, if not defined, a high-resolution timer is setup and used
*
* DEPENDENCIES: * DEPENDENCIES:
* GLFW3 - Manage graphic device, OpenGL context and inputs on PLATFORM_DESKTOP (Windows, Linux, OSX) * GLFW3 - Manage graphic device, OpenGL context and inputs on PLATFORM_DESKTOP (Windows, Linux, OSX)
* raymath - 3D math functionality (Vector3, Matrix, Quaternion) * raymath - 3D math functionality (Vector3, Matrix, Quaternion)
@ -76,6 +78,7 @@
#define SUPPORT_MOUSE_GESTURES #define SUPPORT_MOUSE_GESTURES
#define SUPPORT_CAMERA_SYSTEM #define SUPPORT_CAMERA_SYSTEM
#define SUPPORT_GESTURES_SYSTEM #define SUPPORT_GESTURES_SYSTEM
#define SUPPORT_BUSY_WAIT_LOOP
//------------------------------------------------- //-------------------------------------------------
#include "raylib.h" #include "raylib.h"
@ -105,9 +108,9 @@
#include <string.h> // Required for: strrchr(), strcmp() #include <string.h> // Required for: strrchr(), strcmp()
//#include <errno.h> // Macros for reporting and retrieving error conditions through error codes //#include <errno.h> // Macros for reporting and retrieving error conditions through error codes
#if defined __linux__ || defined(PLATFORM_WEB) #if defined(__linux__) || defined(PLATFORM_WEB)
#include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX #include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX
#elif defined __APPLE__ #elif defined(__APPLE__)
#include <unistd.h> // Required for: usleep() #include <unistd.h> // Required for: usleep()
#endif #endif
@ -115,13 +118,19 @@
//#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3 //#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3
#include <GLFW/glfw3.h> // GLFW3 library: Windows, OpenGL context and Input management #include <GLFW/glfw3.h> // GLFW3 library: Windows, OpenGL context and Input management
#ifdef __linux__ #if defined(__linux__)
#define GLFW_EXPOSE_NATIVE_X11 // Linux specific definitions for getting #define GLFW_EXPOSE_NATIVE_X11 // Linux specific definitions for getting
#define GLFW_EXPOSE_NATIVE_GLX // native functions like glfwGetX11Window #define GLFW_EXPOSE_NATIVE_GLX // native functions like glfwGetX11Window
#include <GLFW/glfw3native.h> // which are required for hiding mouse #include <GLFW/glfw3native.h> // which are required for hiding mouse
#endif #endif
//#include <GL/gl.h> // OpenGL functions (GLFW3 already includes gl.h) //#include <GL/gl.h> // OpenGL functions (GLFW3 already includes gl.h)
//#define GLFW_DLL // Using GLFW DLL on Windows -> No, we use static version! //#define GLFW_DLL // Using GLFW DLL on Windows -> No, we use static version!
#if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32)
// NOTE: Those functions require linking with winmm library
__stdcall unsigned int timeBeginPeriod(unsigned int uPeriod);
__stdcall unsigned int timeEndPeriod(unsigned int uPeriod);
#endif
#endif #endif
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
@ -277,6 +286,10 @@ static int gamepadAxisCount = 0; // Register number of available game
static Vector2 mousePosition; // Mouse position on screen static Vector2 mousePosition; // Mouse position on screen
#if defined(PLATFORM_WEB)
static bool toggleCursorLock = false; // Ask for cursor pointer lock on next click
#endif
#if defined(SUPPORT_GESTURES_SYSTEM) #if defined(SUPPORT_GESTURES_SYSTEM)
static Vector2 touchPosition[MAX_TOUCH_POINTS]; // Touch position on screen static Vector2 touchPosition[MAX_TOUCH_POINTS]; // Touch position on screen
#endif #endif
@ -507,6 +520,10 @@ void CloseWindow(void)
glfwTerminate(); glfwTerminate();
#endif #endif
#if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32)
timeEndPeriod(1); // Restore time period
#endif
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) #if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
// Close surface, context and display // Close surface, context and display
if (display != EGL_NO_DISPLAY) if (display != EGL_NO_DISPLAY)
@ -629,6 +646,15 @@ void SetWindowMonitor(int monitor)
#endif #endif
} }
// Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
void SetWindowMinSize(int width, int height)
{
#if defined(PLATFORM_DESKTOP)
const GLFWvidmode *mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
glfwSetWindowSizeLimits(window, width, height, mode->width, mode->height);
#endif
}
// Get current screen width // Get current screen width
int GetScreenWidth(void) int GetScreenWidth(void)
{ {
@ -646,7 +672,7 @@ int GetScreenHeight(void)
void ShowCursor() void ShowCursor()
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
#ifdef __linux__ #if defined(__linux__)
XUndefineCursor(glfwGetX11Display(), glfwGetX11Window(window)); XUndefineCursor(glfwGetX11Display(), glfwGetX11Window(window));
#else #else
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
@ -659,7 +685,7 @@ void ShowCursor()
void HideCursor() void HideCursor()
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
#ifdef __linux__ #if defined(__linux__)
XColor col; XColor col;
const char nil[] = {0}; const char nil[] = {0};
@ -686,6 +712,9 @@ void EnableCursor()
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
#endif
#if defined(PLATFORM_WEB)
toggleCursorLock = true;
#endif #endif
cursorHidden = false; cursorHidden = false;
} }
@ -695,6 +724,9 @@ void DisableCursor()
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
#endif
#if defined(PLATFORM_WEB)
toggleCursorLock = true;
#endif #endif
cursorHidden = true; cursorHidden = true;
} }
@ -1657,7 +1689,7 @@ static void InitGraphicsDevice(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__ #if defined(__APPLE__)
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // OSX Requires glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // OSX Requires
#else #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!
@ -1799,12 +1831,13 @@ static void InitGraphicsDevice(int width, int height)
const EGLint framebufferAttribs[] = const EGLint framebufferAttribs[] =
{ {
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Type of context support -> Required on RPI? EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Type of context support -> Required on RPI?
//EGL_SURFACE_TYPE, EGL_WINDOW_BIT, // Don't use it on Android! //EGL_SURFACE_TYPE, EGL_WINDOW_BIT, // Don't use it on Android!
EGL_RED_SIZE, 8, // RED color bit depth (alternative: 5) EGL_RED_SIZE, 8, // RED color bit depth (alternative: 5)
EGL_GREEN_SIZE, 8, // GREEN color bit depth (alternative: 6) EGL_GREEN_SIZE, 8, // GREEN color bit depth (alternative: 6)
EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5) EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5)
//EGL_ALPHA_SIZE, 8, // ALPHA bit depth //EGL_ALPHA_SIZE, 8, // ALPHA bit depth
//EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_RGB, // Request transparent framebuffer
EGL_DEPTH_SIZE, 16, // Depth buffer size (Required to use Depth testing!) EGL_DEPTH_SIZE, 16, // Depth buffer size (Required to use Depth testing!)
//EGL_STENCIL_SIZE, 8, // Stencil buffer size //EGL_STENCIL_SIZE, 8, // Stencil buffer size
EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA
@ -1942,7 +1975,7 @@ static void InitGraphicsDevice(int width, int height)
// Set viewport parameters // Set viewport parameters
static void SetupViewport(void) static void SetupViewport(void)
{ {
#ifdef __APPLE__ #if defined(__APPLE__)
// Get framebuffer size of current window // Get framebuffer size of current window
// NOTE: Required to handle HighDPI display correctly on OSX because framebuffer // NOTE: Required to handle HighDPI display correctly on OSX because framebuffer
// is automatically reasized to adapt to new DPI. // is automatically reasized to adapt to new DPI.
@ -2034,6 +2067,10 @@ static void SetupFramebufferSize(int displayWidth, int displayHeight)
static void InitTimer(void) static void InitTimer(void)
{ {
srand(time(NULL)); // Initialize random seed srand(time(NULL)); // Initialize random seed
#if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32)
timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
#endif
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) #if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
struct timespec now; struct timespec now;
@ -2070,7 +2107,6 @@ static double GetTime(void)
// http://stackoverflow.com/questions/43057578/c-programming-win32-games-sleep-taking-longer-than-expected // http://stackoverflow.com/questions/43057578/c-programming-win32-games-sleep-taking-longer-than-expected
static void Wait(float ms) static void Wait(float ms)
{ {
#define SUPPORT_BUSY_WAIT_LOOP
#if defined(SUPPORT_BUSY_WAIT_LOOP) #if defined(SUPPORT_BUSY_WAIT_LOOP)
double prevTime = GetTime(); double prevTime = GetTime();
double nextTime = 0.0; double nextTime = 0.0;
@ -2078,9 +2114,9 @@ static void Wait(float ms)
// Busy wait loop // Busy wait loop
while ((nextTime - prevTime) < ms/1000.0f) nextTime = GetTime(); while ((nextTime - prevTime) < ms/1000.0f) nextTime = GetTime();
#else #else
#if defined _WIN32 #if defined(_WIN32)
Sleep((unsigned int)ms); Sleep((unsigned int)ms);
#elif defined __linux__ || defined(PLATFORM_WEB) #elif defined(__linux__) || defined(PLATFORM_WEB)
struct timespec req = { 0 }; struct timespec req = { 0 };
time_t sec = (int)(ms/1000.0f); time_t sec = (int)(ms/1000.0f);
ms -= (sec*1000); ms -= (sec*1000);
@ -2089,7 +2125,7 @@ static void Wait(float ms)
// NOTE: Use nanosleep() on Unix platforms... usleep() it's deprecated. // NOTE: Use nanosleep() on Unix platforms... usleep() it's deprecated.
while (nanosleep(&req, &req) == -1) continue; while (nanosleep(&req, &req) == -1) continue;
#elif defined __APPLE__ #elif defined(__APPLE__)
usleep(ms*1000.0f); usleep(ms*1000.0f);
#endif #endif
#endif #endif
@ -2719,7 +2755,8 @@ static EM_BOOL EmscriptenKeyboardCallback(int eventType, const EmscriptenKeyboar
// Register mouse input events // Register mouse input events
static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData)
{ {
if (eventType == EMSCRIPTEN_EVENT_CLICK) // Lock mouse pointer when click on screen
if ((eventType == EMSCRIPTEN_EVENT_CLICK) && toggleCursorLock)
{ {
EmscriptenPointerlockChangeEvent plce; EmscriptenPointerlockChangeEvent plce;
emscripten_get_pointerlock_status(&plce); emscripten_get_pointerlock_status(&plce);
@ -2731,6 +2768,8 @@ static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent
emscripten_get_pointerlock_status(&plce); emscripten_get_pointerlock_status(&plce);
//if (plce.isActive) TraceLog(WARNING, "Pointer lock exit did not work!"); //if (plce.isActive) TraceLog(WARNING, "Pointer lock exit did not work!");
} }
toggleCursorLock = false;
} }
return 0; return 0;
@ -3251,7 +3290,7 @@ static void *GamepadThread(void *arg)
// Plays raylib logo appearing animation // Plays raylib logo appearing animation
static void LogoAnimation(void) static void LogoAnimation(void)
{ {
#ifndef PLATFORM_WEB #if !defined(PLATFORM_WEB)
int logoPositionX = screenWidth/2 - 128; int logoPositionX = screenWidth/2 - 128;
int logoPositionY = screenHeight/2 - 128; int logoPositionY = screenHeight/2 - 128;

View file

@ -1218,11 +1218,13 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota
Matrix matRotation = MatrixRotate(rotationAxis, rotationAngle*DEG2RAD); Matrix matRotation = MatrixRotate(rotationAxis, rotationAngle*DEG2RAD);
Matrix matScale = MatrixScale(scale.x, scale.y, scale.z); Matrix matScale = MatrixScale(scale.x, scale.y, scale.z);
Matrix matTranslation = MatrixTranslate(position.x, position.y, position.z); Matrix matTranslation = MatrixTranslate(position.x, position.y, position.z);
Matrix matTransform = MatrixMultiply(MatrixMultiply(matScale, matRotation), matTranslation);
// Combine model transformation matrix (model.transform) with matrix generated by function parameters (matTransform) // Combine model transformation matrix (model.transform) with matrix generated by function parameters (matTransform)
//Matrix matModel = MatrixMultiply(model.transform, matTransform); // Transform to world-space coordinates //Matrix matModel = MatrixMultiply(model.transform, matTransform); // Transform to world-space coordinates
model.transform = MatrixMultiply(MatrixMultiply(matScale, matRotation), matTranslation); model.transform = MatrixMultiply(model.transform, matTransform);
model.material.colDiffuse = tint; // TODO: Multiply tint color by diffuse color? model.material.colDiffuse = tint; // TODO: Multiply tint color by diffuse color?
rlglDrawMesh(model.mesh, model.material, model.transform); rlglDrawMesh(model.mesh, model.material, model.transform);

View file

@ -351,7 +351,7 @@ typedef struct Image {
int format; // Data format (TextureFormat type) int format; // Data format (TextureFormat type)
} Image; } Image;
// Texture2D type, bpp always RGBA (32bit) // Texture2D type
// NOTE: Data stored in GPU memory // NOTE: Data stored in GPU memory
typedef struct Texture2D { typedef struct Texture2D {
unsigned int id; // OpenGL texture id unsigned int id; // OpenGL texture id
@ -553,6 +553,7 @@ typedef enum {
UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha) UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha) UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
UNCOMPRESSED_R8G8B8A8, // 32 bpp UNCOMPRESSED_R8G8B8A8, // 32 bpp
UNCOMPRESSED_R32G32B32, // 32 bit per channel (float) - HDR
COMPRESSED_DXT1_RGB, // 4 bpp (no alpha) COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha) COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
COMPRESSED_DXT3_RGBA, // 8 bpp COMPRESSED_DXT3_RGBA, // 8 bpp
@ -667,6 +668,7 @@ RLAPI void ToggleFullscreen(void); // Fullscreen
RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP) RLAPI void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP)
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP) RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode) RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenWidth(void); // Get current screen width
RLAPI int GetScreenHeight(void); // Get current screen height RLAPI int GetScreenHeight(void); // Get current screen height

View file

@ -189,8 +189,10 @@ RMDEF Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float slerp); //
RMDEF Quaternion QuaternionFromMatrix(Matrix matrix); // Returns a quaternion for a given rotation matrix RMDEF Quaternion QuaternionFromMatrix(Matrix matrix); // Returns a quaternion for a given rotation matrix
RMDEF Matrix QuaternionToMatrix(Quaternion q); // Returns a matrix for a given quaternion RMDEF Matrix QuaternionToMatrix(Quaternion q); // Returns a matrix for a given quaternion
RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle); // Returns rotation quaternion for an angle and axis RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle); // Returns rotation quaternion for an angle and axis
RMDEF void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle); // Returns the rotation angle and axis for a given quaternion RMDEF void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle); // Returns the rotation angle and axis for a given quaternion
RMDEF void QuaternionTransform(Quaternion *q, Matrix mat); // Transform a quaternion given a transformation matrix RMDEF Quaternion QuaternionFromEuler(float roll, float pitch, float yaw); // Returns he quaternion equivalent to Euler angles
RMDEF Vector3 QuaternionToEuler(Quaternion q); // Return the Euler angles equivalent to quaternion (roll, pitch, yaw)
RMDEF void QuaternionTransform(Quaternion *q, Matrix mat); // Transform a quaternion given a transformation matrix
#endif // notdef RAYMATH_EXTERN_INLINE #endif // notdef RAYMATH_EXTERN_INLINE
@ -1180,6 +1182,51 @@ RMDEF void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle
*outAngle = resAngle; *outAngle = resAngle;
} }
// Returns he quaternion equivalent to Euler angles
RMDEF Quaternion QuaternionFromEuler(float roll, float pitch, float yaw)
{
Quaternion q = { 0 };
float x0 = cosf(roll*0.5f);
float x1 = sinf(roll*0.5f);
float y0 = cosf(pitch*0.5f);
float y1 = sinf(pitch*0.5f);
float z0 = cosf(yaw*0.5f);
float z1 = sinf(yaw*0.5f);
q.x = x1*y0*z0 - x0*y1*z1;
q.y = x0*y1*z0 + x1*y0*z1;
q.z = x0*y0*z1 - x1*y1*z0;
q.w = x0*y0*z0 + x1*y1*z1;
return q;
}
// Return the Euler angles equivalent to quaternion (roll, pitch, yaw)
// NOTE: Angles are returned in a Vector3 struct and in degrees
RMDEF Vector3 QuaternionToEuler(Quaternion q)
{
Vector3 v = { 0 };
// roll (x-axis rotation)
float x0 = 2.0f*(q.w*q.x + q.y*q.z);
float x1 = 1.0f - 2.0f*(q.x*q.x + q.y*q.y);
v.x = atan2f(x0, x1)*RAD2DEG;
// pitch (y-axis rotation)
float y0 = 2.0f*(q.w*q.y - q.z*q.x);
y0 = y0 > 1.0f ? 1.0f : y0;
y0 = y0 < -1.0f ? -1.0f : y0;
v.y = asinf(y0)*RAD2DEG;
// yaw (z-axis rotation)
float z0 = 2.0f*(q.w*q.z + q.x*q.y);
float z1 = 1.0f - 2.0f*(q.y*q.y + q.z*q.z);
v.z = atan2f(z0, z1)*RAD2DEG;
return v;
}
// Transform a quaternion given a transformation matrix // Transform a quaternion given a transformation matrix
RMDEF void QuaternionTransform(Quaternion *q, Matrix mat) RMDEF void QuaternionTransform(Quaternion *q, Matrix mat)
{ {

View file

@ -64,15 +64,15 @@
#include <stdio.h> // Required for: fopen(), fclose(), fread()... [Used only on LoadText()] #include <stdio.h> // Required for: fopen(), fclose(), fread()... [Used only on LoadText()]
#include <stdlib.h> // Required for: malloc(), free(), rand() #include <stdlib.h> // Required for: malloc(), free(), rand()
#include <string.h> // Required for: strcmp(), strlen(), strtok() #include <string.h> // Required for: strcmp(), strlen(), strtok() [Used only in extensions loading]
#include <math.h> // Required for: atan2() #include <math.h> // Required for: atan2()
#ifndef RLGL_STANDALONE #if !defined(RLGL_STANDALONE)
#include "raymath.h" // Required for: Vector3 and Matrix functions #include "raymath.h" // Required for: Vector3 and Matrix functions
#endif #endif
#if defined(GRAPHICS_API_OPENGL_11) #if defined(GRAPHICS_API_OPENGL_11)
#ifdef __APPLE__ #if defined(__APPLE__)
#include <OpenGL/gl.h> // OpenGL 1.1 library for OSX #include <OpenGL/gl.h> // OpenGL 1.1 library for OSX
#else #else
#include <GL/gl.h> // OpenGL 1.1 library #include <GL/gl.h> // OpenGL 1.1 library
@ -84,7 +84,7 @@
#endif #endif
#if defined(GRAPHICS_API_OPENGL_33) #if defined(GRAPHICS_API_OPENGL_33)
#ifdef __APPLE__ #if defined(__APPLE__)
#include <OpenGL/gl3.h> // OpenGL 3 library for OSX #include <OpenGL/gl3.h> // OpenGL 3 library for OSX
#else #else
#define GLAD_IMPLEMENTATION #define GLAD_IMPLEMENTATION
@ -317,7 +317,8 @@ static PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArrays;
// Compressed textures support flags // Compressed textures support flags
static bool texCompDXTSupported = false; // DDS texture compression support static bool texCompDXTSupported = false; // DDS texture compression support
static bool npotSupported = false; // NPOT textures full support static bool texNPOTSupported = false; // NPOT textures full support
static bool texFloatSupported = false; // float textures support (32 bit per channel)
static int blendMode = 0; // Track current blending mode static int blendMode = 0; // Track current blending mode
@ -1050,7 +1051,7 @@ void rlglInit(int width, int height)
// NOTE: On OpenGL 3.3 VAO and NPOT are supported by default // NOTE: On OpenGL 3.3 VAO and NPOT are supported by default
vaoSupported = true; vaoSupported = true;
npotSupported = true; texNPOTSupported = true;
// We get a list of available extensions and we check for some of them (compressed textures) // We get a list of available extensions and we check for some of them (compressed textures)
// NOTE: We don't need to check again supported extensions but we do (GLAD already dealt with that) // NOTE: We don't need to check again supported extensions but we do (GLAD already dealt with that)
@ -1119,7 +1120,10 @@ void rlglInit(int width, int height)
// Check NPOT textures support // Check NPOT textures support
// NOTE: Only check on OpenGL ES, OpenGL 3.3 has NPOT textures full support as core feature // NOTE: Only check on OpenGL ES, OpenGL 3.3 has NPOT textures full support as core feature
if (strcmp(extList[i], (const char *)"GL_OES_texture_npot") == 0) npotSupported = true; if (strcmp(extList[i], (const char *)"GL_OES_texture_npot") == 0) texNPOTSupported = true;
// Check texture float support
if (strcmp(extList[i], (const char *)"OES_texture_float") == 0) texFloatSupported = true;
#endif #endif
// DDS texture compression support // DDS texture compression support
@ -1159,7 +1163,7 @@ void rlglInit(int width, int height)
if (vaoSupported) TraceLog(INFO, "[EXTENSION] VAO extension detected, VAO functions initialized successfully"); if (vaoSupported) TraceLog(INFO, "[EXTENSION] VAO extension detected, VAO functions initialized successfully");
else TraceLog(WARNING, "[EXTENSION] VAO extension not found, VAO usage not supported"); else TraceLog(WARNING, "[EXTENSION] VAO extension not found, VAO usage not supported");
if (npotSupported) TraceLog(INFO, "[EXTENSION] NPOT textures extension detected, full NPOT textures supported"); if (texNPOTSupported) TraceLog(INFO, "[EXTENSION] NPOT textures extension detected, full NPOT textures supported");
else TraceLog(WARNING, "[EXTENSION] NPOT textures extension not found, limited NPOT support (no-mipmaps, no-repeat)"); else TraceLog(WARNING, "[EXTENSION] NPOT textures extension not found, limited NPOT support (no-mipmaps, no-repeat)");
#endif #endif
@ -1286,21 +1290,17 @@ void rlglLoadExtensions(void *loader)
{ {
#if defined(GRAPHICS_API_OPENGL_21) || defined(GRAPHICS_API_OPENGL_33) #if defined(GRAPHICS_API_OPENGL_21) || defined(GRAPHICS_API_OPENGL_33)
// NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions (and lower versions) // NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions (and lower versions)
#ifndef __APPLE__ #if !defined(__APPLE__)
if (!gladLoadGLLoader((GLADloadproc)loader)) TraceLog(WARNING, "GLAD: Cannot load OpenGL extensions"); if (!gladLoadGLLoader((GLADloadproc)loader)) TraceLog(WARNING, "GLAD: Cannot load OpenGL extensions");
else TraceLog(INFO, "GLAD: OpenGL extensions loaded successfully"); else TraceLog(INFO, "GLAD: OpenGL extensions loaded successfully");
#endif
#if defined(GRAPHICS_API_OPENGL_21) #if defined(GRAPHICS_API_OPENGL_21)
#ifndef __APPLE__
if (GLAD_GL_VERSION_2_1) TraceLog(INFO, "OpenGL 2.1 profile supported"); if (GLAD_GL_VERSION_2_1) TraceLog(INFO, "OpenGL 2.1 profile supported");
#endif #elif defined(GRAPHICS_API_OPENGL_33)
#elif defined(GRAPHICS_API_OPENGL_33)
#ifndef __APPLE__
if(GLAD_GL_VERSION_3_3) TraceLog(INFO, "OpenGL 3.3 Core profile supported"); if(GLAD_GL_VERSION_3_3) TraceLog(INFO, "OpenGL 3.3 Core profile supported");
else TraceLog(ERROR, "OpenGL 3.3 Core profile not supported"); else TraceLog(ERROR, "OpenGL 3.3 Core profile not supported");
#endif
#endif #endif
#endif
// With GLAD, we can check if an extension is supported using the GLAD_GL_xxx booleans // With GLAD, we can check if an extension is supported using the GLAD_GL_xxx booleans
//if (GLAD_GL_ARB_vertex_array_object) // Use GL_ARB_vertex_array_object //if (GLAD_GL_ARB_vertex_array_object) // Use GL_ARB_vertex_array_object
@ -1425,6 +1425,7 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int format, int
case UNCOMPRESSED_R5G5B5A1: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (unsigned short *)data); break; case UNCOMPRESSED_R5G5B5A1: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, (unsigned short *)data); break;
case UNCOMPRESSED_R4G4B4A4: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA4, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (unsigned short *)data); break; case UNCOMPRESSED_R4G4B4A4: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA4, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (unsigned short *)data); break;
case UNCOMPRESSED_R8G8B8A8: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char *)data); break; case UNCOMPRESSED_R8G8B8A8: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char *)data); break;
case UNCOMPRESSED_R32G32B32: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, height, 0, GL_RGB, GL_FLOAT, (float *)data); break;
case COMPRESSED_DXT1_RGB: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGB_S3TC_DXT1_EXT); break; case COMPRESSED_DXT1_RGB: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGB_S3TC_DXT1_EXT); break;
case COMPRESSED_DXT1_RGBA: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); break; case COMPRESSED_DXT1_RGBA: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); break;
case COMPRESSED_DXT3_RGBA: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); break; case COMPRESSED_DXT3_RGBA: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); break;
@ -1450,6 +1451,7 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int format, int
case UNCOMPRESSED_R4G4B4A4: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (unsigned short *)data); break; case UNCOMPRESSED_R4G4B4A4: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, (unsigned short *)data); break;
case UNCOMPRESSED_R8G8B8A8: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char *)data); break; case UNCOMPRESSED_R8G8B8A8: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char *)data); break;
#if defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_ES2)
case UNCOMPRESSED_R32G32B32: if (texFloatSupported) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_FLOAT, (float *)data); break; // Requries extension OES_texture_float
case COMPRESSED_DXT1_RGB: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGB_S3TC_DXT1_EXT); break; case COMPRESSED_DXT1_RGB: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGB_S3TC_DXT1_EXT); break;
case COMPRESSED_DXT1_RGBA: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); break; case COMPRESSED_DXT1_RGBA: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); break;
case COMPRESSED_DXT3_RGBA: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); break; // NOTE: Not supported by WebGL case COMPRESSED_DXT3_RGBA: if (texCompDXTSupported) LoadCompressedTexture((unsigned char *)data, width, height, mipmapCount, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); break; // NOTE: Not supported by WebGL
@ -1470,7 +1472,7 @@ unsigned int rlglLoadTexture(void *data, int width, int height, int format, int
// NOTE: glTexParameteri does NOT affect texture uploading, just the way it's used // NOTE: glTexParameteri does NOT affect texture uploading, just the way it's used
#if defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_ES2)
// NOTE: OpenGL ES 2.0 with no GL_OES_texture_npot support (i.e. WebGL) has limited NPOT support, so CLAMP_TO_EDGE must be used // NOTE: OpenGL ES 2.0 with no GL_OES_texture_npot support (i.e. WebGL) has limited NPOT support, so CLAMP_TO_EDGE must be used
if (npotSupported) if (texNPOTSupported)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Set texture to repeat on x-axis glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Set texture to repeat on x-axis
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Set texture to repeat on y-axis glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Set texture to repeat on y-axis
@ -1650,7 +1652,7 @@ void rlglGenerateMipmaps(Texture2D *texture)
if (((texture->width > 0) && ((texture->width & (texture->width - 1)) == 0)) && if (((texture->width > 0) && ((texture->width & (texture->width - 1)) == 0)) &&
((texture->height > 0) && ((texture->height & (texture->height - 1)) == 0))) texIsPOT = true; ((texture->height > 0) && ((texture->height & (texture->height - 1)) == 0))) texIsPOT = true;
if ((texIsPOT) || (npotSupported)) if ((texIsPOT) || (texNPOTSupported))
{ {
#if defined(GRAPHICS_API_OPENGL_11) #if defined(GRAPHICS_API_OPENGL_11)
// Compute required mipmaps // Compute required mipmaps

View file

@ -17,7 +17,9 @@
* #define GRAPHICS_API_OPENGL_21 * #define GRAPHICS_API_OPENGL_21
* #define GRAPHICS_API_OPENGL_33 * #define GRAPHICS_API_OPENGL_33
* #define GRAPHICS_API_OPENGL_ES2 * #define GRAPHICS_API_OPENGL_ES2
* Use selected OpenGL backend * Use selected OpenGL graphics backend, should be supported by platform
* Those preprocessor defines are only used on rlgl module, if OpenGL version is
* required by any other module, use rlGetVersion() tocheck it
* *
* #define RLGL_STANDALONE * #define RLGL_STANDALONE
* Use rlgl as standalone library (no raylib dependency) * Use rlgl as standalone library (no raylib dependency)
@ -35,7 +37,7 @@
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -57,28 +59,14 @@
#ifndef RLGL_H #ifndef RLGL_H
#define RLGL_H #define RLGL_H
//#define RLGL_STANDALONE // NOTE: To use rlgl as standalone lib, just uncomment this line #if defined(RLGL_STANDALONE)
#ifndef RLGL_STANDALONE
#include "raylib.h" // Required for: Model, Shader, Texture2D
#include "utils.h" // Required for: TraceLog()
#endif
#ifdef RLGL_STANDALONE
#define RAYMATH_STANDALONE #define RAYMATH_STANDALONE
#else
#include "raylib.h" // Required for: Model, Shader, Texture2D, TraceLog()
#endif #endif
#include "raymath.h" // Required for: Vector3, Matrix #include "raymath.h" // Required for: Vector3, Matrix
// Select desired OpenGL version
// NOTE: Those preprocessor defines are only used on rlgl module,
// if OpenGL version is required by any other module, it uses rlGetVersion()
// Choose opengl version here or just define it at compile time: -DGRAPHICS_API_OPENGL_33
//#define GRAPHICS_API_OPENGL_11 // Only available on PLATFORM_DESKTOP
//#define GRAPHICS_API_OPENGL_33 // Only available on PLATFORM_DESKTOP and RLGL_OCULUS_SUPPORT
//#define GRAPHICS_API_OPENGL_ES2 // Only available on PLATFORM_ANDROID or PLATFORM_RPI or PLATFORM_WEB
// Security check in case no GRAPHICS_API_OPENGL_* defined // Security check in case no GRAPHICS_API_OPENGL_* defined
#if !defined(GRAPHICS_API_OPENGL_11) && !defined(GRAPHICS_API_OPENGL_21) && !defined(GRAPHICS_API_OPENGL_33) && !defined(GRAPHICS_API_OPENGL_ES2) #if !defined(GRAPHICS_API_OPENGL_11) && !defined(GRAPHICS_API_OPENGL_21) && !defined(GRAPHICS_API_OPENGL_33) && !defined(GRAPHICS_API_OPENGL_ES2)
#define GRAPHICS_API_OPENGL_11 #define GRAPHICS_API_OPENGL_11
@ -165,28 +153,23 @@ typedef unsigned char byte;
unsigned char b; unsigned char b;
unsigned char a; unsigned char a;
} Color; } Color;
// Texture2D type
// NOTE: Data stored in GPU memory
typedef struct Texture2D {
unsigned int id; // OpenGL texture id
int width; // Texture base width
int height; // Texture base height
int mipmaps; // Mipmap levels, 1 by default
int format; // Data format (TextureFormat)
} Texture2D;
// Texture formats (support depends on OpenGL version) // RenderTexture2D type, for texture rendering
typedef enum { typedef struct RenderTexture2D {
UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha) unsigned int id; // Render texture (fbo) id
UNCOMPRESSED_GRAY_ALPHA, Texture2D texture; // Color buffer attachment texture
UNCOMPRESSED_R5G6B5, // 16 bpp Texture2D depth; // Depth buffer attachment texture
UNCOMPRESSED_R8G8B8, // 24 bpp } RenderTexture2D;
UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
UNCOMPRESSED_R8G8B8A8, // 32 bpp
COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
COMPRESSED_DXT3_RGBA, // 8 bpp
COMPRESSED_DXT5_RGBA, // 8 bpp
COMPRESSED_ETC1_RGB, // 4 bpp
COMPRESSED_ETC2_RGB, // 4 bpp
COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
COMPRESSED_PVRT_RGB, // 4 bpp
COMPRESSED_PVRT_RGBA, // 4 bpp
COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
COMPRESSED_ASTC_8x8_RGBA // 2 bpp
} TextureFormat;
// Vertex data definning a mesh // Vertex data definning a mesh
typedef struct Mesh { typedef struct Mesh {
@ -228,23 +211,6 @@ typedef unsigned char byte;
int mapTexture2Loc; // Map texture uniform location point (default-texture-unit = 2) int mapTexture2Loc; // Map texture uniform location point (default-texture-unit = 2)
} Shader; } Shader;
// Texture2D type
// NOTE: Data stored in GPU memory
typedef struct Texture2D {
unsigned int id; // OpenGL texture id
int width; // Texture base width
int height; // Texture base height
int mipmaps; // Mipmap levels, 1 by default
int format; // Data format (TextureFormat)
} Texture2D;
// RenderTexture2D type, for texture rendering
typedef struct RenderTexture2D {
unsigned int id; // Render texture (fbo) id
Texture2D texture; // Color buffer attachment texture
Texture2D depth; // Depth buffer attachment texture
} RenderTexture2D;
// Material type // Material type
typedef struct Material { typedef struct Material {
Shader shader; // Standard shader (supports 3 map types: diffuse, normal, specular) Shader shader; // Standard shader (supports 3 map types: diffuse, normal, specular)
@ -267,6 +233,38 @@ typedef unsigned char byte;
Vector3 up; // Camera up vector (rotation over its axis) Vector3 up; // Camera up vector (rotation over its axis)
float fovy; // Camera field-of-view apperture in Y (degrees) float fovy; // Camera field-of-view apperture in Y (degrees)
} Camera; } Camera;
// TraceLog message types
typedef enum {
INFO = 0,
ERROR,
WARNING,
DEBUG,
OTHER
} TraceLogType;
// Texture formats (support depends on OpenGL version)
typedef enum {
UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
UNCOMPRESSED_GRAY_ALPHA,
UNCOMPRESSED_R5G6B5, // 16 bpp
UNCOMPRESSED_R8G8B8, // 24 bpp
UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
UNCOMPRESSED_R8G8B8A8, // 32 bpp
UNCOMPRESSED_R32G32B32, // 32 bit per channel (float) - HDR
COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
COMPRESSED_DXT3_RGBA, // 8 bpp
COMPRESSED_DXT5_RGBA, // 8 bpp
COMPRESSED_ETC1_RGB, // 4 bpp
COMPRESSED_ETC2_RGB, // 4 bpp
COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
COMPRESSED_PVRT_RGB, // 4 bpp
COMPRESSED_PVRT_RGBA, // 4 bpp
COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
COMPRESSED_ASTC_8x8_RGBA // 2 bpp
} TextureFormat;
// Texture parameters: filter mode // Texture parameters: filter mode
// NOTE 1: Filtering considers mipmaps if available in the texture // NOTE 1: Filtering considers mipmaps if available in the texture
@ -281,13 +279,18 @@ typedef unsigned char byte;
} TextureFilterMode; } TextureFilterMode;
// Texture parameters: wrap mode // Texture parameters: wrap mode
typedef enum { WRAP_REPEAT = 0, WRAP_CLAMP, WRAP_MIRROR } TextureWrapMode; typedef enum {
WRAP_REPEAT = 0,
WRAP_CLAMP,
WRAP_MIRROR
} TextureWrapMode;
// Color blending modes (pre-defined) // Color blending modes (pre-defined)
typedef enum { BLEND_ALPHA = 0, BLEND_ADDITIVE, BLEND_MULTIPLIED } BlendMode; typedef enum {
BLEND_ALPHA = 0,
// TraceLog message types BLEND_ADDITIVE,
typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType; BLEND_MULTIPLIED
} BlendMode;
// VR Head Mounted Display devices // VR Head Mounted Display devices
typedef enum { typedef enum {

View file

@ -443,7 +443,7 @@ void DrawTextEx(SpriteFont spriteFont, const char *text, Vector2 position, float
index = GetCharIndex(spriteFont, (int)letter + 64); index = GetCharIndex(spriteFont, (int)letter + 64);
i++; i++;
} }
else index = GetCharIndex(spriteFont, (int)text[i]); else index = GetCharIndex(spriteFont, (unsigned char)text[i]);
DrawTexturePro(spriteFont.texture, spriteFont.chars[index].rec, DrawTexturePro(spriteFont.texture, spriteFont.chars[index].rec,
(Rectangle){ position.x + textOffsetX + spriteFont.chars[index].offsetX*scaleFactor, (Rectangle){ position.x + textOffsetX + spriteFont.chars[index].offsetX*scaleFactor,

View file

@ -53,6 +53,7 @@
// Default configuration flags (supported features) // Default configuration flags (supported features)
//------------------------------------------------- //-------------------------------------------------
#define SUPPORT_FILEFORMAT_PNG #define SUPPORT_FILEFORMAT_PNG
#define SUPPORT_FILEFORMAT_HDR
#define SUPPORT_IMAGE_MANIPULATION #define SUPPORT_IMAGE_MANIPULATION
//------------------------------------------------- //-------------------------------------------------
@ -98,7 +99,7 @@
defined(SUPPORT_FILEFORMAT_JPG) || defined(SUPPORT_FILEFORMAT_PSD) || defined(SUPPORT_FILEFORMAT_GIF) || \ defined(SUPPORT_FILEFORMAT_JPG) || defined(SUPPORT_FILEFORMAT_PSD) || defined(SUPPORT_FILEFORMAT_GIF) || \
defined(SUPPORT_FILEFORMAT_HDR)) defined(SUPPORT_FILEFORMAT_HDR))
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include "external/stb_image.h" // Required for: stbi_load() #include "external/stb_image.h" // Required for: stbi_load_from_file()
// NOTE: Used to read image data (multiple formats support) // NOTE: Used to read image data (multiple formats support)
#endif #endif
@ -154,14 +155,7 @@ static Image LoadASTC(const char *fileName); // Load ASTC file
// Load image from file into CPU memory (RAM) // Load image from file into CPU memory (RAM)
Image LoadImage(const char *fileName) Image LoadImage(const char *fileName)
{ {
Image image; Image image = { 0 };
// Initialize image default values
image.data = NULL;
image.width = 0;
image.height = 0;
image.mipmaps = 0;
image.format = 0;
if (IsFileExtension(fileName, ".rres")) if (IsFileExtension(fileName, ".rres"))
{ {
@ -212,6 +206,29 @@ Image LoadImage(const char *fileName)
else if (imgBpp == 3) image.format = UNCOMPRESSED_R8G8B8; else if (imgBpp == 3) image.format = UNCOMPRESSED_R8G8B8;
else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8; else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8;
} }
#if defined(SUPPORT_FILEFORMAT_HDR)
else if (IsFileExtension(fileName, ".hdr"))
{
int imgBpp = 0;
FILE *imFile = fopen(fileName, "rb");
// Load 32 bit per channel floats data
image.data = stbi_loadf_from_file(imFile, &image.width, &image.height, &imgBpp, 0);
fclose(imFile);
image.mipmaps = 1;
if (imgBpp == 3) image.format = UNCOMPRESSED_R32G32B32;
else
{
// TODO: Support different number of channels at 32 bit float
TraceLog(WARNING, "[%s] Image fileformat not supported (only 3 channel 32 bit floats)", fileName);
UnloadImage(image);
}
}
#endif
#if defined(SUPPORT_FILEFORMAT_DDS) #if defined(SUPPORT_FILEFORMAT_DDS)
else if (IsFileExtension(fileName, ".dds")) image = LoadDDS(fileName); else if (IsFileExtension(fileName, ".dds")) image = LoadDDS(fileName);
#endif #endif
@ -282,13 +299,7 @@ Image LoadImagePro(void *data, int width, int height, int format)
// Load an image from RAW file data // Load an image from RAW file data
Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize) Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize)
{ {
Image image; Image image = { 0 };
image.data = NULL;
image.width = 0;
image.height = 0;
image.mipmaps = 0;
image.format = 0;
FILE *rawFile = fopen(fileName, "rb"); FILE *rawFile = fopen(fileName, "rb");
@ -311,6 +322,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
case UNCOMPRESSED_R5G5B5A1: image.data = (unsigned short *)malloc(size); break; // 16 bpp (1 bit alpha) case UNCOMPRESSED_R5G5B5A1: image.data = (unsigned short *)malloc(size); break; // 16 bpp (1 bit alpha)
case UNCOMPRESSED_R4G4B4A4: image.data = (unsigned short *)malloc(size); break; // 16 bpp (4 bit alpha) case UNCOMPRESSED_R4G4B4A4: image.data = (unsigned short *)malloc(size); break; // 16 bpp (4 bit alpha)
case UNCOMPRESSED_R8G8B8A8: image.data = (unsigned char *)malloc(size*4); size *= 4; break; // 32 bpp case UNCOMPRESSED_R8G8B8A8: image.data = (unsigned char *)malloc(size*4); size *= 4; break; // 32 bpp
case UNCOMPRESSED_R32G32B32: image.data = (float *)malloc(size*12); size *= 12; break; // 4 byte per channel (12 byte)
default: TraceLog(WARNING, "Image format not suported"); break; default: TraceLog(WARNING, "Image format not suported"); break;
} }
@ -342,7 +354,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
// Load texture from file into GPU memory (VRAM) // Load texture from file into GPU memory (VRAM)
Texture2D LoadTexture(const char *fileName) Texture2D LoadTexture(const char *fileName)
{ {
Texture2D texture; Texture2D texture = { 0 };
Image image = LoadImage(fileName); Image image = LoadImage(fileName);
@ -351,11 +363,7 @@ Texture2D LoadTexture(const char *fileName)
texture = LoadTextureFromImage(image); texture = LoadTextureFromImage(image);
UnloadImage(image); UnloadImage(image);
} }
else else TraceLog(WARNING, "Texture could not be created");
{
TraceLog(WARNING, "Texture could not be created");
texture.id = 0;
}
return texture; return texture;
} }
@ -364,14 +372,7 @@ Texture2D LoadTexture(const char *fileName)
// NOTE: image is not unloaded, it must be done manually // NOTE: image is not unloaded, it must be done manually
Texture2D LoadTextureFromImage(Image image) Texture2D LoadTextureFromImage(Image image)
{ {
Texture2D texture; Texture2D texture = { 0 };
// Init texture to default values
texture.id = 0;
texture.width = 0;
texture.height = 0;
texture.mipmaps = 0;
texture.format = 0;
texture.id = rlglLoadTexture(image.data, image.width, image.height, image.format, image.mipmaps); texture.id = rlglLoadTexture(image.data, image.width, image.height, image.format, image.mipmaps);
@ -510,9 +511,8 @@ Color *GetImageData(Image image)
// NOTE: Compressed texture formats not supported // NOTE: Compressed texture formats not supported
Image GetTextureData(Texture2D texture) Image GetTextureData(Texture2D texture)
{ {
Image image; Image image = { 0 };
image.data = NULL;
if (texture.format < 8) if (texture.format < 8)
{ {
image.data = rlglReadTexturePixels(texture); image.data = rlglReadTexturePixels(texture);
@ -787,6 +787,7 @@ Image ImageCopy(Image image)
case UNCOMPRESSED_R4G4B4A4: byteSize *= 2; break; // 16 bpp (2 bytes) case UNCOMPRESSED_R4G4B4A4: byteSize *= 2; break; // 16 bpp (2 bytes)
case UNCOMPRESSED_R8G8B8: byteSize *= 3; break; // 24 bpp (3 bytes) case UNCOMPRESSED_R8G8B8: byteSize *= 3; break; // 24 bpp (3 bytes)
case UNCOMPRESSED_R8G8B8A8: byteSize *= 4; break; // 32 bpp (4 bytes) case UNCOMPRESSED_R8G8B8A8: byteSize *= 4; break; // 32 bpp (4 bytes)
case UNCOMPRESSED_R32G32B32: byteSize *= 12; break; // 4 byte per channel (12 bytes)
case COMPRESSED_DXT3_RGBA: case COMPRESSED_DXT3_RGBA:
case COMPRESSED_DXT5_RGBA: case COMPRESSED_DXT5_RGBA:
case COMPRESSED_ETC2_EAC_RGBA: case COMPRESSED_ETC2_EAC_RGBA:

View file

@ -144,7 +144,7 @@
<div class="emscripten" id="status">Downloading...</div> <div class="emscripten" id="status">Downloading...</div>
<span id='controls'> <span id='controls'>
<span><input type="button" value="Fullscreen" onclick="Module.requestFullScreen(false, false)"></span> <span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(false, false)"></span>
</span> </span>
<div class="emscripten"> <div class="emscripten">