├── content ├── libglfw.dylib ├── shaders │ ├── header.si │ ├── model.txt │ ├── pass.vs │ └── functions.si ├── crate.png ├── monster.png └── normal.png ├── run_mfgd ├── run_mfgd_osx ├── debug_mfgd_osx ├── lib ├── libglfw.a ├── libglfw.lib └── osx │ ├── libglfw.a │ └── libglfw.dylib ├── libglfw.dylib ├── glfw-2.7.9 ├── .swp ├── .readme.html.swp ├── docs │ ├── glfwrm.tex │ ├── glfwug.tex │ ├── Reference.pdf │ ├── UsersGuide.pdf │ ├── cleanup.bat │ ├── Makefile │ ├── readme.txt │ └── glfwdoc.sty ├── examples │ ├── mipmaps.tga │ ├── pong3d_field.tga │ ├── pong3d_instr.tga │ ├── pong3d_menu.tga │ ├── pong3d_title.tga │ ├── pong3d_winner1.tga │ ├── pong3d_winner2.tga │ ├── Makefile.x11.in │ ├── mthello.c │ ├── bundle.sh │ ├── listmodes.c │ ├── Makefile.win32.mingw │ ├── Makefile.win32.msys │ ├── Makefile.win32.cross-mgw │ ├── getopt.h │ ├── Makefile.win32.lcc │ ├── Makefile.win32.ow │ ├── Makefile.cocoa │ ├── Makefile.carbon │ ├── triangle.c │ └── Makefile.carbon.universal ├── support │ ├── d │ │ ├── lib │ │ │ ├── makefile │ │ │ ├── glu32.def │ │ │ └── glfwdll.def │ │ └── examples │ │ │ ├── mthello.d │ │ │ ├── listmodes.d │ │ │ ├── Makefile.win32.dmd │ │ │ └── triangle.d │ └── pascal │ │ └── Triangle.dpr ├── lib │ ├── carbon │ │ ├── libglfw.pc.in │ │ ├── carbon_enable.c │ │ ├── carbon_joystick.c │ │ └── carbon_glext.c │ ├── cocoa │ │ ├── libglfw.pc.in │ │ ├── cocoa_enable.m │ │ └── cocoa_glext.m │ ├── win32 │ │ ├── libglfw.pc.in │ │ ├── glfwdll.def │ │ ├── win32_dllmain.c │ │ └── win32_glext.c │ ├── x11 │ │ ├── x11_enable.c │ │ └── x11_glext.c │ ├── time.c │ ├── fullscreen.c │ ├── joystick.c │ └── init.c ├── COPYING.txt └── tests │ ├── Makefile.x11.in │ ├── bundle.sh │ ├── Makefile.win32.mingw │ ├── getopt.h │ ├── Makefile.win32.msys │ ├── Makefile.win32.cross-mgw │ ├── dynamic.c │ ├── Makefile.carbon │ ├── Makefile.cocoa │ ├── Makefile.carbon.universal │ ├── tearing.c │ ├── defaults.c │ └── accuracy.c ├── renderer ├── stanfordbunny.cpp ├── render_common.h └── keys.h ├── game ├── main.h ├── handle.h ├── main.cpp └── handle.cpp ├── .gitignore ├── math ├── physics.h ├── axisangle.h ├── quaternion.h ├── graph.cpp ├── graph.h ├── euler.h ├── frustum.h ├── collision.h ├── plane.h ├── aabb.h ├── euler.cpp ├── maths.h ├── vector.h ├── color.h ├── vector2d.h ├── vector.cpp └── frustum.cpp ├── mfgd.sublime-project ├── MFGD.vcxproj.user ├── MFGD.sln ├── Makefile ├── Makefile.osx ├── LICENSE.Tinker ├── common ├── mtrand.h ├── mtrand.cpp ├── common_platform.h └── common.h └── datamanager ├── dataserializer.h └── data.h /content/libglfw.dylib: -------------------------------------------------------------------------------- 1 | ../libglfw.dylib -------------------------------------------------------------------------------- /content/shaders/header.si: -------------------------------------------------------------------------------- 1 | #version 150 2 | -------------------------------------------------------------------------------- /run_mfgd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd content 4 | ../mfgd -------------------------------------------------------------------------------- /run_mfgd_osx: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cp lib/osx/*.dylib . 4 | cd content 5 | ./mfgd 6 | -------------------------------------------------------------------------------- /debug_mfgd_osx: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cp lib/osx/*.dylib . 4 | cd content 5 | lldb ./mfgd 6 | -------------------------------------------------------------------------------- /lib/libglfw.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/lib/libglfw.a -------------------------------------------------------------------------------- /libglfw.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/libglfw.dylib -------------------------------------------------------------------------------- /content/crate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/content/crate.png -------------------------------------------------------------------------------- /glfw-2.7.9/.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/.swp -------------------------------------------------------------------------------- /lib/libglfw.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/lib/libglfw.lib -------------------------------------------------------------------------------- /lib/osx/libglfw.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/lib/osx/libglfw.a -------------------------------------------------------------------------------- /content/monster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/content/monster.png -------------------------------------------------------------------------------- /content/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/content/normal.png -------------------------------------------------------------------------------- /lib/osx/libglfw.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/lib/osx/libglfw.dylib -------------------------------------------------------------------------------- /glfw-2.7.9/.readme.html.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/.readme.html.swp -------------------------------------------------------------------------------- /glfw-2.7.9/docs/glfwrm.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/docs/glfwrm.tex -------------------------------------------------------------------------------- /glfw-2.7.9/docs/glfwug.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/docs/glfwug.tex -------------------------------------------------------------------------------- /renderer/stanfordbunny.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/renderer/stanfordbunny.cpp -------------------------------------------------------------------------------- /glfw-2.7.9/docs/Reference.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/docs/Reference.pdf -------------------------------------------------------------------------------- /glfw-2.7.9/docs/UsersGuide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/docs/UsersGuide.pdf -------------------------------------------------------------------------------- /glfw-2.7.9/examples/mipmaps.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/examples/mipmaps.tga -------------------------------------------------------------------------------- /glfw-2.7.9/examples/pong3d_field.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/examples/pong3d_field.tga -------------------------------------------------------------------------------- /glfw-2.7.9/examples/pong3d_instr.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/examples/pong3d_instr.tga -------------------------------------------------------------------------------- /glfw-2.7.9/examples/pong3d_menu.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/examples/pong3d_menu.tga -------------------------------------------------------------------------------- /glfw-2.7.9/examples/pong3d_title.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/examples/pong3d_title.tga -------------------------------------------------------------------------------- /glfw-2.7.9/examples/pong3d_winner1.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/examples/pong3d_winner1.tga -------------------------------------------------------------------------------- /glfw-2.7.9/examples/pong3d_winner2.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BSVino/MathForGameDevelopers/HEAD/glfw-2.7.9/examples/pong3d_winner2.tga -------------------------------------------------------------------------------- /game/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | float RandFloat(float min, float max) 4 | { 5 | return ((float)mtrand()) * (max-min) /MTRAND_MAX + min; 6 | } 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /ipch 2 | /*.sdf 3 | /*.suo 4 | /*.opensdf 5 | /Debug 6 | /Release 7 | mfgd 8 | *.o 9 | .depend 10 | *.sublime-workspace 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /content/shaders/model.txt: -------------------------------------------------------------------------------- 1 | Name: model 2 | Vertex: pass 3 | Fragment: model 4 | 5 | Defaults 6 | { 7 | bDiffuse: no 8 | vecColor: 1 1 1 1 9 | } 10 | -------------------------------------------------------------------------------- /glfw-2.7.9/support/d/lib/makefile: -------------------------------------------------------------------------------- 1 | all: glfwdll.lib opengl32.lib glu32.lib 2 | 3 | IFLAGS = 4 | 5 | glfwdll.lib: glfwdll.def 6 | implib $(IFLAGS) $@ glfwdll.def 7 | 8 | opengl32.lib: opengl32.def 9 | implib $(IFLAGS) $@ opengl32.def 10 | 11 | glu32.lib: glu32.def 12 | implib $(IFLAGS) $@ glu32.def 13 | -------------------------------------------------------------------------------- /math/physics.h: -------------------------------------------------------------------------------- 1 | #include "vector.h" 2 | 3 | // https://www.youtube.com/watch?v=rqhAOc9gvC4 4 | Vector PredictProjectileAtTime(float t, Vector v0, Vector x0, Vector g) 5 | { 6 | return g * (0.5f * t * t) + v0 * t + x0; 7 | } 8 | 9 | float PredictProjectileMaximumHeightTime(Vector v0, Vector g) 10 | { 11 | return -v0.y / g.y; 12 | } 13 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/carbon/libglfw.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@PREFIX@ 2 | exec_prefix=@PREFIX@ 3 | libdir=@PREFIX@/lib 4 | includedir=@PREFIX@/include 5 | 6 | Name: GLFW 7 | Description: A portable framework for OpenGL development 8 | Version: 2.7 9 | URL: http://www.glfw.org/ 10 | Libs: -L${libdir} -lglfw -framework AGL -framework OpenGL -framework Carbon 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/cocoa/libglfw.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@PREFIX@ 2 | exec_prefix=@PREFIX@ 3 | libdir=@PREFIX@/lib 4 | includedir=@PREFIX@/include 5 | 6 | Name: GLFW 7 | Description: A portable framework for OpenGL development 8 | Version: 2.7 9 | URL: http://www.glfw.org/ 10 | Libs: -L${libdir} -lglfw -framework Cocoa -framework OpenGL -framework IOKit 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/win32/libglfw.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@PREFIX@ 2 | exec_prefix=@PREFIX@ 3 | libdir=@PREFIX@/lib 4 | includedir=@PREFIX@/include 5 | 6 | Name: GLFW 7 | Description: A portable framework for OpenGL development 8 | Version: 2.7 9 | URL: http://www.glfw.org/ 10 | Libs: -L${libdir} -lglfw -lglu32 -lopengl32 -lm -s -mwindows -e _mainCRTStartup 11 | Cflags: -I${includedir} -mwin32 12 | -------------------------------------------------------------------------------- /math/axisangle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "vector.h" 4 | 5 | // Rotation of a vector around an axis by theta degrees. 6 | // https://www.youtube.com/watch?v=dttFiVn0rvc 7 | const Vector RotateVectorAroundAxisAngle(const Vector& n, float a, const Vector& v) 8 | { 9 | // a will be our theta. 10 | // We must convert degrees to radians. (This step wasn't shown in the video.) 11 | // 360 degrees == 2pi radians 12 | a = a /360 * (float)M_PI * 2; 13 | 14 | return v*cos(a) + (v.Dot(n)*n*(1-cos(a))) + (n.Cross(v)*sin(a)); 15 | } 16 | -------------------------------------------------------------------------------- /mfgd.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "build_systems": 3 | [ 4 | { 5 | "encoding": "cp850", 6 | "file_regex": "^(.*?)\\(([0-9]+),?([0-9]+)?\\) (.*)", 7 | "name": "MakeOSX", 8 | "osx": 9 | { 10 | "cmd": 11 | [ 12 | "make", 13 | "-f", 14 | "Makefile.osx" 15 | ], 16 | "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", 17 | "working_dir": "${project_path}" 18 | } 19 | } 20 | ], 21 | "folders": 22 | [ 23 | { 24 | "path": "/Users/vino/Documents/git/MathForGameDevelopers" 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /math/quaternion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "vector.h" 4 | 5 | class Quaternion 6 | { 7 | public: 8 | Quaternion() {}; 9 | Quaternion(const Vector& n, float a); 10 | 11 | public: 12 | const Quaternion Inverted() const; 13 | const Quaternion operator*(const Quaternion& q) const; 14 | const Vector operator*(const Vector& p) const; 15 | const Quaternion operator^(float t) const; 16 | const Quaternion Slerp(const Quaternion& r, float t) const; 17 | 18 | void ToAxisAngle(Vector& vecAxis, float& flAngle) const; 19 | 20 | public: 21 | float w; 22 | Vector v; // x, y, z 23 | }; 24 | -------------------------------------------------------------------------------- /MFGD.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(ProjectDir)/content 5 | WindowsLocalDebugger 6 | 4 4 7 | 8 | 9 | $(ProjectDir)/content 10 | WindowsLocalDebugger 11 | 10 10 12 | 13 | -------------------------------------------------------------------------------- /glfw-2.7.9/docs/cleanup.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM ---------------------------------------------------------------------- 4 | REM Windows cleanup batch file for the GLFW documentation. 5 | REM ---------------------------------------------------------------------- 6 | 7 | REM GLFW Reference Manual 8 | if exist glfwrm.dvi del glfwrm.dvi 9 | if exist glfwrm.aux del glfwrm.aux 10 | if exist glfwrm.log del glfwrm.log 11 | if exist glfwrm.out del glfwrm.out 12 | if exist glfwrm.pdf del glfwrm.pdf 13 | if exist glfwrm.toc del glfwrm.toc 14 | if exist glfwrm.lot del glfwrm.lot 15 | 16 | REM GLFW Users Guide 17 | if exist glfwug.dvi del glfwug.dvi 18 | if exist glfwug.aux del glfwug.aux 19 | if exist glfwug.log del glfwug.log 20 | if exist glfwug.out del glfwug.out 21 | if exist glfwug.pdf del glfwug.pdf 22 | if exist glfwug.toc del glfwug.toc 23 | -------------------------------------------------------------------------------- /content/shaders/pass.vs: -------------------------------------------------------------------------------- 1 | uniform vec4 vecColor; 2 | 3 | in vec3 vecPosition; 4 | in vec3 vecNormal; 5 | in vec3 vecTangent; 6 | in vec3 vecBitangent; 7 | in vec2 vecTexCoord0; 8 | in vec3 vecVertexColor; 9 | 10 | out vec3 vecFragmentLocalPosition; 11 | out vec3 vecFragmentGlobalPosition; 12 | out vec3 vecFragmentNormal; 13 | out vec3 vecFragmentTangent; 14 | out vec3 vecFragmentBitangent; 15 | out vec2 vecFragmentTexCoord0; 16 | out vec3 vecFragmentColor; 17 | 18 | void main() 19 | { 20 | vec4 vecGlobal = mGlobal * vec4(vecPosition, 1.0); 21 | 22 | vecFragmentLocalPosition = vecPosition; 23 | vecFragmentGlobalPosition = vecGlobal.xyz; 24 | vecFragmentNormal = vecNormal; 25 | vecFragmentTangent = vecTangent; 26 | vecFragmentBitangent = vecBitangent; 27 | vecFragmentTexCoord0 = vec2(vecTexCoord0.x, 1-vecTexCoord0.y); 28 | vecFragmentColor = vecVertexColor; 29 | 30 | gl_Position = mProjection * mView * vecGlobal; 31 | } 32 | -------------------------------------------------------------------------------- /MFGD.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual C++ Express 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MFGD", "MFGD.vcxproj", "{74F75FB6-111F-46F3-A0A5-013FBDB9C325}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {74F75FB6-111F-46F3-A0A5-013FBDB9C325}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {74F75FB6-111F-46F3-A0A5-013FBDB9C325}.Debug|Win32.Build.0 = Debug|Win32 14 | {74F75FB6-111F-46F3-A0A5-013FBDB9C325}.Release|Win32.ActiveCfg = Release|Win32 15 | {74F75FB6-111F-46F3-A0A5-013FBDB9C325}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /math/graph.cpp: -------------------------------------------------------------------------------- 1 | #include "graph.h" 2 | 3 | void CGraph::AddNode() 4 | { 5 | CGraph::nodes.push_back(CNode()); 6 | } 7 | 8 | void CGraph::AddEdge(node_t a, node_t b, float weight) 9 | { 10 | edges.push_back(CGraph::CEdge()); 11 | edges.back().first = a; 12 | edges.back().second = b; 13 | edges.back().weight = weight; 14 | 15 | nodes[a].edges.push_back(edges.size()-1); 16 | nodes[b].edges.push_back(edges.size()-1); 17 | } 18 | 19 | int CGraph::GetNumNodes() 20 | { 21 | return nodes.size(); 22 | } 23 | 24 | CGraph::CNode* CGraph::GetNode(node_t i) 25 | { 26 | return &nodes[i]; 27 | } 28 | 29 | int CGraph::GetNumEdges() 30 | { 31 | return edges.size(); 32 | } 33 | 34 | CGraph::CEdge* CGraph::GetEdge(edge_t i) 35 | { 36 | return &edges[i]; 37 | } 38 | 39 | node_t CGraph::FollowEdge(node_t node, edge_t edge) 40 | { 41 | if (edges[edge].first == node) 42 | return edges[edge].second; 43 | else 44 | return edges[edge].first; 45 | } 46 | -------------------------------------------------------------------------------- /math/graph.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "vector.h" 6 | 7 | typedef int node_t; 8 | typedef int edge_t; 9 | 10 | class CGraph 11 | { 12 | public: 13 | class CEdge 14 | { 15 | public: 16 | node_t first; 17 | node_t second; 18 | float weight; 19 | }; 20 | 21 | class CNode 22 | { 23 | public: 24 | CNode() 25 | { 26 | seen = false; 27 | path_from = ~0; 28 | path_weight= (float)99999999999; 29 | } 30 | 31 | std::vector edges; 32 | 33 | bool seen; 34 | node_t path_from; 35 | float path_weight; 36 | 37 | Vector debug_position; 38 | }; 39 | 40 | void AddNode(); 41 | void AddEdge(node_t a, node_t b, float weight); 42 | 43 | int GetNumNodes(); 44 | CNode* GetNode(node_t i); 45 | 46 | int GetNumEdges(); 47 | CEdge* GetEdge(edge_t i); 48 | 49 | node_t FollowEdge(node_t node, edge_t edge); 50 | 51 | protected: 52 | std::vector nodes; 53 | std::vector edges; 54 | }; 55 | 56 | 57 | -------------------------------------------------------------------------------- /glfw-2.7.9/COPYING.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | Copyright (c) 2006-2010 Camilla Berglund 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would 15 | be appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and must not 18 | be misrepresented as being the original software. 19 | 20 | 3. This notice may not be removed or altered from any source 21 | distribution. 22 | 23 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/Makefile.x11.in: -------------------------------------------------------------------------------- 1 | BINARIES = accuracy defaults dynamic events fsaa fsinput \ 2 | iconify joysticks peter reopen tearing version 3 | 4 | HEADER = ../include/GL/glfw.h 5 | 6 | all: $(BINARIES) 7 | 8 | accuracy: accuracy.c $(LIB) $(HEADER) 9 | $(CC) $(CFLAGS) accuracy.c $(LFLAGS) -o $@ 10 | 11 | defaults: defaults.c $(LIB) $(HEADER) 12 | $(CC) $(CFLAGS) defaults.c $(LFLAGS) -o $@ 13 | 14 | dynamic: dynamic.c $(SOLIB) $(HEADER) 15 | $(CC) $(CFLAGS) dynamic.c $(SO_LFLAGS) -o $@ 16 | 17 | events: events.c $(LIB) $(HEADER) 18 | $(CC) $(CFLAGS) events.c $(LFLAGS) -o $@ 19 | 20 | fsaa: fsaa.c $(LIB) $(HEADER) 21 | $(CC) $(CFLAGS) fsaa.c $(LFLAGS) -o $@ 22 | 23 | fsinput: fsinput.c $(LIB) $(HEADER) 24 | $(CC) $(CFLAGS) fsinput.c $(LFLAGS) -o $@ 25 | 26 | iconify: iconify.c $(LIB) $(HEADER) 27 | $(CC) $(CFLAGS) iconify.c $(LFLAGS) -o $@ 28 | 29 | joysticks: joysticks.c $(LIB) $(HEADER) 30 | $(CC) $(CFLAGS) joysticks.c $(LFLAGS) -o $@ 31 | 32 | peter: peter.c $(LIB) $(HEADER) 33 | $(CC) $(CFLAGS) peter.c $(LFLAGS) -o $@ 34 | 35 | reopen: reopen.c $(LIB) $(HEADER) 36 | $(CC) $(CFLAGS) reopen.c $(LFLAGS) -o $@ 37 | 38 | tearing: tearing.c $(LIB) $(HEADER) 39 | $(CC) $(CFLAGS) tearing.c $(LFLAGS) -o $@ 40 | 41 | version: version.c $(LIB) $(HEADER) 42 | $(CC) $(CFLAGS) version.c $(LFLAGS) -o $@ 43 | 44 | clean: 45 | rm -f $(BINARIES) 46 | 47 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/Makefile.x11.in: -------------------------------------------------------------------------------- 1 | BINARIES = triangle listmodes mthello pong3d mtbench particles splitview \ 2 | mipmaps gears boing wave heightmap 3 | 4 | all: $(BINARIES) 5 | 6 | triangle: triangle.c ../lib/x11/libglfw.a 7 | $(CC) $(CFLAGS) triangle.c $(LFLAGS) -o $@ 8 | 9 | listmodes: listmodes.c ../lib/x11/libglfw.a 10 | $(CC) $(CFLAGS) listmodes.c $(LFLAGS) -o $@ 11 | 12 | mthello: mthello.c ../lib/x11/libglfw.a 13 | $(CC) $(CFLAGS) mthello.c $(LFLAGS) -o $@ 14 | 15 | pong3d: pong3d.c ../lib/x11/libglfw.a 16 | $(CC) $(CFLAGS) pong3d.c $(LFLAGS) -o $@ 17 | 18 | mtbench: mtbench.c ../lib/x11/libglfw.a 19 | $(CC) $(CFLAGS) mtbench.c $(LFLAGS) -o $@ 20 | 21 | particles: particles.c ../lib/x11/libglfw.a 22 | $(CC) $(CFLAGS) particles.c $(LFLAGS) -o $@ 23 | 24 | splitview: splitview.c ../lib/x11/libglfw.a 25 | $(CC) $(CFLAGS) splitview.c $(LFLAGS) -o $@ 26 | 27 | mipmaps: mipmaps.c ../lib/x11/libglfw.a 28 | $(CC) $(CFLAGS) mipmaps.c $(LFLAGS) -o $@ 29 | 30 | gears: gears.c ../lib/x11/libglfw.a 31 | $(CC) $(CFLAGS) gears.c $(LFLAGS) -o $@ 32 | 33 | boing: boing.c ../lib/x11/libglfw.a 34 | $(CC) $(CFLAGS) boing.c $(LFLAGS) -o $@ 35 | 36 | wave: wave.c ../lib/x11/libglfw.a 37 | $(CC) $(CFLAGS) wave.c $(LFLAGS) -o $@ 38 | 39 | heightmap: heightmap.c ../lib/x11/libglfw.a 40 | $(CC) $(CFLAGS) heightmap.c $(LFLAGS) -o $@ 41 | 42 | clean: 43 | rm -f $(BINARIES) 44 | 45 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/mthello.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // This is a small test application for GLFW. 3 | // The program prints "Hello world!", using two threads. 4 | //======================================================================== 5 | 6 | #include 7 | #include 8 | 9 | 10 | //======================================================================== 11 | // HelloFun() - Thread function 12 | //======================================================================== 13 | 14 | void GLFWCALL HelloFun( void *arg ) 15 | { 16 | // Print the first part of the message 17 | printf( "Hello " ); 18 | } 19 | 20 | 21 | //======================================================================== 22 | // main() - Main function (main thread) 23 | //======================================================================== 24 | 25 | int main( void ) 26 | { 27 | GLFWthread thread; 28 | 29 | // Initialise GLFW 30 | if( !glfwInit() ) 31 | { 32 | return 0; 33 | } 34 | 35 | // Create thread 36 | thread = glfwCreateThread( HelloFun, NULL ); 37 | 38 | // Wait for thread to die 39 | glfwWaitThread( thread, GLFW_WAIT ); 40 | 41 | // Print the rest of the message 42 | printf( "world!\n" ); 43 | 44 | // Terminate GLFW 45 | glfwTerminate(); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /glfw-2.7.9/support/d/examples/mthello.d: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // This is a small test application for GLFW. 3 | // The program prints "Hello world!", using two threads. 4 | //======================================================================== 5 | 6 | import glfw; 7 | 8 | 9 | //======================================================================== 10 | // main() - Main function (main thread) 11 | //======================================================================== 12 | 13 | int main( ) 14 | { 15 | GLFWthread thread; 16 | 17 | // Initialise GLFW 18 | if( !glfwInit() ) 19 | { 20 | return 0; 21 | } 22 | 23 | // Create thread 24 | thread = glfwCreateThread( &HelloFun, null ); 25 | 26 | // Wait for thread to die 27 | glfwWaitThread( thread, GLFW_WAIT ); 28 | 29 | // Print the rest of the message 30 | printf( "world!\n" ); 31 | 32 | // Terminate GLFW 33 | glfwTerminate(); 34 | 35 | return 0; 36 | } 37 | 38 | version(Windows) { 39 | extern(Windows): 40 | } else { 41 | extern(C): 42 | } 43 | 44 | //======================================================================== 45 | // HelloFun() - Thread function 46 | //======================================================================== 47 | 48 | void HelloFun( void *arg ) 49 | { 50 | // Print the first part of the message 51 | printf( "Hello " ); 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/bundle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Creates application bundles for use on Mac OS X. 4 | 5 | if [ -z "$1" ]; then 6 | echo "usage: `basename $0` BUNDLE-NAME" 7 | exit 1 8 | fi 9 | 10 | bundle_name="$1" 11 | 12 | if [ ! -d "${bundle_name}.app/Contents/MacOS" ]; then 13 | mkdir -p "${bundle_name}.app/Contents/MacOS" 14 | fi 15 | 16 | if [ ! -d "${bundle_name}.app/Contents/Resources" ]; then 17 | mkdir -p "${bundle_name}.app/Contents/Resources" 18 | fi 19 | 20 | if [ ! -f "${bundle_name}.app/Contents/PkgInfo" ]; then 21 | echo -n "APPL????" > "${bundle_name}.app/Contents/PkgInfo" 22 | fi 23 | 24 | if [ ! -f "${bundle_name}.app/Contents/Info.plist" ]; then 25 | cat > "${bundle_name}.app/Contents/Info.plist" < 27 | 28 | 29 | 30 | CFBundleDevelopmentRegion 31 | English 32 | CFBundleExecutable 33 | ${bundle_name} 34 | CFBundleInfoDictionaryVersion 35 | 6.0 36 | CFBundlePackageType 37 | APPL 38 | CFBundleSignature 39 | ???? 40 | CFBundleVersion 41 | 0.1 42 | 43 | 44 | EOF 45 | fi 46 | 47 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/bundle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Creates application bundles for use on Mac OS X. 4 | 5 | if [ -z "$1" ]; then 6 | echo "usage: `basename $0` BUNDLE-NAME" 7 | exit 1 8 | fi 9 | 10 | bundle_name="$1" 11 | 12 | if [ ! -d "${bundle_name}.app/Contents/MacOS" ]; then 13 | mkdir -p "${bundle_name}.app/Contents/MacOS" 14 | fi 15 | 16 | if [ ! -d "${bundle_name}.app/Contents/Resources" ]; then 17 | mkdir -p "${bundle_name}.app/Contents/Resources" 18 | fi 19 | 20 | if [ ! -f "${bundle_name}.app/Contents/PkgInfo" ]; then 21 | echo -n "APPL????" > "${bundle_name}.app/Contents/PkgInfo" 22 | fi 23 | 24 | if [ ! -f "${bundle_name}.app/Contents/Info.plist" ]; then 25 | cat > "${bundle_name}.app/Contents/Info.plist" < 27 | 28 | 29 | 30 | CFBundleDevelopmentRegion 31 | English 32 | CFBundleExecutable 33 | ${bundle_name} 34 | CFBundleInfoDictionaryVersion 35 | 6.0 36 | CFBundlePackageType 37 | APPL 38 | CFBundleSignature 39 | ???? 40 | CFBundleVersion 41 | 0.1 42 | 43 | 44 | EOF 45 | fi 46 | 47 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | CXX=g++ 3 | RM=rm -f 4 | CPPFLAGS= 5 | LDFLAGS=-Llib 6 | LDLIBS=-lglfw -lXrandr -lGL 7 | INCLUDES=-I. -Icommon -Imath -Iinclude 8 | 9 | SRCS_CPP= \ 10 | common/platform_linux.cpp \ 11 | common/mtrand.cpp \ 12 | datamanager/data.cpp \ 13 | datamanager/dataserializer.cpp \ 14 | game/character.cpp \ 15 | game/game.cpp \ 16 | game/handle.cpp \ 17 | game/main.cpp \ 18 | math/collision.cpp \ 19 | math/color.cpp \ 20 | math/euler.cpp \ 21 | math/frustum.cpp \ 22 | math/matrix.cpp \ 23 | math/quaternion.cpp \ 24 | math/vector.cpp \ 25 | math/graph.cpp \ 26 | renderer/application.cpp \ 27 | renderer/image_read.cpp \ 28 | renderer/renderer.cpp \ 29 | renderer/renderingcontext.cpp \ 30 | renderer/shaders.cpp \ 31 | renderer/stanfordbunny.cpp \ 32 | 33 | SRCS_C= \ 34 | renderer/gl3w.c \ 35 | 36 | SRCS= $(SRCS_CPP) $(SRCS_C) 37 | 38 | OBJS_CPP=$(subst .cpp,.o,$(SRCS_CPP)) 39 | OBJS_C=$(subst .c,.o,$(SRCS_C)) 40 | 41 | OBJS=$(OBJS_CPP) $(OBJS_C) 42 | 43 | all: mfgd 44 | 45 | mfgd: $(OBJS) 46 | g++ $(LDFLAGS) -o mfgd $(OBJS) $(LDLIBS) 47 | 48 | %.o:%.c 49 | $(CXX) $(CPPFLAGS) $(INCLUDES) -c $< -o $@ 50 | 51 | %.o:%.cpp 52 | $(CXX) $(CPPFLAGS) -std=c++0x $(INCLUDES) -c $< -o $@ 53 | 54 | depend: .depend 55 | 56 | .depend: $(SRCS) 57 | rm -f ./.depend 58 | $(CXX) $(CPPFLAGS) $(INCLUDES) -MM $(SRCS) $^>>./.depend; 59 | 60 | clean: 61 | $(RM) $(OBJS) .depend 62 | 63 | dist-clean: clean 64 | $(RM) *~ .dependtool 65 | 66 | include .depend 67 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/win32/glfwdll.def: -------------------------------------------------------------------------------- 1 | LIBRARY GLFW.DLL 2 | 3 | EXPORTS 4 | glfwBroadcastCond 5 | glfwCloseWindow 6 | glfwCreateCond 7 | glfwCreateMutex 8 | glfwCreateThread 9 | glfwDestroyCond 10 | glfwDestroyMutex 11 | glfwDestroyThread 12 | glfwDisable 13 | glfwEnable 14 | glfwExtensionSupported 15 | glfwFreeImage 16 | glfwGetDesktopMode 17 | glfwGetGLVersion 18 | glfwGetJoystickButtons 19 | glfwGetJoystickParam 20 | glfwGetJoystickPos 21 | glfwGetKey 22 | glfwGetMouseButton 23 | glfwGetMousePos 24 | glfwGetMouseWheel 25 | glfwGetNumberOfProcessors 26 | glfwGetProcAddress 27 | glfwGetThreadID 28 | glfwGetTime 29 | glfwGetVersion 30 | glfwGetVideoModes 31 | glfwGetWindowParam 32 | glfwGetWindowSize 33 | glfwIconifyWindow 34 | glfwInit 35 | glfwLoadMemoryTexture2D 36 | glfwLoadTexture2D 37 | glfwLoadTextureImage2D 38 | glfwLockMutex 39 | glfwOpenWindow 40 | glfwOpenWindowHint 41 | glfwPollEvents 42 | glfwReadImage 43 | glfwReadMemoryImage 44 | glfwRestoreWindow 45 | glfwSetCharCallback 46 | glfwSetKeyCallback 47 | glfwSetMouseButtonCallback 48 | glfwSetMousePos 49 | glfwSetMousePosCallback 50 | glfwSetMouseWheel 51 | glfwSetMouseWheelCallback 52 | glfwSetTime 53 | glfwSetWindowCloseCallback 54 | glfwSetWindowRefreshCallback 55 | glfwSetWindowPos 56 | glfwSetWindowSize 57 | glfwSetWindowSizeCallback 58 | glfwSetWindowTitle 59 | glfwSignalCond 60 | glfwSleep 61 | glfwSwapBuffers 62 | glfwSwapInterval 63 | glfwTerminate 64 | glfwUnlockMutex 65 | glfwWaitCond 66 | glfwWaitEvents 67 | glfwWaitThread 68 | -------------------------------------------------------------------------------- /Makefile.osx: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | CXX=g++ 3 | RM=rm -f 4 | CPPFLAGS=-D_DEBUG -g #-O2 5 | LDFLAGS=-Llib/osx 6 | LDLIBS=-lglfw -framework OpenGL -framework ApplicationServices 7 | INCLUDES=-I. -Icommon -Imath -Iinclude 8 | 9 | SRCS_CPP= \ 10 | common/platform_osx.cpp \ 11 | common/mtrand.cpp \ 12 | datamanager/data.cpp \ 13 | datamanager/dataserializer.cpp \ 14 | game/character.cpp \ 15 | game/game.cpp \ 16 | game/handle.cpp \ 17 | game/main.cpp \ 18 | math/collision.cpp \ 19 | math/color.cpp \ 20 | math/euler.cpp \ 21 | math/frustum.cpp \ 22 | math/matrix.cpp \ 23 | math/quaternion.cpp \ 24 | math/vector.cpp \ 25 | math/graph.cpp \ 26 | renderer/application.cpp \ 27 | renderer/image_read.cpp \ 28 | renderer/renderer.cpp \ 29 | renderer/renderingcontext.cpp \ 30 | renderer/shaders.cpp \ 31 | renderer/stanfordbunny.cpp \ 32 | 33 | SRCS_C= \ 34 | renderer/gl3w.c \ 35 | 36 | SRCS= $(SRCS_CPP) $(SRCS_C) 37 | 38 | OBJS_CPP=$(subst .cpp,.o,$(SRCS_CPP)) 39 | OBJS_C=$(subst .c,.o,$(SRCS_C)) 40 | 41 | OBJS=$(OBJS_CPP) $(OBJS_C) 42 | 43 | all: mfgd 44 | 45 | mfgd: $(OBJS) 46 | g++ $(LDFLAGS) -o mfgd $(OBJS) $(LDLIBS) 47 | 48 | %.o:%.c 49 | $(CXX) $(CPPFLAGS) $(INCLUDES) -c $< -o $@ 50 | 51 | %.o:%.cpp 52 | $(CXX) $(CPPFLAGS) -std=c++0x $(INCLUDES) -c $< -o $@ 53 | 54 | depend: .depend 55 | 56 | .depend: $(SRCS) 57 | rm -f ./.depend 58 | $(CXX) $(CPPFLAGS) $(INCLUDES) -MM $(SRCS) $^>>./.depend; 59 | 60 | clean: 61 | $(RM) $(OBJS) .depend 62 | 63 | dist-clean: clean 64 | $(RM) *~ .dependtool 65 | 66 | include .depend 67 | -------------------------------------------------------------------------------- /glfw-2.7.9/support/d/examples/listmodes.d: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // This is a small test application for GLFW. 3 | // The program lists all available fullscreen video modes. 4 | //======================================================================== 5 | 6 | import glfw; 7 | 8 | // Maximum number of modes that we want to list 9 | const int MAX_NUM_MODES = 400; 10 | 11 | 12 | //======================================================================== 13 | // main() 14 | //======================================================================== 15 | 16 | int main() 17 | { 18 | GLFWvidmode dtmode; 19 | GLFWvidmode modes[ MAX_NUM_MODES ]; 20 | int modecount, i; 21 | 22 | // Initialize GLFW 23 | if( !glfwInit() ) 24 | { 25 | return 0; 26 | } 27 | 28 | // Show desktop video mode 29 | glfwGetDesktopMode( &dtmode ); 30 | printf( "Desktop mode: %d x %d x %d\n\n", 31 | dtmode.Width, dtmode.Height, dtmode.RedBits + 32 | dtmode.GreenBits + dtmode.BlueBits ); 33 | 34 | // List available video modes 35 | modecount = glfwGetVideoModes( modes, MAX_NUM_MODES ); 36 | printf( "Available modes:\n" ); 37 | for( i = 0; i < modecount; i ++ ) 38 | { 39 | printf( "%3d: %d x %d x %d\n", i, 40 | modes[i].Width, modes[i].Height, modes[i].RedBits + 41 | modes[i].GreenBits + modes[i].BlueBits ); 42 | } 43 | 44 | // Terminate GLFW 45 | glfwTerminate(); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/listmodes.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // This is a small test application for GLFW. 3 | // The program lists all available fullscreen video modes. 4 | //======================================================================== 5 | 6 | #include 7 | #include 8 | 9 | // Maximum number of modes that we want to list 10 | #define MAX_NUM_MODES 400 11 | 12 | 13 | //======================================================================== 14 | // main() 15 | //======================================================================== 16 | 17 | int main( void ) 18 | { 19 | GLFWvidmode dtmode, modes[ MAX_NUM_MODES ]; 20 | int modecount, i; 21 | 22 | // Initialize GLFW 23 | if( !glfwInit() ) 24 | { 25 | return 0; 26 | } 27 | 28 | // Show desktop video mode 29 | glfwGetDesktopMode( &dtmode ); 30 | printf( "Desktop mode: %d x %d x %d\n\n", 31 | dtmode.Width, dtmode.Height, dtmode.RedBits + 32 | dtmode.GreenBits + dtmode.BlueBits ); 33 | 34 | // List available video modes 35 | modecount = glfwGetVideoModes( modes, MAX_NUM_MODES ); 36 | printf( "Available modes:\n" ); 37 | for( i = 0; i < modecount; i ++ ) 38 | { 39 | printf( "%3d: %d x %d x %d\n", i, 40 | modes[i].Width, modes[i].Height, modes[i].RedBits + 41 | modes[i].GreenBits + modes[i].BlueBits ); 42 | } 43 | 44 | // Terminate GLFW 45 | glfwTerminate(); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /glfw-2.7.9/support/d/examples/Makefile.win32.dmd: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # This makefile builds the example programs using the Digital Mars D 3 | # compiler. You need to copy the .lib files from support\d\lib to your 4 | # Digital Mars C/C++ compiler/linker lib folder (dm\lib) before compiling 5 | # the programs. 6 | ########################################################################## 7 | 8 | DC = dmd 9 | IMPORTSDIR = ..\imports 10 | DFLAGS = -O -I$(IMPORTSDIR) 11 | LIBDIR = ..\lib 12 | LIBS = $(LIBDIR)\glfwdll.lib $(LIBDIR)\glu32.lib $(LIBDIR)\opengl32.lib 13 | 14 | 15 | all: boing.exe gears.exe listmodes.exe mipmaps.exe mthello.exe mtbench.exe \ 16 | particles.exe pong3d.exe splitview.exe triangle.exe wave.exe 17 | 18 | 19 | clean: 20 | del *.exe *.obj *.map 21 | 22 | 23 | boing.exe: boing.d 24 | $(DC) $(DFLAGS) -of$@ $ 23 | #endif 24 | 25 | void mtsrand(size_t iSeed); 26 | size_t mtrand(); 27 | 28 | #define MTRAND_MAX ((size_t)~0) 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /glfw-2.7.9/docs/Makefile: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for the GLFW documentation. 3 | ########################################################################## 4 | 5 | PDFDOCS = glfwrm.pdf glfwug.pdf 6 | DVIDOCS = glfwrm.dvi glfwug.dvi 7 | 8 | 9 | ########################################################################## 10 | # Build macros 11 | ########################################################################## 12 | default: pdf 13 | pdf: $(PDFDOCS) 14 | dvi: $(DVIDOCS) 15 | 16 | 17 | ########################################################################## 18 | # Clean macros 19 | ########################################################################## 20 | clean: 21 | rm -f glfwrm.dvi glfwrm.aux glfwrm.log glfwrm.out glfwrm.pdf glfwrm.toc glfwrm.lot 22 | rm -f glfwug.dvi glfwug.aux glfwug.log glfwug.out glfwug.pdf glfwug.toc 23 | 24 | clean-win: 25 | @.\\cleanup.bat 26 | 27 | 28 | ########################################################################## 29 | # Rules for building the GLFW Reference Manual 30 | ########################################################################## 31 | 32 | glfwrm.pdf: glfwrm.tex glfwrm.toc glfwrm.lot glfwdoc.sty 33 | pdflatex glfwrm.tex 34 | 35 | glfwrm.dvi: glfwrm.tex glfwrm.toc glfwrm.lot glfwdoc.sty 36 | latex glfwrm.tex 37 | 38 | glfwrm.toc: glfwrm.tex glfwdoc.sty 39 | latex glfwrm.tex 40 | 41 | glfwrm.lot: glfwrm.tex glfwdoc.sty 42 | latex glfwrm.tex 43 | 44 | 45 | ########################################################################## 46 | # Rules for building the GLFW Users Guide 47 | ########################################################################## 48 | 49 | glfwug.pdf: glfwug.tex glfwug.toc glfwdoc.sty 50 | pdflatex glfwug.tex 51 | 52 | glfwug.dvi: glfwug.tex glfwug.toc glfwdoc.sty 53 | latex glfwug.tex 54 | 55 | glfwug.toc: glfwug.tex glfwdoc.sty 56 | latex glfwug.tex 57 | 58 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/win32/win32_dllmain.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: Win32/WGL 4 | // API version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #include "internal.h" 32 | 33 | 34 | #if defined(GLFW_BUILD_DLL) 35 | 36 | //======================================================================== 37 | // GLFW DLL entry point 38 | //======================================================================== 39 | 40 | BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, LPVOID reserved ) 41 | { 42 | // NOTE: Some compilers complains about instance and x never being used - 43 | // never mind that (we don't want to use them)! 44 | 45 | return TRUE; 46 | } 47 | 48 | #endif // GLFW_BUILD_DLL 49 | 50 | -------------------------------------------------------------------------------- /datamanager/dataserializer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #ifndef LW_DATASERIALIZER_H 19 | #define LW_DATASERIALIZER_H 20 | 21 | #include "data.h" 22 | 23 | #include 24 | 25 | #include 26 | 27 | class CDataSerializer 28 | { 29 | public: 30 | static void Read(std::basic_istream& sStream, class CData* pData); 31 | static void Save(std::basic_ostream& sStream, class CData* pData); 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/Makefile.win32.mingw: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on Windows using bare MinGW 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.win32.mingw 6 | ########################################################################## 7 | 8 | CC = gcc 9 | CFLAGS = -I../include -Wall -O2 10 | 11 | LIB = ../lib/win32/libglfw.a 12 | LFLAGS = $(LIB) -lglu32 -lopengl32 -s 13 | 14 | WINDOWS = -mwindows 15 | CONSOLE = -mconsole 16 | 17 | HEADER = ../include/GL/glfw.h 18 | 19 | all: triangle.exe listmodes.exe mthello.exe pong3d.exe mtbench.exe \ 20 | particles.exe splitview.exe mipmaps.exe gears.exe boing.exe \ 21 | wave.exe heightmap.exe 22 | 23 | triangle.exe: triangle.c $(LIB) $(HEADER) 24 | $(CC) $(CFLAGS) $(WINDOWS) triangle.c $(LFLAGS) -o $@ 25 | 26 | listmodes.exe: listmodes.c $(LIB) $(HEADER) 27 | $(CC) $(CFLAGS) $(CONSOLE) listmodes.c $(LFLAGS) -o $@ 28 | 29 | mthello.exe: mthello.c $(LIB) $(HEADER) 30 | $(CC) $(CFLAGS) $(CONSOLE) mthello.c $(LFLAGS) -o $@ 31 | 32 | pong3d.exe: pong3d.c $(LIB) $(HEADER) 33 | $(CC) $(CFLAGS) $(WINDOWS) pong3d.c $(LFLAGS) -lm -o $@ 34 | 35 | mtbench.exe: mtbench.c $(LIB) $(HEADER) 36 | $(CC) $(CFLAGS) $(CONSOLE) mtbench.c $(LFLAGS) -o $@ 37 | 38 | particles.exe: particles.c $(LIB) $(HEADER) 39 | $(CC) $(CFLAGS) $(CONSOLE) particles.c $(LFLAGS) -lm -o $@ 40 | 41 | splitview.exe: splitview.c $(LIB) $(HEADER) 42 | $(CC) $(CFLAGS) $(WINDOWS) splitview.c $(LFLAGS) -lm -o $@ 43 | 44 | mipmaps.exe: mipmaps.c $(LIB) $(HEADER) 45 | $(CC) $(CFLAGS) $(WINDOWS) mipmaps.c $(LFLAGS) -lm -o $@ 46 | 47 | gears.exe: gears.c $(LIB) $(HEADER) 48 | $(CC) $(CFLAGS) $(WINDOWS) gears.c $(LFLAGS) -lm -o $@ 49 | 50 | boing.exe: boing.c $(LIB) $(HEADER) 51 | $(CC) $(CFLAGS) $(WINDOWS) boing.c $(LFLAGS) -lm -o $@ 52 | 53 | wave.exe: wave.c $(LIB) $(HEADER) 54 | $(CC) $(CFLAGS) $(WINDOWS) wave.c $(LFLAGS) -lm -o $@ 55 | 56 | heightmap.exe: heightmap.c getopt.c $(LIB) $(HEADER) 57 | $(CC) $(CFLAGS) $(WINDOWS) heightmap.c getopt.c $(LFLAGS) -lm -o $@ 58 | -------------------------------------------------------------------------------- /math/euler.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #pragma once 19 | 20 | class Vector; 21 | 22 | class EAngle 23 | { 24 | public: 25 | EAngle() 26 | { 27 | p = y = r = 0; 28 | } 29 | 30 | EAngle(float pitch, float yaw, float roll) 31 | { 32 | p = pitch; 33 | y = yaw; 34 | r = roll; 35 | } 36 | 37 | EAngle(const Vector& vecDirection); 38 | 39 | public: 40 | Vector ToVector() const; 41 | void ToAxisAngle(Vector& vecAxis, float& flAngle) const; 42 | 43 | void Normalize(); 44 | 45 | public: 46 | float p; 47 | float y; 48 | float r; 49 | }; 50 | -------------------------------------------------------------------------------- /glfw-2.7.9/support/d/lib/glu32.def: -------------------------------------------------------------------------------- 1 | LIBRARY glu32 2 | EXETYPE NT 3 | SUBSYSTEM WINDOWS 4 | EXPORTS 5 | _gluBeginCurve@4 = gluBeginCurve 6 | _gluBeginPolygon@4 = gluBeginPolygon 7 | _gluBeginSurface@4 = gluBeginSurface 8 | _gluBeginTrim@4 = gluBeginTrim 9 | _gluBuild1DMipmaps@24 = gluBuild1DMipmaps 10 | _gluBuild2DMipmaps@28 = gluBuild2DMipmaps 11 | _gluCylinder@36 = gluCylinder 12 | _gluDeleteNurbsRenderer@4 = gluDeleteNurbsRenderer 13 | _gluDeleteQuadric@4 = gluDeleteQuadric 14 | _gluDeleteTess@4 = gluDeleteTess 15 | _gluDisk@28 = gluDisk 16 | _gluEndCurve@4 = gluEndCurve 17 | _gluEndPolygon@4 = gluEndPolygon 18 | _gluEndSurface@4 = gluEndSurface 19 | _gluEndTrim@4 = gluEndTrim 20 | _gluErrorString@4 = gluErrorString 21 | _gluErrorUnicodeStringEXT@4 = gluErrorUnicodeStringEXT 22 | _gluGetNurbsProperty@12 = gluGetNurbsProperty 23 | _gluGetString@4 = gluGetString 24 | _gluGetTessProperty@12 = gluGetTessProperty 25 | _gluLoadSamplingMatrices@16 = gluLoadSamplingMatrices 26 | _gluLookAt@72 = gluLookAt 27 | _gluNewNurbsRenderer@0 = gluNewNurbsRenderer 28 | _gluNewQuadric@0 = gluNewQuadric 29 | _gluNewTess@0 = gluNewTess 30 | _gluNextContour@8 = gluNextContour 31 | _gluNurbsCallback@12 = gluNurbsCallback 32 | _gluNurbsCurve@28 = gluNurbsCurve 33 | _gluNurbsProperty@12 = gluNurbsProperty 34 | _gluNurbsSurface@44 = gluNurbsSurface 35 | _gluOrtho2D@32 = gluOrtho2D 36 | _gluPartialDisk@44 = gluPartialDisk 37 | _gluPerspective@32 = gluPerspective 38 | _gluPickMatrix@36 = gluPickMatrix 39 | _gluProject@48 = gluProject 40 | _gluPwlCurve@20 = gluPwlCurve 41 | _gluQuadricCallback@12 = gluQuadricCallback 42 | _gluQuadricDrawStyle@8 = gluQuadricDrawStyle 43 | _gluQuadricNormals@8 = gluQuadricNormals 44 | _gluQuadricOrientation@8 = gluQuadricOrientation 45 | _gluQuadricTexture@8 = gluQuadricTexture 46 | _gluScaleImage@36 = gluScaleImage 47 | _gluSphere@20 = gluSphere 48 | _gluTessBeginContour@4 = gluTessBeginContour 49 | _gluTessBeginPolygon@8 = gluTessBeginPolygon 50 | _gluTessCallback@12 = gluTessCallback 51 | _gluTessEndContour@4 = gluTessEndContour 52 | _gluTessEndPolygon@4 = gluTessEndPolygon 53 | _gluTessNormal@28 = gluTessNormal 54 | _gluTessProperty@16 = gluTessProperty 55 | _gluTessVertex@12 = gluTessVertex 56 | _gluUnProject@48 = gluUnProject 57 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/Makefile.win32.msys: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on Windows using MSYS 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.win32.msys 6 | ########################################################################## 7 | 8 | CC = gcc 9 | CFLAGS = -I../include -Wall -O2 -mwin32 10 | 11 | LIB = ../lib/win32/libglfw.a 12 | LFLAGS = $(LIB) -lglu32 -lopengl32 13 | 14 | WINDOWS = -mwindows 15 | CONSOLE = -mconsole 16 | 17 | BINARIES = triangle.exe listmodes.exe mthello.exe pong3d.exe mtbench.exe \ 18 | particles.exe splitview.exe mipmaps.exe gears.exe boing.exe \ 19 | wave.exe heightmap.exe 20 | 21 | HEADER = ../include/GL/glfw.h 22 | 23 | all: $(BINARIES) 24 | 25 | triangle.exe: triangle.c $(LIB) $(HEADER) 26 | $(CC) $(CFLAGS) $(WINDOWS) triangle.c $(LFLAGS) -o $@ 27 | 28 | listmodes.exe: listmodes.c $(LIB) $(HEADER) 29 | $(CC) $(CFLAGS) $(CONSOLE) listmodes.c $(LFLAGS) -o $@ 30 | 31 | mthello.exe: mthello.c $(LIB) $(HEADER) 32 | $(CC) $(CFLAGS) $(CONSOLE) mthello.c $(LFLAGS) -o $@ 33 | 34 | pong3d.exe: pong3d.c $(LIB) $(HEADER) 35 | $(CC) $(CFLAGS) $(WINDOWS) pong3d.c $(LFLAGS) -o $@ 36 | 37 | mtbench.exe: mtbench.c $(LIB) $(HEADER) 38 | $(CC) $(CFLAGS) $(CONSOLE) mtbench.c $(LFLAGS) -o $@ 39 | 40 | particles.exe: particles.c $(LIB) $(HEADER) 41 | $(CC) $(CFLAGS) $(CONSOLE) particles.c $(LFLAGS) -o $@ 42 | 43 | splitview.exe: splitview.c $(LIB) $(HEADER) 44 | $(CC) $(CFLAGS) $(WINDOWS) splitview.c $(LFLAGS) -o $@ 45 | 46 | mipmaps.exe: mipmaps.c $(LIB) $(HEADER) 47 | $(CC) $(CFLAGS) $(WINDOWS) mipmaps.c $(LFLAGS) -o $@ 48 | 49 | gears.exe: gears.c $(LIB) $(HEADER) 50 | $(CC) $(CFLAGS) $(WINDOWS) gears.c $(LFLAGS) -o $@ 51 | 52 | boing.exe: boing.c $(LIB) $(HEADER) 53 | $(CC) $(CFLAGS) $(WINDOWS) boing.c $(LFLAGS) -o $@ 54 | 55 | wave.exe: wave.c $(LIB) $(HEADER) 56 | $(CC) $(CFLAGS) $(WINDOWS) wave.c $(LFLAGS) -o $@ 57 | 58 | heightmap.exe: heightmap.c getopt.c $(LIB) $(HEADER) 59 | $(CC) $(CFLAGS) $(WINDOWS) heightmap.c getopt.c $(LFLAGS) -o $@ 60 | 61 | clean: 62 | rm -f $(BINARIES) 63 | 64 | -------------------------------------------------------------------------------- /math/frustum.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "plane.h" 21 | 22 | class Matrix4x4; 23 | 24 | #define FRUSTUM_NEAR 0 25 | #define FRUSTUM_FAR 1 26 | #define FRUSTUM_LEFT 2 27 | #define FRUSTUM_RIGHT 3 28 | #define FRUSTUM_UP 4 29 | #define FRUSTUM_DOWN 5 30 | 31 | // Frustum class defined by six planes enclosing the frustum. The normals face inward. 32 | class CFrustum 33 | { 34 | public: 35 | CFrustum() {}; 36 | CFrustum(const Matrix4x4& m); 37 | 38 | public: 39 | bool SphereIntersection(const Vector& vecCenter, float flRadius); 40 | 41 | public: 42 | CPlane p[6]; 43 | }; 44 | -------------------------------------------------------------------------------- /renderer/render_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #ifndef TINKER_RENDER_COMMON_H 19 | #define TINKER_RENDER_COMMON_H 20 | 21 | typedef enum 22 | { 23 | BLEND_NONE = 0, 24 | BLEND_ALPHA, // Source image scaled by its alpha channel 25 | BLEND_ADDITIVE, // Source image values added to destination, scaled by its alpha channel 26 | BLEND_BOTH, // Source and destination images added, no scaling 27 | } blendtype_t; 28 | 29 | typedef enum 30 | { 31 | DF_NEVER, 32 | DF_LESS, 33 | DF_EQUAL, 34 | DF_LEQUAL, 35 | DF_GREATER, 36 | DF_NOTEQUAL, 37 | DF_GEQUAL, 38 | DF_ALWAYS, 39 | } depth_function_t; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/Makefile.win32.cross-mgw: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs for Windows on Unix using MinGW32 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.win32.cross-mgw 6 | ########################################################################## 7 | 8 | TARGET ?= i586-mingw32msvc- 9 | 10 | CC = gcc 11 | CFLAGS = -I../include -Wall -O2 12 | 13 | LIB = ../lib/win32/libglfw.a 14 | LFLAGS = $(LIB) -lglu32 -lopengl32 15 | 16 | WINDOWS = -mwindows 17 | CONSOLE = -mconsole 18 | 19 | BINARIES = triangle.exe listmodes.exe mthello.exe pong3d.exe mtbench.exe \ 20 | particles.exe splitview.exe mipmaps.exe gears.exe boing.exe \ 21 | wave.exe heightmap.exe 22 | 23 | all: $(BINARIES) 24 | 25 | triangle.exe: triangle.c $(LIB) 26 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) triangle.c $(LFLAGS) -o $@ 27 | 28 | listmodes.exe: listmodes.c $(LIB) 29 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) listmodes.c $(LFLAGS) -o $@ 30 | 31 | mthello.exe: mthello.c $(LIB) 32 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) mthello.c $(LFLAGS) -o $@ 33 | 34 | pong3d.exe: pong3d.c $(LIB) 35 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) pong3d.c $(LFLAGS) -lm -o $@ 36 | 37 | mtbench.exe: mtbench.c $(LIB) 38 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) mtbench.c $(LFLAGS) -o $@ 39 | 40 | particles.exe: particles.c $(LIB) 41 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) particles.c $(LFLAGS) -lm -o $@ 42 | 43 | splitview.exe: splitview.c $(LIB) 44 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) splitview.c $(LFLAGS) -lm -o $@ 45 | 46 | mipmaps.exe: mipmaps.c $(LIB) 47 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) mipmaps.c $(LFLAGS) -lm -o $@ 48 | 49 | gears.exe: gears.c $(LIB) 50 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) gears.c $(LFLAGS) -lm -o $@ 51 | 52 | boing.exe: boing.c $(LIB) 53 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) boing.c $(LFLAGS) -lm -o $@ 54 | 55 | wave.exe: wave.c $(LIB) 56 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) wave.c $(LFLAGS) -lm -o $@ 57 | 58 | heightmap.exe: heightmap.c getopt.c $(LIB) 59 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) heightmap.c getopt.c $(LFLAGS) -lm -o $@ 60 | 61 | 62 | clean: 63 | rm -f $(BINARIES) 64 | 65 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/Makefile.win32.mingw: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on Windows using bare MinGW 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.win32.mingw 6 | ########################################################################## 7 | 8 | CC = gcc 9 | CFLAGS = -I../include -Wall -O2 10 | 11 | LIB = ../lib/win32/libglfw.a 12 | SOLIB = ../lib/win32/libglfwdll.a 13 | LFLAGS = $(LIB) -lglu32 -lopengl32 14 | SO_LFLAGS = $(SOLIB) -lglu32 -lopengl32 15 | 16 | WINDOWS = -mwindows 17 | CONSOLE = -mconsole 18 | 19 | BINARIES = accuracy.exe defaults.exe dynamic.exe events.exe fsaa.exe \ 20 | fsinput.exe iconify.exe joysticks.exe peter.exe reopen.exe \ 21 | tearing.exe version.exe 22 | 23 | HEADER = ../include/GL/glfw.h 24 | 25 | all: $(BINARIES) 26 | 27 | accuracy.exe: accuracy.c $(LIB) $(HEADER) 28 | $(CC) $(CFLAGS) $(WINDOWS) accuracy.c $(LFLAGS) -o $@ 29 | 30 | defaults.exe: defaults.c $(LIB) $(HEADER) 31 | $(CC) $(CFLAGS) $(CONSOLE) defaults.c $(LFLAGS) -o $@ 32 | 33 | dynamic.exe: dynamic.c $(SOLIB) $(HEADER) 34 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) dynamic.c $(SO_LFLAGS) -o $@ 35 | 36 | events.exe: events.c $(LIB) $(HEADER) 37 | $(CC) $(CFLAGS) $(CONSOLE) events.c $(LFLAGS) -o $@ 38 | 39 | fsaa.exe: fsaa.c $(LIB) $(HEADER) 40 | $(CC) $(CFLAGS) $(CONSOLE) fsaa.c $(LFLAGS) -o $@ 41 | 42 | fsinput.exe: fsinput.c $(LIB) $(HEADER) 43 | $(CC) $(CFLAGS) $(WINDOWS) fsinput.c $(LFLAGS) -o $@ 44 | 45 | iconify.exe: iconify.c getopt.c $(LIB) $(HEADER) 46 | $(CC) $(CFLAGS) $(CONSOLE) iconify.c getopt.c $(LFLAGS) -o $@ 47 | 48 | joysticks.exe: joysticks.c $(LIB) $(HEADER) 49 | $(CC) $(CFLAGS) $(CONSOLE) joysticks.c $(LFLAGS) -o $@ 50 | 51 | peter.exe: peter.c $(LIB) $(HEADER) 52 | $(CC) $(CFLAGS) $(CONSOLE) peter.c $(LFLAGS) -o $@ 53 | 54 | reopen.exe: reopen.c $(LIB) $(HEADER) 55 | $(CC) $(CFLAGS) $(CONSOLE) reopen.c $(LFLAGS) -o $@ 56 | 57 | tearing.exe: tearing.c $(LIB) $(HEADER) 58 | $(CC) $(CFLAGS) $(WINDOWS) tearing.c $(LFLAGS) -o $@ 59 | 60 | version.exe: version.c $(LIB) $(HEADER) 61 | $(CC) $(CFLAGS) $(CONSOLE) version.c $(LFLAGS) -o $@ 62 | 63 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/cocoa/cocoa_enable.m: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: Cocoa/NSOpenGL 4 | // API Version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2009-2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | //************************************************************************ 33 | //**** Platform implementation functions **** 34 | //************************************************************************ 35 | 36 | //======================================================================== 37 | // Enable and disable system keys 38 | //======================================================================== 39 | 40 | void _glfwPlatformEnableSystemKeys( void ) 41 | { 42 | // This is checked in macosx_window.m; we take no action here 43 | } 44 | 45 | void _glfwPlatformDisableSystemKeys( void ) 46 | { 47 | // This is checked in macosx_window.m; we take no action here 48 | // I don't think it's really possible to disable stuff like Exposé 49 | // except in full-screen mode. 50 | } 51 | 52 | -------------------------------------------------------------------------------- /game/handle.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | class CCharacter; 23 | 24 | class CHandle 25 | { 26 | public: 27 | CHandle() 28 | { 29 | m_iIndex = ~0; 30 | } 31 | 32 | public: 33 | void operator=(const CCharacter* pCharacter); 34 | 35 | CCharacter* Get() const; 36 | CCharacter* operator->() const; // Operator overload for when you go hCharacter->GetGlobalOrigin() 37 | operator CCharacter*() const; // Operator overload for when you go CCharacter* pCharacter = hCharacter; 38 | bool operator!() const; // Operator overload for when you go if (!hCharacter) 39 | 40 | public: 41 | size_t m_iIndex; 42 | size_t m_iParity; 43 | }; 44 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/getopt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * getopt.h - competent and free getopt library. 3 | * $Header: /cvsroot/freegetopt/freegetopt/getopt.h,v 1.2 2003/10/26 03:10:20 vindaci Exp $ 4 | * 5 | * Copyright (c)2002-2003 Mark K. Kim 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the original author of this software nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 31 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 32 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 34 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 35 | * DAMAGE. 36 | */ 37 | #ifndef GETOPT_H_ 38 | #define GETOPT_H_ 39 | 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | extern char* optarg; 47 | extern int optind; 48 | extern int opterr; 49 | extern int optopt; 50 | 51 | int getopt(int argc, char** argv, char* optstr); 52 | 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | 59 | #endif /* GETOPT_H_ */ 60 | 61 | 62 | /* vim:ts=3 63 | */ 64 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/getopt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * getopt.h - competent and free getopt library. 3 | * $Header: /cvsroot/freegetopt/freegetopt/getopt.h,v 1.2 2003/10/26 03:10:20 vindaci Exp $ 4 | * 5 | * Copyright (c)2002-2003 Mark K. Kim 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the original author of this software nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 31 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 32 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 34 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 35 | * DAMAGE. 36 | */ 37 | #ifndef GETOPT_H_ 38 | #define GETOPT_H_ 39 | 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | extern char* optarg; 47 | extern int optind; 48 | extern int opterr; 49 | extern int optopt; 50 | 51 | int getopt(int argc, char** argv, char* optstr); 52 | 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | 59 | #endif /* GETOPT_H_ */ 60 | 61 | 62 | /* vim:ts=3 63 | */ 64 | -------------------------------------------------------------------------------- /math/collision.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #pragma once 19 | 20 | class Vector; 21 | class AABB; 22 | 23 | bool LineAABBIntersection(const AABB& aabbBox, const Vector& v0, const Vector& v1, Vector& vecIntersection, float& flFraction); 24 | bool AABBIntersection(const AABB& a, const AABB& b); 25 | 26 | // n - plane normal 27 | // c - any point in the plane 28 | // x0 - the beginning of our line 29 | // x1 - the end of our line 30 | bool LinePlaneIntersection(const Vector& n, const Vector& c, const Vector& x0, const Vector& x1, Vector& vecIntersection, float& flFraction); 31 | 32 | // c - sphere center 33 | // r - sphere radius 34 | // p - test point 35 | const Vector NearestPointOnSphere(const Vector& c, float r, const Vector& p); 36 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/Makefile.win32.msys: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on Windows using MSYS 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.win32.msys 6 | ########################################################################## 7 | 8 | CC = gcc 9 | CFLAGS = -I../include -Wall -O2 -mwin32 10 | 11 | LIB = ../lib/win32/libglfw.a 12 | SOLIB = ../lib/win32/libglfwdll.a 13 | LFLAGS = $(LIB) -lglu32 -lopengl32 14 | SO_LFLAGS = $(SOLIB) -lglu32 -lopengl32 15 | 16 | WINDOWS = -mwindows 17 | CONSOLE = -mconsole 18 | 19 | BINARIES = accuracy.exe defaults.exe dynamic.exe events.exe fsaa.exe \ 20 | fsinput.exe iconify.exe joysticks.exe peter.exe reopen.exe \ 21 | tearing.exe version.exe 22 | 23 | HEADER = ../include/GL/glfw.h 24 | 25 | all: $(BINARIES) 26 | 27 | accuracy.exe: accuracy.c $(LIB) $(HEADER) 28 | $(CC) $(CFLAGS) $(WINDOWS) accuracy.c $(LFLAGS) -o $@ 29 | 30 | defaults.exe: defaults.c $(LIB) $(HEADER) 31 | $(CC) $(CFLAGS) $(CONSOLE) defaults.c $(LFLAGS) -o $@ 32 | 33 | dynamic.exe: dynamic.c $(SOLIB) $(HEADER) 34 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) dynamic.c $(SO_LFLAGS) -o $@ 35 | 36 | events.exe: events.c $(LIB) $(HEADER) 37 | $(CC) $(CFLAGS) $(CONSOLE) events.c $(LFLAGS) -o $@ 38 | 39 | fsaa.exe: fsaa.c $(LIB) $(HEADER) 40 | $(CC) $(CFLAGS) $(CONSOLE) fsaa.c $(LFLAGS) -lm -o $@ 41 | 42 | fsinput.exe: fsinput.c $(LIB) $(HEADER) 43 | $(CC) $(CFLAGS) $(WINDOWS) fsinput.c $(LFLAGS) -lm -o $@ 44 | 45 | iconify.exe: iconify.c getopt.c $(LIB) $(HEADER) 46 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) iconify.c getopt.c $(LFLAGS) -o $@ 47 | 48 | joysticks.exe: joysticks.c $(LIB) $(HEADER) 49 | $(CC) $(CFLAGS) $(CONSOLE) joysticks.c $(LFLAGS) -lm -o $@ 50 | 51 | peter.exe: peter.c $(LIB) $(HEADER) 52 | $(CC) $(CFLAGS) $(CONSOLE) peter.c $(LFLAGS) -o $@ 53 | 54 | reopen.exe: reopen.c $(LIB) $(HEADER) 55 | $(CC) $(CFLAGS) $(CONSOLE) reopen.c $(LFLAGS) -lm -o $@ 56 | 57 | tearing.exe: tearing.c $(LIB) $(HEADER) 58 | $(CC) $(CFLAGS) $(WINDOWS) tearing.c $(LFLAGS) -lm -o $@ 59 | 60 | version.exe: version.c getopt.c $(LIB) $(HEADER) 61 | $(CC) $(CFLAGS) $(CONSOLE) version.c getopt.c $(LFLAGS) -lm -o $@ 62 | 63 | clean: 64 | rm -f $(BINARIES) 65 | 66 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/Makefile.win32.lcc: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on Windows using LCC-Win32. 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.win32.lcc 6 | ########################################################################## 7 | 8 | # Compiler settings 9 | CC = lc 10 | CFLAGS = -I..\\include -O -A 11 | #CFLAGS = -I..\\include -O -A -DGLFW_DLL 12 | 13 | # Linker settings 14 | LFLAGS = ..\\lib\\win32\\glfw.lib glu32.lib opengl32.lib 15 | #LFLAGS = ..\\lib\\win32\\glfwdll.lib glu32.lib opengl32.lib 16 | 17 | # Subsystem settings 18 | WINDOWS = -subsystem windows 19 | CONSOLE = -subsystem console 20 | 21 | 22 | # Default: Build all tests 23 | all: triangle.exe listmodes.exe mthello.exe pong3d.exe mtbench.exe \ 24 | particles.exe splitview.exe mipmaps.exe gears.exe boing.exe \ 25 | wave.exe heightmap.exe 26 | 27 | 28 | # Rule for triangle 29 | triangle.exe: triangle.c 30 | $(CC) $(CFLAGS) triangle.c $(LFLAGS) -o $@ -s $(WINDOWS) 31 | 32 | # Rule for listmodes 33 | listmodes.exe: listmodes.c 34 | $(CC) $(CFLAGS) listmodes.c $(LFLAGS) -o $@ -s $(CONSOLE) 35 | 36 | # Rule for mthello 37 | mthello.exe: mthello.c 38 | $(CC) $(CFLAGS) mthello.c $(LFLAGS) -o $@ -s $(CONSOLE) 39 | 40 | # Rule for pong3d 41 | pong3d.exe: pong3d.c 42 | $(CC) $(CFLAGS) pong3d.c $(LFLAGS) -o $@ -s $(WINDOWS) 43 | 44 | # Rule for mtbench 45 | mtbench.exe: mtbench.c 46 | $(CC) $(CFLAGS) mtbench.c $(LFLAGS) -o $@ -s $(CONSOLE) 47 | 48 | # Rule for particles 49 | particles.exe: particles.c 50 | $(CC) $(CFLAGS) particles.c $(LFLAGS) -o $@ -s $(CONSOLE) 51 | 52 | # Rule for splitview 53 | splitview.exe: splitview.c 54 | $(CC) $(CFLAGS) splitview.c $(LFLAGS) -o $@ -s $(WINDOWS) 55 | 56 | # Rule for mipmaps 57 | mipmaps.exe: mipmaps.c 58 | $(CC) $(CFLAGS) mipmaps.c $(LFLAGS) -o $@ -s $(WINDOWS) 59 | 60 | # Rule for gears 61 | gears.exe: gears.c 62 | $(CC) $(CFLAGS) gears.c $(LFLAGS) -o $@ -s $(WINDOWS) 63 | 64 | # Rule for boing 65 | boing.exe: boing.c 66 | $(CC) $(CFLAGS) boing.c $(LFLAGS) -o $@ -s $(WINDOWS) 67 | 68 | # Rule for wave 69 | wave.exe: wave.c 70 | $(CC) $(CFLAGS) wave.c $(LFLAGS) -o $@ -s $(WINDOWS) 71 | 72 | # Rule for heightmap 73 | heightmap.exe: heightmap.c getopt.c 74 | $(CC) $(CFLAGS) heightmap.c getopt.c $(LFLAGS) -o $@ -s $(WINDOWS) 75 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/Makefile.win32.cross-mgw: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on *nix using MinGW32 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.win32.cross-mgw 6 | ########################################################################## 7 | 8 | TARGET ?= i586-mingw32msvc- 9 | 10 | CC = gcc 11 | CFLAGS = -I../include -Wall -O2 12 | 13 | LIB = ../lib/win32/libglfw.a 14 | SOLIB = ../lib/win32/libglfwdll.a 15 | LFLAGS = $(LIB) -lglu32 -lopengl32 16 | SO_LFLAGS = $(SOLIB) -lglu32 -lopengl32 17 | 18 | WINDOWS = -mwindows 19 | CONSOLE = -mconsole 20 | 21 | BINARIES = accuracy.exe defaults.exe dynamic.exe events.exe fsaa.exe \ 22 | fsinput.exe iconify.exe joysticks.exe peter.exe reopen.exe \ 23 | tearing.exe version.exe 24 | 25 | HEADER = ../include/GL/glfw.h 26 | 27 | all: $(BINARIES) 28 | 29 | accuracy.exe: accuracy.c $(LIB) $(HEADER) 30 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) accuracy.c $(LFLAGS) -o $@ 31 | 32 | defaults.exe: defaults.c $(LIB) $(HEADER) 33 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) defaults.c $(LFLAGS) -o $@ 34 | 35 | dynamic.exe: dynamic.c $(SOLIB) $(HEADER) 36 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) dynamic.c $(SO_LFLAGS) -o $@ 37 | 38 | events.exe: events.c $(LIB) $(HEADER) 39 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) events.c $(LFLAGS) -o $@ 40 | 41 | fsaa.exe: fsaa.c $(LIB) $(HEADER) 42 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) fsaa.c $(LFLAGS) -o $@ 43 | 44 | fsinput.exe: fsinput.c $(LIB) $(HEADER) 45 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) fsinput.c $(LFLAGS) -o $@ 46 | 47 | iconify.exe: iconify.c getopt.c $(LIB) $(HEADER) 48 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) iconify.c getopt.c $(LFLAGS) -o $@ 49 | 50 | joysticks.exe: joysticks.c $(LIB) $(HEADER) 51 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) joysticks.c $(LFLAGS) -o $@ 52 | 53 | peter.exe: peter.c $(LIB) $(HEADER) 54 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) peter.c $(LFLAGS) -o $@ 55 | 56 | reopen.exe: reopen.c $(LIB) $(HEADER) 57 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) reopen.c $(LFLAGS) -o $@ 58 | 59 | tearing.exe: tearing.c $(LIB) $(HEADER) 60 | $(TARGET)$(CC) $(CFLAGS) $(WINDOWS) tearing.c $(LFLAGS) -o $@ 61 | 62 | version.exe: version.c getopt.c $(LIB) $(HEADER) 63 | $(TARGET)$(CC) $(CFLAGS) $(CONSOLE) version.c getopt.c $(LFLAGS) -o $@ 64 | 65 | clean: 66 | rm -f $(BINARIES) 67 | 68 | -------------------------------------------------------------------------------- /game/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #include "game.h" 19 | 20 | #include 21 | 22 | #ifdef _WIN32 23 | #include "sys/timeb.h" 24 | #endif 25 | 26 | #ifdef __clang__ 27 | #include 28 | #include 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include "mtrand.h" 36 | 37 | #include "main.h" 38 | 39 | #define VTB_IMPLEMENTATION 40 | #include "vtb.h" 41 | 42 | 43 | int main(int argc, char* argv[]) 44 | { 45 | // Create a game 46 | CGame game(argc, argv); 47 | 48 | // Open the game's window 49 | if (!game.OpenWindow(1000, 564, false, false)) 50 | { 51 | printf("Couldn't open OpenGL Window!\n"); 52 | return 1; 53 | } 54 | 55 | game.SetMouseCursorEnabled(false); 56 | 57 | game.Load(); 58 | 59 | // Run the game loop! 60 | game.GameLoop(); 61 | 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/carbon/carbon_enable.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: Carbon/AGL/CGL 4 | // API Version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2003 Keith Bauer 9 | // Copyright (c) 2003-2010 Camilla Berglund 10 | // 11 | // This software is provided 'as-is', without any express or implied 12 | // warranty. In no event will the authors be held liable for any damages 13 | // arising from the use of this software. 14 | // 15 | // Permission is granted to anyone to use this software for any purpose, 16 | // including commercial applications, and to alter it and redistribute it 17 | // freely, subject to the following restrictions: 18 | // 19 | // 1. The origin of this software must not be misrepresented; you must not 20 | // claim that you wrote the original software. If you use this software 21 | // in a product, an acknowledgment in the product documentation would 22 | // be appreciated but is not required. 23 | // 24 | // 2. Altered source versions must be plainly marked as such, and must not 25 | // be misrepresented as being the original software. 26 | // 27 | // 3. This notice may not be removed or altered from any source 28 | // distribution. 29 | // 30 | //======================================================================== 31 | 32 | 33 | //************************************************************************ 34 | //**** Platform implementation functions **** 35 | //************************************************************************ 36 | 37 | //======================================================================== 38 | // Enable system keys 39 | //======================================================================== 40 | 41 | void _glfwPlatformEnableSystemKeys( void ) 42 | { 43 | // Nothing to do; event handling code checks the status of 44 | // _glfwWin.sysKeysDisabled to ensure this behavior. 45 | } 46 | 47 | //======================================================================== 48 | // Disable system keys 49 | //======================================================================== 50 | 51 | void _glfwPlatformDisableSystemKeys( void ) 52 | { 53 | // Nothing to do; event handling code checks the status of 54 | // _glfwWin.sysKeysDisabled to ensure this behavior. 55 | } 56 | 57 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/Makefile.win32.ow: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on Windows using Open Watcom 1.0. 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # "wmake -ms -f Makefile.win32.ow" or "nmake -f Makefile.win32.ow" 6 | ########################################################################## 7 | 8 | # Compiler settings 9 | CC = wcl386 10 | CFLAGS = /Ox /I..\\include 11 | #CFLAGS = /Ox /I..\\include /DGLFW_DLL 12 | 13 | # Linker settings 14 | LFLAGS = ..\\lib\\win32\\glfw.lib opengl32.lib glu32.lib user32.lib 15 | #LFLAGS = ..\\lib\\win32\\glfwdll.lib opengl32.lib glu32.lib 16 | 17 | # Subsystem settings 18 | WINDOWS = -"RUNTIME windows=4.0 REFERENCE 'mainCRTStartup' OPTION { start='mainCRTStartup' quiet stack=1M }" 19 | CONSOLE = -"RUNTIME console REFERENCE _cstart_ OPTION { START=_cstart_ quiet stack=1M }" 20 | 21 | 22 | # Default: Build all tests 23 | all: triangle.exe listmodes.exe mthello.exe pong3d.exe mtbench.exe \ 24 | particles.exe splitview.exe mipmaps.exe gears.exe boing.exe \ 25 | wave.exe heightmap.exe 26 | 27 | 28 | # Rule for triangle 29 | triangle.exe: triangle.c 30 | $(CC) $(CFLAGS) /Fe$@ triangle.c $(LFLAGS) $(WINDOWS) 31 | 32 | # Rule for listmodes 33 | listmodes.exe: listmodes.c 34 | $(CC) $(CFLAGS) /Fe$@ listmodes.c $(LFLAGS) $(CONSOLE) 35 | 36 | # Rule for mthello 37 | mthello.exe: mthello.c 38 | $(CC) $(CFLAGS) /Fe$@ mthello.c $(LFLAGS) $(CONSOLE) 39 | 40 | # Rule for pong3d 41 | pong3d.exe: pong3d.c 42 | $(CC) $(CFLAGS) /Fe$@ pong3d.c $(LFLAGS) $(WINDOWS) 43 | 44 | # Rule for mtbench 45 | mtbench.exe: mtbench.c 46 | $(CC) $(CFLAGS) /Fe$@ mtbench.c $(LFLAGS) $(CONSOLE) 47 | 48 | # Rule for particles 49 | particles.exe: particles.c 50 | $(CC) $(CFLAGS) /Fe$@ particles.c $(LFLAGS) $(CONSOLE) 51 | 52 | # Rule for splitview 53 | splitview.exe: splitview.c 54 | $(CC) $(CFLAGS) /Fe$@ splitview.c $(LFLAGS) $(WINDOWS) 55 | 56 | # Rule for mipmaps 57 | mipmaps.exe: mipmaps.c 58 | $(CC) $(CFLAGS) /Fe$@ mipmaps.c $(LFLAGS) $(WINDOWS) 59 | 60 | # Rule for gears 61 | gears.exe: gears.c 62 | $(CC) $(CFLAGS) /Fe$@ gears.c $(LFLAGS) $(WINDOWS) 63 | 64 | # Rule for boing 65 | boing.exe: boing.c 66 | $(CC) $(CFLAGS) /Fe$@ boing.c $(LFLAGS) $(WINDOWS) 67 | 68 | # Rule for wave 69 | wave.exe: wave.c 70 | $(CC) $(CFLAGS) /Fe$@ wave.c $(LFLAGS) $(WINDOWS) 71 | 72 | # Rule for heightmap 73 | heightmap.exe: heightmap.c getopt.c 74 | $(CC) $(CFLAGS) /Fe$@ heightmap.c getopt.c $(LFLAGS) $(WINDOWS) 75 | -------------------------------------------------------------------------------- /math/plane.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "vector.h" 21 | 22 | // Plane class defined by a normal vector which should aways be unit length and a "distance" to the origin. 23 | // Also can be thought of as ax + by + cz + d = 0, the equation of a plane in 3D space, where a b and c are the x, y, z of the normal n. 24 | class CPlane 25 | { 26 | public: 27 | void Normalize() 28 | { 29 | // It helps a ton if our planes are normalized, meaning n is unit length. 30 | // To normalize the plane, we do this operation: 31 | // s(ax + by + cz + d) = s(0) 32 | // We calculate s by using 1/|n|, and it gets us the number we must scale n by to make it unit length. 33 | // Notice how d needs to be scaled also. 34 | 35 | float flScale = 1/n.Length(); 36 | n.x *= flScale; 37 | n.y *= flScale; 38 | n.z *= flScale; 39 | d *= flScale; 40 | } 41 | 42 | public: 43 | Vector n; // The normal 44 | float d; // The "distance" to the origin. 45 | }; 46 | -------------------------------------------------------------------------------- /game/handle.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #include "handle.h" 19 | 20 | #include "game.h" 21 | #include "character.h" 22 | 23 | void CHandle::operator=(const CCharacter* pCharacter) 24 | { 25 | if (!pCharacter) 26 | { 27 | m_iIndex = ~0; 28 | return; 29 | } 30 | 31 | m_iParity = pCharacter->m_iParity; 32 | m_iIndex = pCharacter->m_iIndex; 33 | } 34 | 35 | // Resolve a handle into a character pointer. 36 | // http://youtu.be/V6vq0PRFKgk 37 | CCharacter* CHandle::Get() const 38 | { 39 | if (m_iIndex == ~0) 40 | return nullptr; 41 | 42 | CCharacter* pCharacter = Game()->GetCharacterIndex(m_iIndex); 43 | if (!pCharacter) 44 | return nullptr; 45 | 46 | if (pCharacter->m_iParity != m_iParity) 47 | return nullptr; 48 | 49 | return pCharacter; 50 | } 51 | 52 | CCharacter* CHandle::operator->() const 53 | { 54 | return Get(); 55 | } 56 | 57 | CHandle::operator CCharacter*() const 58 | { 59 | return Get(); 60 | } 61 | 62 | bool CHandle::operator!() const 63 | { 64 | return !Get(); 65 | } 66 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/x11/x11_enable.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: X11 (Unix) 4 | // API version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #include "internal.h" 32 | 33 | 34 | //************************************************************************ 35 | //**** Platform implementation functions **** 36 | //************************************************************************ 37 | 38 | //======================================================================== 39 | // Enable system keys 40 | //======================================================================== 41 | 42 | void _glfwPlatformEnableSystemKeys( void ) 43 | { 44 | if( _glfwWin.keyboardGrabbed ) 45 | { 46 | XUngrabKeyboard( _glfwLibrary.display, CurrentTime ); 47 | _glfwWin.keyboardGrabbed = GL_FALSE; 48 | } 49 | } 50 | 51 | //======================================================================== 52 | // Disable system keys 53 | //======================================================================== 54 | 55 | void _glfwPlatformDisableSystemKeys( void ) 56 | { 57 | if( XGrabKeyboard( _glfwLibrary.display, _glfwWin.window, True, 58 | GrabModeAsync, GrabModeAsync, CurrentTime ) == 59 | GrabSuccess ) 60 | { 61 | _glfwWin.keyboardGrabbed = GL_TRUE; 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /glfw-2.7.9/docs/readme.txt: -------------------------------------------------------------------------------- 1 | Introduction 2 | ------------ 3 | 4 | The GLFW documentation is written in LaTeX, which I have found is a great 5 | tool for handling large and long-lived documents, where clumbsy s.c. 6 | WYSIWYG word processors (especially one from a major moneymaking company) 7 | fails in several aspects (document integrity being a serious Achilles 8 | heel). 9 | 10 | Besides being powerful, LaTeX is also very attractive since all the 11 | necessary tools for dealing with LaTeX documentation are both free and 12 | ported to a wide variety of platforms. Another advantage is that the LaTeX 13 | files are written in plain text, which means that version handling systems 14 | such as CVS handle them perfectly, without having to treat the documents 15 | as binary files. 16 | 17 | Ok, so much for the LaTeX glory. Now to the GLFW documentation... 18 | 19 | 20 | The Documents 21 | ------------- 22 | 23 | There are two main documents: 24 | 25 | glfwrm.tex - The GLFW Reference Manual 26 | glfwug.tex - The GLFW Users Guide 27 | 28 | In addition, there is a common LaTeX style file, which sets up things 29 | such as page formatting and useful macros: 30 | 31 | glfwdoc.sty - Common GLFW document styles and macros 32 | 33 | 34 | Requirements 35 | ------------ 36 | 37 | Of course you need LaTeX installed on your system in order to compile 38 | the GLFW documentation. The easiest way to get a full LaTeX system is to 39 | download/get the TeXLive CD from http://www.tug.org/texlive/. It has all 40 | the necessary software for Windows, Mac OS X and most popular Unix 41 | flavours (including Linux, FreeBSD, Solaris, IRIX etc). 42 | 43 | A number of LaTeX packages have to be installed in order to compile the 44 | GLFW documentation successfully: 45 | 46 | color 47 | fancyhdr 48 | hyperref 49 | lastpage 50 | listings 51 | needspace 52 | textcase 53 | times 54 | titling 55 | 56 | These packages are all available on the TeXLive CD. Just make sure that 57 | you have checked all these packages when installing TeXLive, or get them 58 | in some other way if you do not have the TeXLive CD. 59 | 60 | 61 | Build Files 62 | ----------- 63 | 64 | For convenience, I have created a Makefile that will build PDF documents 65 | from the LaTeX files. It is nothing fancy, but handles things like 66 | up-to-date TOC generation. It can also be used for cleaning up most (all?) 67 | of the files generated by the Makefile, by calling 'make clean' (Unix) or 68 | 'make clean-win' (Windows). 69 | 70 | Since Windows does not have a portable 'rm -f' counterpart, a special 71 | cleanup batch file was created, which is called 'cleanup.bat' (it is 72 | called when 'make clean-win' is run). 73 | 74 | 75 | 76 | Good luck! 77 | 78 | Marcus 79 | 80 | 81 | -------------------------------------------------------------------------------- /common/mtrand.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #include "mtrand.h" 19 | 20 | #define MT_SIZE 624 21 | static size_t g_aiMT[MT_SIZE]; 22 | static size_t g_iMTI = 0; 23 | 24 | // Mersenne Twister implementation from Wikipedia. 25 | void mtsrand(size_t iSeed) 26 | { 27 | g_aiMT[0] = iSeed; 28 | for (size_t i = 1; i < MT_SIZE; i++) 29 | { 30 | size_t inner1 = g_aiMT[i-1]; 31 | size_t inner2 = (g_aiMT[i-1]>>30); 32 | size_t inner = inner1 ^ inner2; 33 | g_aiMT[i] = (0x6c078965 * inner) + i; 34 | } 35 | 36 | g_iMTI = 0; 37 | } 38 | 39 | size_t mtrand() 40 | { 41 | if (g_iMTI == 0) 42 | { 43 | for (size_t i = 0; i < MT_SIZE; i++) 44 | { 45 | size_t y = (0x80000000&(g_aiMT[i])) + (0x7fffffff&(g_aiMT[(i+1) % MT_SIZE])); 46 | g_aiMT[i] = g_aiMT[(i + 397)%MT_SIZE] ^ (y>>1); 47 | if ((y%2) == 1) 48 | g_aiMT[i] = g_aiMT[i] ^ 0x9908b0df; 49 | } 50 | } 51 | 52 | size_t y = g_aiMT[g_iMTI]; 53 | y = y ^ (y >> 11); 54 | y = y ^ ((y << 7) & (0x9d2c5680)); 55 | y = y ^ ((y << 15) & (0xefc60000)); 56 | y = y ^ (y >> 18); 57 | 58 | g_iMTI = (g_iMTI + 1) % MT_SIZE; 59 | 60 | return y; 61 | } 62 | -------------------------------------------------------------------------------- /glfw-2.7.9/support/d/lib/glfwdll.def: -------------------------------------------------------------------------------- 1 | LIBRARY glfw 2 | EXETYPE NT 3 | SUBSYSTEM WINDOWS 4 | EXPORTS 5 | _glfwBroadcastCond@4 = glfwBroadcastCond 6 | _glfwCloseWindow@0 = glfwCloseWindow 7 | _glfwCreateCond@0 = glfwCreateCond 8 | _glfwCreateMutex@0 = glfwCreateMutex 9 | _glfwCreateThread@8 = glfwCreateThread 10 | _glfwDestroyCond@4 = glfwDestroyCond 11 | _glfwDestroyMutex@4 = glfwDestroyMutex 12 | _glfwDestroyThread@4 = glfwDestroyThread 13 | _glfwDisable@4 = glfwDisable 14 | _glfwEnable@4 = glfwEnable 15 | _glfwExtensionSupported@4 = glfwExtensionSupported 16 | _glfwFreeImage@4 = glfwFreeImage 17 | _glfwGetDesktopMode@4 = glfwGetDesktopMode 18 | _glfwGetJoystickButtons@12 = glfwGetJoystickButtons 19 | _glfwGetJoystickParam@8 = glfwGetJoystickParam 20 | _glfwGetJoystickPos@12 = glfwGetJoystickPos 21 | _glfwGetKey@4 = glfwGetKey 22 | _glfwGetMouseButton@4 = glfwGetMouseButton 23 | _glfwGetMousePos@8 = glfwGetMousePos 24 | _glfwGetMouseWheel@0 = glfwGetMouseWheel 25 | _glfwGetNumberOfProcessors@0 = glfwGetNumberOfProcessors 26 | _glfwGetProcAddress@4 = glfwGetProcAddress 27 | _glfwGetThreadID@0 = glfwGetThreadID 28 | _glfwGetTime@0 = glfwGetTime 29 | _glfwGetVersion@12 = glfwGetVersion 30 | _glfwGetVideoModes@8 = glfwGetVideoModes 31 | _glfwGetWindowParam@4 = glfwGetWindowParam 32 | _glfwGetWindowSize@8 = glfwGetWindowSize 33 | _glfwIconifyWindow@0 = glfwIconifyWindow 34 | _glfwInit@0 = glfwInit 35 | _glfwLoadTexture2D@8 = glfwLoadTexture2D 36 | _glfwLockMutex@4 = glfwLockMutex 37 | _glfwOpenWindow@36 = glfwOpenWindow 38 | _glfwOpenWindowHint@8 = glfwOpenWindowHint 39 | _glfwPollEvents@0 = glfwPollEvents 40 | _glfwReadImage@12 = glfwReadImage 41 | _glfwRestoreWindow@0 = glfwRestoreWindow 42 | _glfwSetCharCallback@4 = glfwSetCharCallback 43 | _glfwSetKeyCallback@4 = glfwSetKeyCallback 44 | _glfwSetMouseButtonCallback@4 = glfwSetMouseButtonCallback 45 | _glfwSetMousePos@8 = glfwSetMousePos 46 | _glfwSetMousePosCallback@4 = glfwSetMousePosCallback 47 | _glfwSetMouseWheel@4 = glfwSetMouseWheel 48 | _glfwSetMouseWheelCallback@4 = glfwSetMouseWheelCallback 49 | _glfwSetTime@8 = glfwSetTime 50 | _glfwSetWindowCloseCallback@4 = glfwSetWindowCloseCallback 51 | _glfwSetWindowRefreshCallback@4 = glfwSetWindowRefreshCallback 52 | _glfwSetWindowPos@8 = glfwSetWindowPos 53 | _glfwSetWindowSize@8 = glfwSetWindowSize 54 | _glfwSetWindowSizeCallback@4 = glfwSetWindowSizeCallback 55 | _glfwSetWindowTitle@4 = glfwSetWindowTitle 56 | _glfwSignalCond@4 = glfwSignalCond 57 | _glfwSleep@8 = glfwSleep 58 | _glfwSwapBuffers@0 = glfwSwapBuffers 59 | _glfwSwapInterval@4 = glfwSwapInterval 60 | _glfwTerminate@0 = glfwTerminate 61 | _glfwUnlockMutex@4 = glfwUnlockMutex 62 | _glfwWaitCond@16 = glfwWaitCond 63 | _glfwWaitEvents@0 = glfwWaitEvents 64 | _glfwWaitThread@8 = glfwWaitThread 65 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/dynamic.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Dynamic linking test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test came about as the result of bug #3060461 27 | // 28 | //======================================================================== 29 | 30 | #define GLFW_DLL 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | static void GLFWCALL window_size_callback(int width, int height) 37 | { 38 | glViewport(0, 0, width, height); 39 | } 40 | 41 | int main(void) 42 | { 43 | int major, minor, rev; 44 | glfwGetVersion(&major, &minor, &rev); 45 | 46 | if (major != GLFW_VERSION_MAJOR || 47 | minor != GLFW_VERSION_MINOR || 48 | rev != GLFW_VERSION_REVISION) 49 | { 50 | fprintf(stderr, "GLFW library version mismatch\n"); 51 | exit(EXIT_FAILURE); 52 | } 53 | 54 | if (!glfwInit()) 55 | { 56 | fprintf(stderr, "Failed to initialize GLFW\n"); 57 | exit(EXIT_FAILURE); 58 | } 59 | 60 | if (!glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) 61 | { 62 | fprintf(stderr, "Failed to open GLFW window\n"); 63 | exit(EXIT_FAILURE); 64 | } 65 | 66 | glfwSetWindowTitle("Dynamic Linking Test"); 67 | glfwSetWindowSizeCallback(window_size_callback); 68 | glfwSwapInterval(1); 69 | 70 | glClearColor(0, 0, 0, 0); 71 | 72 | glMatrixMode(GL_MODELVIEW); 73 | glLoadIdentity(); 74 | 75 | while (glfwGetWindowParam(GLFW_OPENED)) 76 | { 77 | glClear(GL_COLOR_BUFFER_BIT); 78 | 79 | glfwSwapBuffers(); 80 | } 81 | 82 | glfwTerminate(); 83 | exit(EXIT_SUCCESS); 84 | } 85 | 86 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/carbon/carbon_joystick.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: Carbon/AGL/CGL 4 | // API Version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2003 Keith Bauer 9 | // Copyright (c) 2003-2010 Camilla Berglund 10 | // 11 | // This software is provided 'as-is', without any express or implied 12 | // warranty. In no event will the authors be held liable for any damages 13 | // arising from the use of this software. 14 | // 15 | // Permission is granted to anyone to use this software for any purpose, 16 | // including commercial applications, and to alter it and redistribute it 17 | // freely, subject to the following restrictions: 18 | // 19 | // 1. The origin of this software must not be misrepresented; you must not 20 | // claim that you wrote the original software. If you use this software 21 | // in a product, an acknowledgment in the product documentation would 22 | // be appreciated but is not required. 23 | // 24 | // 2. Altered source versions must be plainly marked as such, and must not 25 | // be misrepresented as being the original software. 26 | // 27 | // 3. This notice may not be removed or altered from any source 28 | // distribution. 29 | // 30 | //======================================================================== 31 | 32 | #include "internal.h" 33 | 34 | // TO DO: use HID manager to implement joystick support. 35 | 36 | //************************************************************************ 37 | //**** Platform implementation functions **** 38 | //************************************************************************ 39 | 40 | //======================================================================== 41 | // Determine joystick capabilities 42 | //======================================================================== 43 | 44 | int _glfwPlatformGetJoystickParam( int joy, int param ) 45 | { 46 | // GL_FALSE == 0 47 | return 0; 48 | } 49 | 50 | //======================================================================== 51 | // Get joystick axis positions 52 | //======================================================================== 53 | 54 | int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes ) 55 | { 56 | return 0; 57 | } 58 | 59 | //======================================================================== 60 | // Get joystick button states 61 | //======================================================================== 62 | 63 | int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons, int numbuttons ) 64 | { 65 | return 0; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /content/shaders/functions.si: -------------------------------------------------------------------------------- 1 | #if 0//defined(USE_MULTISAMPLE_TEXTURES) 2 | #define tsampler2D sampler2DMS 3 | //#extension GL_ARB_texture_multisample : enable 4 | //#extension GL_ARB_sample_shading : require 5 | 6 | vec4 ttexture(tsampler2D iSampler, vec2 vecCoordinates) 7 | { 8 | vec2 ivecCoords = vecCoordinates*textureSize(iSampler); 9 | return texelFetch(iSampler, ivec2(ivecCoords), 0);//gl_SampleID); 10 | } 11 | #else 12 | #define tsampler2D sampler2D 13 | 14 | vec4 ttexture(tsampler2D iSampler, vec2 vecCoordinates) 15 | { 16 | return texture(iSampler, vecCoordinates); 17 | } 18 | #endif 19 | 20 | // These common functions will be included in the build of every other shader. 21 | 22 | float RemapVal(float flInput, float flInLo, float flInHi, float flOutLo, float flOutHi) 23 | { 24 | return (((flInput-flInLo) / (flInHi-flInLo)) * (flOutHi-flOutLo)) + flOutLo; 25 | } 26 | 27 | float RemapValClamped(float flInput, float flInLo, float flInHi, float flOutLo, float flOutHi) 28 | { 29 | if (flInput < flInLo) 30 | return flOutLo; 31 | if (flInput > flInHi) 32 | return flOutHi; 33 | return (((flInput-flInLo) / (flInHi-flInLo)) * (flOutHi-flOutLo)) + flOutLo; 34 | } 35 | 36 | float Clamped(float flInput, float flLo, float flHi) 37 | { 38 | if (flInput < flLo) 39 | return flLo; 40 | if (flInput > flHi) 41 | return flHi; 42 | return flInput; 43 | } 44 | 45 | float LengthSqr(vec3 v) 46 | { 47 | return v.x*v.x + v.y*v.y + v.z*v.z; 48 | } 49 | 50 | float LengthSqr(vec2 v) 51 | { 52 | return v.x*v.x + v.y*v.y; 53 | } 54 | 55 | float Length2DSqr(vec3 v) 56 | { 57 | return v.x*v.x + v.z*v.z; 58 | } 59 | 60 | float Lerp(float x, float flLerp) 61 | { 62 | if (flLerp == 0.5) 63 | return x; 64 | 65 | return pow(x, log(flLerp) * -1.4427); 66 | } 67 | 68 | float DistanceToLineSegmentSqr(vec3 p, vec3 v1, vec3 v2) 69 | { 70 | float flResult; 71 | vec3 v = v2 - v1; 72 | vec3 w = p - v1; 73 | float c1 = dot(w, v); 74 | if (c1 < 0.0) 75 | flResult = LengthSqr(v1-p); 76 | else 77 | { 78 | float c2 = dot(v, v); 79 | if (c2 < c1) 80 | flResult = LengthSqr(v2-p); 81 | else 82 | { 83 | float b = c1/c2; 84 | vec3 vb = v1 + v*b; 85 | flResult = LengthSqr(vb - p); 86 | } 87 | } 88 | return flResult; 89 | } 90 | 91 | float AngleDifference(float a, float b) 92 | { 93 | float flYawDifference = a - b; 94 | if ( a > b ) 95 | while ( flYawDifference >= 180.0 ) 96 | flYawDifference -= 360.0; 97 | else 98 | while ( flYawDifference <= -180.0 ) 99 | flYawDifference += 360.0; 100 | return flYawDifference; 101 | } 102 | 103 | mat4 InvertTR(mat4 m) 104 | { 105 | mat4 mInverse = m; 106 | mInverse[3] = vec4(0.0, 0.0, 0.0, 1.0); 107 | mInverse = -transpose(mInverse); 108 | mInverse[3] = -m[3]; 109 | 110 | return mInverse; 111 | } 112 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/cocoa/cocoa_glext.m: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: Cocoa/NSOpenGL 4 | // API Version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2009-2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | //************************************************************************ 33 | //**** Platform implementation functions **** 34 | //************************************************************************ 35 | 36 | //======================================================================== 37 | // Check if an OpenGL extension is available at runtime 38 | //======================================================================== 39 | 40 | int _glfwPlatformExtensionSupported( const char *extension ) 41 | { 42 | // There are no AGL, CGL or NSGL extensions. 43 | return GL_FALSE; 44 | } 45 | 46 | 47 | //======================================================================== 48 | // Get the function pointer to an OpenGL function 49 | //======================================================================== 50 | 51 | void * _glfwPlatformGetProcAddress( const char *procname ) 52 | { 53 | CFStringRef symbolName = CFStringCreateWithCString( kCFAllocatorDefault, 54 | procname, 55 | kCFStringEncodingASCII ); 56 | 57 | void *symbol = CFBundleGetFunctionPointerForName( _glfwLibrary.OpenGLFramework, 58 | symbolName ); 59 | 60 | CFRelease( symbolName ); 61 | 62 | return symbol; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /math/aabb.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "vector.h" 21 | 22 | class AABB 23 | { 24 | public: 25 | AABB() 26 | { 27 | } 28 | 29 | AABB(const Vector& min, const Vector& max) 30 | { 31 | vecMin = min; 32 | vecMax = max; 33 | } 34 | 35 | const AABB operator*(const Vector& s) const 36 | { 37 | AABB result = (*this); 38 | 39 | result.vecMin.x *= s.x; 40 | result.vecMin.y *= s.y; 41 | result.vecMin.z *= s.z; 42 | 43 | result.vecMax.x *= s.x; 44 | result.vecMax.y *= s.y; 45 | result.vecMax.z *= s.z; 46 | 47 | return result; 48 | } 49 | 50 | AABB operator+(const Point& p) const 51 | { 52 | AABB result = (*this); 53 | result.vecMin = p + vecMin; 54 | result.vecMax = p + vecMax; 55 | return result; 56 | } 57 | 58 | float GetHeight() const 59 | { 60 | return vecMax.y-vecMin.y; 61 | } 62 | 63 | // What is the center of the smallest sphere that will enclose this AABB? 64 | Vector GetCenter() const 65 | { 66 | return (vecMax+vecMin)/2; 67 | } 68 | 69 | // What is the radius of the smallest sphere that will enclose this AABB? 70 | float GetRadius() const 71 | { 72 | return ((vecMax-vecMin)/2).Length(); 73 | } 74 | 75 | public: 76 | Vector vecMin; 77 | Vector vecMax; 78 | }; 79 | -------------------------------------------------------------------------------- /common/common_platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | void GetScreenSize(int& iWidth, int& iHeight); 24 | size_t GetNumberOfProcessors(); 25 | void SleepMS(size_t iMS); 26 | void OpenBrowser(const std::string& sURL); 27 | void OpenExplorer(const std::string& sDirectory); 28 | void Alert(const std::string& sMessage); 29 | std::string GetClipboard(); 30 | void SetClipboard(const std::string& sBuf); 31 | std::string GetAppDataDirectory(const std::string& sDirectory, const std::string& sFile = ""); 32 | std::vector ListDirectory(const std::string& sDirectory, bool bDirectories = true); 33 | bool IsFile(const std::string& sPath); 34 | bool IsDirectory(const std::string& sPath); 35 | void CreateDirectoryNonRecursive(const std::string& sPath); 36 | bool CopyFileTo(const std::string& sFrom, const std::string& sTo, bool bOverride = true); 37 | std::string FindAbsolutePath(const std::string& sPath); 38 | time_t GetFileModificationTime(const char* pszFile); 39 | void DebugPrint(const char* pszText); 40 | void Exec(const std::string& sLine); 41 | int TranslateKeyToQwerty(int iKey); 42 | int TranslateKeyFromQwerty(int iKey); 43 | 44 | #ifdef _WIN32 45 | #define DIR_SEP "\\" 46 | #else 47 | #define DIR_SEP "/" 48 | #endif 49 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/carbon/carbon_glext.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: Carbon/AGL/CGL 4 | // API Version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2003 Keith Bauer 9 | // Copyright (c) 2003-2010 Camilla Berglund 10 | // 11 | // This software is provided 'as-is', without any express or implied 12 | // warranty. In no event will the authors be held liable for any damages 13 | // arising from the use of this software. 14 | // 15 | // Permission is granted to anyone to use this software for any purpose, 16 | // including commercial applications, and to alter it and redistribute it 17 | // freely, subject to the following restrictions: 18 | // 19 | // 1. The origin of this software must not be misrepresented; you must not 20 | // claim that you wrote the original software. If you use this software 21 | // in a product, an acknowledgment in the product documentation would 22 | // be appreciated but is not required. 23 | // 24 | // 2. Altered source versions must be plainly marked as such, and must not 25 | // be misrepresented as being the original software. 26 | // 27 | // 3. This notice may not be removed or altered from any source 28 | // distribution. 29 | // 30 | //======================================================================== 31 | 32 | #include "internal.h" 33 | 34 | //************************************************************************ 35 | //**** Platform implementation functions **** 36 | //************************************************************************ 37 | 38 | //======================================================================== 39 | // Check if an OpenGL extension is available at runtime 40 | //======================================================================== 41 | 42 | int _glfwPlatformExtensionSupported( const char *extension ) 43 | { 44 | // There are no AGL, CGL or NSGL extensions. 45 | return GL_FALSE; 46 | } 47 | 48 | //======================================================================== 49 | // Get the function pointer to an OpenGL function 50 | //======================================================================== 51 | 52 | void * _glfwPlatformGetProcAddress( const char *procname ) 53 | { 54 | CFStringRef symbolName = CFStringCreateWithCString( kCFAllocatorDefault, 55 | procname, 56 | kCFStringEncodingASCII ); 57 | 58 | void *symbol = CFBundleGetFunctionPointerForName( _glfwLibrary.Libs.OpenGLFramework, 59 | symbolName ); 60 | 61 | CFRelease( symbolName ); 62 | 63 | return symbol; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/Makefile.cocoa: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW examples on Mac OS X on Cocoa using Apple GCC 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.cocoa 6 | ########################################################################## 7 | 8 | # Compiler settings 9 | CC ?= cc 10 | CFLAGS ?= -O2 -g 11 | CFLAGS += -I../include 12 | 13 | # Linker settings 14 | LIB = ../lib/cocoa/libglfw.a 15 | LFLAGS = $(LIB) -framework Cocoa -framework OpenGL -framework IOKit 16 | 17 | # Default: Build all tests 18 | all: Triangle.app/Contents/MacOS/Triangle \ 19 | listmodes \ 20 | mthello \ 21 | Pong3D.app/Contents/MacOS/Pong3D \ 22 | mtbench \ 23 | Particles.app/Contents/MacOS/Particles \ 24 | SplitView.app/Contents/MacOS/SplitView \ 25 | Mipmaps.app/Contents/MacOS/Mipmaps \ 26 | Gears.app/Contents/MacOS/Gears \ 27 | Boing.app/Contents/MacOS/Boing \ 28 | Wave.app/Contents/MacOS/Wave 29 | 30 | Triangle.app/Contents/MacOS/Triangle: triangle.c $(LIB) 31 | /bin/sh bundle.sh Triangle 32 | $(CC) $(CFLAGS) triangle.c $(LFLAGS) -o Triangle.app/Contents/MacOS/Triangle 33 | 34 | listmodes: listmodes.c $(LIB) 35 | $(CC) $(CFLAGS) listmodes.c $(LFLAGS) -o listmodes 36 | 37 | mthello: mthello.c $(LIB) 38 | $(CC) $(CFLAGS) mthello.c $(LFLAGS) -o mthello 39 | 40 | Pong3D.app/Contents/MacOS/Pong3D: pong3d.c $(LIB) 41 | /bin/sh bundle.sh Pong3D 42 | cp pong3d_*.tga Pong3D.app/Contents/Resources/ 43 | $(CC) $(CFLAGS) pong3d.c $(LFLAGS) -o Pong3D.app/Contents/MacOS/Pong3D 44 | 45 | mtbench: mtbench.c $(LIB) 46 | $(CC) $(CFLAGS) mtbench.c $(LFLAGS) -o mtbench 47 | 48 | Particles.app/Contents/MacOS/Particles: particles.c $(LIB) 49 | /bin/sh bundle.sh Particles 50 | $(CC) $(CFLAGS) particles.c $(LFLAGS) -o Particles.app/Contents/MacOS/Particles 51 | 52 | SplitView.app/Contents/MacOS/SplitView: splitview.c $(LIB) 53 | /bin/sh bundle.sh SplitView 54 | $(CC) $(CFLAGS) splitview.c $(LFLAGS) -o SplitView.app/Contents/MacOS/SplitView 55 | 56 | Mipmaps.app/Contents/MacOS/Mipmaps: mipmaps.c $(LIB) 57 | /bin/sh bundle.sh Mipmaps 58 | cp mipmaps.tga Mipmaps.app/Contents/Resources/ 59 | $(CC) $(CFLAGS) mipmaps.c $(LFLAGS) -o Mipmaps.app/Contents/MacOS/Mipmaps 60 | 61 | Gears.app/Contents/MacOS/Gears: gears.c $(LIB) 62 | /bin/sh bundle.sh Gears 63 | $(CC) $(CFLAGS) gears.c $(LFLAGS) -o Gears.app/Contents/MacOS/Gears 64 | 65 | Boing.app/Contents/MacOS/Boing: boing.c $(LIB) 66 | /bin/sh bundle.sh Boing 67 | $(CC) $(CFLAGS) boing.c $(LFLAGS) -o Boing.app/Contents/MacOS/Boing 68 | 69 | Wave.app/Contents/MacOS/Wave: wave.c $(LIB) 70 | /bin/sh bundle.sh Wave 71 | $(CC) $(CFLAGS) wave.c $(LFLAGS) -o Wave.app/Contents/MacOS/Wave 72 | 73 | clean: 74 | rm -rf Triangle.app listmodes mthello Pong3D.app mtbench Particles.app \ 75 | SplitView.app Mipmaps.app Gears.app Boing.app Wave.app 76 | 77 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: Any 4 | // API version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #include "internal.h" 32 | 33 | 34 | //************************************************************************ 35 | //**** GLFW user functions **** 36 | //************************************************************************ 37 | 38 | //======================================================================== 39 | // Return timer value in seconds 40 | //======================================================================== 41 | 42 | GLFWAPI double GLFWAPIENTRY glfwGetTime( void ) 43 | { 44 | // Is GLFW initialized? 45 | if( !_glfwInitialized ) 46 | { 47 | return 0.0; 48 | } 49 | 50 | return _glfwPlatformGetTime(); 51 | } 52 | 53 | 54 | //======================================================================== 55 | // Set timer value in seconds 56 | //======================================================================== 57 | 58 | GLFWAPI void GLFWAPIENTRY glfwSetTime( double time ) 59 | { 60 | // Is GLFW initialized? 61 | if( !_glfwInitialized ) 62 | { 63 | return; 64 | } 65 | 66 | _glfwPlatformSetTime( time ); 67 | } 68 | 69 | 70 | //======================================================================== 71 | // Put a thread to sleep for a specified amount of time 72 | //======================================================================== 73 | 74 | GLFWAPI void GLFWAPIENTRY glfwSleep( double time ) 75 | { 76 | // Is GLFW initialized? 77 | if( !_glfwInitialized ) 78 | { 79 | return; 80 | } 81 | 82 | _glfwPlatformSleep( time ); 83 | } 84 | 85 | -------------------------------------------------------------------------------- /math/euler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #include "euler.h" 19 | 20 | #include "vector.h" 21 | #include "quaternion.h" 22 | 23 | #include 24 | 25 | // Converts a direction vector into an euler angle, assuming up (0, 1, 0) 26 | EAngle::EAngle(const Vector& vecDirection) 27 | { 28 | p = atan2(vecDirection.y, sqrt(vecDirection.x*vecDirection.x + vecDirection.z*vecDirection.z)) * (float)(180/M_PI); 29 | y = (float)atan2(vecDirection.z, vecDirection.x) * (float)(180/M_PI); 30 | r = 0; 31 | } 32 | 33 | // Convert euler angles to a vector: https://www.youtube.com/watch?v=zZM2uUkEoFw 34 | Vector EAngle::ToVector() const 35 | { 36 | Vector result; 37 | 38 | // Convert from degrees to radians. 39 | float y2 = y/360*2*(float)M_PI; 40 | float p2 = p/360*2*(float)M_PI; 41 | 42 | result.x = cos(y2)*cos(p2); 43 | result.y = sin(p2); 44 | result.z = sin(y2)*cos(p2); 45 | 46 | return result; 47 | } 48 | 49 | void EAngle::ToAxisAngle(Vector& vecAxis, float& flAngle) const 50 | { 51 | // Use Quaternions to do our dirty work. 52 | Quaternion qRoll(Vector(1, 0, 0), r); 53 | Quaternion qPitch(Vector(0, 0, 1), p); 54 | Quaternion qYaw(Vector(0, 1, 0), y); 55 | 56 | Quaternion qEuler = qYaw * qPitch * qRoll; 57 | 58 | qEuler.ToAxisAngle(vecAxis, flAngle); 59 | } 60 | 61 | void EAngle::Normalize() 62 | { 63 | if (p > 89) 64 | p = 89; 65 | if (p < -89) 66 | p = -89; 67 | 68 | while (y < -180) 69 | y += 360; 70 | while (y > 180) 71 | y -= 360; 72 | } 73 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/Makefile.carbon: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on Mac OS X using Apple GCC. 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.carbon 6 | ########################################################################## 7 | 8 | # Compiler settings 9 | CC = gcc 10 | CFLAGS = -I../include -m32 11 | 12 | # Linker settings 13 | LIB = ../lib/carbon/libglfw.a 14 | HEADER = ../include/GL/glfw.h 15 | LFLAGS = $(LIB) -framework AGL -framework OpenGL -framework Carbon -m32 16 | 17 | # Default: Build all tests 18 | all: Triangle.app/Contents/MacOS/Triangle \ 19 | listmodes \ 20 | mthello \ 21 | Pong3D.app/Contents/MacOS/Pong3D \ 22 | mtbench \ 23 | Particles.app/Contents/MacOS/Particles \ 24 | SplitView.app/Contents/MacOS/SplitView \ 25 | Mipmaps.app/Contents/MacOS/Mipmaps \ 26 | Gears.app/Contents/MacOS/Gears \ 27 | Boing.app/Contents/MacOS/Boing \ 28 | Wave.app/Contents/MacOS/Wave 29 | 30 | Triangle.app/Contents/MacOS/Triangle: triangle.c $(LIB) $(HEADER) 31 | /bin/sh bundle.sh Triangle 32 | $(CC) $(CFLAGS) triangle.c $(LFLAGS) -o Triangle.app/Contents/MacOS/Triangle 33 | 34 | listmodes: listmodes.c $(LIB) $(HEADER) 35 | $(CC) $(CFLAGS) listmodes.c $(LFLAGS) -o listmodes 36 | 37 | mthello: mthello.c $(LIB) $(HEADER) 38 | $(CC) $(CFLAGS) mthello.c $(LFLAGS) -o mthello 39 | 40 | Pong3D.app/Contents/MacOS/Pong3D: pong3d.c $(LIB) $(HEADER) 41 | /bin/sh bundle.sh Pong3D 42 | cp pong3d_*.tga Pong3D.app/Contents/Resources/ 43 | $(CC) $(CFLAGS) pong3d.c $(LFLAGS) -o Pong3D.app/Contents/MacOS/Pong3D 44 | 45 | mtbench: mtbench.c $(LIB) $(HEADER) 46 | $(CC) $(CFLAGS) mtbench.c $(LFLAGS) -o mtbench 47 | 48 | Particles.app/Contents/MacOS/Particles: particles.c $(LIB) $(HEADER) 49 | /bin/sh bundle.sh Particles 50 | $(CC) $(CFLAGS) particles.c $(LFLAGS) -o Particles.app/Contents/MacOS/Particles 51 | 52 | SplitView.app/Contents/MacOS/SplitView: splitview.c $(LIB) $(HEADER) 53 | /bin/sh bundle.sh SplitView 54 | $(CC) $(CFLAGS) splitview.c $(LFLAGS) -o SplitView.app/Contents/MacOS/SplitView 55 | 56 | Mipmaps.app/Contents/MacOS/Mipmaps: mipmaps.c $(LIB) $(HEADER) 57 | /bin/sh bundle.sh Mipmaps 58 | cp mipmaps.tga Mipmaps.app/Contents/Resources/ 59 | $(CC) $(CFLAGS) mipmaps.c $(LFLAGS) -o Mipmaps.app/Contents/MacOS/Mipmaps 60 | 61 | Gears.app/Contents/MacOS/Gears: gears.c $(LIB) $(HEADER) 62 | /bin/sh bundle.sh Gears 63 | $(CC) $(CFLAGS) gears.c $(LFLAGS) -o Gears.app/Contents/MacOS/Gears 64 | 65 | Boing.app/Contents/MacOS/Boing: boing.c $(LIB) $(HEADER) 66 | /bin/sh bundle.sh Boing 67 | $(CC) $(CFLAGS) boing.c $(LFLAGS) -o Boing.app/Contents/MacOS/Boing 68 | 69 | Wave.app/Contents/MacOS/Wave: wave.c $(LIB) $(HEADER) 70 | /bin/sh bundle.sh Wave 71 | $(CC) $(CFLAGS) wave.c $(LFLAGS) -o Wave.app/Contents/MacOS/Wave 72 | 73 | clean: 74 | rm -rf Triangle.app listmodes mthello Pong3D.app mtbench Particles.app \ 75 | SplitView.app Mipmaps.app Gears.app Boing.app Wave.app 76 | 77 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/Makefile.carbon: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on Mac OS X using Apple GCC. 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.carbon 6 | ########################################################################## 7 | 8 | # Compiler settings 9 | CC = gcc 10 | CFLAGS = -I../include -m32 11 | 12 | # Linker settings 13 | LIB = ../lib/carbon/libglfw.a 14 | SOLIB = ../lib/carbon/libglfw.dylib 15 | LFLAGS = $(LIB) -framework AGL -framework OpenGL -framework Carbon -m32 16 | SO_LFLAGS = $(SOLIB) -framework OpenGL -m32 17 | 18 | # Default: Build all tests 19 | all: Accuracy.app/Contents/MacOS/Accuracy \ 20 | defaults \ 21 | Dynamic.app/Contents/MacOS/Dynamic \ 22 | events \ 23 | FSAA.app/Contents/MacOS/FSAA \ 24 | FSInput.app/Contents/MacOS/FSInput \ 25 | Iconify.app/Contents/MacOS/Iconify \ 26 | joysticks \ 27 | Peter.app/Contents/MacOS/Peter \ 28 | ReOpen.app/Contents/MacOS/ReOpen \ 29 | Tearing.app/Contents/MacOS/Tearing \ 30 | version 31 | 32 | Accuracy.app/Contents/MacOS/Accuracy: accuracy.c $(LIB) 33 | /bin/sh bundle.sh Accuracy 34 | $(CC) $(CFLAGS) accuracy.c $(LFLAGS) -o Accuracy.app/Contents/MacOS/Accuracy 35 | 36 | defaults: defaults.c $(LIB) 37 | $(CC) $(CFLAGS) defaults.c $(LFLAGS) -o defaults 38 | 39 | Dynamic.app/Contents/MacOS/Dynamic: dynamic.c $(SOLIB) 40 | /bin/sh bundle.sh Dynamic 41 | cp $(SOLIB) Dynamic.app/Contents/MacOS/ 42 | $(CC) $(CFLAGS) dynamic.c $(SO_LFLAGS) -o Dynamic.app/Contents/MacOS/Dynamic 43 | 44 | events: events.c $(LIB) 45 | $(CC) $(CFLAGS) events.c $(LFLAGS) -o events 46 | 47 | FSAA.app/Contents/MacOS/FSAA: fsaa.c $(LIB) 48 | /bin/sh bundle.sh FSAA 49 | $(CC) $(CFLAGS) fsaa.c $(LFLAGS) -o FSAA.app/Contents/MacOS/FSAA 50 | 51 | FSInput.app/Contents/MacOS/FSInput: fsinput.c $(LIB) 52 | /bin/sh bundle.sh FSInput 53 | $(CC) $(CFLAGS) fsinput.c $(LFLAGS) -o FSInput.app/Contents/MacOS/FSInput 54 | 55 | Iconify.app/Contents/MacOS/Iconify: iconify.c $(LIB) 56 | /bin/sh bundle.sh Iconify 57 | $(CC) $(CFLAGS) iconify.c $(LFLAGS) -o Iconify.app/Contents/MacOS/Iconify 58 | 59 | joysticks: joysticks.c $(LIB) 60 | $(CC) $(CFLAGS) joysticks.c $(LFLAGS) -o joysticks 61 | 62 | Peter.app/Contents/MacOS/Peter: peter.c $(LIB) 63 | /bin/sh bundle.sh Peter 64 | $(CC) $(CFLAGS) peter.c $(LFLAGS) -o Peter.app/Contents/MacOS/Peter 65 | 66 | ReOpen.app/Contents/MacOS/ReOpen: reopen.c $(LIB) 67 | /bin/sh bundle.sh ReOpen 68 | $(CC) $(CFLAGS) reopen.c $(LFLAGS) -o ReOpen.app/Contents/MacOS/ReOpen 69 | 70 | Tearing.app/Contents/MacOS/Tearing: tearing.c $(LIB) 71 | /bin/sh bundle.sh Tearing 72 | $(CC) $(CFLAGS) tearing.c $(LFLAGS) -o Tearing.app/Contents/MacOS/Tearing 73 | 74 | version: version.c $(LIB) 75 | $(CC) $(CFLAGS) version.c $(LFLAGS) -o version 76 | 77 | clean: 78 | rm -rf Accuracy.app defaults Dynamic.app events FSAA.app FSInput.app \ 79 | Iconify.app joysticks Peter.app ReOpen.app Tearing.app version 80 | 81 | -------------------------------------------------------------------------------- /math/maths.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | // https://www.youtube.com/watch?v=qJq7I2DLGzI 23 | float Approach(float flGoal, float flCurrent, float dt) 24 | { 25 | float flDifference = flGoal - flCurrent; 26 | 27 | if (flDifference > dt) 28 | return flCurrent + dt; 29 | if (flDifference < -dt) 30 | return flCurrent - dt; 31 | 32 | return flGoal; 33 | } 34 | 35 | // http://youtu.be/K3TLNQOxU0o 36 | float Remap(float x, float t1, float t2, float s1, float s2) 37 | { 38 | // "Yellow" is a "normalized" value between 0 and 1 39 | float yellow = (x - t1)/(t2 - t1); 40 | 41 | // "Green" is the result! 42 | float green = yellow*(s2 - s1) + s1; 43 | 44 | return green; 45 | } 46 | 47 | float RemapClamp(float x, float t1, float t2, float s1, float s2) 48 | { 49 | if (x < t1) 50 | return s1; 51 | if (x > t2) 52 | return s2; 53 | 54 | return Remap(x, t1, t2, s1, s2); 55 | } 56 | 57 | // Returns a triangle wave on the interval [0, 1] 58 | inline float TriangleWave(float flTime, float flLength) 59 | { 60 | // flTime is a value in the interval [0, infinity]. 61 | 62 | // flMod is in the interval [0, flLength] 63 | float flMod = (float)fmod(flTime, flLength); 64 | 65 | // flRemapped is in the interval [-1, 1] 66 | float flRemapped = Remap(flMod, 0, flLength, -1, 1); 67 | 68 | // The negative values are flipped to positive, so that you have a triangle wave on [0, 1]: /\/\/\/\/ 69 | return fabs(flRemapped); 70 | } 71 | 72 | inline float CubicInterpolation(float t) 73 | { 74 | return -2*t*t*t + 3*t*t; 75 | } 76 | 77 | 78 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/triangle.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // This is a small test application for GLFW. 3 | // The program opens a window (640x480), and renders a spinning colored 4 | // triangle (it is controlled with both the GLFW timer and the mouse). 5 | //======================================================================== 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | int main( void ) 13 | { 14 | int width, height, x; 15 | double t; 16 | 17 | // Initialise GLFW 18 | if( !glfwInit() ) 19 | { 20 | fprintf( stderr, "Failed to initialize GLFW\n" ); 21 | exit( EXIT_FAILURE ); 22 | } 23 | 24 | // Open a window and create its OpenGL context 25 | if( !glfwOpenWindow( 640, 480, 0,0,0,0, 0,0, GLFW_WINDOW ) ) 26 | { 27 | fprintf( stderr, "Failed to open GLFW window\n" ); 28 | 29 | glfwTerminate(); 30 | exit( EXIT_FAILURE ); 31 | } 32 | 33 | glfwSetWindowTitle( "Spinning Triangle" ); 34 | 35 | // Ensure we can capture the escape key being pressed below 36 | glfwEnable( GLFW_STICKY_KEYS ); 37 | 38 | // Enable vertical sync (on cards that support it) 39 | glfwSwapInterval( 1 ); 40 | 41 | do 42 | { 43 | t = glfwGetTime(); 44 | glfwGetMousePos( &x, NULL ); 45 | 46 | // Get window size (may be different than the requested size) 47 | glfwGetWindowSize( &width, &height ); 48 | 49 | // Special case: avoid division by zero below 50 | height = height > 0 ? height : 1; 51 | 52 | glViewport( 0, 0, width, height ); 53 | 54 | // Clear color buffer to black 55 | glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); 56 | glClear( GL_COLOR_BUFFER_BIT ); 57 | 58 | // Select and setup the projection matrix 59 | glMatrixMode( GL_PROJECTION ); 60 | glLoadIdentity(); 61 | gluPerspective( 65.0f, (GLfloat)width/(GLfloat)height, 1.0f, 100.0f ); 62 | 63 | // Select and setup the modelview matrix 64 | glMatrixMode( GL_MODELVIEW ); 65 | glLoadIdentity(); 66 | gluLookAt( 0.0f, 1.0f, 0.0f, // Eye-position 67 | 0.0f, 20.0f, 0.0f, // View-point 68 | 0.0f, 0.0f, 1.0f ); // Up-vector 69 | 70 | // Draw a rotating colorful triangle 71 | glTranslatef( 0.0f, 14.0f, 0.0f ); 72 | glRotatef( 0.3f*(GLfloat)x + (GLfloat)t*100.0f, 0.0f, 0.0f, 1.0f ); 73 | glBegin( GL_TRIANGLES ); 74 | glColor3f( 1.0f, 0.0f, 0.0f ); 75 | glVertex3f( -5.0f, 0.0f, -4.0f ); 76 | glColor3f( 0.0f, 1.0f, 0.0f ); 77 | glVertex3f( 5.0f, 0.0f, -4.0f ); 78 | glColor3f( 0.0f, 0.0f, 1.0f ); 79 | glVertex3f( 0.0f, 0.0f, 6.0f ); 80 | glEnd(); 81 | 82 | // Swap buffers 83 | glfwSwapBuffers(); 84 | 85 | } // Check if the ESC key was pressed or the window was closed 86 | while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS && 87 | glfwGetWindowParam( GLFW_OPENED ) ); 88 | 89 | // Close OpenGL window and terminate GLFW 90 | glfwTerminate(); 91 | 92 | exit( EXIT_SUCCESS ); 93 | } 94 | 95 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/win32/win32_glext.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: Win32/WGL 4 | // API version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #include "internal.h" 32 | 33 | 34 | //************************************************************************ 35 | //**** Platform implementation functions **** 36 | //************************************************************************ 37 | 38 | //======================================================================== 39 | // Check if the current context supports the specified WGL extension 40 | //======================================================================== 41 | 42 | int _glfwPlatformExtensionSupported( const char *extension ) 43 | { 44 | const GLubyte *extensions; 45 | 46 | if( _glfwWin.GetExtensionsStringEXT != NULL ) 47 | { 48 | extensions = (GLubyte *) _glfwWin.GetExtensionsStringEXT(); 49 | if( extensions != NULL ) 50 | { 51 | if( _glfwStringInExtensionString( extension, extensions ) ) 52 | { 53 | return GL_TRUE; 54 | } 55 | } 56 | } 57 | 58 | if( _glfwWin.GetExtensionsStringARB != NULL ) 59 | { 60 | extensions = (GLubyte *) _glfwWin.GetExtensionsStringARB( _glfwWin.DC ); 61 | if( extensions != NULL ) 62 | { 63 | if( _glfwStringInExtensionString( extension, extensions ) ) 64 | { 65 | return GL_TRUE; 66 | } 67 | } 68 | } 69 | 70 | return GL_FALSE; 71 | } 72 | 73 | 74 | //======================================================================== 75 | // Get the function pointer to an OpenGL function 76 | //======================================================================== 77 | 78 | void *_glfwPlatformGetProcAddress( const char *procname ) 79 | { 80 | return (void *) wglGetProcAddress( procname ); 81 | } 82 | 83 | -------------------------------------------------------------------------------- /glfw-2.7.9/examples/Makefile.carbon.universal: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on Mac OS X using Apple GCC. 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.carbon.universal 6 | ########################################################################## 7 | 8 | # Compiler settings 9 | CC = gcc 10 | FATFLAGS = -isysroot /Developer/SDKs/MacOSX10.4u.sdk \ 11 | -mmacosx-version-min=10.4 -arch ppc -arch i386 12 | CFLAGS = -I../include $(FATFLAGS) 13 | 14 | # Linker settings 15 | LIB = ../lib/carbon/libglfw.a 16 | HEADER = ../include/GL/glfw.h 17 | LFLAGS = $(LIB) -framework AGL -framework OpenGL -framework Carbon -m32 18 | 19 | # Default: Build all tests 20 | all: Triangle.app/Contents/MacOS/Triangle \ 21 | listmodes \ 22 | mthello \ 23 | Pong3D.app/Contents/MacOS/Pong3D \ 24 | mtbench \ 25 | Particles.app/Contents/MacOS/Particles \ 26 | SplitView.app/Contents/MacOS/SplitView \ 27 | Mipmaps.app/Contents/MacOS/Mipmaps \ 28 | Gears.app/Contents/MacOS/Gears \ 29 | Boing.app/Contents/MacOS/Boing \ 30 | Wave.app/Contents/MacOS/Wave 31 | 32 | Triangle.app/Contents/MacOS/Triangle: triangle.c $(LIB) $(HEADER) 33 | /bin/sh bundle.sh Triangle 34 | $(CC) $(CFLAGS) triangle.c $(LFLAGS) -o Triangle.app/Contents/MacOS/Triangle 35 | 36 | listmodes: listmodes.c $(LIB) $(HEADER) 37 | $(CC) $(CFLAGS) listmodes.c $(LFLAGS) -o listmodes 38 | 39 | mthello: mthello.c $(LIB) $(HEADER) 40 | $(CC) $(CFLAGS) mthello.c $(LFLAGS) -o mthello 41 | 42 | Pong3D.app/Contents/MacOS/Pong3D: pong3d.c $(LIB) $(HEADER) 43 | /bin/sh bundle.sh Pong3D 44 | cp pong3d_*.tga Pong3D.app/Contents/Resources/ 45 | $(CC) $(CFLAGS) pong3d.c $(LFLAGS) -o Pong3D.app/Contents/MacOS/Pong3D 46 | 47 | mtbench: mtbench.c $(LIB) $(HEADER) 48 | $(CC) $(CFLAGS) mtbench.c $(LFLAGS) -o mtbench 49 | 50 | Particles.app/Contents/MacOS/Particles: particles.c $(LIB) $(HEADER) 51 | /bin/sh bundle.sh Particles 52 | $(CC) $(CFLAGS) particles.c $(LFLAGS) -o Particles.app/Contents/MacOS/Particles 53 | 54 | SplitView.app/Contents/MacOS/SplitView: splitview.c $(LIB) $(HEADER) 55 | /bin/sh bundle.sh SplitView 56 | $(CC) $(CFLAGS) splitview.c $(LFLAGS) -o SplitView.app/Contents/MacOS/SplitView 57 | 58 | Mipmaps.app/Contents/MacOS/Mipmaps: mipmaps.c $(LIB) $(HEADER) 59 | /bin/sh bundle.sh Mipmaps 60 | cp mipmaps.tga Mipmaps.app/Contents/Resources/ 61 | $(CC) $(CFLAGS) mipmaps.c $(LFLAGS) -o Mipmaps.app/Contents/MacOS/Mipmaps 62 | 63 | Gears.app/Contents/MacOS/Gears: gears.c $(LIB) $(HEADER) 64 | /bin/sh bundle.sh Gears 65 | $(CC) $(CFLAGS) gears.c $(LFLAGS) -o Gears.app/Contents/MacOS/Gears 66 | 67 | Boing.app/Contents/MacOS/Boing: boing.c $(LIB) $(HEADER) 68 | /bin/sh bundle.sh Boing 69 | $(CC) $(CFLAGS) boing.c $(LFLAGS) -o Boing.app/Contents/MacOS/Boing 70 | 71 | Wave.app/Contents/MacOS/Wave: wave.c $(LIB) $(HEADER) 72 | /bin/sh bundle.sh Wave 73 | $(CC) $(CFLAGS) wave.c $(LFLAGS) -o Wave.app/Contents/MacOS/Wave 74 | 75 | clean: 76 | rm -rf Triangle.app listmodes mthello Pong3D.app mtbench Particles.app \ 77 | SplitView.app Mipmaps.app Gears.app Boing.app Wave.app 78 | 79 | -------------------------------------------------------------------------------- /glfw-2.7.9/docs/glfwdoc.sty: -------------------------------------------------------------------------------- 1 | %------------------------------------------------------------------------- 2 | % Common document formatting and macros for GLFW manuals 3 | %------------------------------------------------------------------------- 4 | 5 | % Misc. document info 6 | \date{\today} 7 | 8 | % Packages 9 | \usepackage{fancyhdr} 10 | \usepackage{titling} 11 | \usepackage{lastpage} 12 | \usepackage{listings} 13 | \usepackage{color} 14 | \usepackage[overload]{textcase} 15 | \usepackage{needspace} 16 | \usepackage{times} 17 | 18 | % Logo macros 19 | \newcommand{\OpenGL}[1][0]{OpenGL\textsuperscript{\textregistered}} 20 | \newcommand{\GLFW}[1][0]{GLFW} 21 | 22 | % Encoding 23 | \usepackage[latin1]{inputenc} 24 | \usepackage[T1]{fontenc} 25 | 26 | % Page formatting 27 | \usepackage[hmargin=2.5cm]{geometry} 28 | \raggedright 29 | \raggedbottom 30 | \sloppy 31 | \usepackage{parskip} 32 | 33 | % Header and footer 34 | \pagestyle{fancy} 35 | %\lhead{\textit{GLFW Reference Manual}} 36 | \lhead{\textit{GLFW \glfwdoctype}} 37 | \chead{API version \glfwapiver} 38 | \rhead{Page \thepage/\pageref{LastPage}} 39 | \lfoot{} 40 | \cfoot{} 41 | \rfoot{} 42 | \renewcommand{\headrulewidth}{0.4pt} 43 | \renewcommand{\footrulewidth}{0.0pt} 44 | 45 | % Titlepage 46 | \newcommand{\glfwmaketitle}{\begin{titlepage}\ \\% 47 | \begin{center}% 48 | \vspace{7.0cm}{\Huge\textbf{GLFW}}\\% 49 | \rule{10.0cm}{0.5pt}\\% 50 | \vspace{0.5cm}{\LARGE\textbf{\glfwdoctype}}\\% 51 | \vspace{0.8cm}{\large\textbf{API version \glfwapiver}}\\% 52 | \textit{\today}\\% 53 | \vspace{1.5cm}\textbf{\textcopyright2002-2006 Marcus Geelnard}\\ 54 | \textbf{\textcopyright2006-2010 Camilla Berglund}\\% 55 | \end{center}\end{titlepage}\newpage} 56 | 57 | % Colors 58 | \definecolor{code}{rgb}{0.9,0.9,1.0} 59 | \definecolor{link}{rgb}{0.6,0.0,0.0} 60 | \definecolor{codeA}{rgb}{0.9,1.0,0.9} 61 | \definecolor{codeB}{rgb}{1.0,0.9,0.9} 62 | 63 | % Code listings 64 | \lstset{frame=single,frameround=tttt,backgroundcolor=\color{code},% 65 | language=C,basicstyle={\ttfamily},% 66 | breaklines,breakindent=0pt,postbreak=\space\space\space\space} 67 | 68 | 69 | % A simple hack for keeping lines together 70 | \newenvironment{mysamepage}[1][2]{\begin{samepage}\needspace{#1\baselineskip}}{\end{samepage}} 71 | 72 | % Macros for automating function reference entries 73 | \newenvironment{refparameters}[1][0]{\begin{mysamepage}\textbf{Parameters}\\}{\end{mysamepage}\bigskip} 74 | \newenvironment{refreturn}[1][0]{\begin{mysamepage}\textbf{Return values}\\}{\end{mysamepage}\bigskip} 75 | \newenvironment{refdescription}[1][0]{\begin{mysamepage}\textbf{Description}\\}{\end{mysamepage}\bigskip} 76 | \newenvironment{refnotes}[1][0]{\begin{mysamepage}\textbf{Notes}\\}{\end{mysamepage}\bigskip} 77 | 78 | % hyperref (bookmarks, links etc) - use this package last 79 | \usepackage[colorlinks=true,linkcolor=link,bookmarks=true,bookmarksopen=true,% 80 | pdfhighlight=/N,bookmarksnumbered=true,bookmarksopenlevel=1,% 81 | pdfview=FitH,pdfstartview=FitH]{hyperref} 82 | -------------------------------------------------------------------------------- /math/vector.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #pragma once 19 | 20 | class Vector 21 | { 22 | public: 23 | Vector() 24 | { 25 | x = y = z = 0; 26 | } 27 | Vector(float X, float Y, float Z) 28 | { 29 | x = X; 30 | y = Y; 31 | z = Z; 32 | } 33 | Vector(float XYZ[3]) 34 | { 35 | x = XYZ[0]; 36 | y = XYZ[1]; 37 | z = XYZ[2]; 38 | } 39 | Vector(const class Point& p); 40 | 41 | public: 42 | float Length() const; 43 | float LengthSqr() const; 44 | 45 | Vector operator-() const; 46 | 47 | Vector operator+(const Vector& v) const; 48 | Vector operator-(const Vector& v) const; 49 | 50 | Vector operator*(float s) const; 51 | Vector operator/(float s) const; 52 | 53 | Vector Normalized() const; 54 | void Normalize(); 55 | 56 | float Dot(const Vector& v) const; 57 | Vector Cross(const Vector& v) const; 58 | 59 | public: 60 | union { 61 | struct { 62 | float x, y, z; 63 | }; 64 | float v[3]; 65 | }; 66 | }; 67 | 68 | inline const Vector operator*(float s, const Vector& v) 69 | { 70 | return Vector(s*v.x, s*v.y, s*v.z); 71 | } 72 | 73 | inline const Vector operator/(float s, const Vector& v) 74 | { 75 | return Vector(s/v.x, s/v.y, s/v.z); 76 | } 77 | 78 | class Point 79 | { 80 | public: 81 | Point() {} 82 | Point(float X, float Y, float Z) 83 | { 84 | x = X; 85 | y = Y; 86 | z = Z; 87 | } 88 | 89 | Point(const Vector& v) 90 | { 91 | x = v.x; 92 | y = v.y; 93 | z = v.z; 94 | } 95 | 96 | Point operator+(const Vector& v) const; 97 | Point operator-(const Vector& v) const; 98 | 99 | float x, y, z; 100 | }; 101 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/Makefile.cocoa: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on Mac OS X on Cocoa using Apple GCC 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.cocoa 6 | ########################################################################## 7 | 8 | # Compiler settings 9 | CC ?= cc 10 | CFLAGS ?= -O2 -g 11 | CFLAGS += -I../include 12 | 13 | # Linker settings 14 | LIB = ../lib/cocoa/libglfw.a 15 | SOLIB = ../lib/cocoa/libglfw.dylib 16 | LFLAGS = $(LIB) -framework Cocoa -framework OpenGL -framework IOKit 17 | SO_LFLAGS = $(SOLIB) -framework OpenGL 18 | 19 | HEADER = ../include/GL/glfw.h 20 | 21 | # Default: Build all tests 22 | all: Accuracy.app/Contents/MacOS/Accuracy \ 23 | defaults \ 24 | Dynamic.app/Contents/MacOS/Dynamic \ 25 | events \ 26 | FSAA.app/Contents/MacOS/FSAA \ 27 | FSInput.app/Contents/MacOS/FSInput \ 28 | Iconify.app/Contents/MacOS/Iconify \ 29 | joysticks \ 30 | Peter.app/Contents/MacOS/Peter \ 31 | ReOpen.app/Contents/MacOS/ReOpen \ 32 | Tearing.app/Contents/MacOS/Tearing \ 33 | version 34 | 35 | Accuracy.app/Contents/MacOS/Accuracy: accuracy.c $(LIB) $(HEADER) 36 | /bin/sh bundle.sh Accuracy 37 | $(CC) $(CFLAGS) accuracy.c $(LFLAGS) -o Accuracy.app/Contents/MacOS/Accuracy 38 | 39 | defaults: defaults.c $(LIB) $(HEADER) 40 | $(CC) $(CFLAGS) defaults.c $(LFLAGS) -o defaults 41 | 42 | Dynamic.app/Contents/MacOS/Dynamic: dynamic.c $(SOLIB) $(HEADER) 43 | /bin/sh bundle.sh Dynamic 44 | cp $(SOLIB) Dynamic.app/Contents/MacOS/ 45 | $(CC) $(CFLAGS) dynamic.c $(SO_LFLAGS) -o Dynamic.app/Contents/MacOS/Dynamic 46 | 47 | events: events.c $(LIB) $(HEADER) 48 | $(CC) $(CFLAGS) events.c $(LFLAGS) -o events 49 | 50 | FSAA.app/Contents/MacOS/FSAA: fsaa.c $(LIB) $(HEADER) 51 | /bin/sh bundle.sh FSAA 52 | $(CC) $(CFLAGS) fsaa.c $(LFLAGS) -o FSAA.app/Contents/MacOS/FSAA 53 | 54 | FSInput.app/Contents/MacOS/FSInput: fsinput.c $(LIB) $(HEADER) 55 | /bin/sh bundle.sh FSInput 56 | $(CC) $(CFLAGS) fsinput.c $(LFLAGS) -o FSInput.app/Contents/MacOS/FSInput 57 | 58 | Iconify.app/Contents/MacOS/Iconify: iconify.c $(LIB) $(HEADER) 59 | /bin/sh bundle.sh Iconify 60 | $(CC) $(CFLAGS) iconify.c $(LFLAGS) -o Iconify.app/Contents/MacOS/Iconify 61 | 62 | joysticks: joysticks.c $(LIB) $(HEADER) 63 | $(CC) $(CFLAGS) joysticks.c $(LFLAGS) -o joysticks 64 | 65 | Peter.app/Contents/MacOS/Peter: peter.c $(LIB) $(HEADER) 66 | /bin/sh bundle.sh Peter 67 | $(CC) $(CFLAGS) peter.c $(LFLAGS) -o Peter.app/Contents/MacOS/Peter 68 | 69 | ReOpen.app/Contents/MacOS/ReOpen: reopen.c $(LIB) $(HEADER) 70 | /bin/sh bundle.sh ReOpen 71 | $(CC) $(CFLAGS) reopen.c $(LFLAGS) -o ReOpen.app/Contents/MacOS/ReOpen 72 | 73 | Tearing.app/Contents/MacOS/Tearing: tearing.c $(LIB) $(HEADER) 74 | /bin/sh bundle.sh Tearing 75 | $(CC) $(CFLAGS) tearing.c $(LFLAGS) -o Tearing.app/Contents/MacOS/Tearing 76 | 77 | version: version.c $(LIB) $(HEADER) 78 | $(CC) $(CFLAGS) version.c $(LFLAGS) -o version 79 | 80 | clean: 81 | rm -rf Accuracy.app defaults Dynamic.app events FSAA.app FSInput.app \ 82 | Iconify.app joysticks Peter.app ReOpen.app Tearing.app version 83 | 84 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/Makefile.carbon.universal: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # Makefile for GLFW test programs on Mac OS X using Apple GCC. 3 | #------------------------------------------------------------------------- 4 | # To compile the test files using this makefile, run: 5 | # make -f Makefile.carbon.universal 6 | ########################################################################## 7 | 8 | # Compiler settings 9 | CC = gcc 10 | FATFLAGS = -isysroot /Developer/SDKs/MacOSX10.4u.sdk \ 11 | -mmacosx-version-min=10.4 -arch ppc -arch i386 12 | CFLAGS = -I../include $(FATFLAGS) 13 | 14 | # Linker settings 15 | LIB = ../lib/carbon/libglfw.a 16 | SOLIB = ../lib/carbon/libglfw.dylib 17 | LFLAGS = $(LIB) -framework AGL -framework OpenGL -framework Carbon -m32 18 | SO_LFLAGS = $(SOLIB) -framework OpenGL -m32 19 | 20 | # Default: Build all tests 21 | all: Accuracy.app/Contents/MacOS/Accuracy \ 22 | defaults \ 23 | Dynamic.app/Contents/MacOS/Dynamic \ 24 | events \ 25 | FSAA.app/Contents/MacOS/FSAA \ 26 | FSInput.app/Contents/MacOS/FSInput \ 27 | Iconify.app/Contents/MacOS/Iconify \ 28 | joysticks \ 29 | Peter.app/Contents/MacOS/Peter \ 30 | ReOpen.app/Contents/MacOS/ReOpen \ 31 | Tearing.app/Contents/MacOS/Tearing \ 32 | version 33 | 34 | Accuracy.app/Contents/MacOS/Accuracy: accuracy.c $(LIB) 35 | /bin/sh bundle.sh Accuracy 36 | $(CC) $(CFLAGS) accuracy.c $(LFLAGS) -o Accuracy.app/Contents/MacOS/Accuracy 37 | 38 | defaults: defaults.c $(LIB) 39 | $(CC) $(CFLAGS) defaults.c $(LFLAGS) -o defaults 40 | 41 | Dynamic.app/Contents/MacOS/Dynamic: dynamic.c $(SOLIB) 42 | /bin/sh bundle.sh Dynamic 43 | cp $(SOLIB) Dynamics.app/Contents/MacOS/ 44 | $(CC) $(CFLAGS) dynamic.c $(SO_LFLAGS) -o Dynamic.app/Contents/MacOS/Dynamic 45 | 46 | events: events.c $(LIB) 47 | /bin/sh bundle.sh Events 48 | $(CC) $(CFLAGS) events.c $(LFLAGS) -o events 49 | 50 | FSAA.app/Contents/MacOS/FSAA: fsaa.c $(LIB) 51 | /bin/sh bundle.sh FSAA 52 | $(CC) $(CFLAGS) fsaa.c $(LFLAGS) -o FSAA.app/Contents/MacOS/FSAA 53 | 54 | FSInput.app/Contents/MacOS/FSInput: fsinput.c $(LIB) 55 | /bin/sh bundle.sh FSInput 56 | $(CC) $(CFLAGS) fsinput.c $(LFLAGS) -o FSInput.app/Contents/MacOS/FSInput 57 | 58 | Iconify.app/Contents/MacOS/Iconify: iconify.c $(LIB) 59 | /bin/sh bundle.sh Iconify 60 | $(CC) $(CFLAGS) iconify.c $(LFLAGS) -o Iconify.app/Contents/MacOS/Iconify 61 | 62 | joysticks: joysticks.c $(LIB) 63 | $(CC) $(CFLAGS) joysticks.c $(LFLAGS) -o joysticks 64 | 65 | Peter.app/Contents/MacOS/Peter: peter.c $(LIB) 66 | /bin/sh bundle.sh Peter 67 | $(CC) $(CFLAGS) peter.c $(LFLAGS) -o Peter.app/Contents/MacOS/Peter 68 | 69 | ReOpen.app/Contents/MacOS/ReOpen: reopen.c $(LIB) 70 | /bin/sh bundle.sh ReOpen 71 | $(CC) $(CFLAGS) reopen.c $(LFLAGS) -o ReOpen.app/Contents/MacOS/ReOpen 72 | 73 | Tearing.app/Contents/MacOS/Tearing: tearing.c $(LIB) 74 | /bin/sh bundle.sh Tearing 75 | $(CC) $(CFLAGS) tearing.c $(LFLAGS) -o Tearing.app/Contents/MacOS/Tearing 76 | 77 | version: version.c $(LIB) 78 | $(CC) $(CFLAGS) version.c $(LFLAGS) -o version 79 | 80 | clean: 81 | rm -rf Accuracy.app defaults Dynamic.app events FSAA.app FSInput.app \ 82 | Iconify.app joysticks Peter.app ReOpen.app Tearing.app version 83 | 84 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/tearing.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Vsync enabling test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test renders a high contrast, horizontally moving bar, allowing for 27 | // visual verification of whether the set swap interval is indeed obeyed 28 | // 29 | //======================================================================== 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | static int swap_interval; 38 | 39 | static void set_swap_interval(int interval) 40 | { 41 | char title[256]; 42 | 43 | swap_interval = interval; 44 | glfwSwapInterval(swap_interval); 45 | 46 | sprintf(title, "Tearing detector (interval %i)", swap_interval); 47 | 48 | glfwSetWindowTitle(title); 49 | } 50 | 51 | static void key_callback(int key, int action) 52 | { 53 | if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) 54 | set_swap_interval(1 - swap_interval); 55 | } 56 | 57 | static void GLFWCALL window_size_callback(int width, int height) 58 | { 59 | glViewport(0, 0, width, height); 60 | } 61 | 62 | int main(void) 63 | { 64 | float position; 65 | 66 | if (!glfwInit()) 67 | { 68 | fprintf(stderr, "Failed to initialize GLFW\n"); 69 | exit(1); 70 | } 71 | 72 | if (!glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) 73 | { 74 | glfwTerminate(); 75 | 76 | fprintf(stderr, "Failed to open GLFW window\n"); 77 | exit(1); 78 | } 79 | 80 | glfwSetKeyCallback(key_callback); 81 | glfwSetWindowSizeCallback(window_size_callback); 82 | set_swap_interval(0); 83 | 84 | glClearColor(0.f, 0.f, 0.f, 0.f); 85 | glColor3f(1.f, 1.f, 1.f); 86 | 87 | glMatrixMode(GL_PROJECTION); 88 | glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); 89 | glMatrixMode(GL_MODELVIEW); 90 | 91 | while (glfwGetWindowParam(GLFW_OPENED) == GL_TRUE) 92 | { 93 | glClear(GL_COLOR_BUFFER_BIT); 94 | 95 | position = cosf(glfwGetTime() * 4.f) * 0.75f; 96 | glRectf(position - 0.25f, -1.f, position + 0.25f, 1.f); 97 | 98 | glfwSwapBuffers(); 99 | } 100 | 101 | glfwTerminate(); 102 | exit(0); 103 | } 104 | 105 | -------------------------------------------------------------------------------- /math/color.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | 19 | #pragma once 20 | 21 | class Vector; 22 | 23 | class Color 24 | { 25 | public: 26 | Color(); 27 | Color(Vector v); 28 | Color(int _r, int _g, int _b); 29 | Color(int _r, int _g, int _b, int _a); 30 | Color(float _r, float _g, float _b); 31 | Color(float _r, float _g, float _b, float _a); 32 | 33 | void SetColor(int _r, int _g, int _b, int _a); 34 | void SetColor(float _r, float _g, float _b, float _a); 35 | void SetRed(int _r); 36 | void SetGreen(int _g); 37 | void SetBlue(int _b); 38 | void SetAlpha(int _a); 39 | void SetAlpha(float f); 40 | 41 | void SetHSL(float h, float s, float l); 42 | void GetHSL(float& h, float& s, float& l); 43 | 44 | int r() const { return red; }; 45 | int g() const { return green; }; 46 | int b() const { return blue; }; 47 | int a() const { return alpha; }; 48 | 49 | Color operator-(void) const; 50 | 51 | Color operator+(const Color& v) const; 52 | Color operator-(const Color& v) const; 53 | Color operator*(float s) const; 54 | Color operator/(float s) const; 55 | 56 | void operator+=(const Color &v); 57 | void operator-=(const Color &v); 58 | void operator*=(float s); 59 | void operator/=(float s); 60 | 61 | Color operator*(const Color& v) const; 62 | 63 | friend Color operator*( float f, const Color& v ) 64 | { 65 | return Color( v.red*f, v.green*f, v.blue*f, v.alpha*f ); 66 | } 67 | 68 | friend Color operator/( float f, const Color& v ) 69 | { 70 | return Color( f/v.red, f/v.green, f/v.blue, f/v.alpha ); 71 | } 72 | 73 | operator unsigned char*() 74 | { 75 | return(&red); 76 | } 77 | 78 | operator const unsigned char*() const 79 | { 80 | return(&red); 81 | } 82 | 83 | private: 84 | unsigned char red; 85 | unsigned char green; 86 | unsigned char blue; 87 | unsigned char alpha; 88 | }; 89 | -------------------------------------------------------------------------------- /math/vector2d.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #include 23 | 24 | class Vector2D 25 | { 26 | public: 27 | Vector2D(); 28 | Vector2D(float x, float y); 29 | Vector2D(const Vector& v); 30 | 31 | public: 32 | float Length() const; 33 | float LengthSqr() const; 34 | 35 | const Vector2D operator+(const Vector2D& v) const; 36 | const Vector2D operator-(const Vector2D& v) const; 37 | const Vector2D operator*(float s) const; 38 | const Vector2D operator/(float s) const; 39 | 40 | void operator+=(const Vector2D &v); 41 | void operator-=(const Vector2D &v); 42 | 43 | float x, y; 44 | }; 45 | 46 | inline Vector2D::Vector2D() 47 | : x(0), y(0) 48 | { 49 | } 50 | 51 | inline Vector2D::Vector2D(float X, float Y) 52 | : x(X), y(Y) 53 | { 54 | } 55 | 56 | inline Vector2D::Vector2D(const Vector& v) 57 | : x(v.x), y(v.y) 58 | { 59 | } 60 | 61 | inline float Vector2D::Length() const 62 | { 63 | return sqrt(x*x + y*y); 64 | } 65 | 66 | inline float Vector2D::LengthSqr() const 67 | { 68 | return x*x + y*y; 69 | } 70 | 71 | inline const Vector2D Vector2D::operator+(const Vector2D& v) const 72 | { 73 | return Vector2D(x+v.x, y+v.y); 74 | } 75 | 76 | inline const Vector2D Vector2D::operator-(const Vector2D& v) const 77 | { 78 | return Vector2D(x-v.x, y-v.y); 79 | } 80 | 81 | inline const Vector2D Vector2D::operator*(float s) const 82 | { 83 | return Vector2D(x*s, y*s); 84 | } 85 | 86 | inline const Vector2D Vector2D::operator/(float s) const 87 | { 88 | return Vector2D(x/s, y/s); 89 | } 90 | 91 | inline void Vector2D::operator+=(const Vector2D& v) 92 | { 93 | x += v.x; 94 | y += v.y; 95 | } 96 | 97 | inline void Vector2D::operator-=(const Vector2D& v) 98 | { 99 | x -= v.x; 100 | y -= v.y; 101 | } 102 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/defaults.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Default window/context test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test creates a windowed mode window with all parameters set to 27 | // default values and then reports the actual parameters of the created 28 | // window and context 29 | // 30 | //======================================================================== 31 | 32 | #include 33 | 34 | #include 35 | #include 36 | 37 | typedef struct 38 | { 39 | int param; 40 | char* name; 41 | } Param; 42 | 43 | static Param parameters[] = 44 | { 45 | { GLFW_ACCELERATED, "accelerated" }, 46 | { GLFW_RED_BITS, "red bits" }, 47 | { GLFW_GREEN_BITS, "green bits" }, 48 | { GLFW_BLUE_BITS, "blue bits" }, 49 | { GLFW_ALPHA_BITS, "alpha bits" }, 50 | { GLFW_DEPTH_BITS, "depth bits" }, 51 | { GLFW_STENCIL_BITS, "stencil bits" }, 52 | { GLFW_REFRESH_RATE, "refresh rate" }, 53 | { GLFW_ACCUM_RED_BITS, "accum red bits" }, 54 | { GLFW_ACCUM_GREEN_BITS, "accum green bits" }, 55 | { GLFW_ACCUM_BLUE_BITS, "accum blue bits" }, 56 | { GLFW_ACCUM_ALPHA_BITS, "accum alpha bits" }, 57 | { GLFW_AUX_BUFFERS, "aux buffers" }, 58 | { GLFW_STEREO, "stereo" }, 59 | { GLFW_FSAA_SAMPLES, "FSAA samples" }, 60 | { GLFW_OPENGL_VERSION_MAJOR, "OpenGL major" }, 61 | { GLFW_OPENGL_VERSION_MINOR, "OpenGL minor" }, 62 | { GLFW_OPENGL_FORWARD_COMPAT, "OpenGL forward compatible" }, 63 | { GLFW_OPENGL_DEBUG_CONTEXT, "OpenGL debug context" }, 64 | { GLFW_OPENGL_PROFILE, "OpenGL profile" }, 65 | }; 66 | 67 | int main(void) 68 | { 69 | int i, width, height; 70 | 71 | if (!glfwInit()) 72 | { 73 | fprintf(stderr, "Failed to initialize GLFW\n"); 74 | exit(1); 75 | } 76 | 77 | if (!glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) 78 | { 79 | glfwTerminate(); 80 | 81 | fprintf(stderr, "Failed to open GLFW default window\n"); 82 | exit(1); 83 | } 84 | 85 | glfwGetWindowSize(&width, &height); 86 | 87 | printf("window size: %ix%i\n", width, height); 88 | 89 | for (i = 0; (size_t) i < sizeof(parameters) / sizeof(parameters[0]); i++) 90 | { 91 | printf("%s: %i\n", parameters[i].name, glfwGetWindowParam(parameters[i].param)); 92 | } 93 | 94 | glfwCloseWindow(); 95 | glfwTerminate(); 96 | exit(0); 97 | } 98 | 99 | -------------------------------------------------------------------------------- /glfw-2.7.9/tests/accuracy.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Mouse cursor accuracy test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test came about as the result of bug #1867804 27 | // 28 | // No sign of said bug has so far been detected 29 | // 30 | //======================================================================== 31 | 32 | #include 33 | 34 | #include 35 | #include 36 | 37 | static int cursor_x = 0, cursor_y = 0; 38 | static int window_width = 640, window_height = 480; 39 | 40 | static void GLFWCALL window_size_callback(int width, int height) 41 | { 42 | window_width = width; 43 | window_height = height; 44 | 45 | glViewport(0, 0, window_width, window_height); 46 | 47 | glMatrixMode(GL_PROJECTION); 48 | glLoadIdentity(); 49 | gluOrtho2D(0.f, window_width, 0.f, window_height); 50 | } 51 | 52 | static void GLFWCALL mouse_position_callback(int x, int y) 53 | { 54 | cursor_x = x; 55 | cursor_y = y; 56 | } 57 | 58 | int main(void) 59 | { 60 | if (!glfwInit()) 61 | { 62 | fprintf(stderr, "Failed to initialize GLFW\n"); 63 | exit(EXIT_FAILURE); 64 | } 65 | 66 | if (!glfwOpenWindow(window_width, window_height, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) 67 | { 68 | glfwTerminate(); 69 | 70 | fprintf(stderr, "Failed to open GLFW window\n"); 71 | exit(EXIT_FAILURE); 72 | } 73 | 74 | glfwSetWindowTitle("Cursor Inaccuracy Detector"); 75 | glfwSetMousePosCallback(mouse_position_callback); 76 | glfwSetWindowSizeCallback(window_size_callback); 77 | glfwSwapInterval(1); 78 | 79 | glClearColor(0, 0, 0, 0); 80 | 81 | glMatrixMode(GL_MODELVIEW); 82 | glLoadIdentity(); 83 | 84 | while (glfwGetWindowParam(GLFW_OPENED)) 85 | { 86 | glClear(GL_COLOR_BUFFER_BIT); 87 | 88 | glColor3f(1.f, 1.f, 1.f); 89 | 90 | glBegin(GL_LINES); 91 | glVertex2f(0.f, (GLfloat) window_height - cursor_y); 92 | glVertex2f((GLfloat) window_width, (GLfloat) window_height - cursor_y); 93 | glVertex2f((GLfloat) cursor_x, 0.f); 94 | glVertex2f((GLfloat) cursor_x, (GLfloat) window_height); 95 | glEnd(); 96 | 97 | glfwSwapBuffers(); 98 | } 99 | 100 | glfwTerminate(); 101 | exit(EXIT_SUCCESS); 102 | } 103 | 104 | -------------------------------------------------------------------------------- /math/vector.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #include "vector.h" 19 | 20 | #include 21 | 22 | Vector::Vector(const Point& p) 23 | : x(p.x), y(p.y), z(p.z) 24 | { 25 | } 26 | 27 | Vector Vector::operator-() const 28 | { 29 | return Vector(-x, -y, -z); 30 | } 31 | 32 | Vector Vector::operator+(const Vector& v) const 33 | { 34 | return Vector(x + v.x, y + v.y, z + v.z); 35 | } 36 | 37 | Vector Vector::operator-(const Vector& v) const 38 | { 39 | return Vector(x - v.x, y - v.y, z - v.z); 40 | } 41 | 42 | Vector Vector::Normalized() const 43 | { 44 | return (*this) / Length(); 45 | } 46 | 47 | void Vector::Normalize() 48 | { 49 | (*this) = (*this) / Length(); 50 | } 51 | 52 | Vector Vector::operator*(float s) const 53 | { 54 | return Vector(x * s, y * s, z * s); 55 | } 56 | 57 | Vector Vector::operator/(float s) const 58 | { 59 | return Vector(x / s, y / s, z / s); 60 | } 61 | 62 | float Vector::Length() const 63 | { 64 | return sqrt(x*x + y*y + z*z); 65 | } 66 | 67 | float Vector::LengthSqr() const 68 | { 69 | return (x*x + y*y + z*z); 70 | } 71 | 72 | float Vector::Dot(const Vector& v) const 73 | { 74 | return x*v.x + y*v.y + z*v.z; 75 | } 76 | 77 | // Cross-product http://www.youtube.com/watch?v=FT7MShdqK6w 78 | Vector Vector::Cross(const Vector& v) const 79 | { 80 | Vector c; 81 | 82 | c.x = y*v.z - z*v.y; 83 | c.y = z*v.x - x*v.z; 84 | c.z = x*v.y - y*v.x; 85 | 86 | return c; 87 | } 88 | 89 | Vector operator-(Point a, Point b) 90 | { 91 | Vector v; 92 | 93 | v.x = a.x - b.x; 94 | v.y = a.y - b.y; 95 | v.z = a.z - b.z; 96 | 97 | return v; 98 | } 99 | 100 | Point Point::operator+(const Vector& v) const 101 | { 102 | return Point(x + v.x, y + v.y, z + v.z); 103 | } 104 | 105 | Point Point::operator-(const Vector& v) const 106 | { 107 | return Point(x - v.x, y - v.y, z - v.z); 108 | } 109 | -------------------------------------------------------------------------------- /common/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #ifndef COMMON_H 19 | #define COMMON_H 20 | 21 | #define DECLARE_CLASS( className, baseClassName ) \ 22 | typedef baseClassName BaseClass; \ 23 | typedef className ThisClass; \ 24 | 25 | #ifdef __GNUC__ 26 | 27 | #include 28 | 29 | #define TDebugBreak() \ 30 | ::raise(SIGTRAP); \ 31 | 32 | #else 33 | 34 | #define TDebugBreak() \ 35 | __debugbreak(); \ 36 | 37 | #endif 38 | 39 | // tinker_platform.h 40 | extern void DebugPrint(const char* pszText); 41 | 42 | #ifdef _DEBUG 43 | 44 | #define TAssert(x) \ 45 | { \ 46 | if (!(x)) \ 47 | { \ 48 | DebugPrint("Assert failed: " #x "\n"); \ 49 | TDebugBreak(); \ 50 | } \ 51 | } \ 52 | 53 | #else 54 | 55 | #if defined(_T_RELEASE_ASSERTS) 56 | #define TAssert(x) \ 57 | { \ 58 | if (!(x)) \ 59 | DebugPrint("Assert failed: " #x "\n"); \ 60 | } \ 61 | 62 | #else 63 | 64 | #define TAssert(x) {} 65 | 66 | #endif 67 | 68 | #endif 69 | 70 | // If you hit this, the code is either incomplete or untested. 71 | #define TUnimplemented() TAssert(false) 72 | 73 | #ifdef __GNUC__ 74 | // Clang or GCC 75 | #ifdef __clang__ 76 | #else 77 | #if __GNUC__ < 4 || __GNUC_MINOR__ < 6 78 | 79 | const // this is a const object... 80 | class { 81 | public: 82 | template // convertible to any type 83 | operator T*() const // of null non-member 84 | { return 0; } // pointer... 85 | template // or any type of null 86 | operator T C::*() const // member pointer... 87 | { return 0; } 88 | private: 89 | void operator&() const; // whose address can't be taken 90 | } nullptr = {}; // and whose name is nullptr 91 | 92 | #endif 93 | #endif 94 | 95 | // For std::shared_ptr 96 | #include 97 | 98 | #endif 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/fullscreen.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: Any 4 | // API version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #include "internal.h" 32 | 33 | 34 | //************************************************************************ 35 | //**** GLFW user functions **** 36 | //************************************************************************ 37 | 38 | //======================================================================== 39 | // Get a list of available video modes 40 | //======================================================================== 41 | 42 | GLFWAPI int GLFWAPIENTRY glfwGetVideoModes( GLFWvidmode *list, int maxcount ) 43 | { 44 | int count, i, swap, res1, res2, depth1, depth2; 45 | GLFWvidmode vm; 46 | 47 | if( !_glfwInitialized || maxcount <= 0 || list == (GLFWvidmode*) 0 ) 48 | { 49 | return 0; 50 | } 51 | 52 | // Get list of video modes 53 | count = _glfwPlatformGetVideoModes( list, maxcount ); 54 | 55 | // Sort list (bubble sort) 56 | do 57 | { 58 | swap = 0; 59 | for( i = 0; i < count-1; ++ i ) 60 | { 61 | res1 = list[i].Width*list[i].Height; 62 | depth1 = list[i].RedBits+list[i].GreenBits+list[i].BlueBits; 63 | res2 = list[i+1].Width*list[i+1].Height; 64 | depth2 = list[i+1].RedBits+list[i+1].GreenBits+ 65 | list[i+1].BlueBits; 66 | if( (depth2 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #include "internal.h" 32 | 33 | 34 | //************************************************************************ 35 | //**** GLFW user functions **** 36 | //************************************************************************ 37 | 38 | //======================================================================== 39 | // Determine joystick capabilities 40 | //======================================================================== 41 | 42 | GLFWAPI int GLFWAPIENTRY glfwGetJoystickParam( int joy, int param ) 43 | { 44 | if( !_glfwInitialized ) 45 | { 46 | return 0; 47 | } 48 | 49 | return _glfwPlatformGetJoystickParam( joy, param ); 50 | } 51 | 52 | 53 | //======================================================================== 54 | // Get joystick axis positions 55 | //======================================================================== 56 | 57 | GLFWAPI int GLFWAPIENTRY glfwGetJoystickPos( int joy, float *pos, int numaxes ) 58 | { 59 | int i; 60 | 61 | if( !_glfwInitialized ) 62 | { 63 | return 0; 64 | } 65 | 66 | // Clear positions 67 | for( i = 0; i < numaxes; i++ ) 68 | { 69 | pos[ i ] = 0.0f; 70 | } 71 | 72 | return _glfwPlatformGetJoystickPos( joy, pos, numaxes ); 73 | } 74 | 75 | 76 | //======================================================================== 77 | // Get joystick button states 78 | //======================================================================== 79 | 80 | GLFWAPI int GLFWAPIENTRY glfwGetJoystickButtons( int joy, 81 | unsigned char *buttons, 82 | int numbuttons ) 83 | { 84 | int i; 85 | 86 | if( !_glfwInitialized ) 87 | { 88 | return 0; 89 | } 90 | 91 | // Clear button states 92 | for( i = 0; i < numbuttons; i++ ) 93 | { 94 | buttons[ i ] = GLFW_RELEASE; 95 | } 96 | 97 | return _glfwPlatformGetJoystickButtons( joy, buttons, numbuttons ); 98 | } 99 | 100 | -------------------------------------------------------------------------------- /glfw-2.7.9/support/pascal/Triangle.dpr: -------------------------------------------------------------------------------- 1 | program Triangle; 2 | 3 | {$IFDEF FPC} 4 | {$IFDEF WIN32} 5 | {$APPTYPE GUI} 6 | {$ENDIF} 7 | {$ENDIF} 8 | 9 | //======================================================================== 10 | // This is a small test application for GLFW. 11 | // The program opens a window (640x480), and renders a spinning colored 12 | // triangle (it is controlled with both the GLFW timer and the mouse). It 13 | // also calculates the rendering speed (FPS), which is displayed in the 14 | // window title bar. 15 | // 16 | // Delphi conversion by Jarrod Davis (http://ww.jdsgames.com) 17 | //======================================================================== 18 | 19 | uses 20 | SysUtils, 21 | gl, glu, 22 | glfw; 23 | 24 | var 25 | width, height, running, frames, x, y: Integer; 26 | t, t0, fps: Double; 27 | titlestr: string; 28 | 29 | begin 30 | 31 | // Initialize GLFW 32 | glfwInit; 33 | 34 | // Open OpenGL window 35 | if glfwOpenWindow( 640, 480, 0,0,0,0, 0,0, GLFW_WINDOW ) <> 1 then 36 | begin 37 | glfwTerminate; 38 | Exit; 39 | end; 40 | 41 | // Enable sticky keys 42 | glfwEnable( GLFW_STICKY_KEYS ); 43 | 44 | // Disable vertical sync (on cards that support it) 45 | glfwSwapInterval( 0 ); 46 | 47 | // Main loop 48 | running := 1; 49 | frames := 0; 50 | t0 := glfwGetTime; 51 | while running <> 0 do 52 | begin 53 | // Get time and mouse position 54 | t := glfwGetTime; 55 | glfwGetMousePos(x, y ); 56 | 57 | // Calculate and display FPS (frames per second) 58 | if ((t-t0) > 1.0) or (frames = 0) then 59 | begin 60 | fps := frames / (t-t0); 61 | titlestr := Format('Spinning Triangle (%.1f FPS)', [fps]); 62 | glfwSetWindowTitle( PChar(titlestr) ); 63 | t0 := t; 64 | frames := 0; 65 | end; 66 | inc(frames); 67 | 68 | // Get window size (may be different than the requested size) 69 | glfwGetWindowSize( width, height ); 70 | if height < 1 then height := 1; 71 | 72 | // Set viewport 73 | glViewport( 0, 0, width, height ); 74 | 75 | // Clear color buffer 76 | glClearColor( 0.0, 0.0, 0.0, 0.0 ); 77 | glClear( GL_COLOR_BUFFER_BIT ); 78 | 79 | // Select and setup the projection matrix 80 | glMatrixMode( GL_PROJECTION ); 81 | glLoadIdentity; 82 | gluPerspective( 65.0, width/height, 1.0, 100.0 ); 83 | 84 | // Select and setup the modelview matrix 85 | glMatrixMode( GL_MODELVIEW ); 86 | glLoadIdentity; 87 | gluLookAt( 0.0, 1.0, 0.0, // Eye-position 88 | 0.0, 20.0, 0.0, // View-point 89 | 0.0, 0.0, 1.0 ); // Up-vector 90 | 91 | // Draw a rotating colorful triangle 92 | glTranslatef( 0.0, 14.0, 0.0 ); 93 | glRotatef( 0.3*x + t*100.0, 0.0, 0.0, 1.0 ); 94 | glBegin( GL_TRIANGLES ); 95 | glColor3f( 1.0, 0.0, 0.0 ); 96 | glVertex3f( -5.0, 0.0, -4.0 ); 97 | glColor3f( 0.0, 1.0, 0.0 ); 98 | glVertex3f( 5.0, 0.0, -4.0 ); 99 | glColor3f( 0.0, 0.0, 1.0 ); 100 | glVertex3f( 0.0, 0.0, 6.0 ); 101 | glEnd; 102 | 103 | // Swap buffers 104 | glfwSwapBuffers; 105 | 106 | // Check if the ESC key was pressed or the window was closed 107 | running := (not glfwGetKey( GLFW_KEY_ESC )) and 108 | glfwGetWindowParam( GLFW_OPENED ); 109 | end; 110 | 111 | // Close OpenGL window and terminate GLFW 112 | glfwTerminate; 113 | 114 | end. 115 | -------------------------------------------------------------------------------- /math/frustum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #include "frustum.h" 19 | 20 | #include "matrix.h" 21 | 22 | CFrustum::CFrustum(const Matrix4x4& m) 23 | { 24 | // I'll explain all this junk in a future video. 25 | p[FRUSTUM_RIGHT].n.x = m.m[0][3] - m.m[0][0]; 26 | p[FRUSTUM_RIGHT].n.y = m.m[1][3] - m.m[1][0]; 27 | p[FRUSTUM_RIGHT].n.z = m.m[2][3] - m.m[2][0]; 28 | p[FRUSTUM_RIGHT].d = m.m[3][3] - m.m[3][0]; 29 | 30 | p[FRUSTUM_LEFT].n.x = m.m[0][3] + m.m[0][0]; 31 | p[FRUSTUM_LEFT].n.y = m.m[1][3] + m.m[1][0]; 32 | p[FRUSTUM_LEFT].n.z = m.m[2][3] + m.m[2][0]; 33 | p[FRUSTUM_LEFT].d = m.m[3][3] + m.m[3][0]; 34 | 35 | p[FRUSTUM_DOWN].n.x = m.m[0][3] + m.m[0][1]; 36 | p[FRUSTUM_DOWN].n.y = m.m[1][3] + m.m[1][1]; 37 | p[FRUSTUM_DOWN].n.z = m.m[2][3] + m.m[2][1]; 38 | p[FRUSTUM_DOWN].d = m.m[3][3] + m.m[3][1]; 39 | 40 | p[FRUSTUM_UP].n.x = m.m[0][3] - m.m[0][1]; 41 | p[FRUSTUM_UP].n.y = m.m[1][3] - m.m[1][1]; 42 | p[FRUSTUM_UP].n.z = m.m[2][3] - m.m[2][1]; 43 | p[FRUSTUM_UP].d = m.m[3][3] - m.m[3][1]; 44 | 45 | p[FRUSTUM_FAR].n.x = m.m[0][3] - m.m[0][2]; 46 | p[FRUSTUM_FAR].n.y = m.m[1][3] - m.m[1][2]; 47 | p[FRUSTUM_FAR].n.z = m.m[2][3] - m.m[2][2]; 48 | p[FRUSTUM_FAR].d = m.m[3][3] - m.m[3][2]; 49 | 50 | p[FRUSTUM_NEAR].n.x = m.m[0][3] + m.m[0][2]; 51 | p[FRUSTUM_NEAR].n.y = m.m[1][3] + m.m[1][2]; 52 | p[FRUSTUM_NEAR].n.z = m.m[2][3] + m.m[2][2]; 53 | p[FRUSTUM_NEAR].d = m.m[3][3] + m.m[3][2]; 54 | 55 | // Normalize all plane normals 56 | for(int i = 0; i < 6; i++) 57 | p[i].Normalize(); 58 | } 59 | 60 | bool CFrustum::SphereIntersection(const Vector& vecCenter, float flRadius) 61 | { 62 | // Loop through each plane that comprises the frustum. 63 | for (int i = 0; i < 6; i++) 64 | { 65 | // Plane-sphere intersection test. If p*n + d + r < 0 then we're outside the plane. 66 | // http://youtu.be/4p-E_31XOPM 67 | if (vecCenter.Dot(p[i].n) + p[i].d + flRadius <= 0) 68 | return false; 69 | } 70 | 71 | // If none of the planes had the entity lying on its "negative" side then it must be 72 | // on the "positive" side for all of them. Thus the entity is inside or touching the frustum. 73 | return true; 74 | } 75 | -------------------------------------------------------------------------------- /glfw-2.7.9/lib/x11/x11_glext.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: X11/GLX 4 | // API version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #include "internal.h" 32 | 33 | 34 | void (*glXGetProcAddress(const GLubyte *procName))(); 35 | void (*glXGetProcAddressARB(const GLubyte *procName))(); 36 | void (*glXGetProcAddressEXT(const GLubyte *procName))(); 37 | 38 | // We support four different ways for getting addresses for GL/GLX 39 | // extension functions: glXGetProcAddress, glXGetProcAddressARB, 40 | // glXGetProcAddressEXT, and dlsym 41 | #if defined( _GLFW_HAS_GLXGETPROCADDRESSARB ) 42 | #define _glfw_glXGetProcAddress(x) glXGetProcAddressARB(x) 43 | #elif defined( _GLFW_HAS_GLXGETPROCADDRESS ) 44 | #define _glfw_glXGetProcAddress(x) glXGetProcAddress(x) 45 | #elif defined( _GLFW_HAS_GLXGETPROCADDRESSEXT ) 46 | #define _glfw_glXGetProcAddress(x) glXGetProcAddressEXT(x) 47 | #elif defined( _GLFW_HAS_DLOPEN ) 48 | #define _glfw_glXGetProcAddress(x) dlsym(_glfwLibrary.Libs.libGL,x) 49 | #else 50 | #define _glfw_glXGetProcAddress(x) NULL 51 | #endif 52 | 53 | 54 | //************************************************************************ 55 | //**** Platform implementation functions **** 56 | //************************************************************************ 57 | 58 | //======================================================================== 59 | // Check if an OpenGL extension is available at runtime 60 | //======================================================================== 61 | 62 | int _glfwPlatformExtensionSupported( const char *extension ) 63 | { 64 | const GLubyte *extensions; 65 | 66 | // Get list of GLX extensions 67 | extensions = (const GLubyte*) glXQueryExtensionsString( _glfwLibrary.display, 68 | _glfwWin.screen ); 69 | if( extensions != NULL ) 70 | { 71 | if( _glfwStringInExtensionString( extension, extensions ) ) 72 | { 73 | return GL_TRUE; 74 | } 75 | } 76 | 77 | return GL_FALSE; 78 | } 79 | 80 | 81 | //======================================================================== 82 | // Get the function pointer to an OpenGL function 83 | //======================================================================== 84 | 85 | void * _glfwPlatformGetProcAddress( const char *procname ) 86 | { 87 | return (void *) _glfw_glXGetProcAddress( (const GLubyte *) procname ); 88 | } 89 | 90 | -------------------------------------------------------------------------------- /datamanager/data.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | class CData 28 | { 29 | public: 30 | CData(); 31 | CData(std::string sKey, std::string sValue); 32 | ~CData(); 33 | 34 | public: 35 | CData* AddChild(std::string sKey); 36 | CData* AddChild(std::string sKey, std::string sValue); 37 | 38 | CData* GetParent() const { return m_pParent; } 39 | 40 | size_t FindChildIndex(const std::string& sKey) const; 41 | CData* FindChild(const std::string& sKey) const; 42 | std::string FindChildValueString(const std::string& sKey, const std::string& sDefault="") const; 43 | bool FindChildValueBool(const std::string& sKey, bool bDefault=false) const; 44 | int FindChildValueInt(const std::string& sKey, int iDefault=0) const; 45 | size_t FindChildValueUInt(const std::string& sKey, size_t iDefault=0) const; 46 | float FindChildValueFloat(const std::string& sKey, float flDefault=0) const; 47 | Vector2D FindChildValueVector2D(const std::string& sKey, Vector2D vecDefault=Vector()) const; 48 | 49 | std::string GetKey() const { return m_sKey; } 50 | std::string GetValueString() const { return m_sValue; } 51 | bool GetValueBool() const; 52 | int GetValueInt() const; 53 | size_t GetValueUInt() const; 54 | float GetValueFloat() const; 55 | Vector2D GetValueVector2D() const; 56 | Vector GetValueVector() const; 57 | Vector4D GetValueVector4D() const; 58 | 59 | void SetKey(std::string sKey) { m_sKey = sKey; } 60 | void SetValue(std::string sValue) { m_sValue = sValue; } 61 | void SetValue(bool); 62 | void SetValue(int); 63 | void SetValue(size_t); 64 | void SetValue(float); 65 | void SetValue(Vector2D); 66 | 67 | size_t GetNumChildren() const { return m_apChildren.size(); } 68 | CData* GetChild(size_t i) const { return m_apChildren[i]; } 69 | 70 | protected: 71 | CData* m_pParent; 72 | 73 | std::string m_sKey; 74 | std::string m_sValue; 75 | std::vector m_apChildren; 76 | }; 77 | -------------------------------------------------------------------------------- /glfw-2.7.9/support/d/examples/triangle.d: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // This is a small test application for GLFW. 3 | // The program opens a window (640x480), and renders a spinning colored 4 | // triangle (it is controlled with both the GLFW timer and the mouse). It 5 | // also calculates the rendering speed (FPS), which is displayed in the 6 | // window title bar. 7 | //======================================================================== 8 | 9 | import std.string; 10 | import glfw; 11 | 12 | 13 | //======================================================================== 14 | // main() 15 | //======================================================================== 16 | 17 | int main() 18 | { 19 | int width, height, running, frames, x, y; 20 | double t, t0, fps; 21 | char[] titlestr; 22 | 23 | // Initialise GLFW 24 | glfwInit(); 25 | 26 | // Open OpenGL window 27 | if( !glfwOpenWindow( 640, 480, 0,0,0,0, 0,0, GLFW_WINDOW ) ) 28 | { 29 | glfwTerminate(); 30 | return 0; 31 | } 32 | 33 | // Enable sticky keys 34 | glfwEnable( GLFW_STICKY_KEYS ); 35 | 36 | // Disable vertical sync (on cards that support it) 37 | glfwSwapInterval( 0 ); 38 | 39 | // Main loop 40 | running = GL_TRUE; 41 | frames = 0; 42 | t0 = glfwGetTime(); 43 | while( running ) 44 | { 45 | // Get time and mouse position 46 | t = glfwGetTime(); 47 | glfwGetMousePos( &x, &y ); 48 | 49 | // Calculate and display FPS (frames per second) 50 | if( (t-t0) > 1.0 || frames == 0 ) 51 | { 52 | fps = cast(double)frames / (t-t0); 53 | titlestr = "Spinning Triangle (" ~ toString(fps) ~ " FPS)\0"; 54 | glfwSetWindowTitle( titlestr ); 55 | t0 = t; 56 | frames = 0; 57 | } 58 | frames ++; 59 | 60 | // Get window size (may be different than the requested size) 61 | glfwGetWindowSize( &width, &height ); 62 | height = height > 0 ? height : 1; 63 | 64 | // Set viewport 65 | glViewport( 0, 0, width, height ); 66 | 67 | // Clear color buffer 68 | glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); 69 | glClear( GL_COLOR_BUFFER_BIT ); 70 | 71 | // Select and setup the projection matrix 72 | glMatrixMode( GL_PROJECTION ); 73 | glLoadIdentity(); 74 | gluPerspective( 65.0f, cast(GLfloat)width/cast(GLfloat)height, 1.0f, 75 | 100.0f ); 76 | 77 | // Select and setup the modelview matrix 78 | glMatrixMode( GL_MODELVIEW ); 79 | glLoadIdentity(); 80 | gluLookAt( 0.0f, 1.0f, 0.0f, // Eye-position 81 | 0.0f, 20.0f, 0.0f, // View-point 82 | 0.0f, 0.0f, 1.0f ); // Up-vector 83 | 84 | // Draw a rotating colorful triangle 85 | glTranslatef( 0.0f, 14.0f, 0.0f ); 86 | glRotatef( 0.3*cast(GLfloat)x + cast(GLfloat)t*100.0f, 0.0f, 0.0f, 1.0f ); 87 | glBegin( GL_TRIANGLES ); 88 | glColor3f( 1.0f, 0.0f, 0.0f ); 89 | glVertex3f( -5.0f, 0.0f, -4.0f ); 90 | glColor3f( 0.0f, 1.0f, 0.0f ); 91 | glVertex3f( 5.0f, 0.0f, -4.0f ); 92 | glColor3f( 0.0f, 0.0f, 1.0f ); 93 | glVertex3f( 0.0f, 0.0f, 6.0f ); 94 | glEnd(); 95 | 96 | // Swap buffers 97 | glfwSwapBuffers(); 98 | 99 | // Check if the ESC key was pressed or the window was closed 100 | running = !glfwGetKey( GLFW_KEY_ESC ) && 101 | glfwGetWindowParam( GLFW_OPENED ); 102 | } 103 | 104 | // Close OpenGL window and terminate GLFW 105 | glfwTerminate(); 106 | 107 | return 0; 108 | } 109 | -------------------------------------------------------------------------------- /renderer/keys.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Lunar Workshop, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: 8 | This product includes software developed by Lunar Workshop, Inc. 9 | 4. Neither the name of the Lunar Workshop nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY LUNAR WORKSHOP INC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUNAR WORKSHOP BE LIABLE FOR ANY 13 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 14 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | */ 17 | 18 | #ifndef TINKER_KEYS_H 19 | #define TINKER_KEYS_H 20 | 21 | typedef enum 22 | { 23 | TINKER_KEY_UKNOWN = -1, 24 | TINKER_KEY_FIRST = 256, 25 | TINKER_KEY_ESCAPE = TINKER_KEY_FIRST, 26 | TINKER_KEY_F1, 27 | TINKER_KEY_F2, 28 | TINKER_KEY_F3, 29 | TINKER_KEY_F4, 30 | TINKER_KEY_F5, 31 | TINKER_KEY_F6, 32 | TINKER_KEY_F7, 33 | TINKER_KEY_F8, 34 | TINKER_KEY_F9, 35 | TINKER_KEY_F10, 36 | TINKER_KEY_F11, 37 | TINKER_KEY_F12, 38 | TINKER_KEY_UP, 39 | TINKER_KEY_DOWN, 40 | TINKER_KEY_LEFT, 41 | TINKER_KEY_RIGHT, 42 | TINKER_KEY_LSHIFT, 43 | TINKER_KEY_RSHIFT, 44 | TINKER_KEY_LCTRL, 45 | TINKER_KEY_RCTRL, 46 | TINKER_KEY_LALT, 47 | TINKER_KEY_RALT, 48 | TINKER_KEY_TAB, 49 | TINKER_KEY_ENTER, 50 | TINKER_KEY_BACKSPACE, 51 | TINKER_KEY_INSERT, 52 | TINKER_KEY_DEL, 53 | TINKER_KEY_PAGEUP, 54 | TINKER_KEY_PAGEDOWN, 55 | TINKER_KEY_HOME, 56 | TINKER_KEY_END, 57 | TINKER_KEY_KP_0, 58 | TINKER_KEY_KP_1, 59 | TINKER_KEY_KP_2, 60 | TINKER_KEY_KP_3, 61 | TINKER_KEY_KP_4, 62 | TINKER_KEY_KP_5, 63 | TINKER_KEY_KP_6, 64 | TINKER_KEY_KP_7, 65 | TINKER_KEY_KP_8, 66 | TINKER_KEY_KP_9, 67 | TINKER_KEY_KP_DIVIDE, 68 | TINKER_KEY_KP_MULTIPLY, 69 | TINKER_KEY_KP_SUBTRACT, 70 | TINKER_KEY_KP_ADD, 71 | TINKER_KEY_KP_DECIMAL, 72 | TINKER_KEY_KP_EQUAL, 73 | TINKER_KEY_KP_ENTER, 74 | TINKER_KEY_MOUSE_LEFT, 75 | TINKER_KEY_MOUSE_RIGHT, 76 | TINKER_KEY_MOUSE_MIDDLE, 77 | TINKER_KEY_JOYSTICK_1, 78 | TINKER_KEY_JOYSTICK_2, 79 | TINKER_KEY_JOYSTICK_3, 80 | TINKER_KEY_JOYSTICK_4, 81 | TINKER_KEY_JOYSTICK_5, 82 | TINKER_KEY_JOYSTICK_6, 83 | TINKER_KEY_JOYSTICK_7, 84 | TINKER_KEY_JOYSTICK_8, 85 | TINKER_KEY_JOYSTICK_9, 86 | TINKER_KEY_JOYSTICK_10, 87 | TINKER_KEY_JOYSTICK_11, 88 | TINKER_KEY_JOYSTICK_12, 89 | TINKER_KEY_JOYSTICK_13, 90 | TINKER_KEY_JOYSTICK_14, 91 | TINKER_KEY_JOYSTICK_15, 92 | TINKER_KEY_JOYSTICK_16, 93 | TINKER_KEY_JOYSTICK_17, 94 | TINKER_KEY_JOYSTICK_18, 95 | TINKER_KEY_JOYSTICK_19, 96 | TINKER_KEY_JOYSTICK_20, 97 | } tinker_keys_t; 98 | 99 | typedef enum 100 | { 101 | TINKER_MOUSE_RELEASED = 0, 102 | TINKER_MOUSE_PRESSED = 1, 103 | TINKER_MOUSE_DOUBLECLICK = 2, 104 | } tinker_mouse_state_t; 105 | 106 | #endif -------------------------------------------------------------------------------- /glfw-2.7.9/lib/init.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL framework 3 | // Platform: Any 4 | // API version: 2.7 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #define _init_c_ 32 | #include "internal.h" 33 | 34 | 35 | //************************************************************************ 36 | //**** GLFW user functions **** 37 | //************************************************************************ 38 | 39 | //======================================================================== 40 | // Initialize various GLFW state 41 | //======================================================================== 42 | 43 | GLFWAPI int GLFWAPIENTRY glfwInit( void ) 44 | { 45 | // Is GLFW already initialized? 46 | if( _glfwInitialized ) 47 | { 48 | return GL_TRUE; 49 | } 50 | 51 | memset( &_glfwLibrary, 0, sizeof( _glfwLibrary ) ); 52 | memset( &_glfwWin, 0, sizeof( _glfwWin ) ); 53 | 54 | // Window is not yet opened 55 | _glfwWin.opened = GL_FALSE; 56 | 57 | // Default enable/disable settings 58 | _glfwWin.sysKeysDisabled = GL_FALSE; 59 | 60 | // Clear window hints 61 | _glfwClearWindowHints(); 62 | 63 | // Platform specific initialization 64 | if( !_glfwPlatformInit() ) 65 | { 66 | return GL_FALSE; 67 | } 68 | 69 | // Form now on, GLFW state is valid 70 | _glfwInitialized = GL_TRUE; 71 | 72 | return GL_TRUE; 73 | } 74 | 75 | 76 | 77 | //======================================================================== 78 | // Close window and kill all threads. 79 | //======================================================================== 80 | 81 | GLFWAPI void GLFWAPIENTRY glfwTerminate( void ) 82 | { 83 | // Is GLFW initialized? 84 | if( !_glfwInitialized ) 85 | { 86 | return; 87 | } 88 | 89 | // Platform specific termination 90 | if( !_glfwPlatformTerminate() ) 91 | { 92 | return; 93 | } 94 | 95 | // GLFW is no longer initialized 96 | _glfwInitialized = GL_FALSE; 97 | } 98 | 99 | 100 | //======================================================================== 101 | // Get GLFW version 102 | //======================================================================== 103 | 104 | GLFWAPI void GLFWAPIENTRY glfwGetVersion( int *major, int *minor, int *rev ) 105 | { 106 | if( major != NULL ) *major = GLFW_VERSION_MAJOR; 107 | if( minor != NULL ) *minor = GLFW_VERSION_MINOR; 108 | if( rev != NULL ) *rev = GLFW_VERSION_REVISION; 109 | } 110 | 111 | --------------------------------------------------------------------------------