├── Workshop ├── Day 6 │ ├── .vscode │ │ ├── settings.json │ │ ├── launch.json │ │ └── tasks.json │ ├── 4.5_read_write.c │ ├── 1_fputs │ ├── 2_fgets │ ├── 3_fputc │ ├── 4_fgetc │ ├── 5_fprintf │ ├── 6_fscanf │ ├── dummy.txt │ ├── copy_paste │ ├── 0_open_close │ ├── 7_record_Array │ ├── 8_record_structure │ ├── slide │ │ └── The File Remembers.pdf │ ├── movie.txt │ ├── 0_open_close.c │ ├── 2_fgets.c │ ├── 4_fgetc.c │ ├── 5_fprintf.c │ ├── 6_fscanf.c │ ├── 3_fputc.c │ ├── 1_fputs.c │ ├── copy_paste.c │ ├── 7_record_Array.c │ └── 8_record_structure.c ├── Day 0 │ ├── day0.pdf │ └── codes │ │ ├── one.c │ │ ├── three.c │ │ ├── four.c │ │ ├── five.c │ │ ├── six.c │ │ ├── two.c │ │ └── twopointfive.c ├── Day 2 │ ├── Day2.pdf │ ├── 4.c │ ├── 3.c │ ├── 2.c │ ├── 8.c │ ├── 6.c │ ├── 7.c │ ├── 5.c │ └── 1.c ├── Day 1 │ ├── Day 1.pptx │ ├── onetofourgoto.c │ ├── goto.c │ ├── prime.c │ ├── goto switch.c │ ├── isvowel.c │ ├── loops.c │ ├── whynotgoto.c │ ├── nosted.c │ ├── ternary.c │ ├── switch.c │ └── gotovowel.c ├── Day 4 │ ├── Lecture 4.pdf │ └── string functions.c └── Day 3 │ ├── Code │ ├── array_mutable.c │ ├── Looping-1d.c │ ├── array_access.c │ ├── struct_obj_decl.c │ ├── 2d_access.c │ ├── Looping-2d.c │ ├── struct_array.c │ └── struct_init.c │ └── Day 3_indeSTRUCTible.pptx.pdf ├── .gitignore ├── Samples ├── Michi │ ├── .gitignore │ ├── Logo.bmp │ ├── Logo.ico │ ├── Screenshot.png │ ├── Stanberry.ttf │ ├── resource.h │ ├── glfw │ │ ├── src │ │ │ ├── glfw.rc.in │ │ │ ├── xkb_unicode.h │ │ │ ├── null_joystick.h │ │ │ ├── posix_time.h │ │ │ ├── posix_thread.h │ │ │ ├── cocoa_joystick.h │ │ │ ├── null_joystick.c │ │ │ ├── win32_joystick.h │ │ │ ├── null_init.c │ │ │ ├── linux_joystick.h │ │ │ ├── cocoa_time.c │ │ │ ├── nsgl_context.h │ │ │ ├── glfw_config.h.in │ │ │ ├── win32_time.c │ │ │ ├── null_platform.h │ │ │ └── posix_time.c │ │ └── LICENSE.md │ ├── build.muda │ ├── readme.md │ ├── Michi.sln │ ├── build.sh │ └── resource.rc ├── Mandelbrot-GPU │ ├── .gitignore │ ├── Logo.bmp │ ├── Logo.ico │ ├── screenshot.png │ ├── mandelbrot.vert │ ├── resource.h │ ├── readme.md │ ├── glfw │ │ ├── src │ │ │ ├── glfw.rc.in │ │ │ ├── xkb_unicode.h │ │ │ ├── null_joystick.h │ │ │ ├── posix_time.h │ │ │ ├── posix_thread.h │ │ │ ├── cocoa_joystick.h │ │ │ ├── null_joystick.c │ │ │ ├── win32_joystick.h │ │ │ ├── null_init.c │ │ │ ├── linux_joystick.h │ │ │ ├── cocoa_time.c │ │ │ ├── nsgl_context.h │ │ │ ├── glfw_config.h.in │ │ │ ├── win32_time.c │ │ │ ├── posix_time.c │ │ │ └── null_platform.h │ │ └── LICENSE.md │ ├── mandelbrot.frag │ ├── build.muda │ ├── Mandelbrot-GPU.sln │ ├── build.sh │ └── resource.rc ├── Mandelbrot-DX11 │ ├── .gitignore │ ├── Logo.ico │ ├── screenshot.png │ ├── build.muda │ ├── resource.h │ ├── readme.md │ ├── Mandelbrot-DX11.sln │ ├── build.bat │ └── Resource.rc ├── Resources │ └── Logo.png ├── Voronoi │ ├── voronoi.png │ ├── README.md │ ├── build.sh │ └── build.muda ├── Mandelbrot │ ├── mandelbrot.png │ ├── glfw │ │ ├── lib │ │ │ └── glfw3.lib │ │ ├── src │ │ │ ├── glfw.rc.in │ │ │ ├── xkb_unicode.h │ │ │ ├── null_joystick.h │ │ │ ├── posix_time.h │ │ │ ├── posix_thread.h │ │ │ ├── cocoa_joystick.h │ │ │ ├── null_joystick.c │ │ │ ├── win32_joystick.h │ │ │ ├── null_init.c │ │ │ ├── linux_joystick.h │ │ │ ├── cocoa_time.c │ │ │ ├── nsgl_context.h │ │ │ ├── glfw_config.h.in │ │ │ ├── win32_time.c │ │ │ ├── null_platform.h │ │ │ └── posix_time.c │ │ └── LICENSE.md │ ├── README.md │ ├── build.muda │ └── build.bat ├── Calculator │ ├── includes │ │ ├── calc1.png │ │ ├── calc2.png │ │ ├── io_stream.h │ │ ├── regex.h │ │ ├── token.h │ │ ├── parser.h │ │ └── symbol_table.h │ ├── build.sh │ ├── build.bat │ ├── README.md │ ├── src │ │ └── symbol_table.c │ └── build.muda ├── build.muda ├── LissajousCurve │ ├── build.sh │ └── build.muda ├── Fractals │ ├── build.sh │ └── build.muda ├── README.md ├── Flowfield │ ├── build.sh │ ├── build.muda │ ├── noise.h │ └── flowfield.c ├── install_sdl.bat ├── Cellular-Automata │ └── build.muda └── Fourier-series │ └── build.muda ├── Project List └── README.md ├── README.md └── CONTRIBUTING.md /Workshop/Day 6/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.errorSquiggles": "Disabled" 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | Samples/Libraries/ 3 | /Samples/.muda/muda.dll 4 | /Samples/build.log 5 | -------------------------------------------------------------------------------- /Samples/Michi/.gitignore: -------------------------------------------------------------------------------- 1 | *.vcxproj.user 2 | *.vcxproj.filters 3 | .vs/ 4 | /Resource.aps 5 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/.gitignore: -------------------------------------------------------------------------------- 1 | *.vcxproj.user 2 | *.vcxproj.filters 3 | .vs/ 4 | /Resource.aps 5 | -------------------------------------------------------------------------------- /Workshop/Day 6/4.5_read_write.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | return 0; 6 | } -------------------------------------------------------------------------------- /Samples/Mandelbrot-DX11/.gitignore: -------------------------------------------------------------------------------- 1 | *.vcxproj.user 2 | *.vcxproj.filters 3 | .vs/ 4 | /Resource.aps 5 | Captures/ 6 | -------------------------------------------------------------------------------- /Samples/Michi/Logo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Michi/Logo.bmp -------------------------------------------------------------------------------- /Samples/Michi/Logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Michi/Logo.ico -------------------------------------------------------------------------------- /Workshop/Day 0/day0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 0/day0.pdf -------------------------------------------------------------------------------- /Workshop/Day 2/Day2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 2/Day2.pdf -------------------------------------------------------------------------------- /Workshop/Day 6/1_fputs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/1_fputs -------------------------------------------------------------------------------- /Workshop/Day 6/2_fgets: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/2_fgets -------------------------------------------------------------------------------- /Workshop/Day 6/3_fputc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/3_fputc -------------------------------------------------------------------------------- /Workshop/Day 6/4_fgetc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/4_fgetc -------------------------------------------------------------------------------- /Workshop/Day 6/5_fprintf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/5_fprintf -------------------------------------------------------------------------------- /Workshop/Day 6/6_fscanf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/6_fscanf -------------------------------------------------------------------------------- /Workshop/Day 6/dummy.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/dummy.txt -------------------------------------------------------------------------------- /Samples/Resources/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Resources/Logo.png -------------------------------------------------------------------------------- /Workshop/Day 1/Day 1.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 1/Day 1.pptx -------------------------------------------------------------------------------- /Workshop/Day 6/copy_paste: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/copy_paste -------------------------------------------------------------------------------- /Samples/Michi/Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Michi/Screenshot.png -------------------------------------------------------------------------------- /Samples/Michi/Stanberry.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Michi/Stanberry.ttf -------------------------------------------------------------------------------- /Samples/Voronoi/voronoi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Voronoi/voronoi.png -------------------------------------------------------------------------------- /Workshop/Day 4/Lecture 4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 4/Lecture 4.pdf -------------------------------------------------------------------------------- /Workshop/Day 6/0_open_close: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/0_open_close -------------------------------------------------------------------------------- /Workshop/Day 6/7_record_Array: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/7_record_Array -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/Logo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Mandelbrot-GPU/Logo.bmp -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/Logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Mandelbrot-GPU/Logo.ico -------------------------------------------------------------------------------- /Samples/Mandelbrot-DX11/Logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Mandelbrot-DX11/Logo.ico -------------------------------------------------------------------------------- /Samples/Mandelbrot/mandelbrot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Mandelbrot/mandelbrot.png -------------------------------------------------------------------------------- /Workshop/Day 3/Code/array_mutable.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | int a[5] = { 32,34,67,89,21 }; 3 | a[3] = 1; 4 | a[1] = 2; 5 | return 0; 6 | } -------------------------------------------------------------------------------- /Workshop/Day 6/8_record_structure: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/8_record_structure -------------------------------------------------------------------------------- /Samples/Calculator/includes/calc1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Calculator/includes/calc1.png -------------------------------------------------------------------------------- /Samples/Calculator/includes/calc2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Calculator/includes/calc2.png -------------------------------------------------------------------------------- /Samples/Mandelbrot-DX11/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Mandelbrot-DX11/screenshot.png -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Mandelbrot-GPU/screenshot.png -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/lib/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Samples/Mandelbrot/glfw/lib/glfw3.lib -------------------------------------------------------------------------------- /Workshop/Day 3/Day 3_indeSTRUCTible.pptx.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 3/Day 3_indeSTRUCTible.pptx.pdf -------------------------------------------------------------------------------- /Workshop/Day 6/slide/The File Remembers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ITClubPulchowk/C-Programming-Guide/HEAD/Workshop/Day 6/slide/The File Remembers.pdf -------------------------------------------------------------------------------- /Workshop/Day 2/4.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | static int a=1; 4 | { 5 | int a=2; 6 | 7 | a += 1; 8 | } 9 | return 0; 10 | } -------------------------------------------------------------------------------- /Workshop/Day 1/onetofourgoto.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | int i = 1; 4 | HERE: 5 | if (i <= 5) 6 | { 7 | i++; 8 | goto HERE; 9 | } 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Workshop/Day 3/Code/Looping-1d.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | int num[5] = { 1,2,3,4,5 }, i; 3 | for (i = 0; i < 5; i++) { 4 | num[i] = num[i] + 2; 5 | } 6 | return 0; 7 | } -------------------------------------------------------------------------------- /Workshop/Day 3/Code/array_access.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | int a[5] = { 32,34,67,89,21 }; //can also use a[]={...} 3 | int b = a[0]; 4 | int c = a[2]; 5 | return 0; 6 | } -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/mandelbrot.vert: -------------------------------------------------------------------------------- 1 | #version 420 2 | 3 | layout (location = 0) in vec2 Vertex; 4 | 5 | void main() { 6 | gl_Position = vec4(Vertex, 0, 1); 7 | } 8 | -------------------------------------------------------------------------------- /Workshop/Day 6/movie.txt: -------------------------------------------------------------------------------- 1 | asdf1312asdfasdasdfC3 -------------------------------------------------------------------------------- /Workshop/Day 2/3.c: -------------------------------------------------------------------------------- 1 | int func() 2 | { 3 | int a, b; 4 | a = 1; 5 | return 0; 6 | b = 1; 7 | } 8 | 9 | int main() 10 | { 11 | func(); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /Workshop/Day 2/2.c: -------------------------------------------------------------------------------- 1 | // prototyping and definitions 2 | 3 | void func() 4 | { 5 | int b = 1; 6 | } 7 | 8 | int main() 9 | { 10 | int a=1; 11 | func(); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /Workshop/Day 0/codes/one.c: -------------------------------------------------------------------------------- 1 | 2 | int main() 3 | { 4 | int a=5, c=2; 5 | float d; 6 | a = 8; 7 | d = 2.5; 8 | float b = 'a'/2.5f; 9 | char z = 'A' + 32; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Workshop/Day 3/Code/struct_obj_decl.c: -------------------------------------------------------------------------------- 1 | struct Students{ 2 | int roll; 3 | int marks[5]; 4 | float percent; 5 | }; 6 | 7 | int main() { 8 | struct Students a; 9 | int b; 10 | 11 | return 0; 12 | } -------------------------------------------------------------------------------- /Workshop/Day 1/goto.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | int i=0; 4 | int inconditional = 0; 5 | if (i == 1) 6 | { 7 | here: 8 | inconditional = 1; 9 | goto there; 10 | } 11 | goto here; 12 | there: 13 | return 0; 14 | } -------------------------------------------------------------------------------- /Workshop/Day 2/8.c: -------------------------------------------------------------------------------- 1 | int factorial( int n) 2 | { 3 | if(n==1)return 1; 4 | return n*factorial(n-1); 5 | } 6 | 7 | int main() 8 | { 9 | int facto; 10 | 11 | facto = factorial(4); 12 | 13 | return 0; 14 | } -------------------------------------------------------------------------------- /Samples/Calculator/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -d "./bin" ]; then 4 | mkdir bin 5 | fi 6 | 7 | 8 | cc -I./includes/ ./src/main.c ./src/regex.c ./src/parser.c ./src/symbol_table.c -I./includes ./src/token.c -lm -o ./bin/calculator 9 | -------------------------------------------------------------------------------- /Workshop/Day 1/prime.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | int num = 6; 4 | int isPrime = 1; 5 | for (int i = 2; i <= num - 1; i++) 6 | { 7 | if (num % i == 0) 8 | { 9 | isPrime = 0; 10 | break; 11 | 12 | } 13 | else 14 | continue; 15 | } 16 | } -------------------------------------------------------------------------------- /Workshop/Day 2/6.c: -------------------------------------------------------------------------------- 1 | // Static variables inside a block 2 | 3 | int main() 4 | { 5 | int val = 0; 6 | for(int i=0; i<2; i++) 7 | { 8 | static int k = 1; 9 | k++; 10 | val = k; 11 | } 12 | 13 | return 0; 14 | } -------------------------------------------------------------------------------- /Workshop/Day 2/7.c: -------------------------------------------------------------------------------- 1 | // difference between global and static variables 2 | 3 | int a = 5; 4 | 5 | int fun() 6 | { 7 | a = 7; 8 | return a; 9 | } 10 | 11 | int main() 12 | { 13 | int b; 14 | 15 | b = fun(); 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Samples/Mandelbrot-DX11/build.muda: -------------------------------------------------------------------------------- 1 | @version 1.2.0 2 | 3 | Kind: Project; 4 | Build: Mandelbrot-DX11; 5 | BuildDirectory: ./bin; 6 | 7 | Defines: _CRT_SECURE_NO_WARNINGS UNICODE; 8 | Sources: main.c; 9 | ResourceFile: Resource.rc; 10 | Subsystem: Windows; 11 | -------------------------------------------------------------------------------- /Workshop/Day 1/goto switch.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | int num = 8; 4 | int isodd; 5 | 6 | if (num % 2 == 0) 7 | goto even; 8 | else 9 | goto odd; 10 | even: 11 | isodd = 0; 12 | goto end; 13 | odd: 14 | isodd = 1; 15 | goto end; 16 | end: 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Workshop/Day 0/codes/three.c: -------------------------------------------------------------------------------- 1 | int main(){ 2 | int aInt = 1; 3 | float bFloat = 2.5f; 4 | 5 | int cMul = aInt * bFloat; 6 | float dMul = aInt * bFloat; 7 | float cDiv = aInt / bFloat; 8 | int div = aInt / bFloat; 9 | 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Workshop/Day 0/codes/four.c: -------------------------------------------------------------------------------- 1 | int main(){ 2 | int birthYear, age; 3 | int drinkingAge; 4 | birthYear = 2015; 5 | age = 2021 - birthYear; 6 | if (age <= 18) 7 | drinkingAge = 0; 8 | else 9 | drinkingAge = 1; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /Workshop/Day 1/isvowel.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | int isvowel; 4 | // isvowel = 0 for consonant and 1 for vowel 5 | char letter = 'b'; 6 | if (letter == 'a' || letter == 'e' || letter == 'i' || letter == 'o' || letter == 'u') 7 | isvowel = 1; 8 | else 9 | isvowel = 0; 10 | } -------------------------------------------------------------------------------- /Workshop/Day 6/0_open_close.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | // Step 1: declare the file pointer 5 | FILE *fptr; 6 | 7 | // Step 2: open the file 8 | fptr = fopen("apple.txt", "w"); 9 | 10 | // Step 3: close the file 11 | fclose(fptr); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /Workshop/Day 0/codes/five.c: -------------------------------------------------------------------------------- 1 | int main(){ 2 | int num = 100; 3 | int toggle; 4 | //&& is a boolean and operator that is true if both of the conditions are true 5 | if(num > 5 && num < 15) 6 | toggle =1; 7 | else 8 | toggle =0; 9 | 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Workshop/Day 1/loops.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | int i = 1; 4 | while (i < 5) 5 | { 6 | i++; 7 | } 8 | return 0; 9 | } 10 | 11 | 12 | //////////do while equivalent 13 | //int main() 14 | //{ 15 | // int i = 1; 16 | // do 17 | // { 18 | // i++; 19 | // } while (i ==10); 20 | //} 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Workshop/Day 2/5.c: -------------------------------------------------------------------------------- 1 | // static variables 2 | 3 | int count = 0; 4 | 5 | int fun() 6 | { 7 | static int count = 0; 8 | count++; 9 | return count; 10 | } 11 | 12 | int main() 13 | { 14 | int val; 15 | 16 | val = 1; 17 | 18 | val = fun(); 19 | 20 | val = fun(); 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Workshop/Day 3/Code/2d_access.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | int matrix_reloaded[3][4] = {{1, 2, 3, 4}, 3 | {5, 6, 7, 8}, 4 | {9,10,11,12} }; 5 | int a = matrix_reloaded[1][1]; // a=6 6 | int b = matrix_reloaded[2][0]; // b=9 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /Samples/build.muda: -------------------------------------------------------------------------------- 1 | @version 1.5.0 2 | 3 | Kind: Solution; 4 | 5 | # Here "Libraries" and "Resources" directories are being ignored because it is not a project directory 6 | IgnoredDirectories: Libraries Resources; 7 | 8 | :OS.LINUX 9 | IgnoredDirectories: Mandelbrot-DX11; 10 | 11 | :OS.MAC 12 | IgnoredDirectories: Mandelbrot-DX11; 13 | -------------------------------------------------------------------------------- /Workshop/Day 0/codes/six.c: -------------------------------------------------------------------------------- 1 | int main(){ 2 | int hisNumber = 4000; 3 | int toggle; 4 | //first condition 5 | if (hisNumber>500 && hisNumber<5000){ 6 | //second condition 7 | if (hisNumber%177==0){ 8 | toggle = 1; 9 | } 10 | } 11 | else 12 | toggle = 0; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /Workshop/Day 0/codes/two.c: -------------------------------------------------------------------------------- 1 | int main(){ 2 | //These are comments int main() 3 | /*ksj These 4 | dhfoid Are 5 | fkjasdg Multi Line 6 | fhsadklComments 7 | jfhlkasdf*/ 8 | 9 | //int int = 76; (doesnt work because int is a keyword hence cannot be a variable name) 10 | int rollNo = 76; 11 | 12 | return 0; 13 | } -------------------------------------------------------------------------------- /Workshop/Day 1/whynotgoto.c: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | int n = 1; 4 | int isodd; 5 | START: 6 | if (n <= 5) 7 | { 8 | if (n % 2 == 0) 9 | goto EVEN; 10 | goto ODD; 11 | } 12 | goto end; 13 | EVEN: 14 | // 0 means even 15 | isodd = 0; 16 | n++; 17 | goto START; 18 | ODD: 19 | // 1 is odd 20 | isodd = 1; 21 | n++; 22 | goto START; 23 | end: 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Workshop/Day 1/nosted.c: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | char letter = 'u'; 4 | int vorc = 0; 5 | // vorc 1 for vowel and 0 for consonants 6 | switch (letter) 7 | { 8 | case 'a': 9 | vorc = 1; 10 | break; 11 | case'e': 12 | vorc = 1; 13 | break; 14 | case'i': 15 | vorc = 1; 16 | break; 17 | case'o': 18 | vorc = 1; 19 | break; 20 | case'u': 21 | vorc = 1; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /Samples/LissajousCurve/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCEFILES=../main.c 4 | OUTPUTFILE=lissajous 5 | 6 | if [ ! -d "./bin" ]; then 7 | mkdir bin 8 | fi 9 | 10 | if ! command -v gcc &> /dev/null 11 | then 12 | echo GCC Not Found 13 | echo ------------------------------ 14 | exit 15 | fi 16 | pushd bin 17 | gcc $SOURCEFILES -o $OUTPUTFILE -lSDL2main -lSDL2 -lm 18 | popd 19 | 20 | -------------------------------------------------------------------------------- /Workshop/Day 3/Code/Looping-2d.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | int i,j,a,matrix_reloaded[3][4] = { {1, 2, 3, 4}, 3 | {5, 6, 7, 8}, 4 | {9,10,11,12}}; 5 | for (i = 0; i < 3; i++) { 6 | for (j = 0; j < 4; j++) { 7 | matrix_reloaded[i][j] = matrix_reloaded[i][j]*2; 8 | } 9 | } 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Workshop/Day 6/2_fgets.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE *fptr; 5 | char s[100]; 6 | 7 | fptr = fopen("dummy123.txt", "r"); 8 | if(fptr == NULL){ 9 | printf("File cannot be opened. \n"); 10 | exit(0); 11 | } 12 | // fgets 13 | // Syntax : fgets(string_variable, int_value, fptr) 14 | fgets(s, 20, fptr); 15 | 16 | fclose(fptr); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Samples/Fractals/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | COMPILER=gcc 4 | FLAGS="-lSDL2 -lm" 5 | FILENAME="koch-snowflake-fractal.c" 6 | BINARY_NAME="bin" 7 | 8 | if command -v gcc &> /dev/null 9 | then 10 | ${COMPILER} ${FILENAME} -o ${BINARY_NAME} ${FLAGS} 11 | else 12 | echo "Could not find the compiler ${COMPILER} in your path." 13 | echo "Aborting the build process..." 14 | exit 1 15 | fi 16 | 17 | 18 | exit 0 19 | -------------------------------------------------------------------------------- /Workshop/Day 3/Code/struct_array.c: -------------------------------------------------------------------------------- 1 | struct Student { 2 | int roll; 3 | int marks[5]; 4 | float percent; 5 | }; 6 | 7 | int fun(struct Student a) { 8 | 9 | } 10 | 11 | int main() { 12 | struct Student a[5] = { {1,{95,95,95,97,87}},{2,{34,45,66,78,88}} }; 13 | int i, total = 0; 14 | for (i = 0; i < 5; i++) { 15 | total += a[0].marks[i]; 16 | } 17 | a[0].percent = total / 5.0f; 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Workshop/Day 0/codes/twopointfive.c: -------------------------------------------------------------------------------- 1 | int main(){ 2 | int num1, num2, sum; 3 | float pointnumber; 4 | char firstChar; 5 | int sizeofInt, sizeofChar, sizeofFloat; 6 | 7 | num1=5; 8 | num2=10; 9 | sum = num1 + num2; 10 | pointnumber = 2.5; 11 | firstChar = 'A'; 12 | sizeofInt = sizeof(sum); 13 | sizeofChar = sizeof(firstChar); 14 | sizeofFloat = sizeof(2.5f); 15 | 16 | 17 | 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Workshop/Day 1/ternary.c: -------------------------------------------------------------------------------- 1 | 2 | int main() 3 | { 4 | //ternery operator 5 | int a = 1; 6 | int b = 3; 7 | int c = 4; 8 | int greatest = (a > b) ? (a > c ? a : c) : (b > c ? b : c); 9 | 10 | //if else equivalent 11 | //if (a > b) 12 | //{ 13 | // if (a > c) 14 | // greatest = a; 15 | // else 16 | // greatest = c; 17 | //} 18 | //else 19 | //{ 20 | // if (b > c) 21 | // greatest = b; 22 | // else 23 | // greatest = c; 24 | //} 25 | } -------------------------------------------------------------------------------- /Workshop/Day 6/4_fgetc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | FILE *f; 6 | char c; 7 | 8 | f = fopen("dummy.txt", "r"); 9 | if(f == NULL){ 10 | printf("File cannot be opened."); 11 | exit(0); 12 | } 13 | // fgetc 14 | // syntax : fgetc(fptr) 15 | while((c = fgetc(f)) != EOF){ 16 | printf("%c", c); 17 | } 18 | printf("\n"); 19 | 20 | fclose(f); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Workshop/Day 6/5_fprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | FILE *fptr; 6 | char name[20]; 7 | 8 | fptr = fopen("dummy.txt", "w"); 9 | if(fptr == NULL){ 10 | printf("File cannot be opened"); 11 | exit(0); 12 | } 13 | 14 | printf("Enter your name : "); 15 | scanf("%s", name); 16 | 17 | // fprintf(); 18 | fprintf(fptr, "Name : %s", name); 19 | 20 | fclose(fptr); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Workshop/Day 1/switch.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | char letter = 'u'; 4 | int isVowel = 0; 5 | //is vowel is 0 if letter is consonant 6 | switch(letter) 7 | { 8 | case 'a': 9 | isVowel = 1; 10 | break; 11 | case 'e': 12 | isVowel = 1; 13 | break; 14 | case 'i': 15 | isVowel = 1; 16 | break; 17 | case 'o': 18 | isVowel = 1; 19 | break; 20 | case 'u': 21 | isVowel = 1; 22 | 23 | default: 24 | isVowel = 0; 25 | break; 26 | } 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Samples/README.md: -------------------------------------------------------------------------------- 1 | ## Build Instruction 2 | 3 | * Each sample directory contains `build.bat` and `build.sh` file 4 | * From the sample project directory, run `build.bat` in windows and `build.sh` in linux and mac 5 | * The output will be generated in `bin` directory 6 | * The default build process will build the sample in debug configuration i.e. no optimization 7 | * For optimization build, you must specify `optimize` flag when running the build file, for example: `build.bat optimize` or `build.sh optimize` 8 | -------------------------------------------------------------------------------- /Workshop/Day 6/6_fscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | FILE *fptr; 6 | char s[10]; 7 | 8 | fptr = fopen("dummy.txt", "r"); 9 | if(fptr == NULL){ 10 | printf("File cannot be opened"); 11 | exit(0); 12 | } 13 | 14 | //fscanf(fptr, control_string, variable_list); 15 | 16 | while((fscanf(fptr, "%s", s)) != EOF){ 17 | printf("%s", s); 18 | } 19 | printf("\n"); 20 | 21 | fclose(fptr); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Workshop/Day 6/3_fputc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE *fptr; 5 | char c; 6 | 7 | fptr = fopen("dummy.txt", "w"); 8 | if(fptr == NULL){ 9 | printf("File cannot be opened"); 10 | exit(0); 11 | } 12 | 13 | // fputc 14 | // Syntax : fputc(c, file_ptr_variable); 15 | printf("Start writing what you want to enter in file..."); 16 | while((c = getchar()) != '0'){ 17 | fputc(c, fptr); 18 | } 19 | 20 | fclose(fptr); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Samples/Michi/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Resource.rc 4 | // 5 | #define IDI_ICON1 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-DX11/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Resource.rc 4 | // 5 | #define IDI_ICON1 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Resource.rc 4 | // 5 | #define IDI_ICON1 105 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 106 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /Workshop/Day 6/1_fputs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE *fptr; 5 | char sentence[100]; 6 | 7 | fptr = fopen("dummy.txt", "a"); 8 | if(fptr == NULL){ 9 | printf("File cannot be opened. \n"); 10 | exit(0); 11 | } 12 | // "%[^\n]" for multiple words. 13 | printf("Enter a sentence : "); 14 | scanf("%[^\n]", sentence); 15 | 16 | // fputs 17 | // Syntax : fputs(string, file_ptr); 18 | fputs(sentence, fptr); 19 | 20 | fclose(fptr); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Samples/Flowfield/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCEFILES=../flowfield.c 4 | OUTPUTFILE=flowfield.o 5 | 6 | if [ ! -d "./bin" ]; then 7 | mkdir bin 8 | fi 9 | 10 | echo ------------------------- 11 | echo Building with GCC 12 | echo ------------------------- 13 | if ! command -v gcc &> /dev/null 14 | then 15 | echo GCC Not Found 16 | echo ------------------------- 17 | exit 18 | fi 19 | pushd bin 20 | gcc $SOURCEFILES -o $OUTPUTFILE -w -Wall -lSDL2main -lSDL2 -lm 21 | popd 22 | echo ------------------------- 23 | echo GCC build Complete 24 | echo ------------------------- 25 | -------------------------------------------------------------------------------- /Workshop/Day 2/1.c: -------------------------------------------------------------------------------- 1 | // need for functions. 2 | 3 | 4 | int is_prime(int number); 5 | 6 | 7 | int main() 8 | { 9 | int number = 17; 10 | 11 | int prime_ho_ki_nai; 12 | 13 | prime_ho_ki_nai = is_prime(17); 14 | 15 | int another_no = 97; 16 | 17 | prime_ho_ki_nai = is_prime(another_no); 18 | 19 | return 0; 20 | } 21 | 22 | 23 | int is_prime(int number) 24 | { 25 | int is_prime = 1; 26 | 27 | for(int i=2;i 2 | #include 3 | 4 | int main(){ 5 | FILE *s, *d; 6 | char c; 7 | 8 | s = fopen("source.txt", "r"); 9 | d = fopen("destination.txt", "w"); 10 | 11 | if(s == NULL){ 12 | printf("Source file cannot be opened."); 13 | exit(0); 14 | } 15 | if(d == NULL){ 16 | printf("Destination file cannot be opened"); 17 | exit(0); 18 | } 19 | 20 | // fgetc(s) for reading from source file 21 | // fputc(character_variable, d) for writing 22 | while((c = fgetc(s)) != EOF){ 23 | fputc(c, d); 24 | } 25 | 26 | fclose(s); 27 | fclose(d); 28 | } 29 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/README.md: -------------------------------------------------------------------------------- 1 | # Mandelbrot Set 2 | 3 | ## Definition 4 | The Mandelbrot set is the set of complex numbers c for which the function $f_c(z) = z^2 + c$ does not diverge when iterated from z = 0 ,remains bounded in absolute value. 5 | 6 | For eg: $c = 1 + i$ belongs to the mandelbrot set if the final $f_c(z)$ does not reach infinity 7 | * $f_c(z) = c$ 8 | * $f_c(z) = c^2 + c$ 9 | * $f_c(z) = (c^2 + c)^2 + c$ 10 | 11 | And if the final result is inifinty then $c$ doesn’t blong to Mandelbrot set. 12 | 13 | Check out [Wikipdia](https://en.wikipedia.org/wiki/Mandelbrot_set) for more details. 14 | 15 | 16 | 17 | 18 | ## Here is the final result 19 | ![Mandelbrot Diagram](./mandelbrot.png) -------------------------------------------------------------------------------- /Samples/install_sdl.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | pushd .. 6 | 7 | if not exist "Libraries" mkdir Libraries 8 | if exist "Libraries/SDL2/SDL2-2.0.14" goto SkipDownloadSDL 9 | echo Downloading SDL 10 | 11 | pushd Libraries 12 | mkdir SDL2 13 | curl "https://www.libsdl.org/release/SDL2-devel-2.0.14-VC.zip" --output SDL2.zip 14 | tar -zxvf SDL2.zip -C SDL2 15 | del SDL2.zip 16 | ren "SDL2\SDL2-2.0.14\include" "SDL2" 17 | popd 18 | 19 | :SkipDownloadSDL 20 | if exist "Libraries/SDL2MinGw/SDL2-2.0.14/" goto SkipDownloadSDLMinGw 21 | echo Downloading SDLMinGw 22 | 23 | pushd Libraries 24 | mkdir SDL2MinGw 25 | curl "https://www.libsdl.org/release/SDL2-devel-2.0.14-mingw.tar.gz" --output SDL2MinGw.tar.gz 26 | tar -xf SDL2MinGw.tar.gz -C SDL2MinGw 27 | del SDL2MinGw.tar.gz 28 | popd 29 | 30 | :SkipDownloadSDLMinGw 31 | echo ------------------- 32 | 33 | popd 34 | -------------------------------------------------------------------------------- /Samples/Voronoi/README.md: -------------------------------------------------------------------------------- 1 | # Voronoi Diagrams 2 | This program generates __Vonoroi Diagrams__ using the incremental perpendicular 3 | bisector method. See [Voronoi Diagrams](https://en.wikipedia.org/wiki/Voronoi_diagram) 4 | for some details. 5 | 6 | ## Building 7 | In `build.sh`, change the `INCLUDE` variable to the directory where your SDL header files are 8 | and then run `build.sh`. 9 | 10 | ## Usage 11 | ![Voronoi diagram](./voronoi.png) 12 | 13 | Run `main`. 14 | You can change various parameters like the size of the bounding box and the inital 15 | point directly from the first few lines of `main.c` (re-building is necessary). 16 | Left click inside to insert a voronoi site in the diagram. 17 | 18 | ## TODO 19 | * Add colored regions 20 | * Maybe deletion of regions(?) 21 | 22 | ## Limitations 23 | This implementation is not perfect and will surely have some bugs. Use with care! 24 | -------------------------------------------------------------------------------- /Samples/Calculator/includes/regex.h: -------------------------------------------------------------------------------- 1 | #ifndef REGEX_H 2 | #define REGEX_H 3 | #include 4 | 5 | enum finite_states {q0,q1,q2,q3,q4,q5,q6,q7,q8,null_state}; 6 | 7 | enum finite_states transition_func(enum finite_states, char ); 8 | 9 | float simulate_dfa(const char* input_string,char* , int); 10 | 11 | // Return the length of the supplied null terminated string 12 | int str_len(const char* ); 13 | 14 | // Return the number of bytes transfered from src to destination string 15 | int str_cpy(char* dest, const char* src, int len); 16 | 17 | float str_to_float(const char* string, int len); 18 | int str_to_int(const char* string, int len); 19 | 20 | bool is_valid_id(char ch); 21 | 22 | // check whether given char is digit or not 23 | bool is_digit(char ch); 24 | 25 | // check whether given char is operator or not 26 | bool is_op(char ch); 27 | bool is_valid_ch(char ch); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/readme.md: -------------------------------------------------------------------------------- 1 | # [Mandelbrot Set](https://en.wikipedia.org/wiki/Mandelbrot_set) 2 | 3 | ## Usage 4 | * Build by running the `build.bat` in Windows and `build.sh` in Linux 5 | * The executables are generated in `bin/` directory 6 | * In the same directroy as the executables there exits `mandelbrot.frag` file 7 | * You can edit and save the `mandelbrot.frag` file and it will automatically be reloaded by the program 8 | * You can use the mouse wheel to zoom in and out 9 | 10 | ## Variables 11 | *Note: The following variables are present in mandelbrot.frag file* 12 | - `Radius` : Change the value and observe the result 13 | - `ColorWeight` : Using this variable, control the output color of the Mandelbrot 14 | - `MAX_ITERATIONS` : Change the number of iterations made in the calculation and observe the result 15 | 16 | ## Screeenshot 17 | 18 | ![Mandelbrot Diagram](screenshot.png) 19 | -------------------------------------------------------------------------------- /Workshop/Day 6/7_record_Array.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | FILE *fptr; 6 | int num[3], i, number[3]; 7 | 8 | fptr = fopen("dummy.txt", "w+b"); 9 | if(fptr == NULL){ 10 | printf("File cannot be opened"); 11 | exit(0); 12 | } 13 | 14 | printf("Reading the array \n"); 15 | for(i = 0; i < 3; i++){ 16 | printf("Enter number #%d : ", i + 1); 17 | scanf("%d", &num[i]); 18 | } 19 | 20 | // fwrite(&ptr, sizeof(array), num of array, fptr); 21 | fwrite(&num, sizeof(num), 1, fptr); 22 | 23 | rewind(fptr); 24 | 25 | // fread(&ptr, sizeof(array), num of array, fptr); 26 | fread(&number, sizeof(num), 1, fptr); 27 | 28 | printf("Reading the number \n"); 29 | for(i = 0; i < 3; i++){ 30 | printf("%d \n", number[i]); 31 | } 32 | 33 | fclose(fptr); 34 | return 0; 35 | } -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/glfw.rc.in: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 6 | PRODUCTVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_NT_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 12 | { 13 | BLOCK "StringFileInfo" 14 | { 15 | BLOCK "040904B0" 16 | { 17 | VALUE "CompanyName", "GLFW" 18 | VALUE "FileDescription", "GLFW @GLFW_VERSION@ DLL" 19 | VALUE "FileVersion", "@GLFW_VERSION@" 20 | VALUE "OriginalFilename", "glfw3.dll" 21 | VALUE "ProductName", "GLFW" 22 | VALUE "ProductVersion", "@GLFW_VERSION@" 23 | } 24 | } 25 | BLOCK "VarFileInfo" 26 | { 27 | VALUE "Translation", 0x409, 1200 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/glfw.rc.in: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 6 | PRODUCTVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_NT_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 12 | { 13 | BLOCK "StringFileInfo" 14 | { 15 | BLOCK "040904B0" 16 | { 17 | VALUE "CompanyName", "GLFW" 18 | VALUE "FileDescription", "GLFW @GLFW_VERSION@ DLL" 19 | VALUE "FileVersion", "@GLFW_VERSION@" 20 | VALUE "OriginalFilename", "glfw3.dll" 21 | VALUE "ProductName", "GLFW" 22 | VALUE "ProductVersion", "@GLFW_VERSION@" 23 | } 24 | } 25 | BLOCK "VarFileInfo" 26 | { 27 | VALUE "Translation", 0x409, 1200 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/glfw.rc.in: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 6 | PRODUCTVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_NT_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 12 | { 13 | BLOCK "StringFileInfo" 14 | { 15 | BLOCK "040904B0" 16 | { 17 | VALUE "CompanyName", "GLFW" 18 | VALUE "FileDescription", "GLFW @GLFW_VERSION@ DLL" 19 | VALUE "FileVersion", "@GLFW_VERSION@" 20 | VALUE "OriginalFilename", "glfw3.dll" 21 | VALUE "ProductName", "GLFW" 22 | VALUE "ProductVersion", "@GLFW_VERSION@" 23 | } 24 | } 25 | BLOCK "VarFileInfo" 26 | { 27 | VALUE "Translation", 0x409, 1200 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Project List/README.md: -------------------------------------------------------------------------------- 1 | ## Some simple projects for you to try in no particular order: 2 | - Snake game (C++ reference: [youtube Link](https://www.youtube.com/watch?v=e8lYLYlrGLg)) 3 | - Pong 4 | - HTTP server 5 | - Terminal file explorer 6 | - Search anime from terminal 7 | - Simple grep 8 | - Online chatting via terminal 9 | - Simple Turing machine 10 | ``` 11 | What this program (Turing Machine) basically has is: data which is the data memory, commands which is the code memory (these 2 are input from user), stack is temp memory (fixed size) 12 | so one command is each one character: 13 | f -> move forward in data memomry 14 | b -> move backward in data memory 15 | a -> push the character from data memory to stack where cursor is present 16 | d -> pop the character from stack 17 | p -> display the character 18 | + -> add the 2 characters at top of stack and push the result to stack 19 | - -> same as + but sub 20 | well this is just example, this can be made into whatever fits 21 | ``` -------------------------------------------------------------------------------- /Samples/Michi/glfw/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | 3 | Copyright (c) 2006-2019 Camilla Löwy 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 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | 3 | Copyright (c) 2006-2019 Camilla Löwy 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 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | 3 | Copyright (c) 2006-2019 Camilla Löwy 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 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/mandelbrot.frag: -------------------------------------------------------------------------------- 1 | #version 420 2 | 3 | #define MAX_ITERATIONS 500 4 | #define cproduct(a, b) vec2(a.x*b.x-a.y*b.y, a.x*b.y+a.y*b.x) 5 | 6 | out vec4 FragmentColor; 7 | 8 | uniform vec2 u_Resolution; 9 | uniform vec2 u_RectMin; 10 | uniform vec2 u_RectMax; 11 | 12 | float Radius = 10.0f; 13 | vec3 ColorWeight = vec3(2.0, 4.0, 5.0); 14 | 15 | uint Diverge(inout vec2 c, float radius) { 16 | vec2 z = vec2(0, 0); 17 | uint iter = 0; 18 | while (length(z) <= radius && iter < MAX_ITERATIONS) { 19 | z = cproduct(z, z) + c; 20 | iter += 1; 21 | } 22 | c = z; 23 | return iter; 24 | } 25 | 26 | void main() { 27 | vec2 st = gl_FragCoord.xy / u_Resolution; 28 | float aspect_ratio = u_Resolution.x / u_Resolution.y; 29 | vec2 z = u_RectMin + st * (u_RectMax - u_RectMin) * vec2(aspect_ratio, 1); 30 | uint iterations = Diverge(z, Radius); 31 | float luminance = ((iterations - log2(length(z) / Radius)) / MAX_ITERATIONS); 32 | vec3 color = ColorWeight * luminance; 33 | FragmentColor = vec4(color, 1); 34 | } 35 | -------------------------------------------------------------------------------- /Samples/Calculator/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | if not exist "./bin" (md bin) 6 | 7 | set SourceFiles=./src/main.c ./src/parser.c ./src/regex.c ./src/symbol_table.c ./src/token.c 8 | 9 | where gcc >nul 2>nul 10 | IF %ERRORLEVEL% NEQ 0 goto SkipGCC 11 | call gcc -I./includes/ %SourceFiles% -lm -o ./bin/calculator 12 | goto Finished 13 | :SkipGCC 14 | 15 | where clang >nul 2>nul 16 | IF %ERRORLEVEL% NEQ 0 goto SkipCLANG 17 | echo Building with CLANG 18 | call clang -g -gcodeview -I./includes/ %SourceFiles% -o ./bin/calculator.exe 19 | goto Finished 20 | :SkipCLANG 21 | 22 | where cl >nul 2>nul 23 | if %ERRORLEVEL% neq 0 goto SkipMSVC 24 | echo Building with MSVC 25 | pushd bin 26 | call cl -I../includes/ -nologo -Zi -EHsc ../src/main.c ../src/parser.c ../src/regex.c ../src/symbol_table.c ../src/token.c /Fecalculator.exe 27 | popd 28 | goto Finished 29 | 30 | echo No compiler found, please setup compiler. Instructions: https://github.com/IT-Club-Pulchowk/C-Programming-Guide 31 | 32 | :Finished 33 | echo ------------------- 34 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/build.muda: -------------------------------------------------------------------------------- 1 | @version 1.5.0 2 | 3 | Kind : Project; 4 | Language : C; 5 | Application : Executable; 6 | Optimization : False; 7 | Build : mandelbrot; 8 | BuildDirectory : ./bin; 9 | 10 | Sources: main.c glfw/src/context.c glfw/src/egl_context.c glfw/src/init.c glfw/src/input.c; 11 | Sources: glfw/src/monitor.c glfw/src/osmesa_context.c glfw/src/vulkan.c glfw/src/window.c; 12 | 13 | Defines : _CRT_SECURE_NO_WARNINGS ; 14 | Subsystem : Console; 15 | 16 | :OS.WINDOWS 17 | Defines: _GLFW_WIN32; 18 | Sources: glfw/src/wgl_context.c glfw/src/win32_init.c glfw/src/win32_joystick.c glfw/src/win32_monitor.c; 19 | Sources: glfw/src/win32_thread.c glfw/src/win32_time.c glfw/src/win32_window.c; 20 | Libraries: user32 gdi32 shell32 opengl32; 21 | 22 | : OS.LINUX 23 | Defines: _GLFW_X11; 24 | Sources: glfw/src/glx_context.c glfw/src/linux_joystick.c glfw/src/posix_thread.c glfw/src/posix_time.c; 25 | Sources: glfw/src/x11_init.c glfw/src/x11_monitor.c glfw/src/x11_window.c glfw/src/xkb_unicode.c; 26 | Libraries: dl GL pthread m; 27 | -------------------------------------------------------------------------------- /Samples/Calculator/includes/token.h: -------------------------------------------------------------------------------- 1 | #ifndef TOKEN_H 2 | #define TOKEN_H 3 | 4 | #include 5 | #include "io_stream.h" 6 | // Let's just forward declare the struct io_stream without including the relevant header file 7 | 8 | // stream; 9 | 10 | #define MAX_ID_LENGTH 50 // All define and enum are ad hoc.. They can be managed systematically 11 | 12 | enum token_type { ID, OP, INT_NUM,FLOAT_NUM, ERR_TYPE,END_M }; 13 | 14 | enum errors { Q2, Q7, Q5, E_LVALUE,E_RVALUE, E_OPERATOR, E_SYM_ID, I_MOD, U_SYM,L_MISS, E_OP, SYN_ERROR, E_RPAREN}; // Will add other as necessary 15 | 16 | 17 | // when token type is null, error will represent the error code 18 | 19 | struct token 20 | { 21 | enum token_type type; 22 | char op; // For operator 23 | char id [MAX_ID_LENGTH]; 24 | int i_num; 25 | float f_num; 26 | enum errors error_code; 27 | }; 28 | 29 | 30 | typedef struct token token; 31 | 32 | token get_next_token(stream* ); // These pointer are passed to make the use of global variable redundant.. Thats functional (but not pure) 33 | 34 | token next_token(stream*); 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /Samples/Michi/build.muda: -------------------------------------------------------------------------------- 1 | @version 1.5.0 2 | 3 | Kind : Project; 4 | Language : C; 5 | Application : Executable; 6 | Optimization : False; 7 | Build : Michi; 8 | BuildDirectory : ./bin; 9 | 10 | Sources: main.c glfw/src/context.c glfw/src/egl_context.c glfw/src/init.c glfw/src/input.c; 11 | Sources: glfw/src/monitor.c glfw/src/osmesa_context.c glfw/src/vulkan.c glfw/src/window.c; 12 | 13 | IncludeDirectories: glfw/include glad/include; 14 | 15 | Defines : _CRT_SECURE_NO_WARNINGS; 16 | Subsystem : Console; 17 | 18 | :OS.WINDOWS 19 | ResourceFile: resource.rc; 20 | Defines: _GLFW_WIN32; 21 | Sources: glfw/src/wgl_context.c glfw/src/win32_init.c glfw/src/win32_joystick.c glfw/src/win32_monitor.c; 22 | Sources: glfw/src/win32_thread.c glfw/src/win32_time.c glfw/src/win32_window.c; 23 | Libraries: user32 gdi32 shell32; 24 | 25 | : OS.LINUX 26 | Sources: glfw/src/glx_context.c glfw/src/linux_joystick.c glfw/src/posix_thread.c glfw/src/posix_time.c; 27 | Sources: glfw/src/x11_init.c glfw/src/x11_monitor.c glfw/src/x11_window.c glfw/src/xkb_unicode.c; 28 | Libraries: dl GL pthread m; 29 | -------------------------------------------------------------------------------- /Workshop/Day 6/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "gcc - Build and debug active file", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${fileDirname}/${fileBasenameNoExtension}", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${fileDirname}", 15 | "environment": [], 16 | "externalConsole": false, 17 | "MIMode": "gdb", 18 | "setupCommands": [ 19 | { 20 | "description": "Enable pretty-printing for gdb", 21 | "text": "-enable-pretty-printing", 22 | "ignoreFailures": true 23 | } 24 | ], 25 | "preLaunchTask": "C/C++: gcc build active file", 26 | "miDebuggerPath": "/usr/bin/gdb" 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /Samples/Mandelbrot-DX11/readme.md: -------------------------------------------------------------------------------- 1 | # [Mandelbrot Set](https://en.wikipedia.org/wiki/Mandelbrot_set) 2 | 3 | ## Usage 4 | * This program only runs on Windows 10 5 | * Build by running the `build.bat` (requires visual studio or msvc compiler) 6 | * The executables are generated in `bin/` directory 7 | * In the same directroy as the executables there exits `mandelbrot.hlsl` file 8 | * You can edit and save the `mandelbrot.hlsl` file and it will automatically be reloaded by the program 9 | * You can use the mouse wheel to zoom in and out, and drag the screen for panning 10 | * Press [F5] to capture the screen, the images will be saved in `Captures` directory 11 | 12 | ## Variables 13 | *Note: The following variables are present in mandelbrot.frag file* 14 | - The `ps_main` function can be modified to call different coloring methods 15 | - The available methods are: `Mandelbrot_SimpleColoring`, `Mandelbrot_SmoothColoring`, `Mandelbrot_WaveColoring` and `Mandelbrot_WaveColoringAnimated` 16 | - At the top of each of the coloring functions, constansts are defined which can be tweaked as required 17 | 18 | ## Screeenshot 19 | 20 | ![Mandelbrot Diagram](screenshot.png) 21 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/build.muda: -------------------------------------------------------------------------------- 1 | @version 1.5.0 2 | 3 | Kind : Project; 4 | Language : C; 5 | Application : Executable; 6 | Optimization : False; 7 | Build : Mandelbrot-GPU; 8 | BuildDirectory : ./bin; 9 | 10 | Sources: main.c glfw/src/context.c glfw/src/egl_context.c glfw/src/init.c glfw/src/input.c; 11 | Sources: glfw/src/monitor.c glfw/src/osmesa_context.c glfw/src/vulkan.c glfw/src/window.c; 12 | Sources: glad/src/glad.c; 13 | 14 | IncludeDirectories: glfw/include glad/include; 15 | 16 | Defines : _CRT_SECURE_NO_WARNINGS; 17 | Subsystem : Console; 18 | 19 | :OS.WINDOWS 20 | ResourceFile: resource.rc; 21 | Defines: _GLFW_WIN32; 22 | Sources: glfw/src/wgl_context.c glfw/src/win32_init.c glfw/src/win32_joystick.c glfw/src/win32_monitor.c; 23 | Sources: glfw/src/win32_thread.c glfw/src/win32_time.c glfw/src/win32_window.c; 24 | Libraries: user32 gdi32 shell32 opengl32; 25 | 26 | : OS.LINUX 27 | Sources: glfw/src/glx_context.c glfw/src/linux_joystick.c glfw/src/posix_thread.c glfw/src/posix_time.c; 28 | Sources: glfw/src/x11_init.c glfw/src/x11_monitor.c glfw/src/x11_window.c glfw/src/xkb_unicode.c; 29 | Libraries: dl GL pthread m; 30 | -------------------------------------------------------------------------------- /Samples/Calculator/README.md: -------------------------------------------------------------------------------- 1 | # Calculator 2 | This isn't even a full calculator. It evaluates simple expression and supports following operator with given precedence :

3 |
 4 | parenthesis     -> ( ) 
5 | unaray operator -> + -
6 | exponentiation -> ^
7 | mul / div -> / *
8 | binary add/sub -> + -
9 | assignment -> =
10 |
11 | All operators are left assosciative except exponentiation ('^') and assignment ('=') operator.
12 | There's no support for comparison or any bitwise operator. 13 |
14 | Simple error messages are displayed. So, don't make hard errors.
15 | 16 |
Note : No color support for windows (>.<)
17 | # Build 18 | ### For windows :
19 | `build.bat` 20 |
21 | It will generate bin/ folder if it doesn't exist and put executable inside bin. 22 |
23 | Run
24 | `"bin\calculator.exe"` or 25 |
26 | `cd bin`
27 | `calculator.exe`
28 |
29 |
30 | ### For linux : 31 |
Execute
`chmod u+x build.sh`
to make it executable
32 | Build using `./build.sh` 33 |
Run
`./bin/calculator` 34 |
35 | -------------------------------------------------------------------------------- /Workshop/Day 6/8_record_structure.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct movie{ 4 | char name[50], genre[20]; 5 | int year_released; 6 | }; 7 | 8 | int main(){ 9 | struct movie m[2], m2[2]; 10 | 11 | FILE *fptr = fopen("movie.txt", "w+b"); 12 | 13 | for(int i = 0; i < 2; i++){ 14 | printf("Enter the movie name : "); 15 | scanf("%s", m[i].name); 16 | printf("Enter the genre : "); 17 | scanf("%s", m[i].genre); 18 | printf("Enter the year released : "); 19 | scanf("%d", &m[i].year_released); 20 | } 21 | 22 | // Syntax : fwrite(&ptr, sizeof(structure), num of structure, fptr); 23 | fwrite(&m, sizeof(struct movie), 2, fptr); 24 | 25 | rewind(fptr); 26 | 27 | // Syntax : fread(&ptr, sizeof(structure), num of structure, fptr); 28 | fread(&m2, sizeof(struct movie), 2, fptr); 29 | 30 | // Use the fread data to print 31 | for(int i = 0; i < 2; i++){ 32 | printf("Movie #%d \n", i+1); 33 | printf("name : %s \n", m2[i].name); 34 | printf("genre : %s \n", m2[i].genre); 35 | printf("year released : %d \n", m2[i].year_released); 36 | printf("\n"); 37 | } 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /Samples/Michi/readme.md: -------------------------------------------------------------------------------- 1 | ## Michi 2 | 3 | 'Michi' (道ーみち) means path. This program let's you control the actor by using commands that you enter in graphics console. It is also capable of displaying various internal information about the values and working of the system. 4 | 5 | ## Documentation 6 | ### Actions 7 | * `move: ` 8 | * `rotate: ` 9 | * `enlarge: ` 10 | * `change: ` 11 | * `follow: ` 12 | * `draw: ` 13 | * `disp: ` 14 | * `exit` 15 | 16 | Example: 17 | ``` 18 | move: 50 19 | rotate: -90 20 | enlarge: 1, 2 21 | change: 1, 1, 0 22 | follow: on 23 | draw: off 24 | disp: expr 25 | disp: help 26 | disp: output 27 | exit 28 | ``` 29 | 30 | ### Variables 31 | * `output` - dynamic variable 32 | * `actor` - struct { position: vector2, rotation: float, scale: vector2, color: vector4 } 33 | * `speed` - struct { position: float, rotation: float, scale: float, color: float } 34 | 35 | ### Syntax for setting the variables 36 | ``` 37 | variable: value 38 | ``` 39 | Example: 40 | ``` 41 | actor.position: 1, 2 42 | actor.position.x: 5 43 | actor.scale: 2, 2 44 | speed.position: 0.3, 10 45 | actor.color: output.x, .3, .4, 1 46 | ``` 47 | 48 | ## Screenshot 49 | ![Screenshot](Screenshot.png) 50 | -------------------------------------------------------------------------------- /Samples/Voronoi/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p ./bin 3 | # Enter your SDL include directory here. SDL.h must exist in this directory and not in any other subdirectory 4 | # e.g. INCLUDE="${HOME}/libraries/SDL2-2.0.14/include" 5 | INCLUDE="" 6 | CC="" 7 | compile_command="" 8 | SRC="main.c" 9 | BIN_NAME="voronoi" 10 | 11 | echo "Checking if gcc exists...." 12 | if gcc -v >/dev/null 2>&1; then 13 | echo "gcc exists. Compiling with gcc." 14 | CC="gcc " 15 | else 16 | echo "gcc not found. Searching for clang instead..." 17 | if clang -v>/dev/null 2>&1; then 18 | echo "clang exists. Compiling with clang." 19 | CC="clang " 20 | else 21 | echo "No compiler found. Exiting.." 22 | exit 0 23 | fi 24 | fi 25 | 26 | if [ $# -eq 0 ]; then 27 | #Run debug build 28 | compile_command="$CC -g" 29 | elif [ "$1" = "optimized" ]; then 30 | compile_command="$CC -O2" 31 | else 32 | compile_command="$CC -g" 33 | fi 34 | 35 | while [ ! -f "${INCLUDE}/SDL.h" ] 36 | do 37 | echo "SDL.h not found in the provided directory" 38 | read -p "Enter you SDL directory here: " INCLUDE 39 | done 40 | compile_command="${compile_command} -I${INCLUDE} -o ./bin/${BIN_NAME} ${SRC} -lSDL2" 41 | echo $compile_command 42 | if eval $compile_command ; then 43 | echo "Compilation finished successfully!" 44 | fi 45 | 46 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/xkb_unicode.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | long _glfwKeySym2Unicode(unsigned int keysym); 28 | 29 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/xkb_unicode.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | long _glfwKeySym2Unicode(unsigned int keysym); 28 | 29 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/xkb_unicode.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | long _glfwKeySym2Unicode(unsigned int keysym); 28 | 29 | -------------------------------------------------------------------------------- /Workshop/Day 6/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "type": "cppbuild", 5 | "label": "C/C++: gcc build active file", 6 | "command": "/usr/bin/gcc", 7 | "args": [ 8 | "-g", 9 | "${file}", 10 | "-o", 11 | "${fileDirname}/${fileBasenameNoExtension}" 12 | ], 13 | "options": { 14 | "cwd": "${fileDirname}" 15 | }, 16 | "problemMatcher": [ 17 | "$gcc" 18 | ], 19 | "group": "build", 20 | "detail": "Task generated by Debugger." 21 | }, 22 | { 23 | "type": "cppbuild", 24 | "label": "C/C++: gcc build active file", 25 | "command": "/usr/bin/gcc", 26 | "args": [ 27 | "-g", 28 | "${file}", 29 | "-o", 30 | "${fileDirname}/${fileBasenameNoExtension}" 31 | ], 32 | "options": { 33 | "cwd": "${fileDirname}" 34 | }, 35 | "problemMatcher": [ 36 | "$gcc" 37 | ], 38 | "group": { 39 | "kind": "build", 40 | "isDefault": true 41 | }, 42 | "detail": "compiler: /usr/bin/gcc" 43 | } 44 | ], 45 | "version": "2.0.0" 46 | } -------------------------------------------------------------------------------- /Samples/Flowfield/build.muda: -------------------------------------------------------------------------------- 1 | # Generated by: Muda Console Setup [2021-10-17 19:11:50] 2 | 3 | @version 1.5.0 4 | 5 | Kind : Project; 6 | Language : C; 7 | Application : Executable; 8 | 9 | # Use optimization while compiling or not (true/false) 10 | Optimization : False; 11 | 12 | Build : flowfield; 13 | BuildDirectory : ./bin; 14 | Sources : flowfield.c ; 15 | Subsystem : Windows; 16 | 17 | :OS.WINDOWS 18 | Prebuild : ..\install_sdl.bat; 19 | 20 | :COMPILER.CL 21 | Libraries : SDL2 SDL2main Shell32; 22 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 23 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/; 24 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 25 | 26 | :COMPILER.CLANG 27 | Libraries : SDL2 SDL2main Shell32; 28 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 29 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/; 30 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 31 | 32 | :COMPILER.GCC 33 | Libraries : SDL2 SDL2main Shell32; 34 | LibraryDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/lib/; 35 | IncludeDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/include/; 36 | Postbuild : "xcopy ..\Libraries\SDL2MinGw\SDL2-2.0.14\i686-w64-mingw32\bin\SDL2.dll .\bin\ /Y"; 37 | 38 | :OS.LINUX 39 | Libraries: SDL2; 40 | -------------------------------------------------------------------------------- /Samples/LissajousCurve/build.muda: -------------------------------------------------------------------------------- 1 | # Generated by: Muda Console Setup [2021-10-17 19:11:50] 2 | 3 | @version 1.5.0 4 | 5 | Kind : Project; 6 | Language : C; 7 | Application : Executable; 8 | 9 | # Use optimization while compiling or not (true/false) 10 | Optimization : False; 11 | 12 | Build : lissajous; 13 | BuildDirectory : ./bin; 14 | Sources : main.c ; 15 | Subsystem : Windows; 16 | 17 | :OS.WINDOWS 18 | Prebuild : ..\install_sdl.bat; 19 | 20 | :COMPILER.CL 21 | Libraries : SDL2 SDL2main Shell32; 22 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 23 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/; 24 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 25 | 26 | :COMPILER.CLANG 27 | Libraries : SDL2 SDL2main Shell32; 28 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 29 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/; 30 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 31 | 32 | :COMPILER.GCC 33 | Libraries : SDL2 SDL2main Shell32; 34 | LibraryDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/lib/; 35 | IncludeDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/include/; 36 | Postbuild : "xcopy ..\Libraries\SDL2MinGw\SDL2-2.0.14\i686-w64-mingw32\bin\SDL2.dll .\bin\ /Y"; 37 | 38 | :OS.LINUX 39 | Libraries: SDL2; 40 | -------------------------------------------------------------------------------- /Samples/Voronoi/build.muda: -------------------------------------------------------------------------------- 1 | # Generated by: Muda Console Setup [2021-10-17 19:11:50] 2 | 3 | @version 1.5.0 4 | 5 | Kind : Project; 6 | Language : C; 7 | Application : Executable; 8 | 9 | # Use optimization while compiling or not (true/false) 10 | Optimization : False; 11 | 12 | Build : voronoi; 13 | BuildDirectory : ./bin; 14 | Sources : main.c ; 15 | Subsystem : Windows; 16 | 17 | :OS.WINDOWS 18 | Prebuild : ..\install_sdl.bat; 19 | 20 | :COMPILER.CL 21 | Libraries : SDL2 SDL2main Shell32; 22 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 23 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/SDL2/; 24 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 25 | 26 | :COMPILER.CLANG 27 | Libraries : SDL2 SDL2main Shell32; 28 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 29 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/SDL2/; 30 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 31 | 32 | :COMPILER.GCC 33 | Libraries : SDL2 SDL2main Shell32; 34 | LibraryDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/lib/; 35 | IncludeDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/include/SDL2/; 36 | Postbuild : "xcopy ..\Libraries\SDL2MinGw\SDL2-2.0.14\i686-w64-mingw32\bin\SDL2.dll .\bin\ /Y"; 37 | 38 | :OS.LINUX 39 | Libraries: SDL2; 40 | -------------------------------------------------------------------------------- /Samples/Cellular-Automata/build.muda: -------------------------------------------------------------------------------- 1 | # Generated by: Muda Console Setup [2021-10-17 19:11:50] 2 | 3 | @version 1.5.0 4 | 5 | Kind : Project; 6 | Language : C; 7 | Application : Executable; 8 | 9 | # Use optimization while compiling or not (true/false) 10 | Optimization : False; 11 | 12 | Build : game-of-life; 13 | BuildDirectory : ./bin; 14 | Sources : game-of-life.c ; 15 | Subsystem : Windows; 16 | 17 | :OS.WINDOWS 18 | Prebuild : ..\install_sdl.bat; 19 | 20 | :COMPILER.CL 21 | Libraries : SDL2 SDL2main Shell32; 22 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 23 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/; 24 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 25 | 26 | :COMPILER.CLANG 27 | Libraries : SDL2 SDL2main Shell32; 28 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 29 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/; 30 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 31 | 32 | :COMPILER.GCC 33 | Libraries : SDL2 SDL2main Shell32; 34 | LibraryDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/lib/; 35 | IncludeDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/include/; 36 | Postbuild : "xcopy ..\Libraries\SDL2MinGw\SDL2-2.0.14\i686-w64-mingw32\bin\SDL2.dll .\bin\ /Y"; 37 | 38 | :OS.LINUX 39 | Libraries: SDL2; 40 | -------------------------------------------------------------------------------- /Samples/Fourier-series/build.muda: -------------------------------------------------------------------------------- 1 | # Generated by: Muda Console Setup [2021-10-17 19:11:50] 2 | 3 | @version 1.5.0 4 | 5 | Kind : Project; 6 | Language : C; 7 | Application : Executable; 8 | 9 | # Use optimization while compiling or not (true/false) 10 | Optimization : False; 11 | 12 | Build : fourier-series; 13 | BuildDirectory : ./bin; 14 | Sources : fourier-series.c ; 15 | Subsystem : Windows; 16 | 17 | :OS.WINDOWS 18 | Prebuild : ..\install_sdl.bat; 19 | 20 | :COMPILER.CL 21 | Libraries : SDL2 SDL2main Shell32; 22 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 23 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/; 24 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 25 | 26 | :COMPILER.CLANG 27 | Libraries : SDL2 SDL2main Shell32; 28 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 29 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/; 30 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 31 | 32 | :COMPILER.GCC 33 | Libraries : SDL2 SDL2main Shell32; 34 | LibraryDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/lib/; 35 | IncludeDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/include/; 36 | Postbuild : "xcopy ..\Libraries\SDL2MinGw\SDL2-2.0.14\i686-w64-mingw32\bin\SDL2.dll .\bin\ /Y"; 37 | 38 | :OS.LINUX 39 | Libraries: SDL2; 40 | -------------------------------------------------------------------------------- /Samples/Fractals/build.muda: -------------------------------------------------------------------------------- 1 | # Generated by: Muda Console Setup [2021-10-17 19:11:50] 2 | 3 | @version 1.5.0 4 | 5 | Kind : Project; 6 | Language : C; 7 | Application : Executable; 8 | 9 | # Use optimization while compiling or not (true/false) 10 | Optimization : False; 11 | 12 | Build : koch-snowflake-fractal; 13 | BuildDirectory : ./bin; 14 | Sources : koch-snowflake-fractal.c ; 15 | Subsystem : Windows; 16 | 17 | :OS.WINDOWS 18 | Prebuild : ..\install_sdl.bat; 19 | 20 | :COMPILER.CL 21 | Libraries : SDL2 SDL2main Shell32; 22 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 23 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/; 24 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 25 | 26 | :COMPILER.CLANG 27 | Libraries : SDL2 SDL2main Shell32; 28 | LibraryDirectories : ../Libraries/SDL2/SDL2-2.0.14/lib/x64/; 29 | IncludeDirectories : ../Libraries/SDL2/SDL2-2.0.14/; 30 | Postbuild : "xcopy ..\Libraries\SDL2\SDL2-2.0.14\lib\x64\SDL2.dll .\bin\ /Y"; 31 | 32 | :COMPILER.GCC 33 | Libraries : SDL2 SDL2main Shell32; 34 | LibraryDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/lib/; 35 | IncludeDirectories : ../Libraries/SDL2MinGw/SDL2-2.0.14/i686-w64-mingw32/include/; 36 | Postbuild : "xcopy ..\Libraries\SDL2MinGw\SDL2-2.0.14\i686-w64-mingw32\bin\SDL2.dll .\bin\ /Y"; 37 | 38 | :OS.LINUX 39 | Libraries: SDL2; 40 | -------------------------------------------------------------------------------- /Samples/Michi/Michi.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30517.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Michi", "Michi.vcxproj", "{B6A6AE59-CF4D-4108-B555-88455DC82115}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {B6A6AE59-CF4D-4108-B555-88455DC82115}.Debug|x64.ActiveCfg = Debug|x64 17 | {B6A6AE59-CF4D-4108-B555-88455DC82115}.Debug|x64.Build.0 = Debug|x64 18 | {B6A6AE59-CF4D-4108-B555-88455DC82115}.Debug|x86.ActiveCfg = Debug|Win32 19 | {B6A6AE59-CF4D-4108-B555-88455DC82115}.Debug|x86.Build.0 = Debug|Win32 20 | {B6A6AE59-CF4D-4108-B555-88455DC82115}.Release|x64.ActiveCfg = Release|x64 21 | {B6A6AE59-CF4D-4108-B555-88455DC82115}.Release|x64.Build.0 = Release|x64 22 | {B6A6AE59-CF4D-4108-B555-88455DC82115}.Release|x86.ActiveCfg = Release|Win32 23 | {B6A6AE59-CF4D-4108-B555-88455DC82115}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {EBE707C6-CC48-4319-819D-987769E3BC00} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/null_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; } 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "" 31 | 32 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/null_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; } 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "" 31 | 32 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/null_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; } 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "" 31 | 32 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/Mandelbrot-GPU.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31205.134 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mandelbrot-GPU", "Mandelbrot-GPU.vcxproj", "{1AC2D53E-990B-42B3-B318-A3951150DD90}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {1AC2D53E-990B-42B3-B318-A3951150DD90}.Debug|x64.ActiveCfg = Debug|x64 17 | {1AC2D53E-990B-42B3-B318-A3951150DD90}.Debug|x64.Build.0 = Debug|x64 18 | {1AC2D53E-990B-42B3-B318-A3951150DD90}.Debug|x86.ActiveCfg = Debug|Win32 19 | {1AC2D53E-990B-42B3-B318-A3951150DD90}.Debug|x86.Build.0 = Debug|Win32 20 | {1AC2D53E-990B-42B3-B318-A3951150DD90}.Release|x64.ActiveCfg = Release|x64 21 | {1AC2D53E-990B-42B3-B318-A3951150DD90}.Release|x64.Build.0 = Release|x64 22 | {1AC2D53E-990B-42B3-B318-A3951150DD90}.Release|x86.ActiveCfg = Release|Win32 23 | {1AC2D53E-990B-42B3-B318-A3951150DD90}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {700CBE27-8828-4642-819B-5DEFCAE0065A} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-DX11/Mandelbrot-DX11.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31205.134 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mandelbrot-DX11", "Mandelbrot-DX11.vcxproj", "{15A6A596-DE89-40D8-A15B-7727C0C6C63A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {15A6A596-DE89-40D8-A15B-7727C0C6C63A}.Debug|x64.ActiveCfg = Debug|x64 17 | {15A6A596-DE89-40D8-A15B-7727C0C6C63A}.Debug|x64.Build.0 = Debug|x64 18 | {15A6A596-DE89-40D8-A15B-7727C0C6C63A}.Debug|x86.ActiveCfg = Debug|Win32 19 | {15A6A596-DE89-40D8-A15B-7727C0C6C63A}.Debug|x86.Build.0 = Debug|Win32 20 | {15A6A596-DE89-40D8-A15B-7727C0C6C63A}.Release|x64.ActiveCfg = Release|x64 21 | {15A6A596-DE89-40D8-A15B-7727C0C6C63A}.Release|x64.Build.0 = Release|x64 22 | {15A6A596-DE89-40D8-A15B-7727C0C6C63A}.Release|x86.ActiveCfg = Release|Win32 23 | {15A6A596-DE89-40D8-A15B-7727C0C6C63A}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {BB5C5CB7-51D7-4337-9809-E1342CBED971} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/posix_time.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix 29 | 30 | #include 31 | 32 | 33 | // POSIX-specific global timer data 34 | // 35 | typedef struct _GLFWtimerPOSIX 36 | { 37 | GLFWbool monotonic; 38 | uint64_t frequency; 39 | 40 | } _GLFWtimerPOSIX; 41 | 42 | 43 | void _glfwInitTimerPOSIX(void); 44 | 45 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/posix_time.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix 29 | 30 | #include 31 | 32 | 33 | // POSIX-specific global timer data 34 | // 35 | typedef struct _GLFWtimerPOSIX 36 | { 37 | GLFWbool monotonic; 38 | uint64_t frequency; 39 | 40 | } _GLFWtimerPOSIX; 41 | 42 | 43 | void _glfwInitTimerPOSIX(void); 44 | 45 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/posix_time.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix 29 | 30 | #include 31 | 32 | 33 | // POSIX-specific global timer data 34 | // 35 | typedef struct _GLFWtimerPOSIX 36 | { 37 | GLFWbool monotonic; 38 | uint64_t frequency; 39 | 40 | } _GLFWtimerPOSIX; 41 | 42 | 43 | void _glfwInitTimerPOSIX(void); 44 | 45 | -------------------------------------------------------------------------------- /Workshop/Day 4/string functions.c: -------------------------------------------------------------------------------- 1 | int string_length(char* string) 2 | { 3 | char* beginning = string; 4 | for(; *string++ != '\0';); 5 | return (int)(string - beginning) - 1; 6 | } 7 | 8 | int string_compare2(char* string1, char* string2) 9 | { 10 | int result = *string1 - *string2; 11 | while(*string1++ != '\0' && *string2++ != '\0') 12 | { 13 | result = *string1 - *string2; 14 | if (result != 0) 15 | break; 16 | } 17 | return result > 0 ? 1 : result < 0 ? -1 : 0; 18 | } 19 | 20 | int string_compare(char* string1, char* string2) 21 | { 22 | int result = *string1 - *string2; 23 | while((*string1 != '\0') && (*string2 != '\0') && result == 0) 24 | result = *string1++ - *string2++; 25 | return result > 0 ? 1 : result < 0 ? -1 : 0; 26 | } 27 | 28 | // Size of destination should be enough to accomodate both source1 and source2 29 | void string_concatinate(char* destination, char* source1, char* source2) 30 | { 31 | while (*source1 != '\0') 32 | *destination++ = *source1++; 33 | while (*source2 != '\0') 34 | *destination++ = *source2++; 35 | *destination = '\0'; 36 | } 37 | 38 | // The size of destination should be large enough to accomodate the characters in size (i.e. sizeof(source) == sizeof(destination) at the least 39 | void string_copy(char* destination, char* source) 40 | { 41 | while ((*destination++ = *source++) != '\0'); 42 | } 43 | 44 | int main() 45 | { 46 | char* name = "Hari"; 47 | char* other_name = "Harihar"; 48 | char* other_nameee = "Hariharr"; 49 | int length = string_length(name); 50 | int same_string = string_compare2(name, other_name); 51 | int same_string2 = string_compare2("HallO", "Hallo"); 52 | int same_string3 = string_compare2("", ""); 53 | char arr[100]; 54 | string_copy(arr, ""); 55 | return 0; 56 | } -------------------------------------------------------------------------------- /Samples/Calculator/includes/parser.h: -------------------------------------------------------------------------------- 1 | #ifndef PARSER_H 2 | #define PARSER_H 3 | #include "token.h" 4 | 5 | // #include "io_stream.h" 6 | 7 | // struct stream; // Forward declaration 8 | // typedef messed the forward declaration .. so let's just include io_stream.h 9 | // Again listing the grammar for reference purpose 10 | 11 | /* expr -> term (+ term)* | term (- term)* | term | assign 12 | assign -> id = base 13 | term -> factor (* factor)* | (factor - factor)* | factor 14 | factor -> base | base (^ factor)* 15 | base -> digits | ( expr ) | + digits | - digits 16 | digits -> DFA results 17 | We will exclude the identifer for now 18 | */ 19 | 20 | typedef token return_type; // just typdef 21 | 22 | // Need to pass input stream explicitly in order to avoid global mess 23 | // Similarly we are passing the struct token instead of making it global .. That's functional style 24 | 25 | // make symbol_table global or let the stream* carry it); 26 | 27 | return_type expression (stream * , struct token* , bool); 28 | 29 | return_type term (stream *, struct token* ); 30 | 31 | return_type factor (stream*, struct token* ); 32 | 33 | return_type base (stream *, struct token* ); 34 | return_type assign (stream *, struct token* lhs, struct token* lookahead ); 35 | 36 | // for proper ad hoc error handling 37 | 38 | 39 | // Needed to change the function declaration for left parenthesis messages .. 40 | // There must be a better way .. But let's leave it for now 41 | 42 | return_type calc_run(stream*, struct token*); 43 | 44 | // return_type expression(stream* input_stream, struct token* lookahead, bool called_from_base); 45 | 46 | 47 | int exponentiation(int base, int index); 48 | int tail_exp(int base, int index, int result); 49 | 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /Samples/Calculator/src/symbol_table.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "symbol_table.h" 7 | 8 | struct symbol_table init_symbol_table() 9 | { 10 | struct symbol_table sym_table; 11 | sym_table.current_symbol_table_index = 0; 12 | 13 | sym_table.symbol_table = malloc(sizeof(struct symbol) * MAX_SYMBOL_TABLE_SIZE); 14 | if(!sym_table.symbol_table) 15 | assert(!"Failed to initialize symbol table..."); 16 | return sym_table; 17 | } 18 | 19 | int find_symbol(struct symbol_table* sym_table, struct symbol sym) 20 | { 21 | /* for(int i = 0; i < MAX_SYMBOL_TABLE_SIZE; ++i) */ 22 | for (int i = 0; i < sym_table->current_symbol_table_index; ++i) 23 | { 24 | enum Ordering Ord = cmp_id(sym.id,sym_table->symbol_table[i].id,MAX_SYMID_LEN); 25 | if (Ord == equal) 26 | return i; 27 | } 28 | // Return -1 if no match found 29 | return -1; 30 | } 31 | 32 | int insert_symbol(struct symbol_table* sym_table, struct symbol sym) 33 | { 34 | // if size is max return -1 35 | if (sym_table->current_symbol_table_index == MAX_SYMBOL_TABLE_SIZE) 36 | return -1; 37 | sym_table->symbol_table[sym_table->current_symbol_table_index++] = sym; 38 | 39 | // else return the index at which it was inserted 40 | return sym_table->current_symbol_table_index-1; 41 | 42 | } 43 | enum Ordering cmp_id(char *str1, char* str2, int max) 44 | { 45 | int a = strncmp(str1,str2,max); // might do a rewrite but just leave it 46 | if (!a) 47 | return equal; 48 | if (a<0) 49 | return less; 50 | if (a>0) 51 | return greater; 52 | } 53 | 54 | int clean_up(struct symbol_table* sym_table) 55 | { 56 | free(sym_table->symbol_table); 57 | return 0; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /Samples/Calculator/includes/symbol_table.h: -------------------------------------------------------------------------------- 1 | #ifndef SYMBOL_TABLE_H 2 | #define SYMBOL_TABLE_H 3 | 4 | //size of symbol table is fixed .. No more than 100 variable declarations 5 | #define MAX_SYMBOL_TABLE_SIZE 100 6 | #define MAX_SYMID_LEN 50 7 | enum Ordering { less, equal, greater}; 8 | 9 | enum symbol_type {INT_TYPE,FLOAT_TYPE,NO_TYPE}; 10 | 11 | // already available token could've been used as symbol... 12 | // but this file was written earlier .. So no changing now 13 | struct symbol 14 | { 15 | // The first is name 16 | char id[MAX_SYMID_LEN]; // Heavenly restriction 17 | enum symbol_type type; 18 | union num 19 | { 20 | int i_num; 21 | float f_num; // who cares whatever the name is ... we'll just cast whatever we need 22 | } num; 23 | }; 24 | 25 | struct symbol_table 26 | { 27 | struct symbol* symbol_table; 28 | int current_symbol_table_index; 29 | }; 30 | 31 | struct symbol_table init_symbol_table(); // we could've used hash table for better searching and insertion but who cares.. It is the small project so let's just stick with linear array 32 | 33 | // return the index of the current symbol in the symbol table .. Return -1 if no matching symbol is found 34 | 35 | int find_symbol(struct symbol_table* sym_table,struct symbol); 36 | 37 | int insert_symbol(struct symbol_table* sym_table,struct symbol); 38 | 39 | // hash entries needn't be deleted during the current interactive session 40 | enum Ordering cmp_id(char*, char*,int ); // last parameter checks the maximum length of the string that is allowed to be compared 41 | // returns less, equal or greater (first parameter with respect to second) 42 | 43 | int clean_up(struct symbol_table* ); // Gracefully clean up the program 44 | 45 | // create a wrapper for the symbol table 46 | 47 | 48 | #endif 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Samples/Michi/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SourceFiles="../../main.c ../../glfw/src/context.c ../../glfw/src/egl_context.c ../../glfw/src/glx_context.c ../../glfw/src/init.c ../../glfw/src/input.c ../../glfw/src/linux_joystick.c ../../glfw/src/monitor.c ../../glfw/src/osmesa_context.c ../../glfw/src/posix_thread.c ../../glfw/src/posix_time.c ../../glfw/src/vulkan.c ../../glfw/src/window.c ../../glfw/src/x11_init.c ../../glfw/src/x11_monitor.c ../../glfw/src/x11_window.c ../../glfw/src/xkb_unicode.c" 4 | 5 | CompilerFlags=-O 6 | if [ "$1" == "optimize" ]; then 7 | CompilerFlags=-O2 8 | echo -------------------------------------------------- 9 | echo Compiling with Optimizations 10 | fi 11 | 12 | mkdir -p bin 13 | 14 | echo -------------------------------------------------- 15 | which clang &> /dev/null 16 | if [ $? == 0 ]; then 17 | mkdir -p bin/CLANG 18 | cp Stanberry.ttf bin/CLANG/ &> /dev/null 19 | cp Logo.bmp bin/CLANG/ &> /dev/null 20 | pushd bin/CLANG &> /dev/null 21 | echo Compiling with CLANG... 22 | clang $CompilerFlags -Wno-switch -Wno-pointer-sign -D_GLFW_X11 $SourceFiles -o Michi.out -ldl -lGL -lpthread -lm 23 | popd &> /dev/null 24 | echo Compiling with CLANG finished. 25 | else 26 | echo Clang compiler not detected. Skipping compiling with Clang. 27 | fi 28 | echo -------------------------------------------------- 29 | 30 | which gcc &> /dev/null 31 | if [ $? == 0 ]; then 32 | mkdir -p bin/GCC 33 | cp Stanberry.ttf bin/GCC/ &> /dev/null 34 | cp Logo.bmp bin/GCC/ &> /dev/null 35 | pushd bin/GCC &> /dev/null 36 | echo Compiling with GCC... 37 | gcc $CompilerFlags -Wno-switch -Wno-pointer-sign -Wno-unused-result -D_GLFW_X11 $SourceFiles -o Michi.out -ldl -lGL -lpthread -lm 38 | popd &> /dev/null 39 | echo Compiling with GCC finished. 40 | else 41 | echo Gcc compiler not detected. Skipping compiling with Gcc. 42 | fi 43 | echo -------------------------------------------------- 44 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/posix_thread.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include 29 | 30 | #define _GLFW_PLATFORM_TLS_STATE _GLFWtlsPOSIX posix 31 | #define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexPOSIX posix 32 | 33 | 34 | // POSIX-specific thread local storage data 35 | // 36 | typedef struct _GLFWtlsPOSIX 37 | { 38 | GLFWbool allocated; 39 | pthread_key_t key; 40 | 41 | } _GLFWtlsPOSIX; 42 | 43 | // POSIX-specific mutex data 44 | // 45 | typedef struct _GLFWmutexPOSIX 46 | { 47 | GLFWbool allocated; 48 | pthread_mutex_t handle; 49 | 50 | } _GLFWmutexPOSIX; 51 | 52 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/posix_thread.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include 29 | 30 | #define _GLFW_PLATFORM_TLS_STATE _GLFWtlsPOSIX posix 31 | #define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexPOSIX posix 32 | 33 | 34 | // POSIX-specific thread local storage data 35 | // 36 | typedef struct _GLFWtlsPOSIX 37 | { 38 | GLFWbool allocated; 39 | pthread_key_t key; 40 | 41 | } _GLFWtlsPOSIX; 42 | 43 | // POSIX-specific mutex data 44 | // 45 | typedef struct _GLFWmutexPOSIX 46 | { 47 | GLFWbool allocated; 48 | pthread_mutex_t handle; 49 | 50 | } _GLFWmutexPOSIX; 51 | 52 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/posix_thread.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include 29 | 30 | #define _GLFW_PLATFORM_TLS_STATE _GLFWtlsPOSIX posix 31 | #define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexPOSIX posix 32 | 33 | 34 | // POSIX-specific thread local storage data 35 | // 36 | typedef struct _GLFWtlsPOSIX 37 | { 38 | GLFWbool allocated; 39 | pthread_key_t key; 40 | 41 | } _GLFWtlsPOSIX; 42 | 43 | // POSIX-specific mutex data 44 | // 45 | typedef struct _GLFWmutexPOSIX 46 | { 47 | GLFWbool allocated; 48 | pthread_mutex_t handle; 49 | 50 | } _GLFWmutexPOSIX; 51 | 52 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-DX11/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | 5 | set ResourceFileIn=Resource.rc 6 | set ResourceFileOut=Resource.res 7 | set SourceFiles=../../main.c 8 | 9 | set MsBuildConfiguration=Debug 10 | set CLFlags=-Od -D_DEBUG 11 | 12 | if "%1" neq "optimize" goto DoneConfig 13 | set MsBuildConfiguration=Release 14 | set CLFlags=-O2 -D_RELEASE 15 | 16 | echo ------------------------------------- 17 | echo Optimize Build configured 18 | echo ------------------------------------- 19 | :DoneConfig 20 | 21 | echo ------------------------------------- 22 | 23 | :MSBUILD 24 | where msbuild >nul 2>nul 25 | if %ERRORLEVEL% neq 0 goto SkipMSBUILD 26 | echo Building with MsBuild 27 | call msbuild Mandelbrot-DX11.vcxproj -p:Configuration=%MsBuildConfiguration% -nologo -p:Platform=x64 28 | call msbuild Mandelbrot-DX11.vcxproj -p:Configuration=%MsBuildConfiguration% -nologo -p:Platform=x86 29 | echo ------------------------------------- 30 | goto MSVC 31 | :SkipMSBUILD 32 | echo MsBuild not found. Skipping build with msbuild 33 | echo ------------------------------------- 34 | 35 | if not exist "bin" mkdir bin 36 | 37 | :MSVC 38 | where cl >nul 2>nul 39 | if %ERRORLEVEL% neq 0 goto SkipMSVC 40 | where rc >nul 2>nul 41 | if %ERRORLEVEL% neq 0 goto SkipMSVC 42 | echo Building with Msvc 43 | if not exist "bin\MsvcBuild" mkdir bin\MsvcBuild 44 | call xcopy "Resource.h" bin\MsvcBuild\ /Y 45 | call xcopy "Resource.rc" bin\MsvcBuild\ /Y 46 | call xcopy "Logo.ico" bin\MsvcBuild\ /Y 47 | call xcopy "mandelbrot.hlsl" bin\MsvcBuild\ /Y 48 | pushd bin\MsvcBuild 49 | call rc /fm%ResourceFileOut% %ResourceFileIn% 50 | call cl -nologo -D_CRT_SECURE_NO_WARNINGS -DUNICODE -nologo -Zi -EHsc %CLFlags% %SourceFiles% %ResourceFileOut% -FeMandelbrot-DX11.exe 51 | popd 52 | echo ------------------------------------- 53 | goto Finished 54 | :SkipMSVC 55 | echo Msvc not found. Skipping build with Msvc 56 | echo ------------------------------------- 57 | 58 | :Finished 59 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/cocoa_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Cocoa - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns 33 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; } 34 | 35 | #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" 36 | 37 | // Cocoa-specific per-joystick data 38 | // 39 | typedef struct _GLFWjoystickNS 40 | { 41 | IOHIDDeviceRef device; 42 | CFMutableArrayRef axes; 43 | CFMutableArrayRef buttons; 44 | CFMutableArrayRef hats; 45 | } _GLFWjoystickNS; 46 | 47 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/cocoa_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Cocoa - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns 33 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; } 34 | 35 | #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" 36 | 37 | // Cocoa-specific per-joystick data 38 | // 39 | typedef struct _GLFWjoystickNS 40 | { 41 | IOHIDDeviceRef device; 42 | CFMutableArrayRef axes; 43 | CFMutableArrayRef buttons; 44 | CFMutableArrayRef hats; 45 | } _GLFWjoystickNS; 46 | 47 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/cocoa_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Cocoa - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns 33 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; } 34 | 35 | #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" 36 | 37 | // Cocoa-specific per-joystick data 38 | // 39 | typedef struct _GLFWjoystickNS 40 | { 41 | IOHIDDeviceRef device; 42 | CFMutableArrayRef axes; 43 | CFMutableArrayRef buttons; 44 | CFMutableArrayRef hats; 45 | } _GLFWjoystickNS; 46 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C-Programming-Guide 2 | 3 | This README contains a list of resources that will be required as you get used to programming in C. 4 | For more of a walkthrough guide, visit the [wiki](https://github.com/IT-Club-Pulchowk/C-Programming-Guide/wiki) page. 5 | 6 | ## Compilers 7 | * [GCC](https://gcc.gnu.org/) 8 | * [Clang](https://clang.llvm.org/) 9 | * [MSVC](https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk/) - Windows 10 | * [Intel](https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/dpc-compiler.html#gs.zaftxw) 11 | 12 | ## IDEs 13 | * [Visual Studio](https://visualstudio.microsoft.com/vs/features/cplusplus/) - Windows 14 | * [XCode](https://developer.apple.com/xcode/) - Mac 15 | * [Clion](https://www.jetbrains.com/clion/) - Linux, requires a JetBrains account with student account (pcampus mail) for free access 16 | 17 | ## Tools 18 | * [RemedyBG](https://remedybg.itch.io/remedybg) - Windows 19 | * [GDB](https://www.gnu.org/software/gdb/) - To debug executables generated by GCC 20 | * [LLDB](https://lldb.llvm.org/) - To debug executables generated by Clang 21 | * [GodBolt](https://godbolt.org/) 22 | * [ValGrind](https://valgrind.org/) 23 | * [VTune](https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/vtune-profiler.html#gs.zaft1e) 24 | 25 | ## Reference Docs 26 | * [Specification](http://www.open-std.org/JTC1/SC22/WG14/) 27 | * [Reference](https://en.cppreference.com/w/c) 28 | 29 | ## Reference Books (Recommended) 30 | * [The C Programming Language (2nd ed.)](https://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628) - Brian Kernighan and Dennis Ritchie, available in Pulchowk Campus Library 31 | 32 | ## Tutorial Links 33 | * [C Wiki](https://en.wikibooks.org/wiki/C_Programming) 34 | * [CSPC 223 - Yale University, 2021](http://cs.yale.edu/homes/aspnes/classes/223/notes.html) 35 | 36 | ## Tutorial Video 37 | * [HandmadeHero](https://www.youtube.com/watch?v=F3ntGDm6hOs&list=PLEMXAbCVnmY6RverunClc_DMLNDd3ASRp) 38 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SourceFiles="../../main.c ../../glfw/src/context.c ../../glfw/src/egl_context.c ../../glfw/src/glx_context.c ../../glfw/src/init.c ../../glfw/src/input.c ../../glfw/src/linux_joystick.c ../../glfw/src/monitor.c ../../glfw/src/osmesa_context.c ../../glfw/src/posix_thread.c ../../glfw/src/posix_time.c ../../glfw/src/vulkan.c ../../glfw/src/window.c ../../glfw/src/x11_init.c ../../glfw/src/x11_monitor.c ../../glfw/src/x11_window.c ../../glfw/src/xkb_unicode.c ../../glad/src/glad.c" 4 | IncludeDirs="-I../../glfw/include/ -I../../glad/include/" 5 | 6 | CompilerFlags=-O 7 | if [ "$1" == "optimize" ]; then 8 | CompilerFlags=-O2 9 | echo -------------------------------------------------- 10 | echo Compiling with Optimizations 11 | fi 12 | 13 | mkdir -p bin 14 | 15 | echo -------------------------------------------------- 16 | which clang &> /dev/null 17 | if [ $? == 0 ]; then 18 | mkdir -p bin/CLANG 19 | cp Logo.bmp bin/CLANG/ &> /dev/null 20 | pushd bin/CLANG &> /dev/null 21 | echo Compiling with CLANG... 22 | clang $CompilerFlags $IncludeDirs -Wno-switch -Wno-pointer-sign -D_GLFW_X11 $SourceFiles -o Mandelbrot-GPU.out -ldl -lGL -lpthread -lm 23 | popd &> /dev/null 24 | echo Compiling with CLANG finished. 25 | cp -t ./bin/CLANG/ *.vert *.frag 26 | else 27 | echo Clang compiler not detected. Skipping compiling with Clang. 28 | fi 29 | echo -------------------------------------------------- 30 | 31 | which gcc &> /dev/null 32 | if [ $? == 0 ]; then 33 | mkdir -p bin/GCC 34 | cp Logo.bmp bin/GCC/ &> /dev/null 35 | pushd bin/GCC &> /dev/null 36 | echo Compiling with GCC... 37 | gcc $CompilerFlags $IncludeDirs -g -Wno-switch -Wno-pointer-sign -Wno-unused-result -D_GLFW_X11 $SourceFiles -o Mandelbrot-GPU.out -ldl -lGL -lpthread -lm 38 | popd &> /dev/null 39 | echo Compiling with GCC finished. 40 | cp -t ./bin/GCC/ *.vert *.frag 41 | else 42 | echo Gcc compiler not detected. Skipping compiling with Gcc. 43 | fi 44 | echo -------------------------------------------------- 45 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/null_joystick.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // It is fine to use C99 in this file because it will not be built with VS 27 | //======================================================================== 28 | 29 | #include "internal.h" 30 | 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | ////// GLFW platform API ////// 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | GLFWbool _glfwPlatformInitJoysticks(void) 37 | { 38 | return GLFW_TRUE; 39 | } 40 | 41 | void _glfwPlatformTerminateJoysticks(void) 42 | { 43 | } 44 | 45 | int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) 46 | { 47 | return GLFW_FALSE; 48 | } 49 | 50 | void _glfwPlatformUpdateGamepadGUID(char* guid) 51 | { 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/null_joystick.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // It is fine to use C99 in this file because it will not be built with VS 27 | //======================================================================== 28 | 29 | #include "internal.h" 30 | 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | ////// GLFW platform API ////// 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | GLFWbool _glfwPlatformInitJoysticks(void) 37 | { 38 | return GLFW_TRUE; 39 | } 40 | 41 | void _glfwPlatformTerminateJoysticks(void) 42 | { 43 | } 44 | 45 | int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) 46 | { 47 | return GLFW_FALSE; 48 | } 49 | 50 | void _glfwPlatformUpdateGamepadGUID(char* guid) 51 | { 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/null_joystick.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // It is fine to use C99 in this file because it will not be built with VS 27 | //======================================================================== 28 | 29 | #include "internal.h" 30 | 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | ////// GLFW platform API ////// 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | GLFWbool _glfwPlatformInitJoysticks(void) 37 | { 38 | return GLFW_TRUE; 39 | } 40 | 41 | void _glfwPlatformTerminateJoysticks(void) 42 | { 43 | } 44 | 45 | int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) 46 | { 47 | return GLFW_FALSE; 48 | } 49 | 50 | void _glfwPlatformUpdateGamepadGUID(char* guid) 51 | { 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/win32_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "Windows" 31 | 32 | // Joystick element (axis, button or slider) 33 | // 34 | typedef struct _GLFWjoyobjectWin32 35 | { 36 | int offset; 37 | int type; 38 | } _GLFWjoyobjectWin32; 39 | 40 | // Win32-specific per-joystick data 41 | // 42 | typedef struct _GLFWjoystickWin32 43 | { 44 | _GLFWjoyobjectWin32* objects; 45 | int objectCount; 46 | IDirectInputDevice8W* device; 47 | DWORD index; 48 | GUID guid; 49 | } _GLFWjoystickWin32; 50 | 51 | void _glfwDetectJoystickConnectionWin32(void); 52 | void _glfwDetectJoystickDisconnectionWin32(void); 53 | 54 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/win32_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "Windows" 31 | 32 | // Joystick element (axis, button or slider) 33 | // 34 | typedef struct _GLFWjoyobjectWin32 35 | { 36 | int offset; 37 | int type; 38 | } _GLFWjoyobjectWin32; 39 | 40 | // Win32-specific per-joystick data 41 | // 42 | typedef struct _GLFWjoystickWin32 43 | { 44 | _GLFWjoyobjectWin32* objects; 45 | int objectCount; 46 | IDirectInputDevice8W* device; 47 | DWORD index; 48 | GUID guid; 49 | } _GLFWjoystickWin32; 50 | 51 | void _glfwDetectJoystickConnectionWin32(void); 52 | void _glfwDetectJoystickDisconnectionWin32(void); 53 | 54 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/win32_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "Windows" 31 | 32 | // Joystick element (axis, button or slider) 33 | // 34 | typedef struct _GLFWjoyobjectWin32 35 | { 36 | int offset; 37 | int type; 38 | } _GLFWjoyobjectWin32; 39 | 40 | // Win32-specific per-joystick data 41 | // 42 | typedef struct _GLFWjoystickWin32 43 | { 44 | _GLFWjoyobjectWin32* objects; 45 | int objectCount; 46 | IDirectInputDevice8W* device; 47 | DWORD index; 48 | GUID guid; 49 | } _GLFWjoystickWin32; 50 | 51 | void _glfwDetectJoystickConnectionWin32(void); 52 | void _glfwDetectJoystickDisconnectionWin32(void); 53 | 54 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/null_init.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2016-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | // It is fine to use C99 in this file because it will not be built with VS 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | 34 | 35 | ////////////////////////////////////////////////////////////////////////// 36 | ////// GLFW platform API ////// 37 | ////////////////////////////////////////////////////////////////////////// 38 | 39 | int _glfwPlatformInit(void) 40 | { 41 | _glfwInitTimerPOSIX(); 42 | _glfwPollMonitorsNull(); 43 | 44 | return GLFW_TRUE; 45 | } 46 | 47 | void _glfwPlatformTerminate(void) 48 | { 49 | free(_glfw.null.clipboardString); 50 | _glfwTerminateOSMesa(); 51 | } 52 | 53 | const char* _glfwPlatformGetVersionString(void) 54 | { 55 | return _GLFW_VERSION_NUMBER " null OSMesa"; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/null_init.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2016-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | // It is fine to use C99 in this file because it will not be built with VS 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | 34 | 35 | ////////////////////////////////////////////////////////////////////////// 36 | ////// GLFW platform API ////// 37 | ////////////////////////////////////////////////////////////////////////// 38 | 39 | int _glfwPlatformInit(void) 40 | { 41 | _glfwInitTimerPOSIX(); 42 | _glfwPollMonitorsNull(); 43 | 44 | return GLFW_TRUE; 45 | } 46 | 47 | void _glfwPlatformTerminate(void) 48 | { 49 | free(_glfw.null.clipboardString); 50 | _glfwTerminateOSMesa(); 51 | } 52 | 53 | const char* _glfwPlatformGetVersionString(void) 54 | { 55 | return _GLFW_VERSION_NUMBER " null OSMesa"; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/null_init.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2016-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | // It is fine to use C99 in this file because it will not be built with VS 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | 34 | 35 | ////////////////////////////////////////////////////////////////////////// 36 | ////// GLFW platform API ////// 37 | ////////////////////////////////////////////////////////////////////////// 38 | 39 | int _glfwPlatformInit(void) 40 | { 41 | _glfwInitTimerPOSIX(); 42 | _glfwPollMonitorsNull(); 43 | 44 | return GLFW_TRUE; 45 | } 46 | 47 | void _glfwPlatformTerminate(void) 48 | { 49 | free(_glfw.null.clipboardString); 50 | _glfwTerminateOSMesa(); 51 | } 52 | 53 | const char* _glfwPlatformGetVersionString(void) 54 | { 55 | return _GLFW_VERSION_NUMBER " null OSMesa"; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/linux_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs 32 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs 33 | 34 | #define _GLFW_PLATFORM_MAPPING_NAME "Linux" 35 | 36 | // Linux-specific joystick data 37 | // 38 | typedef struct _GLFWjoystickLinux 39 | { 40 | int fd; 41 | char path[PATH_MAX]; 42 | int keyMap[KEY_CNT - BTN_MISC]; 43 | int absMap[ABS_CNT]; 44 | struct input_absinfo absInfo[ABS_CNT]; 45 | int hats[4][2]; 46 | } _GLFWjoystickLinux; 47 | 48 | // Linux-specific joystick API data 49 | // 50 | typedef struct _GLFWlibraryLinux 51 | { 52 | int inotify; 53 | int watch; 54 | regex_t regex; 55 | GLFWbool dropped; 56 | } _GLFWlibraryLinux; 57 | 58 | void _glfwDetectJoystickConnectionLinux(void); 59 | 60 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/linux_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs 32 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs 33 | 34 | #define _GLFW_PLATFORM_MAPPING_NAME "Linux" 35 | 36 | // Linux-specific joystick data 37 | // 38 | typedef struct _GLFWjoystickLinux 39 | { 40 | int fd; 41 | char path[PATH_MAX]; 42 | int keyMap[KEY_CNT - BTN_MISC]; 43 | int absMap[ABS_CNT]; 44 | struct input_absinfo absInfo[ABS_CNT]; 45 | int hats[4][2]; 46 | } _GLFWjoystickLinux; 47 | 48 | // Linux-specific joystick API data 49 | // 50 | typedef struct _GLFWlibraryLinux 51 | { 52 | int inotify; 53 | int watch; 54 | regex_t regex; 55 | GLFWbool dropped; 56 | } _GLFWlibraryLinux; 57 | 58 | void _glfwDetectJoystickConnectionLinux(void); 59 | 60 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/linux_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs 32 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs 33 | 34 | #define _GLFW_PLATFORM_MAPPING_NAME "Linux" 35 | 36 | // Linux-specific joystick data 37 | // 38 | typedef struct _GLFWjoystickLinux 39 | { 40 | int fd; 41 | char path[PATH_MAX]; 42 | int keyMap[KEY_CNT - BTN_MISC]; 43 | int absMap[ABS_CNT]; 44 | struct input_absinfo absInfo[ABS_CNT]; 45 | int hats[4][2]; 46 | } _GLFWjoystickLinux; 47 | 48 | // Linux-specific joystick API data 49 | // 50 | typedef struct _GLFWlibraryLinux 51 | { 52 | int inotify; 53 | int watch; 54 | regex_t regex; 55 | GLFWbool dropped; 56 | } _GLFWlibraryLinux; 57 | 58 | void _glfwDetectJoystickConnectionLinux(void); 59 | 60 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/cocoa_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // It is fine to use C99 in this file because it will not be built with VS 27 | //======================================================================== 28 | 29 | #include "internal.h" 30 | 31 | #include 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW internal API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | // Initialise timer 39 | // 40 | void _glfwInitTimerNS(void) 41 | { 42 | mach_timebase_info_data_t info; 43 | mach_timebase_info(&info); 44 | 45 | _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer; 46 | } 47 | 48 | 49 | ////////////////////////////////////////////////////////////////////////// 50 | ////// GLFW platform API ////// 51 | ////////////////////////////////////////////////////////////////////////// 52 | 53 | uint64_t _glfwPlatformGetTimerValue(void) 54 | { 55 | return mach_absolute_time(); 56 | } 57 | 58 | uint64_t _glfwPlatformGetTimerFrequency(void) 59 | { 60 | return _glfw.timer.ns.frequency; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/cocoa_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // It is fine to use C99 in this file because it will not be built with VS 27 | //======================================================================== 28 | 29 | #include "internal.h" 30 | 31 | #include 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW internal API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | // Initialise timer 39 | // 40 | void _glfwInitTimerNS(void) 41 | { 42 | mach_timebase_info_data_t info; 43 | mach_timebase_info(&info); 44 | 45 | _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer; 46 | } 47 | 48 | 49 | ////////////////////////////////////////////////////////////////////////// 50 | ////// GLFW platform API ////// 51 | ////////////////////////////////////////////////////////////////////////// 52 | 53 | uint64_t _glfwPlatformGetTimerValue(void) 54 | { 55 | return mach_absolute_time(); 56 | } 57 | 58 | uint64_t _glfwPlatformGetTimerFrequency(void) 59 | { 60 | return _glfw.timer.ns.frequency; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/cocoa_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // It is fine to use C99 in this file because it will not be built with VS 27 | //======================================================================== 28 | 29 | #include "internal.h" 30 | 31 | #include 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW internal API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | // Initialise timer 39 | // 40 | void _glfwInitTimerNS(void) 41 | { 42 | mach_timebase_info_data_t info; 43 | mach_timebase_info(&info); 44 | 45 | _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer; 46 | } 47 | 48 | 49 | ////////////////////////////////////////////////////////////////////////// 50 | ////// GLFW platform API ////// 51 | ////////////////////////////////////////////////////////////////////////// 52 | 53 | uint64_t _glfwPlatformGetTimerValue(void) 54 | { 55 | return mach_absolute_time(); 56 | } 57 | 58 | uint64_t _glfwPlatformGetTimerFrequency(void) 59 | { 60 | return _glfw.timer.ns.frequency; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Samples/Flowfield/noise.h: -------------------------------------------------------------------------------- 1 | 2 | // https://en.wikipedia.org/wiki/Perlin_noise 3 | 4 | #include 5 | 6 | /* Function to linearly interpolate between a0 and a1 7 | * Weight w should be in the range [0.0, 1.0] 8 | */ 9 | float interpolate(float a0, float a1, float w) { 10 | /* // You may want clamping by inserting: 11 | * if (0.0 > w) return a0; 12 | * if (1.0 < w) return a1; 13 | */ 14 | return (a1 - a0) * w + a0; 15 | /* // Use this cubic interpolation [[Smoothstep]] instead, for a smooth appearance: 16 | * return (a1 - a0) * (3.0 - w * 2.0) * w * w + a0; 17 | * 18 | * // Use [[Smootherstep]] for an even smoother result with a second derivative equal to zero on boundaries: 19 | * return (a1 - a0) * ((w * (w * 6.0 - 15.0) + 10.0) * w * w * w) + a0; 20 | */ 21 | } 22 | 23 | typedef struct { 24 | float x, y; 25 | } vector2; 26 | 27 | /* Create random direction vector 28 | */ 29 | vector2 randomGradient(int ix, int iy) { 30 | // Random float. No precomputed gradients mean this works for any number of grid coordinates 31 | float random = 2920.f * sin(ix * 21942.f + iy * 171324.f + 8912.f) * cos(ix * 23157.f * iy * 217832.f + 9758.f); 32 | return (vector2) { .x = cos(random), .y = sin(random) }; 33 | } 34 | 35 | // Computes the dot product of the distance and gradient vectors. 36 | float dotGridGradient(int ix, int iy, float x, float y) { 37 | // Get gradient from integer coordinates 38 | vector2 gradient = randomGradient(ix, iy); 39 | 40 | // Compute the distance vector 41 | float dx = x - (float)ix; 42 | float dy = y - (float)iy; 43 | 44 | // Compute the dot-product 45 | return (dx*gradient.x + dy*gradient.y); 46 | } 47 | 48 | // Compute Perlin noise at coordinates x, y 49 | float perlin(float x, float y) { 50 | // Determine grid cell coordinates 51 | int x0 = (int)x; 52 | int x1 = x0 + 1; 53 | int y0 = (int)y; 54 | int y1 = y0 + 1; 55 | 56 | // Determine interpolation weights 57 | // Could also use higher order polynomial/s-curve here 58 | float sx = x - (float)x0; 59 | float sy = y - (float)y0; 60 | 61 | // Interpolate between grid point gradients 62 | float n0, n1, ix0, ix1, value; 63 | 64 | n0 = dotGridGradient(x0, y0, x, y); 65 | n1 = dotGridGradient(x1, y0, x, y); 66 | ix0 = interpolate(n0, n1, sx); 67 | 68 | n0 = dotGridGradient(x0, y1, x, y); 69 | n1 = dotGridGradient(x1, y1, x, y); 70 | ix1 = interpolate(n0, n1, sx); 71 | 72 | value = interpolate(ix0, ix1, sy); 73 | return value; 74 | } 75 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/nsgl_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2019 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | // NOTE: Many Cocoa enum values have been renamed and we need to build across 28 | // SDK versions where one is unavailable or the other deprecated 29 | // We use the newer names in code and these macros to handle compatibility 30 | #if MAC_OS_X_VERSION_MAX_ALLOWED < 101400 31 | #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval 32 | #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity 33 | #endif 34 | 35 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl 36 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl 37 | 38 | #include 39 | 40 | 41 | // NSGL-specific per-context data 42 | // 43 | typedef struct _GLFWcontextNSGL 44 | { 45 | id pixelFormat; 46 | id object; 47 | 48 | } _GLFWcontextNSGL; 49 | 50 | // NSGL-specific global data 51 | // 52 | typedef struct _GLFWlibraryNSGL 53 | { 54 | // dlopen handle for OpenGL.framework (for glfwGetProcAddress) 55 | CFBundleRef framework; 56 | 57 | } _GLFWlibraryNSGL; 58 | 59 | 60 | GLFWbool _glfwInitNSGL(void); 61 | void _glfwTerminateNSGL(void); 62 | GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, 63 | const _GLFWctxconfig* ctxconfig, 64 | const _GLFWfbconfig* fbconfig); 65 | void _glfwDestroyContextNSGL(_GLFWwindow* window); 66 | 67 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal 4 | set SourceFiles=../../main.c ../../glfw/src/context.c ../../glfw/src/egl_context.c ../../glfw/src/init.c ../../glfw/src/input.c ../../glfw/src/monitor.c ../../glfw/src/osmesa_context.c ../../glfw/src/vulkan.c ../../glfw/src/wgl_context.c ../../glfw/src/win32_init.c ../../glfw/src/win32_joystick.c ../../glfw/src/win32_monitor.c ../../glfw/src/win32_thread.c ../../glfw/src/win32_time.c ../../glfw/src/win32_window.c ../../glfw/src/window.c 5 | 6 | set CLFlags=-Od 7 | set CLANGFlags=-g -gcodeview 8 | set GCCFlags=-O 9 | 10 | if "%1" neq "optimize" goto DoneConfig 11 | set MsBuildConfiguration=Release 12 | set CLFlags=-O2 13 | set CLANGFlags=-O2 -gcodeview 14 | set GCCFlags=-O2 15 | 16 | echo ------------------------------------- 17 | echo Optimize Build configured 18 | echo ------------------------------------- 19 | :DoneConfig 20 | 21 | echo ------------------------------------- 22 | 23 | if not exist "bin" mkdir bin 24 | 25 | :MSVC 26 | where cl >nul 2>nul 27 | if %ERRORLEVEL% neq 0 goto SkipMSVC 28 | echo Building with Msvc 29 | if not exist "bin\MsvcBuild" mkdir bin\MsvcBuild 30 | pushd bin\MsvcBuild 31 | call cl -nologo -D_CRT_SECURE_NO_WARNINGS -D_GLFW_WIN32 -nologo -Zi -EHsc %CLFlags% %SourceFiles% -Femandelbrot.exe /link user32.lib gdi32.lib shell32.lib opengl32.lib 32 | popd 33 | echo ------------------------------------- 34 | goto CLANG 35 | :SkipMSVC 36 | echo Msvc not found. Skipping build with Msvc 37 | echo ------------------------------------- 38 | 39 | :CLANG 40 | where clang >nul 2>nul 41 | IF %ERRORLEVEL% NEQ 0 goto SkipCLANG 42 | echo Building with CLANG 43 | if not exist "bin\ClangBuild" mkdir bin\ClangBuild 44 | pushd bin\ClangBuild 45 | call clang -Wno-switch -Wno-pointer-sign -Wno-enum-conversion -D_CRT_SECURE_NO_WARNINGS -D_GLFW_WIN32 %CLANGFlags% %SourceFiles% -o mandelbrot.exe -luser32.lib -lgdi32.lib -lshell32.lib -lopengl32.lib 46 | popd 47 | echo ------------------------------------- 48 | goto GCC 49 | :SkipCLANG 50 | echo Clang not found. Skipping build with Clang 51 | echo ------------------------------------- 52 | 53 | :GCC 54 | where gcc >nul 2>nul 55 | IF %ERRORLEVEL% NEQ 0 goto SkipGCC 56 | where windres >nul 2>nul 57 | IF %ERRORLEVEL% NEQ 0 goto SkipGCC 58 | echo Building with GCC 59 | if not exist "bin\GccBuild" mkdir bin\GccBuild 60 | pushd bin\GccBuild 61 | call gcc -Wno-switch -Wno-pointer-sign -Wno-enum-conversion -D_CRT_SECURE_NO_WARNINGS -D_GLFW_WIN32 %GCCFlags% %SourceFiles% -o mandelbrot.exe -luser32 -lgdi32 -lshell32 -lopengl32 62 | popd 63 | echo ------------------------------------- 64 | goto Finished 65 | :SkipGCC 66 | echo Gcc not found. Skipping build with Gcc 67 | echo ------------------------------------- 68 | 69 | :Finished -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/nsgl_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2019 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | // NOTE: Many Cocoa enum values have been renamed and we need to build across 28 | // SDK versions where one is unavailable or the other deprecated 29 | // We use the newer names in code and these macros to handle compatibility 30 | #if MAC_OS_X_VERSION_MAX_ALLOWED < 101400 31 | #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval 32 | #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity 33 | #endif 34 | 35 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl 36 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl 37 | 38 | #include 39 | 40 | 41 | // NSGL-specific per-context data 42 | // 43 | typedef struct _GLFWcontextNSGL 44 | { 45 | id pixelFormat; 46 | id object; 47 | 48 | } _GLFWcontextNSGL; 49 | 50 | // NSGL-specific global data 51 | // 52 | typedef struct _GLFWlibraryNSGL 53 | { 54 | // dlopen handle for OpenGL.framework (for glfwGetProcAddress) 55 | CFBundleRef framework; 56 | 57 | } _GLFWlibraryNSGL; 58 | 59 | 60 | GLFWbool _glfwInitNSGL(void); 61 | void _glfwTerminateNSGL(void); 62 | GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, 63 | const _GLFWctxconfig* ctxconfig, 64 | const _GLFWfbconfig* fbconfig); 65 | void _glfwDestroyContextNSGL(_GLFWwindow* window); 66 | 67 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/nsgl_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2019 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | // NOTE: Many Cocoa enum values have been renamed and we need to build across 28 | // SDK versions where one is unavailable or the other deprecated 29 | // We use the newer names in code and these macros to handle compatibility 30 | #if MAC_OS_X_VERSION_MAX_ALLOWED < 101400 31 | #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval 32 | #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity 33 | #endif 34 | 35 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl 36 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl 37 | 38 | #include 39 | 40 | 41 | // NSGL-specific per-context data 42 | // 43 | typedef struct _GLFWcontextNSGL 44 | { 45 | id pixelFormat; 46 | id object; 47 | 48 | } _GLFWcontextNSGL; 49 | 50 | // NSGL-specific global data 51 | // 52 | typedef struct _GLFWlibraryNSGL 53 | { 54 | // dlopen handle for OpenGL.framework (for glfwGetProcAddress) 55 | CFBundleRef framework; 56 | 57 | } _GLFWlibraryNSGL; 58 | 59 | 60 | GLFWbool _glfwInitNSGL(void); 61 | void _glfwTerminateNSGL(void); 62 | GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, 63 | const _GLFWctxconfig* ctxconfig, 64 | const _GLFWfbconfig* fbconfig); 65 | void _glfwDestroyContextNSGL(_GLFWwindow* window); 66 | 67 | -------------------------------------------------------------------------------- /Samples/Calculator/build.muda: -------------------------------------------------------------------------------- 1 | # Generated by: Muda Console Setup [2021-10-17 18:25:23] 2 | 3 | @version 1.5.0 4 | 5 | # Type of compilation. Project only build using a single muda file. Solution iterates through subdirectories and build each muda file found. 6 | Kind : Project; 7 | # Possible values: Project, or Solution 8 | 9 | # Langauge to be compiled. 10 | Language : C; 11 | # Possible values: C, or Cpp 12 | 13 | # The type of Application that is to be built 14 | Application : Executable; 15 | # Possible values: Executable, StaticLibrary, or DynamicLibrary 16 | 17 | # Use optimization while compiling or not (true/false) 18 | Optimization : False; 19 | 20 | # Name of the output binary. 21 | Build : calculator; 22 | 23 | # Path to the directory where the output binary should be placed. 24 | BuildDirectory : ./bin; 25 | 26 | # Path to the source files. 27 | Sources : src/main.c src/parser.c src/regex.c src/symbol_table.c src/token.c ; 28 | 29 | # Flags for the compiler. Different compiler may use different flags, so it is recommended to use sections for using this property. 30 | Flags : ; 31 | 32 | # List of preprocessing symbols to be defined. 33 | Defines : ; 34 | 35 | # List of directories to search for include files. 36 | IncludeDirectories : includes ; 37 | 38 | # This property is only used in Windows. can be Console or Windows. Windows uses the win main entry point. 39 | Subsystem : Console; 40 | # Possible values: Console, or Windows 41 | 42 | # List of additional libraries to be linked (For MSVC: do not include the .lib extension). 43 | Libraries : ; 44 | 45 | # List of paths to be searched for additional libraries. 46 | LibraryDirectories : ; 47 | 48 | # Flags for the linker. Different linkers may use different flags, so it is recommended to use sections for using this property. 49 | LinkerFlags : ; 50 | 51 | # The directories to be ignored when build kind of Solution. Ignored when build kind is Project. 52 | IgnoredDirectories : ; 53 | 54 | # The directories where build process is to be executed. When this is non-empty IgnoredDirectories is ignored 55 | ProjectDirectories : ; 56 | 57 | # Executes the command before executing muda file. 58 | Prebuild : ; 59 | 60 | # Executes the command if the compilation executed sucessfully. 61 | Postbuild : ; 62 | 63 | :OS.WINDOWS 64 | # Place values specific to windows here 65 | 66 | : OS.LINUX 67 | # Place values specific to linux here 68 | 69 | : OS.MAC 70 | #Place values specific to mac here 71 | 72 | : COMPILER.CL 73 | #Place values specific to MSVC compiler here 74 | 75 | : COMPILER.CLANG 76 | #Place values specific to CLANG compiler here 77 | 78 | : COMPILER.GCC 79 | #Place values specific to GC compiler here 80 | 81 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/glfw_config.h.in: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // As glfw_config.h.in, this file is used by CMake to produce the 27 | // glfw_config.h configuration header file. If you are adding a feature 28 | // requiring conditional compilation, this is where to add the macro. 29 | //======================================================================== 30 | // As glfw_config.h, this file defines compile-time option macros for a 31 | // specific platform and development environment. If you are using the 32 | // GLFW CMake files, modify glfw_config.h.in instead of this file. If you 33 | // are using your own build system, make this file define the appropriate 34 | // macros in whatever way is suitable. 35 | //======================================================================== 36 | 37 | // Define this to 1 if building GLFW for X11 38 | #cmakedefine _GLFW_X11 39 | // Define this to 1 if building GLFW for Win32 40 | #cmakedefine _GLFW_WIN32 41 | // Define this to 1 if building GLFW for Cocoa 42 | #cmakedefine _GLFW_COCOA 43 | // Define this to 1 if building GLFW for Wayland 44 | #cmakedefine _GLFW_WAYLAND 45 | // Define this to 1 if building GLFW for OSMesa 46 | #cmakedefine _GLFW_OSMESA 47 | 48 | // Define this to 1 to use Vulkan loader linked statically into application 49 | #cmakedefine _GLFW_VULKAN_STATIC 50 | 51 | // Define this to 1 to force use of high-performance GPU on hybrid systems 52 | #cmakedefine _GLFW_USE_HYBRID_HPG 53 | 54 | // Define this to 1 if xkbcommon supports the compose key 55 | #cmakedefine HAVE_XKBCOMMON_COMPOSE_H 56 | // Define this to 1 if the libc supports memfd_create() 57 | #cmakedefine HAVE_MEMFD_CREATE 58 | 59 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/glfw_config.h.in: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // As glfw_config.h.in, this file is used by CMake to produce the 27 | // glfw_config.h configuration header file. If you are adding a feature 28 | // requiring conditional compilation, this is where to add the macro. 29 | //======================================================================== 30 | // As glfw_config.h, this file defines compile-time option macros for a 31 | // specific platform and development environment. If you are using the 32 | // GLFW CMake files, modify glfw_config.h.in instead of this file. If you 33 | // are using your own build system, make this file define the appropriate 34 | // macros in whatever way is suitable. 35 | //======================================================================== 36 | 37 | // Define this to 1 if building GLFW for X11 38 | #cmakedefine _GLFW_X11 39 | // Define this to 1 if building GLFW for Win32 40 | #cmakedefine _GLFW_WIN32 41 | // Define this to 1 if building GLFW for Cocoa 42 | #cmakedefine _GLFW_COCOA 43 | // Define this to 1 if building GLFW for Wayland 44 | #cmakedefine _GLFW_WAYLAND 45 | // Define this to 1 if building GLFW for OSMesa 46 | #cmakedefine _GLFW_OSMESA 47 | 48 | // Define this to 1 to use Vulkan loader linked statically into application 49 | #cmakedefine _GLFW_VULKAN_STATIC 50 | 51 | // Define this to 1 to force use of high-performance GPU on hybrid systems 52 | #cmakedefine _GLFW_USE_HYBRID_HPG 53 | 54 | // Define this to 1 if xkbcommon supports the compose key 55 | #cmakedefine HAVE_XKBCOMMON_COMPOSE_H 56 | // Define this to 1 if the libc supports memfd_create() 57 | #cmakedefine HAVE_MEMFD_CREATE 58 | 59 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/win32_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | // Please use C89 style variable declarations in this file because VS 2010 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | ////// GLFW internal API ////// 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | // Initialise timer 38 | // 39 | void _glfwInitTimerWin32(void) 40 | { 41 | uint64_t frequency; 42 | 43 | if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) 44 | { 45 | _glfw.timer.win32.hasPC = GLFW_TRUE; 46 | _glfw.timer.win32.frequency = frequency; 47 | } 48 | else 49 | { 50 | _glfw.timer.win32.hasPC = GLFW_FALSE; 51 | _glfw.timer.win32.frequency = 1000; 52 | } 53 | } 54 | 55 | 56 | ////////////////////////////////////////////////////////////////////////// 57 | ////// GLFW platform API ////// 58 | ////////////////////////////////////////////////////////////////////////// 59 | 60 | uint64_t _glfwPlatformGetTimerValue(void) 61 | { 62 | if (_glfw.timer.win32.hasPC) 63 | { 64 | uint64_t value; 65 | QueryPerformanceCounter((LARGE_INTEGER*) &value); 66 | return value; 67 | } 68 | else 69 | return (uint64_t) timeGetTime(); 70 | } 71 | 72 | uint64_t _glfwPlatformGetTimerFrequency(void) 73 | { 74 | return _glfw.timer.win32.frequency; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/glfw_config.h.in: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // As glfw_config.h.in, this file is used by CMake to produce the 27 | // glfw_config.h configuration header file. If you are adding a feature 28 | // requiring conditional compilation, this is where to add the macro. 29 | //======================================================================== 30 | // As glfw_config.h, this file defines compile-time option macros for a 31 | // specific platform and development environment. If you are using the 32 | // GLFW CMake files, modify glfw_config.h.in instead of this file. If you 33 | // are using your own build system, make this file define the appropriate 34 | // macros in whatever way is suitable. 35 | //======================================================================== 36 | 37 | // Define this to 1 if building GLFW for X11 38 | #cmakedefine _GLFW_X11 39 | // Define this to 1 if building GLFW for Win32 40 | #cmakedefine _GLFW_WIN32 41 | // Define this to 1 if building GLFW for Cocoa 42 | #cmakedefine _GLFW_COCOA 43 | // Define this to 1 if building GLFW for Wayland 44 | #cmakedefine _GLFW_WAYLAND 45 | // Define this to 1 if building GLFW for OSMesa 46 | #cmakedefine _GLFW_OSMESA 47 | 48 | // Define this to 1 to use Vulkan loader linked statically into application 49 | #cmakedefine _GLFW_VULKAN_STATIC 50 | 51 | // Define this to 1 to force use of high-performance GPU on hybrid systems 52 | #cmakedefine _GLFW_USE_HYBRID_HPG 53 | 54 | // Define this to 1 if xkbcommon supports the compose key 55 | #cmakedefine HAVE_XKBCOMMON_COMPOSE_H 56 | // Define this to 1 if the libc supports memfd_create() 57 | #cmakedefine HAVE_MEMFD_CREATE 58 | 59 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/win32_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | // Please use C89 style variable declarations in this file because VS 2010 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | ////// GLFW internal API ////// 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | // Initialise timer 38 | // 39 | void _glfwInitTimerWin32(void) 40 | { 41 | uint64_t frequency; 42 | 43 | if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) 44 | { 45 | _glfw.timer.win32.hasPC = GLFW_TRUE; 46 | _glfw.timer.win32.frequency = frequency; 47 | } 48 | else 49 | { 50 | _glfw.timer.win32.hasPC = GLFW_FALSE; 51 | _glfw.timer.win32.frequency = 1000; 52 | } 53 | } 54 | 55 | 56 | ////////////////////////////////////////////////////////////////////////// 57 | ////// GLFW platform API ////// 58 | ////////////////////////////////////////////////////////////////////////// 59 | 60 | uint64_t _glfwPlatformGetTimerValue(void) 61 | { 62 | if (_glfw.timer.win32.hasPC) 63 | { 64 | uint64_t value; 65 | QueryPerformanceCounter((LARGE_INTEGER*) &value); 66 | return value; 67 | } 68 | else 69 | return (uint64_t) timeGetTime(); 70 | } 71 | 72 | uint64_t _glfwPlatformGetTimerFrequency(void) 73 | { 74 | return _glfw.timer.win32.frequency; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/win32_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | // Please use C89 style variable declarations in this file because VS 2010 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | ////// GLFW internal API ////// 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | // Initialise timer 38 | // 39 | void _glfwInitTimerWin32(void) 40 | { 41 | uint64_t frequency; 42 | 43 | if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) 44 | { 45 | _glfw.timer.win32.hasPC = GLFW_TRUE; 46 | _glfw.timer.win32.frequency = frequency; 47 | } 48 | else 49 | { 50 | _glfw.timer.win32.hasPC = GLFW_FALSE; 51 | _glfw.timer.win32.frequency = 1000; 52 | } 53 | } 54 | 55 | 56 | ////////////////////////////////////////////////////////////////////////// 57 | ////// GLFW platform API ////// 58 | ////////////////////////////////////////////////////////////////////////// 59 | 60 | uint64_t _glfwPlatformGetTimerValue(void) 61 | { 62 | if (_glfw.timer.win32.hasPC) 63 | { 64 | uint64_t value; 65 | QueryPerformanceCounter((LARGE_INTEGER*) &value); 66 | return value; 67 | } 68 | else 69 | return (uint64_t) timeGetTime(); 70 | } 71 | 72 | uint64_t _glfwPlatformGetTimerFrequency(void) 73 | { 74 | return _glfw.timer.win32.frequency; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /Samples/Michi/resource.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | 5 | #include "resource.h" 6 | 7 | #define APSTUDIO_READONLY_SYMBOLS 8 | ///////////////////////////////////////////////////////////////////////////// 9 | // 10 | // Generated from the TEXTINCLUDE 2 resource. 11 | // 12 | #include "winres.h" 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // English (United States) resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 21 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 22 | 23 | #ifdef APSTUDIO_INVOKED 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // TEXTINCLUDE 27 | // 28 | 29 | 1 TEXTINCLUDE 30 | BEGIN 31 | "resource.h\0" 32 | END 33 | 34 | 2 TEXTINCLUDE 35 | BEGIN 36 | "#include ""winres.h""\r\n" 37 | "\0" 38 | END 39 | 40 | 3 TEXTINCLUDE 41 | BEGIN 42 | "\r\n" 43 | "\0" 44 | END 45 | 46 | #endif // APSTUDIO_INVOKED 47 | 48 | 49 | ///////////////////////////////////////////////////////////////////////////// 50 | // 51 | // Icon 52 | // 53 | 54 | // Icon with lowest ID value placed first to ensure application icon 55 | // remains consistent on all systems. 56 | IDI_ICON1 ICON "Logo.ico" 57 | 58 | 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // 61 | // Version 62 | // 63 | 64 | VS_VERSION_INFO VERSIONINFO 65 | FILEVERSION 1,0,0,1 66 | PRODUCTVERSION 1,0,0,1 67 | FILEFLAGSMASK 0x3fL 68 | #ifdef _DEBUG 69 | FILEFLAGS 0x1L 70 | #else 71 | FILEFLAGS 0x0L 72 | #endif 73 | FILEOS 0x40004L 74 | FILETYPE 0x1L 75 | FILESUBTYPE 0x0L 76 | BEGIN 77 | BLOCK "StringFileInfo" 78 | BEGIN 79 | BLOCK "040904b0" 80 | BEGIN 81 | VALUE "CompanyName", "Zero" 82 | VALUE "FileDescription", "Michi" 83 | VALUE "FileVersion", "1.0.0.1" 84 | VALUE "InternalName", "Michi.exe" 85 | VALUE "LegalCopyright", "Copyright (C) 2021" 86 | VALUE "OriginalFilename", "Michi.exe" 87 | VALUE "ProductName", "Michi" 88 | VALUE "ProductVersion", "1.0.0.1" 89 | END 90 | END 91 | BLOCK "VarFileInfo" 92 | BEGIN 93 | VALUE "Translation", 0x409, 1200 94 | END 95 | END 96 | 97 | #endif // English (United States) resources 98 | ///////////////////////////////////////////////////////////////////////////// 99 | 100 | 101 | 102 | #ifndef APSTUDIO_INVOKED 103 | ///////////////////////////////////////////////////////////////////////////// 104 | // 105 | // Generated from the TEXTINCLUDE 3 resource. 106 | // 107 | 108 | 109 | ///////////////////////////////////////////////////////////////////////////// 110 | #endif // not APSTUDIO_INVOKED 111 | 112 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-DX11/Resource.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United States) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_ICON1 ICON "Logo.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | VS_VERSION_INFO VERSIONINFO 64 | FILEVERSION 1,0,0,1 65 | PRODUCTVERSION 1,0,0,1 66 | FILEFLAGSMASK 0x3fL 67 | #ifdef _DEBUG 68 | FILEFLAGS 0x1L 69 | #else 70 | FILEFLAGS 0x0L 71 | #endif 72 | FILEOS 0x40004L 73 | FILETYPE 0x1L 74 | FILESUBTYPE 0x0L 75 | BEGIN 76 | BLOCK "StringFileInfo" 77 | BEGIN 78 | BLOCK "040904b0" 79 | BEGIN 80 | VALUE "CompanyName", "Zero" 81 | VALUE "FileDescription", "Mandelbrot" 82 | VALUE "FileVersion", "1.0.0.1" 83 | VALUE "InternalName", "Mandelbr.exe" 84 | VALUE "LegalCopyright", "Copyright (C) 2021" 85 | VALUE "OriginalFilename", "Mandelbr.exe" 86 | VALUE "ProductName", "Mandelbrot" 87 | VALUE "ProductVersion", "1.0.0.1" 88 | END 89 | END 90 | BLOCK "VarFileInfo" 91 | BEGIN 92 | VALUE "Translation", 0x409, 1200 93 | END 94 | END 95 | 96 | #endif // English (United States) resources 97 | ///////////////////////////////////////////////////////////////////////////// 98 | 99 | 100 | 101 | #ifndef APSTUDIO_INVOKED 102 | ///////////////////////////////////////////////////////////////////////////// 103 | // 104 | // Generated from the TEXTINCLUDE 3 resource. 105 | // 106 | 107 | 108 | ///////////////////////////////////////////////////////////////////////////// 109 | #endif // not APSTUDIO_INVOKED 110 | 111 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/resource.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | 5 | #include "resource.h" 6 | 7 | #define APSTUDIO_READONLY_SYMBOLS 8 | ///////////////////////////////////////////////////////////////////////////// 9 | // 10 | // Generated from the TEXTINCLUDE 2 resource. 11 | // 12 | #include "winres.h" 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // English (United States) resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 21 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 22 | 23 | #ifdef APSTUDIO_INVOKED 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // TEXTINCLUDE 27 | // 28 | 29 | 1 TEXTINCLUDE 30 | BEGIN 31 | "resource.h\0" 32 | END 33 | 34 | 2 TEXTINCLUDE 35 | BEGIN 36 | "#include ""winres.h""\r\n" 37 | "\0" 38 | END 39 | 40 | 3 TEXTINCLUDE 41 | BEGIN 42 | "\r\n" 43 | "\0" 44 | END 45 | 46 | #endif // APSTUDIO_INVOKED 47 | 48 | 49 | ///////////////////////////////////////////////////////////////////////////// 50 | // 51 | // Icon 52 | // 53 | 54 | // Icon with lowest ID value placed first to ensure application icon 55 | // remains consistent on all systems. 56 | IDI_ICON1 ICON "Logo.ico" 57 | 58 | 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // 61 | // Version 62 | // 63 | 64 | VS_VERSION_INFO VERSIONINFO 65 | FILEVERSION 1,0,0,1 66 | PRODUCTVERSION 1,0,0,1 67 | FILEFLAGSMASK 0x3fL 68 | #ifdef _DEBUG 69 | FILEFLAGS 0x1L 70 | #else 71 | FILEFLAGS 0x0L 72 | #endif 73 | FILEOS 0x40004L 74 | FILETYPE 0x1L 75 | FILESUBTYPE 0x0L 76 | BEGIN 77 | BLOCK "StringFileInfo" 78 | BEGIN 79 | BLOCK "040904b0" 80 | BEGIN 81 | VALUE "CompanyName", "Zero" 82 | VALUE "FileDescription", "Mandelbrot Set" 83 | VALUE "FileVersion", "1.0.0.1" 84 | VALUE "InternalName", "Mandelbr.exe" 85 | VALUE "LegalCopyright", "Copyright (C) 2021" 86 | VALUE "OriginalFilename", "Mandelbrot.exe" 87 | VALUE "ProductName", "Mandelbrot" 88 | VALUE "ProductVersion", "1.0.0.1" 89 | END 90 | END 91 | BLOCK "VarFileInfo" 92 | BEGIN 93 | VALUE "Translation", 0x409, 1200 94 | END 95 | END 96 | 97 | #endif // English (United States) resources 98 | ///////////////////////////////////////////////////////////////////////////// 99 | 100 | 101 | 102 | #ifndef APSTUDIO_INVOKED 103 | ///////////////////////////////////////////////////////////////////////////// 104 | // 105 | // Generated from the TEXTINCLUDE 3 resource. 106 | // 107 | 108 | 109 | ///////////////////////////////////////////////////////////////////////////// 110 | #endif // not APSTUDIO_INVOKED 111 | 112 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/null_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2016-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include 29 | 30 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null 31 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null 32 | #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNull null 33 | 34 | #define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } 35 | #define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; } 36 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } 37 | 38 | #include "posix_time.h" 39 | #include "posix_thread.h" 40 | #include "null_joystick.h" 41 | 42 | #if defined(_GLFW_WIN32) 43 | #define _glfw_dlopen(name) LoadLibraryA(name) 44 | #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) 45 | #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) 46 | #else 47 | #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) 48 | #define _glfw_dlclose(handle) dlclose(handle) 49 | #define _glfw_dlsym(handle, name) dlsym(handle, name) 50 | #endif 51 | 52 | // Null-specific per-window data 53 | // 54 | typedef struct _GLFWwindowNull 55 | { 56 | int xpos; 57 | int ypos; 58 | int width; 59 | int height; 60 | char* title; 61 | GLFWbool visible; 62 | GLFWbool iconified; 63 | GLFWbool maximized; 64 | GLFWbool resizable; 65 | GLFWbool decorated; 66 | GLFWbool floating; 67 | GLFWbool transparent; 68 | float opacity; 69 | } _GLFWwindowNull; 70 | 71 | // Null-specific per-monitor data 72 | // 73 | typedef struct _GLFWmonitorNull 74 | { 75 | GLFWgammaramp ramp; 76 | } _GLFWmonitorNull; 77 | 78 | // Null-specific global data 79 | // 80 | typedef struct _GLFWlibraryNull 81 | { 82 | int xcursor; 83 | int ycursor; 84 | char* clipboardString; 85 | _GLFWwindow* focusedWindow; 86 | } _GLFWlibraryNull; 87 | 88 | void _glfwPollMonitorsNull(void); 89 | 90 | -------------------------------------------------------------------------------- /Samples/Michi/glfw/src/posix_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | // It is fine to use C99 in this file because it will not be built with VS 28 | //======================================================================== 29 | 30 | #define _POSIX_C_SOURCE 199309L 31 | 32 | #include "internal.h" 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | ////////////////////////////////////////////////////////////////////////// 40 | ////// GLFW internal API ////// 41 | ////////////////////////////////////////////////////////////////////////// 42 | 43 | // Initialise timer 44 | // 45 | void _glfwInitTimerPOSIX(void) 46 | { 47 | #if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) 48 | struct timespec ts; 49 | 50 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 51 | { 52 | _glfw.timer.posix.monotonic = GLFW_TRUE; 53 | _glfw.timer.posix.frequency = 1000000000; 54 | } 55 | else 56 | #endif 57 | { 58 | _glfw.timer.posix.monotonic = GLFW_FALSE; 59 | _glfw.timer.posix.frequency = 1000000; 60 | } 61 | } 62 | 63 | 64 | ////////////////////////////////////////////////////////////////////////// 65 | ////// GLFW platform API ////// 66 | ////////////////////////////////////////////////////////////////////////// 67 | 68 | uint64_t _glfwPlatformGetTimerValue(void) 69 | { 70 | #if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) 71 | if (_glfw.timer.posix.monotonic) 72 | { 73 | struct timespec ts; 74 | clock_gettime(CLOCK_MONOTONIC, &ts); 75 | return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec; 76 | } 77 | else 78 | #endif 79 | { 80 | struct timeval tv; 81 | gettimeofday(&tv, NULL); 82 | return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec; 83 | } 84 | } 85 | 86 | uint64_t _glfwPlatformGetTimerFrequency(void) 87 | { 88 | return _glfw.timer.posix.frequency; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/posix_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | // It is fine to use C99 in this file because it will not be built with VS 28 | //======================================================================== 29 | 30 | #define _POSIX_C_SOURCE 199309L 31 | 32 | #include "internal.h" 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | ////////////////////////////////////////////////////////////////////////// 40 | ////// GLFW internal API ////// 41 | ////////////////////////////////////////////////////////////////////////// 42 | 43 | // Initialise timer 44 | // 45 | void _glfwInitTimerPOSIX(void) 46 | { 47 | #if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) 48 | struct timespec ts; 49 | 50 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 51 | { 52 | _glfw.timer.posix.monotonic = GLFW_TRUE; 53 | _glfw.timer.posix.frequency = 1000000000; 54 | } 55 | else 56 | #endif 57 | { 58 | _glfw.timer.posix.monotonic = GLFW_FALSE; 59 | _glfw.timer.posix.frequency = 1000000; 60 | } 61 | } 62 | 63 | 64 | ////////////////////////////////////////////////////////////////////////// 65 | ////// GLFW platform API ////// 66 | ////////////////////////////////////////////////////////////////////////// 67 | 68 | uint64_t _glfwPlatformGetTimerValue(void) 69 | { 70 | #if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) 71 | if (_glfw.timer.posix.monotonic) 72 | { 73 | struct timespec ts; 74 | clock_gettime(CLOCK_MONOTONIC, &ts); 75 | return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec; 76 | } 77 | else 78 | #endif 79 | { 80 | struct timeval tv; 81 | gettimeofday(&tv, NULL); 82 | return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec; 83 | } 84 | } 85 | 86 | uint64_t _glfwPlatformGetTimerFrequency(void) 87 | { 88 | return _glfw.timer.posix.frequency; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/null_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2016-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include 29 | 30 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null 31 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null 32 | #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNull null 33 | 34 | #define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } 35 | #define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; } 36 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } 37 | 38 | #include "posix_time.h" 39 | #include "posix_thread.h" 40 | #include "null_joystick.h" 41 | 42 | #if defined(_GLFW_WIN32) 43 | #define _glfw_dlopen(name) LoadLibraryA(name) 44 | #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) 45 | #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) 46 | #else 47 | #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) 48 | #define _glfw_dlclose(handle) dlclose(handle) 49 | #define _glfw_dlsym(handle, name) dlsym(handle, name) 50 | #endif 51 | 52 | // Null-specific per-window data 53 | // 54 | typedef struct _GLFWwindowNull 55 | { 56 | int xpos; 57 | int ypos; 58 | int width; 59 | int height; 60 | char* title; 61 | GLFWbool visible; 62 | GLFWbool iconified; 63 | GLFWbool maximized; 64 | GLFWbool resizable; 65 | GLFWbool decorated; 66 | GLFWbool floating; 67 | GLFWbool transparent; 68 | float opacity; 69 | } _GLFWwindowNull; 70 | 71 | // Null-specific per-monitor data 72 | // 73 | typedef struct _GLFWmonitorNull 74 | { 75 | GLFWgammaramp ramp; 76 | } _GLFWmonitorNull; 77 | 78 | // Null-specific global data 79 | // 80 | typedef struct _GLFWlibraryNull 81 | { 82 | int xcursor; 83 | int ycursor; 84 | char* clipboardString; 85 | _GLFWwindow* focusedWindow; 86 | } _GLFWlibraryNull; 87 | 88 | void _glfwPollMonitorsNull(void); 89 | 90 | -------------------------------------------------------------------------------- /Samples/Mandelbrot/glfw/src/posix_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | // It is fine to use C99 in this file because it will not be built with VS 28 | //======================================================================== 29 | 30 | #define _POSIX_C_SOURCE 199309L 31 | 32 | #include "internal.h" 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | ////////////////////////////////////////////////////////////////////////// 40 | ////// GLFW internal API ////// 41 | ////////////////////////////////////////////////////////////////////////// 42 | 43 | // Initialise timer 44 | // 45 | void _glfwInitTimerPOSIX(void) 46 | { 47 | #if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) 48 | struct timespec ts; 49 | 50 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 51 | { 52 | _glfw.timer.posix.monotonic = GLFW_TRUE; 53 | _glfw.timer.posix.frequency = 1000000000; 54 | } 55 | else 56 | #endif 57 | { 58 | _glfw.timer.posix.monotonic = GLFW_FALSE; 59 | _glfw.timer.posix.frequency = 1000000; 60 | } 61 | } 62 | 63 | 64 | ////////////////////////////////////////////////////////////////////////// 65 | ////// GLFW platform API ////// 66 | ////////////////////////////////////////////////////////////////////////// 67 | 68 | uint64_t _glfwPlatformGetTimerValue(void) 69 | { 70 | #if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) 71 | if (_glfw.timer.posix.monotonic) 72 | { 73 | struct timespec ts; 74 | clock_gettime(CLOCK_MONOTONIC, &ts); 75 | return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec; 76 | } 77 | else 78 | #endif 79 | { 80 | struct timeval tv; 81 | gettimeofday(&tv, NULL); 82 | return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec; 83 | } 84 | } 85 | 86 | uint64_t _glfwPlatformGetTimerFrequency(void) 87 | { 88 | return _glfw.timer.posix.frequency; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /Samples/Mandelbrot-GPU/glfw/src/null_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2016-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include 29 | 30 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null 31 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null 32 | #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNull null 33 | 34 | #define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } 35 | #define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; } 36 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } 37 | 38 | #include "posix_time.h" 39 | #include "posix_thread.h" 40 | #include "null_joystick.h" 41 | 42 | #if defined(_GLFW_WIN32) 43 | #define _glfw_dlopen(name) LoadLibraryA(name) 44 | #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) 45 | #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) 46 | #else 47 | #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) 48 | #define _glfw_dlclose(handle) dlclose(handle) 49 | #define _glfw_dlsym(handle, name) dlsym(handle, name) 50 | #endif 51 | 52 | // Null-specific per-window data 53 | // 54 | typedef struct _GLFWwindowNull 55 | { 56 | int xpos; 57 | int ypos; 58 | int width; 59 | int height; 60 | char* title; 61 | GLFWbool visible; 62 | GLFWbool iconified; 63 | GLFWbool maximized; 64 | GLFWbool resizable; 65 | GLFWbool decorated; 66 | GLFWbool floating; 67 | GLFWbool transparent; 68 | float opacity; 69 | } _GLFWwindowNull; 70 | 71 | // Null-specific per-monitor data 72 | // 73 | typedef struct _GLFWmonitorNull 74 | { 75 | GLFWgammaramp ramp; 76 | } _GLFWmonitorNull; 77 | 78 | // Null-specific global data 79 | // 80 | typedef struct _GLFWlibraryNull 81 | { 82 | int xcursor; 83 | int ycursor; 84 | char* clipboardString; 85 | _GLFWwindow* focusedWindow; 86 | } _GLFWlibraryNull; 87 | 88 | void _glfwPollMonitorsNull(void); 89 | 90 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing Guidelines 2 | 3 | ### General 4 | 5 | * Fork the repo to your profile. 6 | * Make any changes in your forked repository. 7 | * All changes should be made in the 'main' branch. Do not create a new branch. 8 | * Make a pull request to this main repository. 9 | 10 | ### Sample Projects 11 | 12 | Add all sample projects in the path 13 | `/Samples//.c`. 14 | 15 | There may be multiple users with their own sample file for the 16 | sample projects. Do not edit the files contributed by other users. 17 | If naming conflict arises, append your username as a part of your 18 | filename. 19 | 20 | #### List of sample projects you can contribute 21 | 22 | - Cellular Automaton 23 | - 2D Particle Systems 24 | - Basic Interpreter (calculator with memory) 25 | - Fractals 26 | - Tetris 27 | - Basic HTTP Server 28 | - Compression + Decompression of text and binary files using Huffman Encoding (or other compression algorithm of choice) 29 | 30 | #### Sample Project Guidelines 31 | 32 | * Make use of small elegant libraries that are cross-platform. 33 | * We recommend a single source file (and a few if absolutely necessary). 34 | * Be sure to put instructions about downloading and installing the required libraries, link to relevant sites and you user names at the top of your source file as comments. An example format - 35 | 36 | ```cpp 37 | /* 38 | * Libraries 39 | * SDL2 (link) - zlib license 40 | * other libraries 41 | */ 42 | 43 | // Authors: name (github handle), name (github handle) 44 | 45 | /* 46 | * Project Name 47 | small desc about the project and wiki links and such 48 | */ 49 | ``` 50 | 51 | #### Build Instructions 52 | 53 | These are general guidelines you can follow to keep the build 54 | process consistent across all systems. 55 | 56 | Create build.bat (Windows) and build.sh (Linux) that contains the 57 | build instructions for your program depending upon the system. The 58 | build file should be placed in the path - 59 | `./Samples//` 60 | 61 | Please follow the following guidelines as much as possible when 62 | creating a build file : 63 | 64 | - The build files should detect the compiler and properly tell the user if the compiler is not present in the system. 65 | - The build files should take input to all the variables required for the build process. 66 | - The default build file should output the executable in debug configuration (i.e. no optimization). 67 | - The build file should detect `optimize` flag and build optimized executable when the flag is passed to the build file. 68 | - The output of the files should be placed in directory `bin` relative to the local project directory. 69 | - All the bin directories (including object files) are to be ignored in the repo. 70 | 71 | #### Final Directory Structure 72 | 73 | Your final directory structure may look something like this : 74 | ``` 75 | [/Samples//] 76 | ├── main.c # your main program 77 | ├── build.bat # build instructions for windows 78 | ├── build.sh # build instructions for linux (or unix shell, mac) 79 | ``` 80 | 81 | ### README.md 82 | 83 | You may contribute by adding to the list of resources. You can also 84 | make grammatical corrections. Create a new category if needed and 85 | explain in short about the new category/resource in your pull 86 | request description. 87 | -------------------------------------------------------------------------------- /Samples/Flowfield/flowfield.c: -------------------------------------------------------------------------------- 1 | #include "noise.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define PI 3.141592654 8 | 9 | SDL_Window *window = NULL; 10 | SDL_Renderer *renderer = NULL; 11 | 12 | // width and height of screen 13 | #define WIDTH 900 14 | #define HEIGHT 700 15 | // number of particles 16 | #define PNUM 1000 17 | // area in which the aligning vector will act 18 | // has to be a factor of both width and height 19 | #define SIZE 10 20 | 21 | bool init() { 22 | if (SDL_Init(SDL_INIT_VIDEO) < 0) 23 | return false; 24 | window = SDL_CreateWindow("Flow Field", SDL_WINDOWPOS_UNDEFINED, 25 | SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, 26 | SDL_WINDOW_SHOWN); 27 | renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE); 28 | return renderer && window; 29 | } 30 | 31 | void endAll() { 32 | // Deallocate renderer 33 | SDL_DestroyRenderer(renderer); 34 | renderer = NULL; 35 | // Destroy window 36 | SDL_DestroyWindow(window); 37 | window = NULL; 38 | // Quit SDL subsystems 39 | SDL_Quit(); 40 | } 41 | 42 | int main(int argc, char **args) { 43 | // aligning vectors based on perlin noise 44 | vector2 alignVectors[WIDTH / SIZE][HEIGHT / SIZE]; 45 | float angle; 46 | for (int x = 0; x < WIDTH / SIZE; x++) { 47 | for (int y = 0; y < HEIGHT / SIZE; y++) { 48 | angle = perlin(x / (float)SIZE, y / (float)SIZE) * PI; 49 | alignVectors[x][y].x = cos(angle); 50 | alignVectors[x][y].y = sin(angle); 51 | } 52 | } 53 | 54 | // create particles 55 | vector2 particles[PNUM]; 56 | for (int i = 0; i < PNUM; i++) { 57 | particles[i].x = rand() % WIDTH; 58 | particles[i].y = rand() % HEIGHT; 59 | } 60 | vector2 pos; 61 | SDL_Rect particle; 62 | particle.w = 2; 63 | particle.h = 2; 64 | 65 | if (init()) { 66 | bool quit = false; 67 | SDL_Event e; 68 | SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); 69 | SDL_Rect rects[PNUM], 70 | screenFiller = {.x = 0, .y = 0, .w = WIDTH, .h = HEIGHT}; 71 | 72 | while (!quit) { 73 | while (SDL_PollEvent(&e)) { 74 | if (e.type == SDL_QUIT) 75 | quit = true; 76 | } 77 | 78 | for (int i = 0; i < PNUM; i++) { 79 | // display the particles 80 | particle.x = particles[i].x; 81 | particle.y = particles[i].y; 82 | rects[i] = particle; 83 | 84 | // align the particles 85 | pos.x = particles[i].x / SIZE; 86 | pos.y = particles[i].y / SIZE; 87 | particles[i].x += alignVectors[(int)pos.x][(int)pos.y].x; 88 | particles[i].y += alignVectors[(int)pos.x][(int)pos.y].y; 89 | 90 | // if particles are out of bound give them a random position inside 91 | // the bounds 92 | if (particles[i].x >= WIDTH || particles[i].x < 0 || 93 | particles[i].y >= HEIGHT || particles[i].y < 0) { 94 | particles[i].x = rand() % WIDTH; 95 | particles[i].y = rand() % HEIGHT; 96 | } 97 | } 98 | SDL_SetRenderDrawColor(renderer, 0, 0, 0, 5); 99 | SDL_RenderFillRect(renderer, &screenFiller); 100 | SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); 101 | SDL_RenderFillRects(renderer, rects, PNUM); 102 | 103 | SDL_RenderPresent(renderer); 104 | SDL_Delay(5); 105 | } 106 | } 107 | endAll(); 108 | return 0; 109 | } 110 | --------------------------------------------------------------------------------