├── .gitignore ├── OpenGL ├── opengl-lesson01 │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.01.fs │ ├── mini-sdl-1.00.fs │ ├── opengl-lesson01-info.txt │ ├── opengl-lesson01.fs │ ├── opengl-lesson01.txt │ ├── opengllib-1.01.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson02 │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.02.fs │ ├── mini-sdl-1.00.fs │ ├── opengl-lesson02-info.txt │ ├── opengl-lesson02.fs │ ├── opengl-lesson02.txt │ ├── opengllib-1.02.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson03 │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.03.fs │ ├── mini-sdl-1.00.fs │ ├── opengl-lesson03-info.txt │ ├── opengl-lesson03.fs │ ├── opengl-lesson03.txt │ ├── opengllib-1.03.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson04 │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.04.fs │ ├── mini-sdl-1.00.fs │ ├── opengl-lesson04-info.txt │ ├── opengl-lesson04.fs │ ├── opengl-lesson04.txt │ ├── opengllib-1.04.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson05 │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.05.fs │ ├── mini-sdl-1.00.fs │ ├── opengl-lesson05-info.txt │ ├── opengl-lesson05.fs │ ├── opengl-lesson05.txt │ ├── opengllib-1.05.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson06 │ ├── data │ │ └── nehe.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.06.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson06-info.txt │ ├── opengl-lesson06.fs │ ├── opengl-lesson06.txt │ ├── opengllib-1.06.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson07 │ ├── data │ │ └── crate.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.07.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson07-info.txt │ ├── opengl-lesson07.fs │ ├── opengl-lesson07.txt │ ├── opengllib-1.07.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson08 │ ├── data │ │ └── glass.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.08.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson08-info.txt │ ├── opengl-lesson08.fs │ ├── opengl-lesson08.txt │ ├── opengllib-1.08.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson09 │ ├── data │ │ └── star.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.09.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson09-info.txt │ ├── opengl-lesson09.fs │ ├── opengl-lesson09.txt │ ├── opengllib-1.09.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson10 │ ├── data │ │ └── mud.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.10.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson10-info.txt │ ├── opengl-lesson10.fs │ ├── opengl-lesson10.txt │ ├── opengllib-1.10.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson11 │ ├── data │ │ └── tim.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.11.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson11-info.txt │ ├── opengl-lesson11.fs │ ├── opengl-lesson11.txt │ ├── opengllib-1.11.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson12 │ ├── data │ │ └── cube.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.12.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson12-info.txt │ ├── opengl-lesson12.fs │ ├── opengl-lesson12.txt │ ├── opengllib-1.12.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson13 │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.13.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson13-info.txt │ ├── opengl-lesson13.fs │ ├── opengl-lesson13.txt │ ├── opengllib-1.13.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson16 │ ├── data │ │ └── crate.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.16.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson16-info.txt │ ├── opengl-lesson16.fs │ ├── opengl-lesson16.txt │ ├── opengllib-1.16.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson17 │ ├── data │ │ ├── bumps.bmp │ │ └── font.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.17.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson17-info.txt │ ├── opengl-lesson17.fs │ ├── opengl-lesson17.txt │ ├── opengllib-1.17.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson18 │ ├── data │ │ └── wall.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.18.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson18-info.txt │ ├── opengl-lesson18.fs │ ├── opengl-lesson18.txt │ ├── opengllib-1.18.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson19 │ ├── data │ │ └── particle.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.19.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson19-info.txt │ ├── opengl-lesson19.fs │ ├── opengl-lesson19.txt │ ├── opengllib-1.19.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson20 │ ├── data │ │ ├── image1.bmp │ │ ├── image2.bmp │ │ ├── logo.bmp │ │ ├── mask1.bmp │ │ └── mask2.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.20.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson20-info.txt │ ├── opengl-lesson20.fs │ ├── opengl-lesson20.txt │ ├── opengllib-1.20.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson21 │ ├── data │ │ ├── complete.wav │ │ ├── die.wav │ │ ├── font.bmp │ │ ├── freeze.wav │ │ ├── hourglass.wav │ │ ├── image.bmp │ │ └── lktheme.mod │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-mixer-1.00.fs │ ├── mini-opengl-1.21.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson21-info.txt │ ├── opengl-lesson21.fs │ ├── opengl-lesson21.txt │ ├── opengllib-1.21.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson22 │ ├── data │ │ ├── base.bmp │ │ ├── bump.bmp │ │ ├── multi_on.bmp │ │ ├── multi_on_alpha.bmp │ │ ├── opengl.bmp │ │ └── opengl_alpha.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.22.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson22-info.txt │ ├── opengl-lesson22.fs │ ├── opengl-lesson22.txt │ ├── opengllib-1.22.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson23 │ ├── data │ │ ├── bg.bmp │ │ └── reflect.bmp │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.23.fs │ ├── mini-sdl-1.01.fs │ ├── opengl-lesson23-info.txt │ ├── opengl-lesson23.fs │ ├── opengl-lesson23.txt │ ├── opengllib-1.23.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson24 │ ├── data │ │ ├── font.bmp │ │ └── font.tga │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.24.fs │ ├── mini-sdl-1.02.fs │ ├── opengl-lesson24-info.txt │ ├── opengl-lesson24.fs │ ├── opengl-lesson24.txt │ ├── opengllib-1.24.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson25 │ ├── data │ │ ├── Sphere.txt │ │ ├── Torus.txt │ │ └── Tube.txt │ ├── glconstants.fs │ ├── libutil.sh │ ├── libutil.txt │ ├── mini-opengl-1.25.fs │ ├── mini-sdl-1.02.fs │ ├── opengl-lesson25-info.txt │ ├── opengl-lesson25.fs │ ├── opengl-lesson25.txt │ ├── opengllib-1.25.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── opengl-lesson26 │ ├── data │ │ ├── Ball.bmp │ │ ├── Envroll.bmp │ │ └── Envwall.bmp │ ├── glconstants.fs │ ├── libutil.txt │ ├── mini-opengl-1.26.fs │ ├── mini-sdl-1.02.fs │ ├── opengl-lesson26-info.txt │ ├── opengl-lesson26.fs │ ├── opengl-lesson26.txt │ ├── opengllib-1.26.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs └── opengl-lesson27 │ ├── glconstants.fs │ ├── libutil.txt │ ├── mini-opengl-1.27.fs │ ├── mini-sdl-1.02.fs │ ├── opengl-lesson27-info.txt │ ├── opengl-lesson27.fs │ ├── opengl-lesson27.txt │ ├── opengllib-1.27.fs │ ├── sdlconstants.fs │ └── sdlkeysym.fs ├── README.md └── SDL ├── README.md ├── sdl-01-gforth install-and-followups.txt ├── sdl-01-description.txt └── sdl-01-gforth install-and-followups.txt ├── sdl-16bpp.fs ├── sdl-16bpp.txt ├── sdl-bug-report01.txt ├── sdl-tut02 ├── gforth1.bmp ├── sdl-tut02-info.txt ├── sdl-tut02.fs ├── sdl-tut02.txt ├── sdl.fs └── sdlconstants.fs ├── sdl-tut03 ├── sdl-putpixel.fs ├── sdl-tut03-info.txt └── sdl-tut03.txt ├── sdl-tut04 ├── sdl-tut04-info.txt ├── sdl-tut04.fs └── sdl-tut04.txt ├── sdl-tut05 ├── sdl-1.0b.fs ├── sdl-tut05-info.txt ├── sdl-tut05.txt ├── sdlconstants.fs ├── sdllib.bmp └── sdllib.fs ├── sdl-tut06 ├── edo.fs ├── sdl-1.0b.fs ├── sdl-tut06-info.txt ├── sdl-tut06.txt ├── sdl-vboll-data.fs ├── sdl-vboll.fs ├── sdlconstants.fs ├── sdllib.bmp └── sdllib.fs ├── sdl-tut07 ├── sdl-1.0c.fs ├── sdl-ttf-1.00.fs ├── sdl-tut07-info.txt ├── sdl-tut07.fs ├── sdl-tut07.txt ├── sdlconstants.fs ├── sdllib-10c.png ├── sdllib.fs └── ttflib.fs ├── sdl-tut08 ├── font8x16.fs ├── sdl-1.0c.fs ├── sdl-basicfontdemo.fs ├── sdl-basicfontlib.fs ├── sdl-tut08-info.txt ├── sdl-tut08.txt ├── sdlconstants.fs ├── sdllib-10c.png └── sdllib.fs ├── sdl-tut09 ├── sdl-1.0d.fs ├── sdl-tut09-info.txt ├── sdl-tut09.fs ├── sdl-tut09.txt ├── sdlconstants.fs ├── sdlkeysym.fs ├── sdllib-10d.png └── sdllib.fs ├── sdl-tut10 ├── font8x16.fs ├── sdl-1.0e.fs ├── sdl-basicfontlib.fs ├── sdl-raycaster.fs ├── sdl-raycaster.txt ├── sdl-tut10-info.txt ├── sdlconstants.fs ├── sdlkeysym.fs ├── sdllib-10e.png └── sdllib.fs ├── sdl-tut11 ├── font8x16.fs ├── sdl-1.0e.fs ├── sdl-basicfontlib.fs ├── sdl-raycaster2.fs ├── sdl-raycaster2.txt ├── sdl-tut11-info.txt ├── sdlconstants.fs ├── sdlkeysym.fs ├── sdllib-10e.png ├── sdllib.fs └── wolftextures.png └── sdl-tut12 ├── font8x16.fs ├── sdl-1.0f.fs ├── sdl-basicfontlib.fs ├── sdl-raycast3-1.00.fs ├── sdl-raycaster3.fs ├── sdl-raycaster3.txt ├── sdl-tut12-info.txt ├── sdlconstants.fs ├── sdlkeysym.fs ├── sdllib-10f.png ├── sdllib.fs └── wolftextures.png /.gitignore: -------------------------------------------------------------------------------- 1 | *.zip 2 | *~ 3 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson01/mini-opengl-1.01.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 03 ]============================================ 2 | \ gforth: OpenGL Graphics Lesson 01 3 | \ =================================================================== 4 | \ File: mini-opengl-1.01.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 07/06/2010 7 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 01 8 | \ Forth System: gforth-0.7.0 9 | \ Assembler: Built-in FORTH assembler 10 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 11 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 12 | \ =================================================================== 13 | \ This libcc interface contains the cumulatively added OpenGL code 14 | \ function calls that are required for use with the gforth version of 15 | \ the NeHe OpenGL Tutorial Lessons. 16 | \ =================================================================== 17 | 18 | c-library mini_opengl_lib 19 | 20 | s" GL" add-lib 21 | s" GLU" add-lib 22 | 23 | \c #if defined(__APPLE__) && defined(__MACH__) 24 | \c #include 25 | \c #include 26 | \c #else 27 | \c #include 28 | \c #include 29 | \c #endif 30 | 31 | \ Initial Entries for Lesson 01 32 | c-function gl-clear glClear n -- void 33 | c-function gl-clear-color glClearColor r r r r -- void 34 | c-function gl-clear-depth glClearDepth r -- void 35 | c-function gl-enable glEnable n -- void 36 | c-function gl-depth-func glDepthFunc n -- void 37 | c-function gl-hint glHint n n -- void 38 | c-function gl-load-identity glLoadIdentity -- void 39 | c-function gl-matrix-mode glMatrixMode n -- void 40 | c-function gl-shade-model glShadeModel n -- void 41 | c-function gl-viewport glViewport n n n n -- void 42 | c-function glu-perspective gluPerspective r r r r -- void 43 | 44 | end-c-library 45 | 46 | include glconstants.fs 47 | 48 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson01/opengl-lesson01-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson01.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/06/2010 6 | Description: Setting up an OpenGL window 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 01 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 01 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson01/opengllib-1.01.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 02 ]============================================ 2 | \ gforth: OpenGL Graphics Lesson 01 3 | \ =================================================================== 4 | \ File: opengllib-1.01.fs 5 | \ Author: Jeff Molofee 6 | \ Linux Version: Ti Leggett 7 | \ gForth Version: Timothy Trussell, 07/06/2010 8 | \ Description: Setting up an OpenGL window 9 | \ Forth System: gforth-0.7.0 10 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 11 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 12 | \ =================================================================== 13 | \ NeHe Productions 14 | \ http://nehe.gamedev.net/ 15 | \ =================================================================== 16 | \ OpenGL Tutorial Lesson 01 17 | \ =================================================================== 18 | \ This code was created by Jeff Molofee '99 19 | \ (ported to Linux/SDL by Ti Leggett '01) 20 | \ Visit Jeff at http://nehe.gamedev.net/ 21 | \ =================================================================== 22 | 23 | require ~/.gforth/opengl-libs/mini-opengl-current.fs 24 | require ~/.gforth/opengl-libs/mini-sdl-1.00.fs 25 | require ~/.gforth/opengl-libs/sdlkeysym.fs 26 | 27 | \ ---[ Prototype Listing ]------------------------------------------- 28 | \ : HandleKeyPress ( &event -- ) 29 | \ : InitGL ( -- boolean ) 30 | \ : ShutDown ( -- ) 31 | \ : Reset-FPS-Counter ( -- ) 32 | \ : Display-FPS ( -- ) 33 | \ : DrawGLScene ( -- boolean ) 34 | \ ------------------------------------------------[End Prototypes]--- 35 | 36 | \ ---[ HandleKeyPress ]---------------------------------------------- 37 | \ function to handle key press events: 38 | \ ESC exits the program 39 | \ F1 toggles between fullscreen and windowed modes 40 | 41 | : HandleKeyPress ( &event -- ) 42 | sdl-keyboard-event-keysym sdl-keysym-sym uw@ 43 | case 44 | SDLK_ESCAPE of TRUE to opengl-exit-flag endof 45 | SDLK_F1 of screen sdl-wm-togglefullscreen drop endof 46 | endcase 47 | ; 48 | 49 | \ ---[ InitGL ]------------------------------------------------------ 50 | \ General OpenGL initialization function 51 | 52 | : InitGL ( -- boolean ) 53 | \ Enable smooth shading 54 | GL_SMOOTH gl-shade-model 55 | \ Set the background black 56 | 0e 0e 0e 0e gl-clear-color 57 | \ Depth buffer setup 58 | 1e gl-clear-depth 59 | \ Enable depth testing 60 | GL_DEPTH_TEST gl-enable 61 | \ Type of depth test to do 62 | GL_LEQUAL gl-depth-func 63 | \ Really nice perspective calculations 64 | GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST gl-hint 65 | \ Return a good value 66 | TRUE 67 | ; 68 | 69 | \ ---[ ShutDown ]---------------------------------------------------- 70 | \ Close down the system gracefully ;-) 71 | 72 | : ShutDown ( -- ) 73 | FALSE to opengl-exit-flag \ reset these flag for next time 74 | sdl-quit \ close down the SDL systems 75 | ; 76 | 77 | fvariable fps-seconds 78 | fvariable fps-count 79 | 0 value fps-ticks 80 | 0 value fps-t0 81 | 0 value fps-frames 82 | 0 value fps-line 83 | 84 | \ ---[ Reset-FPS-Counter ]------------------------------------------- 85 | 86 | : Reset-FPS-Counter ( -- ) 87 | sdl-get-ticks to fps-t0 88 | 0 to fps-frames 89 | ; 90 | 91 | \ ---[ Display-FPS ]------------------------------------------------- 92 | 93 | : Display-FPS ( -- ) 94 | sdl-get-ticks to fps-ticks 95 | fps-ticks fps-t0 - 1000 >= if 96 | fps-ticks fps-t0 - S>F 1000e F/ fps-seconds F! 97 | fps-frames S>F fps-seconds F@ F/ fps-count F! 98 | 0 fps-line at-xy 50 spaces \ clear previous fps display 99 | 0 fps-line at-xy \ display new fps count 100 | fps-frames . ." frames in " 101 | fps-seconds F@ F>S . ." seconds = " 102 | fps-count F@ F>S . ." FPS" cr 103 | fps-ticks to fps-t0 104 | 0 to fps-frames 105 | then 106 | ; 107 | 108 | \ ---[ DrawGLScene ]------------------------------------------------- 109 | \ Here goes our drawing code 110 | 111 | : DrawGLScene ( -- boolean ) 112 | \ Clear the screen and the depth buffer 113 | GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT OR gl-clear 114 | 115 | \ Reset the matrix 116 | gl-load-identity 117 | 118 | \ Draw it to the screen -- if double buffering is permitted 119 | sdl-gl-swap-buffers 120 | 121 | \ Gather our frames per second count 122 | fps-frames 1+ to fps-frames 123 | 124 | \ Display the FPS count to the terminal window 125 | Display-FPS 126 | 127 | \ Return a good value 128 | TRUE 129 | ; 130 | 131 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson02/mini-opengl-1.02.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 03 ]============================================ 2 | \ gforth: OpenGL Graphics Lesson 02 3 | \ =================================================================== 4 | \ File: mini-opengl-1.02.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 07/06/2010 7 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 02 8 | \ Forth System: gforth-0.7.0 9 | \ Assembler: Built-in FORTH assembler 10 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 11 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 12 | \ =================================================================== 13 | \ This libcc interface contains the cumulatively added OpenGL code 14 | \ function calls that are required for use with the gforth version of 15 | \ the NeHe OpenGL Tutorial Lessons. 16 | \ =================================================================== 17 | 18 | c-library mini_opengl_lib 19 | 20 | s" GL" add-lib 21 | s" GLU" add-lib 22 | 23 | \c #if defined(__APPLE__) && defined(__MACH__) 24 | \c #include 25 | \c #include 26 | \c #else 27 | \c #include 28 | \c #include 29 | \c #endif 30 | 31 | \ Initial Entries for Lesson 01 32 | c-function gl-clear glClear n -- void 33 | c-function gl-clear-color glClearColor r r r r -- void 34 | c-function gl-clear-depth glClearDepth r -- void 35 | c-function gl-enable glEnable n -- void 36 | c-function gl-depth-func glDepthFunc n -- void 37 | c-function gl-hint glHint n n -- void 38 | c-function gl-load-identity glLoadIdentity -- void 39 | c-function gl-matrix-mode glMatrixMode n -- void 40 | c-function gl-shade-model glShadeModel n -- void 41 | c-function gl-viewport glViewport n n n n -- void 42 | c-function glu-perspective gluPerspective r r r r -- void 43 | 44 | \ Additions for Lesson 02 45 | c-function gl-begin glBegin n -- void 46 | c-function gl-end glEnd -- void 47 | c-function gl-translate-f glTranslatef r r r -- void 48 | c-function gl-vertex-3f glVertex3f r r r -- void 49 | 50 | end-c-library 51 | 52 | include glconstants.fs 53 | 54 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson02/opengl-lesson02-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson02.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/06/2010 6 | Description: Your first polygon 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 02 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 02 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson02/opengl-lesson02.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 02 ]--------------[07/06/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson02.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 02 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-begin ( mode -- ) 33 | 34 | Starts the definition of a list of vertex data 35 | 36 | Parameter is a GLenum (gforth integer) type, that is 37 | defined in the glconstants.fs file. 38 | 39 | gl-end ( -- ) 40 | 41 | Ends the definition of the vertex data started by gl-begin 42 | 43 | gl-translate-f ( x y z -- ) 44 | 45 | Multiply the current matrix by a translation matrix 46 | 47 | Parameters , and are 32-bit floats. 48 | 49 | If the matrix mode is either GL_MODELVIEW or GL_PROJECTION, all 50 | objects drawn after a call to glTranslate are translated. 51 | 52 | (In gforth, as these are passed by value, there is no conversion 53 | necessary to make these values into 32-bit floats from the normal 54 | gforth 64-bit floating point value.) 55 | 56 | gl-vertex-3f ( x y z -- ) 57 | 58 | Parameters , and are 32-bit floats. 59 | 60 | glVertex commands are used within glBegin/glEnd pairs to specify 61 | point, line, and polygon vertices. The current color, normal, and 62 | texture coordinates are associated with the vertex when glVertex 63 | is called. 64 | 65 | (The parameters are passed by value...) 66 | 67 | ---[ Installation ]-------------------------------------------------- 68 | 69 | For the files received from the comp.lang.forth newsgroup, copy these 70 | files: 71 | 72 | opengl-lesson02.fs - Code Addendum 1 73 | opengllib-1.02.fs - Code Addendum 2 74 | mini-opengl-1.02.fs - Code Addendum 3 75 | 76 | to the same directory with ALL of the files from Lesson 01. 77 | 78 | For the files from the opengl-lesson02.zip, extract them to wherever 79 | you wish to place them, or extract the above three files into the 80 | directory you have placed the Lesson 01 files. 81 | 82 | From a terminal window, cd to your directory, and execute the LibUtil 83 | program: 84 | 85 | ./libutil.sh -r 86 | 87 | to remove the previous mini_opengl_lib compilations (after you have 88 | compiled/run Lesson 01, of course), then execute it again: 89 | 90 | ./libutil.sh -i 91 | 92 | to install the libcc interface for this second Lesson. 93 | 94 | Then: 95 | gforth 96 | include opengl-lesson02.fs 97 | lesson02 98 | 99 | 100 | 101 | ---[ Next Up ]------------------------------------------------------- 102 | 103 | Lesson 3 - Adding color 104 | 105 | ----------------------------------------------------[End Lesson02]--- 106 | 107 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson02/opengllib-1.02.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 02 ]============================================ 2 | \ gforth: OpenGL Graphics Lesson 02 3 | \ =================================================================== 4 | \ File: opengllib-1.02.fs 5 | \ Author: Jeff Molofee 6 | \ Linux Version: Ti Leggett 7 | \ gForth Version: Timothy Trussell, 07/06/2010 8 | \ Description: Your first polygon 9 | \ Forth System: gforth-0.7.0 10 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 11 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 12 | \ =================================================================== 13 | \ NeHe Productions 14 | \ http://nehe.gamedev.net/ 15 | \ =================================================================== 16 | \ OpenGL Tutorial Lesson 02 17 | \ =================================================================== 18 | \ This code was created by Jeff Molofee '99 19 | \ (ported to Linux/SDL by Ti Leggett '01) 20 | \ Visit Jeff at http://nehe.gamedev.net/ 21 | \ =================================================================== 22 | 23 | require ~/.gforth/opengl-libs/mini-opengl-current.fs 24 | require ~/.gforth/opengl-libs/mini-sdl-1.00.fs 25 | require ~/.gforth/opengl-libs/sdlkeysym.fs 26 | 27 | \ ---[ Prototype Listing ]------------------------------------------- 28 | \ : HandleKeyPress ( &event -- ) 29 | \ : InitGL ( -- boolean ) 30 | \ : ShutDown ( -- ) 31 | \ : Reset-FPS-Counter ( -- ) 32 | \ : Display-FPS ( -- ) 33 | \ : DrawGLScene ( -- boolean ) 34 | \ ------------------------------------------------[End Prototypes]--- 35 | 36 | \ ---[ HandleKeyPress ]---------------------------------------------- 37 | \ function to handle key press events: 38 | \ ESC exits the program 39 | \ F1 toggles between fullscreen and windowed modes 40 | 41 | : HandleKeyPress ( &event -- ) 42 | sdl-keyboard-event-keysym sdl-keysym-sym uw@ 43 | case 44 | SDLK_ESCAPE of TRUE to opengl-exit-flag endof 45 | SDLK_F1 of screen sdl-wm-togglefullscreen drop endof 46 | endcase 47 | ; 48 | 49 | \ ---[ InitGL ]------------------------------------------------------ 50 | \ general OpenGL initialization function 51 | 52 | : InitGL ( -- boolean ) 53 | \ Enable smooth shading 54 | GL_SMOOTH gl-shade-model 55 | \ Set the background black 56 | 0e 0e 0e 0e gl-clear-color 57 | \ Depth buffer setup 58 | 1e gl-clear-depth 59 | \ Enable depth testing 60 | GL_DEPTH_TEST gl-enable 61 | \ Type of depth test to do 62 | GL_LEQUAL gl-depth-func 63 | \ Really nice perspective calculations 64 | GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST gl-hint 65 | \ Return a good value 66 | TRUE 67 | ; 68 | 69 | \ ---[ ShutDown ]---------------------------------------------------- 70 | \ Close down the system gracefully ;-) 71 | 72 | : ShutDown ( -- ) 73 | FALSE to opengl-exit-flag \ reset these flag for next time 74 | sdl-quit \ close down the SDL systems 75 | ; 76 | 77 | fvariable fps-seconds 78 | fvariable fps-count 79 | 0 value fps-ticks 80 | 0 value fps-t0 81 | 0 value fps-frames 82 | 0 value fps-line 83 | 84 | \ ---[ Reset-FPS-Counter ]------------------------------------------- 85 | 86 | : Reset-FPS-Counter ( -- ) 87 | sdl-get-ticks to fps-t0 88 | 0 to fps-frames 89 | ; 90 | 91 | \ ---[ Display-FPS ]------------------------------------------------- 92 | 93 | : Display-FPS ( -- ) 94 | sdl-get-ticks to fps-ticks 95 | fps-ticks fps-t0 - 1000 >= if 96 | fps-ticks fps-t0 - S>F 1000e F/ fps-seconds F! 97 | fps-frames S>F fps-seconds F@ F/ fps-count F! 98 | 0 fps-line at-xy 50 spaces \ clear previous fps display 99 | 0 fps-line at-xy \ display new fps count 100 | fps-frames . ." frames in " 101 | fps-seconds F@ F>S . ." seconds = " 102 | fps-count F@ F>S . ." FPS" cr 103 | fps-ticks to fps-t0 104 | 0 to fps-frames 105 | then 106 | ; 107 | 108 | \ ---[ DrawGLScene ]------------------------------------------------- 109 | \ Here goes our drawing code 110 | 111 | : DrawGLScene ( -- boolean ) 112 | \ Clear the screen and the depth buffer 113 | GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT OR gl-clear 114 | 115 | gl-load-identity 116 | 117 | \ Move left 1.5 units, and into the screen 6.0 118 | -1.5e 0e -6e gl-translate-f 119 | GL_TRIANGLES gl-begin \ drawing using triangles 120 | 0e 1e 0e gl-vertex-3f \ top 121 | -1e -1e 0e gl-vertex-3f \ bottom left 122 | 1e -1e 0e gl-vertex-3f \ bottom right 123 | gl-end \ finished drawing the triangle 124 | 125 | \ Move right 3 units 126 | 3e 0e 0e gl-translate-f 127 | GL_QUADS gl-begin \ draw a quad 128 | -1e 1e 0e gl-vertex-3f \ top left 129 | 1e 1e 0e gl-vertex-3f \ top right 130 | 1e -1e 0e gl-vertex-3f \ bottom right 131 | -1e -1e 0e gl-vertex-3f \ bottom left 132 | gl-end 133 | 134 | \ Draw it to the screen 135 | sdl-gl-swap-buffers 136 | 137 | \ Gather our frames per second count 138 | fps-frames 1+ to fps-frames 139 | 140 | \ Display the FPS count to the terminal window 141 | Display-FPS 142 | 143 | \ Return a good value 144 | TRUE 145 | ; 146 | 147 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson03/mini-opengl-1.03.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 03 ]============================================ 2 | \ gforth: OpenGL Graphics Lesson 03 3 | \ =================================================================== 4 | \ File: mini-opengl-1.03.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 07/06/2010 7 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 03 8 | \ Forth System: gforth-0.7.0 9 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 10 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 11 | \ =================================================================== 12 | \ This libcc interface contains the cumulatively added OpenGL code 13 | \ function calls that are required for use with the gforth version of 14 | \ the NeHe OpenGL Tutorial Lessons. 15 | \ =================================================================== 16 | 17 | c-library mini_opengl_lib 18 | 19 | s" GL" add-lib 20 | s" GLU" add-lib 21 | 22 | \c #if defined(__APPLE__) && defined(__MACH__) 23 | \c #include 24 | \c #include 25 | \c #else 26 | \c #include 27 | \c #include 28 | \c #endif 29 | 30 | \ Initial Entries for Lesson 01 31 | c-function gl-clear glClear n -- void 32 | c-function gl-clear-color glClearColor r r r r -- void 33 | c-function gl-clear-depth glClearDepth r -- void 34 | c-function gl-enable glEnable n -- void 35 | c-function gl-depth-func glDepthFunc n -- void 36 | c-function gl-hint glHint n n -- void 37 | c-function gl-load-identity glLoadIdentity -- void 38 | c-function gl-matrix-mode glMatrixMode n -- void 39 | c-function gl-shade-model glShadeModel n -- void 40 | c-function gl-viewport glViewport n n n n -- void 41 | c-function glu-perspective gluPerspective r r r r -- void 42 | 43 | \ Additions for Lesson 02 44 | c-function gl-begin glBegin n -- void 45 | c-function gl-end glEnd -- void 46 | c-function gl-translate-f glTranslatef r r r -- void 47 | c-function gl-vertex-3f glVertex3f r r r -- void 48 | 49 | \ Additions for Lesson 03 50 | c-function gl-color-3f glColor3f r r r -- void 51 | 52 | end-c-library 53 | 54 | include glconstants.fs 55 | 56 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson03/opengl-lesson03-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson03.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/06/2010 6 | Description: Adding Color 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 03 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 03 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson03/opengl-lesson03.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 03 ]--------------[07/06/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson03.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 03 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-color-3f ( r g b -- ) 33 | 34 | Parameters , and are 32-bit floats. 35 | 36 | Specify new red, green, and blue values for the current color. 37 | 38 | The value range for the colors is from 0.0 to 1.0, with: 39 | 40 | r=0.0, g=0.0, b=0.0 meaning black, and 41 | r=1.0, g=1.0, b=1.0 meaning full white 42 | 43 | (In gforth, as these are passed by value, there is no conversion 44 | necessary to make these values into 32-bit floats from the normal 45 | gforth 64-bit floating point value.) 46 | 47 | ---[ Installation ]-------------------------------------------------- 48 | 49 | For the files received from the comp.lang.forth newsgroup, copy these 50 | files: 51 | 52 | opengl-lesson03.fs - Code Addendum 1 53 | opengllib-1.03.fs - Code Addendum 2 54 | mini-opengl-1.03.fs - Code Addendum 3 55 | 56 | to the same directory with the previous Lesson files. 57 | 58 | For the files from the opengl-lesson03.zip, extract them to wherever 59 | you wish to place them, or extract the above three files into the 60 | directory you have placed the previous Lesson files. 61 | 62 | From a terminal window, cd to your directory, and execute the LibUtil 63 | program: 64 | 65 | ./libutil.sh -r 66 | 67 | to remove the previous mini_opengl_lib compilations (after you have 68 | compiled/run the previous Lessons, of course), then execute it again: 69 | 70 | ./libutil.sh -i 71 | 72 | to install the libcc interface for this second Lesson. 73 | 74 | Then: 75 | gforth 76 | include opengl-lesson03.fs 77 | lesson03 78 | 79 | ---[ Next Up ]------------------------------------------------------- 80 | 81 | Lesson 4 - Rotation 82 | 83 | ----------------------------------------------------[End Lesson03]--- 84 | 85 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson03/opengllib-1.03.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 02 ]============================================ 2 | \ gforth: OpenGL Graphics Lesson 03 3 | \ =================================================================== 4 | \ File: opengllib-1.03.fs 5 | \ Author: Jeff Molofee 6 | \ Linux Version: Ti Leggett 7 | \ gForth Version: Timothy Trussell, 07/06/2010 8 | \ Description: Adding color 9 | \ Forth System: gforth-0.7.0 10 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 11 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 12 | \ =================================================================== 13 | \ NeHe Productions 14 | \ http://nehe.gamedev.net/ 15 | \ =================================================================== 16 | \ OpenGL Tutorial Lesson 03 17 | \ =================================================================== 18 | \ This code was created by Jeff Molofee '99 19 | \ (ported to Linux/SDL by Ti Leggett '01) 20 | \ Visit Jeff at http://nehe.gamedev.net/ 21 | \ =================================================================== 22 | 23 | require ~/.gforth/opengl-libs/mini-opengl-current.fs 24 | require ~/.gforth/opengl-libs/mini-sdl-1.00.fs 25 | require ~/.gforth/opengl-libs/sdlkeysym.fs 26 | 27 | \ ---[ Prototype Listing ]------------------------------------------- 28 | \ : HandleKeyPress ( &event -- ) 29 | \ : InitGL ( -- boolean ) 30 | \ : ShutDown ( -- ) 31 | \ : Reset-FPS-Counter ( -- ) 32 | \ : Display-FPS ( -- ) 33 | \ : DrawGLScene ( -- boolean ) 34 | \ ------------------------------------------------[End Prototypes]--- 35 | 36 | \ ---[ HandleKeyPress ]---------------------------------------------- 37 | \ function to handle key press events: 38 | \ ESC exits the program 39 | \ F1 toggles between fullscreen and windowed modes 40 | 41 | : HandleKeyPress ( &event -- ) 42 | sdl-keyboard-event-keysym sdl-keysym-sym uw@ 43 | case 44 | SDLK_ESCAPE of TRUE to opengl-exit-flag endof 45 | SDLK_F1 of screen sdl-wm-togglefullscreen drop endof 46 | endcase 47 | ; 48 | 49 | \ ---[ InitGL ]------------------------------------------------------ 50 | \ General OpenGL initialization function 51 | 52 | : InitGL ( -- boolean ) 53 | \ Enable smooth shading 54 | GL_SMOOTH gl-shade-model 55 | \ Set the background black 56 | 0e 0e 0e 0e gl-clear-color 57 | \ Depth buffer setup 58 | 1e gl-clear-depth 59 | \ Enable depth testing 60 | GL_DEPTH_TEST gl-enable 61 | \ Type of depth test to do 62 | GL_LEQUAL gl-depth-func 63 | \ Really nice perspective calculations 64 | GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST gl-hint 65 | \ Return a good value 66 | TRUE 67 | ; 68 | 69 | \ ---[ ShutDown ]---------------------------------------------------- 70 | \ Close down the system gracefully ;-) 71 | 72 | : ShutDown ( -- ) 73 | FALSE to opengl-exit-flag \ reset these flag for next time 74 | sdl-quit \ close down the SDL systems 75 | ; 76 | 77 | fvariable fps-seconds 78 | fvariable fps-count 79 | 0 value fps-ticks 80 | 0 value fps-t0 81 | 0 value fps-frames 82 | 0 value fps-line 83 | 84 | \ ---[ Reset-FPS-Counter ]------------------------------------------- 85 | 86 | : Reset-FPS-Counter ( -- ) 87 | sdl-get-ticks to fps-t0 88 | 0 to fps-frames 89 | ; 90 | 91 | \ ---[ Display-FPS ]------------------------------------------------- 92 | 93 | : Display-FPS ( -- ) 94 | sdl-get-ticks to fps-ticks 95 | fps-ticks fps-t0 - 1000 >= if 96 | fps-ticks fps-t0 - S>F 1000e F/ fps-seconds F! 97 | fps-frames S>F fps-seconds F@ F/ fps-count F! 98 | 0 fps-line at-xy 50 spaces \ clear previous fps display 99 | 0 fps-line at-xy \ display new fps count 100 | fps-frames . ." frames in " 101 | fps-seconds F@ F>S . ." seconds = " 102 | fps-count F@ F>S . ." FPS" cr 103 | fps-ticks to fps-t0 104 | 0 to fps-frames 105 | then 106 | ; 107 | 108 | \ ---[ DrawGLScene ]------------------------------------------------- 109 | \ Here goes our drawing code 110 | 111 | : DrawGLScene ( -- boolean ) 112 | \ Clear the screen and the depth buffer 113 | GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT OR gl-clear 114 | 115 | \ Reset the matrix 116 | gl-load-identity 117 | 118 | \ Move left 1.5 units, and into the screen 6.0 119 | -1.5e 0e -6e gl-translate-f 120 | 121 | GL_TRIANGLES gl-begin \ drawing using triangles 122 | 1e 0e 0e gl-color-3f \ red 123 | 0e 1e 0e gl-vertex-3f \ top of triangle 124 | 0e 1e 0e gl-color-3f \ green 125 | -1e -1e 0e gl-vertex-3f \ left of triangle 126 | 0e 0e 1e gl-color-3f \ blue 127 | 1e -1e 0e gl-vertex-3f \ right of triangle 128 | gl-end \ finished drawing the triangle 129 | 130 | \ Move right 3 units 131 | 3e 0e 0e gl-translate-f 132 | 0.5e 0.5e 1e gl-color-3f \ Set The Color To Blue One Time Only 133 | 134 | GL_QUADS gl-begin \ draw a quad 135 | 1e 1e 0e gl-vertex-3f \ top right 136 | -1e 1e 0e gl-vertex-3f \ top left 137 | -1e -1e 0e gl-vertex-3f \ bottom left 138 | 1e -1e 0e gl-vertex-3f \ bottom right 139 | gl-end 140 | 141 | \ Draw it to the screen -- if double buffering is permitted 142 | sdl-gl-swap-buffers 143 | 144 | \ Gather our frames per second count 145 | fps-frames 1+ to fps-frames 146 | 147 | \ Display the FPS count to the terminal window 148 | Display-FPS 149 | 150 | \ Return a good value 151 | TRUE 152 | ; 153 | 154 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson04/mini-opengl-1.04.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 03 ]============================================ 2 | \ gforth: OpenGL Graphics Lesson 04 3 | \ =================================================================== 4 | \ Program: mini-opengl-1.04.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 07/07/2010 7 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 04 8 | \ Forth System: gforth-0.7.0 9 | \ Assembler: Built-in FORTH assembler 10 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 11 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 12 | \ =================================================================== 13 | \ This libcc interface contains the cumulatively added OpenGL code 14 | \ function calls that are required for use with the gforth version of 15 | \ the NeHe OpenGL Tutorial Lessons. 16 | \ =================================================================== 17 | 18 | c-library mini_opengl_lib 19 | 20 | s" GL" add-lib 21 | s" GLU" add-lib 22 | 23 | \c #if defined(__APPLE__) && defined(__MACH__) 24 | \c #include 25 | \c #include 26 | \c #else 27 | \c #include 28 | \c #include 29 | \c #endif 30 | 31 | \ Initial Entries for Lesson 01 32 | c-function gl-clear glClear n -- void 33 | c-function gl-clear-color glClearColor r r r r -- void 34 | c-function gl-clear-depth glClearDepth r -- void 35 | c-function gl-enable glEnable n -- void 36 | c-function gl-depth-func glDepthFunc n -- void 37 | c-function gl-hint glHint n n -- void 38 | c-function gl-load-identity glLoadIdentity -- void 39 | c-function gl-matrix-mode glMatrixMode n -- void 40 | c-function gl-shade-model glShadeModel n -- void 41 | c-function gl-viewport glViewport n n n n -- void 42 | c-function glu-perspective gluPerspective r r r r -- void 43 | 44 | \ Additions for Lesson 02 45 | c-function gl-begin glBegin n -- void 46 | c-function gl-end glEnd -- void 47 | c-function gl-translate-f glTranslatef r r r -- void 48 | c-function gl-vertex-3f glVertex3f r r r -- void 49 | 50 | \ Additions for Lesson 03 51 | c-function gl-color-3f glColor3f r r r -- void 52 | 53 | \ Additions for Lesson 04 54 | c-function gl-rotate-f glRotatef r r r r -- void 55 | 56 | end-c-library 57 | 58 | include glconstants.fs 59 | 60 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson04/opengl-lesson04-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson04.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/07/2010 6 | Description: Rotation 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 04 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 04 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson04/opengl-lesson04.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 04 ]--------------[07/07/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson04.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 04 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-rotate-f ( angle x y z -- ) 33 | 34 | Multiply the current matrix by a rotation matrix 35 | 36 | Parameters , , and are 32-bit floats. 37 | 38 | angle: Specifies the angle of rotation, in degrees. 39 | x/y/z: Specify the x, y, and z coordinates of a vector. 40 | 41 | (In gforth, as these are passed by value, there is no conversion 42 | necessary to make these values into 32-bit floats from the normal 43 | gforth 64-bit floating point value.) 44 | 45 | ---[ Installation ]-------------------------------------------------- 46 | 47 | For the files received from the comp.lang.forth newsgroup, copy these 48 | files: 49 | 50 | opengl-lesson04.fs - Code Addendum 1 51 | opengllib-1.04.fs - Code Addendum 2 52 | mini-opengl-1.04.fs - Code Addendum 3 53 | 54 | to the same directory with the previous Lesson files. 55 | 56 | For the files from the opengl-lesson04.zip, extract them to wherever 57 | you wish to place them, or extract the above three files into the 58 | directory you have placed the previous Lesson files. 59 | 60 | From a terminal window, cd to your directory, and execute the LibUtil 61 | program: 62 | 63 | ./libutil.sh -r 64 | 65 | to remove the previous mini_opengl_lib compilations (after you have 66 | compiled/run the previous Lessons, of course), then execute it again: 67 | 68 | ./libutil.sh -i 69 | 70 | to install the libcc interface for this second Lesson. 71 | 72 | Then: 73 | gforth 74 | include opengl-lesson03.fs 75 | lesson04 76 | 77 | ---[ Next Up ]------------------------------------------------------- 78 | 79 | Lesson 5 - 3D shapes 80 | 81 | ----------------------------------------------------[End Lesson04]--- 82 | 83 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson05/mini-opengl-1.05.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 03 ]============================================ 2 | \ gforth: OpenGL Graphics Lesson 05 3 | \ =================================================================== 4 | \ Program: mini-opengl-1.05.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 07/07/2010 7 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 05 8 | \ Forth System: gforth-0.7.0 9 | \ Assembler: Built-in FORTH assembler 10 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 11 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 12 | \ =================================================================== 13 | \ This libcc interface contains the cumulatively added OpenGL code 14 | \ function calls that are required for use with the gforth version of 15 | \ the NeHe OpenGL Tutorial Lessons. 16 | \ =================================================================== 17 | 18 | c-library mini_opengl_lib 19 | 20 | s" GL" add-lib 21 | s" GLU" add-lib 22 | 23 | \c #if defined(__APPLE__) && defined(__MACH__) 24 | \c #include 25 | \c #include 26 | \c #else 27 | \c #include 28 | \c #include 29 | \c #endif 30 | 31 | \ Initial Entries for Lesson 01 32 | c-function gl-clear glClear n -- void 33 | c-function gl-clear-color glClearColor r r r r -- void 34 | c-function gl-clear-depth glClearDepth r -- void 35 | c-function gl-enable glEnable n -- void 36 | c-function gl-depth-func glDepthFunc n -- void 37 | c-function gl-hint glHint n n -- void 38 | c-function gl-load-identity glLoadIdentity -- void 39 | c-function gl-matrix-mode glMatrixMode n -- void 40 | c-function gl-shade-model glShadeModel n -- void 41 | c-function gl-viewport glViewport n n n n -- void 42 | c-function glu-perspective gluPerspective r r r r -- void 43 | 44 | \ Additions for Lesson 02 45 | c-function gl-begin glBegin n -- void 46 | c-function gl-end glEnd -- void 47 | c-function gl-translate-f glTranslatef r r r -- void 48 | c-function gl-vertex-3f glVertex3f r r r -- void 49 | 50 | \ Additions for Lesson 03 51 | c-function gl-color-3f glColor3f r r r -- void 52 | 53 | \ Additions for Lesson 04 54 | c-function gl-rotate-f glRotatef r r r r -- void 55 | 56 | \ Additions for Lesson 05 57 | \ -- none 58 | 59 | end-c-library 60 | 61 | include glconstants.fs 62 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson05/opengl-lesson05-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson05.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/07/2010 6 | Description: 3D Shapes 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 05 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 05 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson05/opengl-lesson05.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 05 ]--------------[07/07/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson05.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 05 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | There are no new additions to the mini-opengl libcc interface for 31 | this lesson. 32 | 33 | ---[ Installation ]-------------------------------------------------- 34 | 35 | For the files received from the comp.lang.forth newsgroup, copy these 36 | files: 37 | 38 | opengl-lesson05.fs - Code Addendum 1 39 | opengllib-1.05.fs - Code Addendum 2 40 | mini-opengl-1.05.fs - Code Addendum 3 41 | 42 | to the same directory with the previous Lesson files. 43 | 44 | For the files from the opengl-lesson05.zip, extract them to wherever 45 | you wish to place them, or extract the above three files into the 46 | directory you have placed the previous Lesson files. 47 | 48 | From a terminal window, cd to your directory, and execute the LibUtil 49 | program: 50 | 51 | ./libutil.sh -r 52 | 53 | to remove the previous mini_opengl_lib compilations (after you have 54 | compiled/run the previous Lessons, of course), then execute it again: 55 | 56 | ./libutil.sh -i 57 | 58 | to install the libcc interface for this second Lesson. 59 | 60 | Then: 61 | gforth 62 | include opengl-lesson05.fs 63 | lesson05 64 | 65 | ---[ Next Up ]------------------------------------------------------- 66 | 67 | Lesson 6 - Texture mapping 68 | 69 | ----------------------------------------------------[End Lesson05]--- 70 | 71 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson06/data/nehe.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson06/data/nehe.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson06/mini-opengl-1.06.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 03 ]============================================ 2 | \ gforth: OpenGL Graphics Lesson 06 3 | \ =================================================================== 4 | \ File: mini-opengl-1.06.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 07/24/2010 7 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 06 8 | \ Forth System: gforth-0.7.0 9 | \ Assembler: Built-in FORTH assembler 10 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 11 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 12 | \ =================================================================== 13 | \ This libcc interface contains the cumulatively added OpenGL code 14 | \ function calls that are required for use with the gforth version of 15 | \ the NeHe OpenGL Tutorial Lessons. 16 | \ =================================================================== 17 | 18 | UseLibUtil [if] 19 | c-library mini_opengl_lib 20 | [else] 21 | c-library mini_opengl_lib06 22 | [then] 23 | 24 | s" GL" add-lib 25 | s" GLU" add-lib 26 | 27 | \c #if defined(__APPLE__) && defined(__MACH__) 28 | \c #include 29 | \c #include 30 | \c #else 31 | \c #include 32 | \c #include 33 | \c #endif 34 | 35 | \ Initial Entries for Lesson 01 36 | c-function gl-clear glClear n -- void 37 | c-function gl-clear-color glClearColor r r r r -- void 38 | c-function gl-clear-depth glClearDepth r -- void 39 | c-function gl-enable glEnable n -- void 40 | c-function gl-depth-func glDepthFunc n -- void 41 | c-function gl-hint glHint n n -- void 42 | c-function gl-load-identity glLoadIdentity -- void 43 | c-function gl-matrix-mode glMatrixMode n -- void 44 | c-function gl-shade-model glShadeModel n -- void 45 | c-function gl-viewport glViewport n n n n -- void 46 | c-function glu-perspective gluPerspective r r r r -- void 47 | 48 | \ Additions for Lesson 02 49 | c-function gl-begin glBegin n -- void 50 | c-function gl-end glEnd -- void 51 | c-function gl-translate-f glTranslatef r r r -- void 52 | c-function gl-vertex-3f glVertex3f r r r -- void 53 | 54 | \ Additions for Lesson 03 55 | c-function gl-color-3f glColor3f r r r -- void 56 | 57 | \ Additions for Lesson 04 58 | c-function gl-rotate-f glRotatef r r r r -- void 59 | 60 | \ Additions for Lesson 05 61 | \ -- none 62 | 63 | \ Additions for Lesson 06 64 | c-function gl-bind-texture glBindTexture n n -- void 65 | c-function gl-gen-textures glGenTextures n a -- void 66 | c-function gl-tex-coord-2f glTexCoord2f r r -- void 67 | c-function gl-tex-image-2d glTexImage2D n n n n n n n n a -- void 68 | c-function gl-tex-parameter-i glTexParameteri n n n -- void 69 | 70 | end-c-library 71 | 72 | include glconstants.fs 73 | 74 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson06/opengl-lesson06-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson06.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/24/2010 6 | Description: Texture Mapping 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 06 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 06 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson07/data/crate.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson07/data/crate.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson07/mini-opengl-1.07.fs: -------------------------------------------------------------------------------- 1 | \ =================================================================== 2 | \ Program: mini-opengl-1.07.fs 3 | \ Author: Timothy Trussell 4 | \ Date: 07/25/2010 5 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 07 6 | \ Forth System: gforth-0.7.0 7 | \ Assembler: Built-in FORTH assembler 8 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | \ =================================================================== 11 | \ This libcc interface contains the cumulatively added OpenGL code 12 | \ function calls that are required for use with the gforth version of 13 | \ the NeHe OpenGL Tutorial Lessons. 14 | \ =================================================================== 15 | 16 | UseLibUtil [if] 17 | c-library mini_opengl_lib 18 | [else] 19 | c-library mini_opengl_lib07 20 | [then] 21 | 22 | s" GL" add-lib 23 | s" GLU" add-lib 24 | 25 | \c #if defined(__APPLE__) && defined(__MACH__) 26 | \c #include 27 | \c #include 28 | \c #else 29 | \c #include 30 | \c #include 31 | \c #endif 32 | 33 | \ Initial Entries for Lesson 01 34 | c-function gl-clear glClear n -- void 35 | c-function gl-clear-color glClearColor r r r r -- void 36 | c-function gl-clear-depth glClearDepth r -- void 37 | c-function gl-enable glEnable n -- void 38 | c-function gl-depth-func glDepthFunc n -- void 39 | c-function gl-hint glHint n n -- void 40 | c-function gl-load-identity glLoadIdentity -- void 41 | c-function gl-matrix-mode glMatrixMode n -- void 42 | c-function gl-shade-model glShadeModel n -- void 43 | c-function gl-viewport glViewport n n n n -- void 44 | c-function glu-perspective gluPerspective r r r r -- void 45 | 46 | \ Additions for Lesson 02 47 | c-function gl-begin glBegin n -- void 48 | c-function gl-end glEnd -- void 49 | c-function gl-translate-f glTranslatef r r r -- void 50 | c-function gl-vertex-3f glVertex3f r r r -- void 51 | 52 | \ Additions for Lesson 03 53 | c-function gl-color-3f glColor3f r r r -- void 54 | 55 | \ Additions for Lesson 04 56 | c-function gl-rotate-f glRotatef r r r r -- void 57 | 58 | \ Additions for Lesson 05 59 | \ -- none 60 | 61 | \ Additions for Lesson 06 62 | c-function gl-bind-texture glBindTexture n n -- void 63 | c-function gl-gen-textures glGenTextures n a -- void 64 | c-function gl-tex-coord-2f glTexCoord2f r r -- void 65 | c-function gl-tex-image-2d glTexImage2D n n n n n n n n a -- void 66 | c-function gl-tex-parameter-i glTexParameteri n n n -- void 67 | 68 | \ Additions for Lesson 07 69 | c-function gl-disable glDisable n -- void 70 | c-function gl-light-fv glLightfv n n a -- void 71 | c-function gl-normal-3f glNormal3f r r r -- void 72 | c-function glu-build-2d-mipmaps gluBuild2DMipmaps n n n n n n a -- void 73 | 74 | end-c-library 75 | 76 | include glconstants.fs 77 | 78 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson07/opengl-lesson07-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson07.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/25/2010 6 | Description: Filters, lighting and keyboard 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 07 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 07 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson08/data/glass.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson08/data/glass.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson08/mini-opengl-1.08.fs: -------------------------------------------------------------------------------- 1 | \ =================================================================== 2 | \ Program: mini-opengl-1.08.fs 3 | \ Author: Timothy Trussell 4 | \ Date: 07/25/2010 5 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 08 6 | \ Forth System: gforth-0.7.0 7 | \ Assembler: Built-in FORTH assembler 8 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | \ =================================================================== 11 | \ This libcc interface contains the cumulatively added OpenGL code 12 | \ function calls that are required for use with the gforth version of 13 | \ the NeHe OpenGL Tutorial Lessons. 14 | \ =================================================================== 15 | 16 | UseLibUtil [if] 17 | c-library mini_opengl_lib 18 | [else] 19 | c-library mini_opengl_lib08 20 | [then] 21 | 22 | s" GL" add-lib 23 | s" GLU" add-lib 24 | 25 | \c #if defined(__APPLE__) && defined(__MACH__) 26 | \c #include 27 | \c #include 28 | \c #else 29 | \c #include 30 | \c #include 31 | \c #endif 32 | 33 | \ Initial Entries for Lesson 01 34 | c-function gl-clear glClear n -- void 35 | c-function gl-clear-color glClearColor r r r r -- void 36 | c-function gl-clear-depth glClearDepth r -- void 37 | c-function gl-enable glEnable n -- void 38 | c-function gl-depth-func glDepthFunc n -- void 39 | c-function gl-hint glHint n n -- void 40 | c-function gl-load-identity glLoadIdentity -- void 41 | c-function gl-matrix-mode glMatrixMode n -- void 42 | c-function gl-shade-model glShadeModel n -- void 43 | c-function gl-viewport glViewport n n n n -- void 44 | c-function glu-perspective gluPerspective r r r r -- void 45 | 46 | \ Additions for Lesson 02 47 | c-function gl-begin glBegin n -- void 48 | c-function gl-end glEnd -- void 49 | c-function gl-translate-f glTranslatef r r r -- void 50 | c-function gl-vertex-3f glVertex3f r r r -- void 51 | 52 | \ Additions for Lesson 03 53 | c-function gl-color-3f glColor3f r r r -- void 54 | 55 | \ Additions for Lesson 04 56 | c-function gl-rotate-f glRotatef r r r r -- void 57 | 58 | \ Additions for Lesson 05 59 | \ -- none 60 | 61 | \ Additions for Lesson 06 62 | c-function gl-bind-texture glBindTexture n n -- void 63 | c-function gl-gen-textures glGenTextures n a -- void 64 | c-function gl-tex-coord-2f glTexCoord2f r r -- void 65 | c-function gl-tex-image-2d glTexImage2D n n n n n n n n a -- void 66 | c-function gl-tex-parameter-i glTexParameteri n n n -- void 67 | 68 | \ Additions for Lesson 07 69 | c-function gl-disable glDisable n -- void 70 | c-function gl-light-fv glLightfv n n a -- void 71 | c-function gl-normal-3f glNormal3f r r r -- void 72 | c-function glu-build-2d-mipmaps gluBuild2DMipmaps n n n n n n a -- void 73 | 74 | \ Additions for Lesson 08 75 | c-function gl-blend-func glBlendFunc n n -- void 76 | c-function gl-color-4f glColor4f r r r r -- void 77 | 78 | end-c-library 79 | 80 | include glconstants.fs 81 | 82 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson08/opengl-lesson08-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson08.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/25/2010 6 | Description: Blending 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 08 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 08 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson08/opengl-lesson08.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 08 ]--------------[07/25/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson08.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 08 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-blend-func ( sfactor dfactor -- ) 33 | 34 | Specify pixel arithmetic. 35 | 36 | Parameters and are integer values. 37 | 38 | sfactor: Specifies how the red, green, blue, and alpha source 39 | blending factors are computed. The following symbolic 40 | constants are accepted: 41 | 42 | GL_ZERO, GL_ONE, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, 43 | GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, 44 | GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA_SATURATE 45 | 46 | The initial value is GL_ONE. Additionally, if the 47 | GL_ARB_imaging extension is supported, the following 48 | constants are accepted: 49 | 50 | GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, 51 | GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA. 52 | 53 | dfactor: Specifies how the red, green, blue, and alpha 54 | destination blending factors are computed. Eight symbolic 55 | constants are accepted: 56 | 57 | GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, 58 | GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, 59 | GL_ONE_MINUS_DST_ALPHA 60 | 61 | The initial value is GL_ZERO. Additionally, if the 62 | GL_ARB_imaging extension is supported, the following 63 | constants are accepted: 64 | 65 | GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, 66 | GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA. 67 | 68 | gl-color-4f ( red green blue alpha -- ) 69 | 70 | Set the current color. 71 | 72 | Parameters are 32-bit floats in the range 0.0 to 1.0 73 | 74 | ---[ Installation ]-------------------------------------------------- 75 | 76 | If you are placing all of the Lessons in one directory, copy these 77 | three files to that directory: 78 | 79 | opengl-lesson08.fs - Code Addendum 1 80 | opengllib-1.08.fs - Code Addendum 2 81 | mini-opengl-1.08.fs - Code Addendum 3 82 | 83 | This Lesson requires the mini-sdl-1.01.fs file from Lesson 6, as well 84 | as all of the usual constants definition files. 85 | 86 | This Lesson also uses an image file which, as with Lesson 6, you can 87 | retrieve immediately from the NeHe Lesson 7 page at: 88 | 89 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=08 90 | 91 | or from the opengl-lesson08.zip file that will be posted to the 92 | Taygeta Forth Archives site listed at the start of this column. 93 | 94 | For the files from the opengl-lesson08.zip, extract them to wherever 95 | you wish to place them, or extract the above three files and the data 96 | directory into the directory you have placed the previous Lesson 97 | files. 98 | 99 | To use the LibUtil script, set the flag in opengllib-1.08.fs: 100 | 101 | 1 constant UseLibUtil 102 | 103 | and then run the script to install the files to the ~/.gforth dirs: 104 | 105 | cd 106 | ./libutil.sh -ra 107 | ./libutil.sh -i 108 | gforth 109 | include opengl-lesson08.fs 110 | lesson08 111 | 112 | If you prefer not to use the LibUtil script, set the flag to: 113 | 114 | 0 constant UseLibUtil 115 | 116 | and then you can execute the Lesson code with: 117 | 118 | cd 119 | gforth 120 | include opengl-lesson08.fs 121 | lesson08 122 | 123 | ---[ Next Up ]------------------------------------------------------- 124 | 125 | Lesson 8 - Blending 126 | 127 | ----------------------------------------------------[End Lesson08]--- 128 | 129 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson09/data/star.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson09/data/star.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson09/mini-opengl-1.09.fs: -------------------------------------------------------------------------------- 1 | \ =================================================================== 2 | \ Program: mini-opengl-1.09.fs 3 | \ Author: Timothy Trussell 4 | \ Date: 07/25/2010 5 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 09 6 | \ Forth System: gforth-0.7.0 7 | \ Assembler: Built-in FORTH assembler 8 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | \ =================================================================== 11 | \ This libcc interface contains the cumulatively added OpenGL code 12 | \ function calls that are required for use with the gforth version of 13 | \ the NeHe OpenGL Tutorial Lessons. 14 | \ =================================================================== 15 | 16 | UseLibUtil [if] 17 | c-library mini_opengl_lib 18 | [else] 19 | c-library mini_opengl_lib09 20 | [then] 21 | 22 | s" GL" add-lib 23 | s" GLU" add-lib 24 | 25 | \c #if defined(__APPLE__) && defined(__MACH__) 26 | \c #include 27 | \c #include 28 | \c #else 29 | \c #include 30 | \c #include 31 | \c #endif 32 | 33 | \ Initial Entries for Lesson 01 34 | c-function gl-clear glClear n -- void 35 | c-function gl-clear-color glClearColor r r r r -- void 36 | c-function gl-clear-depth glClearDepth r -- void 37 | c-function gl-enable glEnable n -- void 38 | c-function gl-depth-func glDepthFunc n -- void 39 | c-function gl-hint glHint n n -- void 40 | c-function gl-load-identity glLoadIdentity -- void 41 | c-function gl-matrix-mode glMatrixMode n -- void 42 | c-function gl-shade-model glShadeModel n -- void 43 | c-function gl-viewport glViewport n n n n -- void 44 | c-function glu-perspective gluPerspective r r r r -- void 45 | 46 | \ Additions for Lesson 02 47 | c-function gl-begin glBegin n -- void 48 | c-function gl-end glEnd -- void 49 | c-function gl-translate-f glTranslatef r r r -- void 50 | c-function gl-vertex-3f glVertex3f r r r -- void 51 | 52 | \ Additions for Lesson 03 53 | c-function gl-color-3f glColor3f r r r -- void 54 | 55 | \ Additions for Lesson 04 56 | c-function gl-rotate-f glRotatef r r r r -- void 57 | 58 | \ Additions for Lesson 05 59 | \ -- none 60 | 61 | \ Additions for Lesson 06 62 | c-function gl-bind-texture glBindTexture n n -- void 63 | c-function gl-gen-textures glGenTextures n a -- void 64 | c-function gl-tex-coord-2f glTexCoord2f r r -- void 65 | c-function gl-tex-image-2d glTexImage2D n n n n n n n n a -- void 66 | c-function gl-tex-parameter-i glTexParameteri n n n -- void 67 | 68 | \ Additions for Lesson 07 69 | c-function gl-disable glDisable n -- void 70 | c-function gl-light-fv glLightfv n n a -- void 71 | c-function gl-normal-3f glNormal3f r r r -- void 72 | c-function glu-build-2d-mipmaps gluBuild2DMipmaps n n n n n n a -- void 73 | 74 | \ Additions for Lesson 08 75 | c-function gl-blend-func glBlendFunc n n -- void 76 | c-function gl-color-4f glColor4f r r r r -- void 77 | 78 | \ Additions for Lesson 09 79 | c-function gl-color-4ub glColor4ub n n n n -- void 80 | 81 | end-c-library 82 | 83 | include glconstants.fs 84 | 85 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson09/opengl-lesson09-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson09.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/25/2010 6 | Description: Moving bitmaps in 3D space 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 09 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 09 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson09/opengl-lesson09.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 09 ]--------------[07/25/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson09.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 09 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-color-4ub ( red green blue alpha -- ) 33 | 34 | Sets the current color. 35 | 36 | Parameters are unsigned byte values in the range of [0..255]. 37 | 38 | 39 | ---[ Installation ]-------------------------------------------------- 40 | 41 | If you are placing all of the Lessons in one directory, copy these 42 | three files to that directory: 43 | 44 | opengl-lesson09.fs - Code Addendum 1 45 | opengllib-1.09.fs - Code Addendum 2 46 | mini-opengl-1.09.fs - Code Addendum 3 47 | 48 | This Lesson requires the mini-sdl-1.01.fs file from Lesson 6, as well 49 | as all of the usual constants definition files. 50 | 51 | This Lesson also uses an image file which you can retrieve from the 52 | NeHe Lesson 9 page at: 53 | 54 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=09 55 | 56 | or from the opengl-lesson09.zip file that will be posted to the 57 | Taygeta Forth Archives site listed at the start of this column. 58 | 59 | For the files from the opengl-lesson09.zip, extract them to wherever 60 | you wish to place them, or extract the above three files and the data 61 | directory into the directory you have placed the previous Lesson 62 | files. 63 | 64 | To use the LibUtil script, set the flag in opengllib-1.09.fs: 65 | 66 | 1 constant UseLibUtil 67 | 68 | and then run the script to install the files to the ~/.gforth dirs: 69 | 70 | cd 71 | ./libutil.sh -ra 72 | ./libutil.sh -i 73 | gforth 74 | include opengl-lesson09.fs 75 | lesson09 76 | 77 | If you prefer not to use the LibUtil script, set the flag to: 78 | 79 | 0 constant UseLibUtil 80 | 81 | and then you can execute the Lesson code with: 82 | 83 | cd 84 | gforth 85 | include opengl-lesson09.fs 86 | lesson09 87 | 88 | ---[ Next Up ]------------------------------------------------------- 89 | 90 | Lesson 10 - Moving in a 3D world 91 | 92 | ----------------------------------------------------[End Lesson09]--- 93 | 94 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson10/data/mud.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson10/data/mud.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson10/mini-opengl-1.10.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 03 ]============================================ 2 | \ gforth: OpenGL Graphics Lesson 10 3 | \ =================================================================== 4 | \ File: mini-opengl-1.10.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 07/25/2010 7 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 10 8 | \ Forth System: gforth-0.7.0 9 | \ Assembler: Built-in FORTH assembler 10 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 11 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 12 | \ =================================================================== 13 | \ This libcc interface contains the cumulatively added OpenGL code 14 | \ function calls that are required for use with the gforth version of 15 | \ the NeHe OpenGL Tutorial Lessons. 16 | \ =================================================================== 17 | 18 | UseLibUtil [if] 19 | c-library mini_opengl_lib 20 | [else] 21 | c-library mini_opengl_lib10 22 | [then] 23 | 24 | s" GL" add-lib 25 | s" GLU" add-lib 26 | 27 | \c #if defined(__APPLE__) && defined(__MACH__) 28 | \c #include 29 | \c #include 30 | \c #else 31 | \c #include 32 | \c #include 33 | \c #endif 34 | 35 | \ Initial Entries for Lesson 01 36 | c-function gl-clear glClear n -- void 37 | c-function gl-clear-color glClearColor r r r r -- void 38 | c-function gl-clear-depth glClearDepth r -- void 39 | c-function gl-enable glEnable n -- void 40 | c-function gl-depth-func glDepthFunc n -- void 41 | c-function gl-hint glHint n n -- void 42 | c-function gl-load-identity glLoadIdentity -- void 43 | c-function gl-matrix-mode glMatrixMode n -- void 44 | c-function gl-shade-model glShadeModel n -- void 45 | c-function gl-viewport glViewport n n n n -- void 46 | c-function glu-perspective gluPerspective r r r r -- void 47 | 48 | \ Additions for Lesson 02 49 | c-function gl-begin glBegin n -- void 50 | c-function gl-end glEnd -- void 51 | c-function gl-translate-f glTranslatef r r r -- void 52 | c-function gl-vertex-3f glVertex3f r r r -- void 53 | 54 | \ Additions for Lesson 03 55 | c-function gl-color-3f glColor3f r r r -- void 56 | 57 | \ Additions for Lesson 04 58 | c-function gl-rotate-f glRotatef r r r r -- void 59 | 60 | \ Additions for Lesson 05 61 | \ -- none 62 | 63 | \ Additions for Lesson 06 64 | c-function gl-bind-texture glBindTexture n n -- void 65 | c-function gl-gen-textures glGenTextures n a -- void 66 | c-function gl-tex-coord-2f glTexCoord2f r r -- void 67 | c-function gl-tex-image-2d glTexImage2D n n n n n n n n a -- void 68 | c-function gl-tex-parameter-i glTexParameteri n n n -- void 69 | 70 | \ Additions for Lesson 07 71 | c-function gl-disable glDisable n -- void 72 | c-function gl-light-fv glLightfv n n a -- void 73 | c-function gl-normal-3f glNormal3f r r r -- void 74 | c-function glu-build-2d-mipmaps gluBuild2DMipmaps n n n n n n a -- void 75 | 76 | \ Additions for Lesson 08 77 | c-function gl-blend-func glBlendFunc n n -- void 78 | c-function gl-color-4f glColor4f r r r r -- void 79 | 80 | \ Additions for Lesson 09 81 | c-function gl-color-4ub glColor4ub n n n n -- void 82 | 83 | \ Additions for Lesson 10 84 | \ -- none 85 | 86 | end-c-library 87 | 88 | include glconstants.fs 89 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson10/opengl-lesson10-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson10.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/25/2010 6 | Description: Moving in a 3D world 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 10 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 10 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson10/opengl-lesson10.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 10 ]--------------[07/25/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson10.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 10 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | There are no new OpenGL additions to the mini-opengl libcc interface 31 | for this lesson. 32 | 33 | ---[ Installation ]-------------------------------------------------- 34 | 35 | If you are placing all of the Lessons in one directory, copy these 36 | three files to that directory: 37 | 38 | opengl-lesson10.fs - Code Addendum 1 39 | opengllib-1.10.fs - Code Addendum 2 40 | mini-opengl-1.10.fs - Code Addendum 3 41 | 42 | This Lesson requires the mini-sdl-1.01.fs file from Lesson 6, as well 43 | as all of the usual constants definition files. 44 | 45 | This Lesson also uses an image file which you can retrieve from the 46 | NeHe Lesson 10 page at: 47 | 48 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=10 49 | 50 | or from the opengl-lesson10.zip file that will be posted to the 51 | Taygeta Forth Archives site listed at the start of this column. 52 | 53 | For the files from the opengl-lesson10.zip, extract them to wherever 54 | you wish to place them, or extract the above three files and the data 55 | directory into the directory you have placed the previous Lesson 56 | files. 57 | 58 | To use the LibUtil script, set the flag in opengllib-1.10.fs: 59 | 60 | 1 constant UseLibUtil 61 | 62 | and then run the script to install the files to the ~/.gforth dirs: 63 | 64 | cd 65 | ./libutil.sh -ra 66 | ./libutil.sh -i 67 | gforth 68 | include opengl-lesson10.fs 69 | lesson10 70 | 71 | If you prefer not to use the LibUtil script, set the flag to: 72 | 73 | 0 constant UseLibUtil 74 | 75 | and then you can execute the Lesson code with: 76 | 77 | cd 78 | gforth 79 | include opengl-lesson10.fs 80 | lesson10 81 | 82 | ---[ Next Up ]------------------------------------------------------- 83 | 84 | Lesson 11 - Flag effect (waving texture) 85 | 86 | ----------------------------------------------------[End Lesson10]--- 87 | 88 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson11/data/tim.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson11/data/tim.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson11/mini-opengl-1.11.fs: -------------------------------------------------------------------------------- 1 | \ =================================================================== 2 | \ File: mini-opengl-1.11.fs 3 | \ Author: Timothy Trussell 4 | \ Date: 07/25/2010 5 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 11 6 | \ Forth System: gforth-0.7.0 7 | \ Assembler: Built-in FORTH assembler 8 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | \ =================================================================== 11 | \ This libcc interface contains the cumulatively added OpenGL code 12 | \ function calls that are required for use with the gforth version of 13 | \ the NeHe OpenGL Tutorial Lessons. 14 | \ =================================================================== 15 | 16 | UseLibUtil [if] 17 | c-library mini_opengl_lib 18 | [else] 19 | c-library mini_opengl_lib11 20 | [then] 21 | 22 | s" GL" add-lib 23 | s" GLU" add-lib 24 | 25 | \c #if defined(__APPLE__) && defined(__MACH__) 26 | \c #include 27 | \c #include 28 | \c #else 29 | \c #include 30 | \c #include 31 | \c #endif 32 | 33 | \ Initial Entries for Lesson 01 34 | c-function gl-clear glClear n -- void 35 | c-function gl-clear-color glClearColor r r r r -- void 36 | c-function gl-clear-depth glClearDepth r -- void 37 | c-function gl-enable glEnable n -- void 38 | c-function gl-depth-func glDepthFunc n -- void 39 | c-function gl-hint glHint n n -- void 40 | c-function gl-load-identity glLoadIdentity -- void 41 | c-function gl-matrix-mode glMatrixMode n -- void 42 | c-function gl-shade-model glShadeModel n -- void 43 | c-function gl-viewport glViewport n n n n -- void 44 | c-function glu-perspective gluPerspective r r r r -- void 45 | 46 | \ Additions for Lesson 02 47 | c-function gl-begin glBegin n -- void 48 | c-function gl-end glEnd -- void 49 | c-function gl-translate-f glTranslatef r r r -- void 50 | c-function gl-vertex-3f glVertex3f r r r -- void 51 | 52 | \ Additions for Lesson 03 53 | c-function gl-color-3f glColor3f r r r -- void 54 | 55 | \ Additions for Lesson 04 56 | c-function gl-rotate-f glRotatef r r r r -- void 57 | 58 | \ Additions for Lesson 05 59 | \ -- none 60 | 61 | \ Additions for Lesson 06 62 | c-function gl-bind-texture glBindTexture n n -- void 63 | c-function gl-gen-textures glGenTextures n a -- void 64 | c-function gl-tex-coord-2f glTexCoord2f r r -- void 65 | c-function gl-tex-image-2d glTexImage2D n n n n n n n n a -- void 66 | c-function gl-tex-parameter-i glTexParameteri n n n -- void 67 | 68 | \ Additions for Lesson 07 69 | c-function gl-disable glDisable n -- void 70 | c-function gl-light-fv glLightfv n n a -- void 71 | c-function gl-normal-3f glNormal3f r r r -- void 72 | c-function glu-build-2d-mipmaps gluBuild2DMipmaps n n n n n n a -- void 73 | 74 | \ Additions for Lesson 08 75 | c-function gl-blend-func glBlendFunc n n -- void 76 | c-function gl-color-4f glColor4f r r r r -- void 77 | 78 | \ Additions for Lesson 09 79 | c-function gl-color-4ub glColor4ub n n n n -- void 80 | 81 | \ Additions for Lesson 10 82 | \ -- none 83 | 84 | \ Additions for Lesson 11 85 | c-function gl-polygon-mode glPolygonMode n n -- void 86 | 87 | end-c-library 88 | 89 | include glconstants.fs 90 | 91 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson11/opengl-lesson11-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson11.zip 3 | Author: Bosco 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/25/2010 6 | Description: Flag effect (waving texture) 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-23 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 11 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 11 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson11/opengl-lesson11.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 11 ]--------------[07/25/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson11.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 11 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-polygon-mode ( face mode -- ) 33 | 34 | Select a polygon rasterization mode 35 | 36 | Parameters and are integer values. 37 | 38 | face: Specifies the polygons that mode applies to. Must be 39 | GL_FRONT for front-facing polygons, GL_BACK for back-facing 40 | polygons, or GL_FRONT_AND_BACK for front- and back-facing 41 | polygons. 42 | 43 | mode: Specifies how polygons will be rasterized. 44 | Accepted values are GL_POINT, GL_LINE, and GL_FILL. 45 | The initial value is GL_FILL for both front and back-facing 46 | polygons. 47 | 48 | 49 | ---[ Installation ]-------------------------------------------------- 50 | 51 | If you are placing all of the Lessons in one directory, copy these 52 | three files to that directory: 53 | 54 | opengl-lesson11.fs - Code Addendum 1 55 | opengllib-1.11.fs - Code Addendum 2 56 | mini-opengl-1.11.fs - Code Addendum 3 57 | 58 | This Lesson requires the mini-sdl-1.01.fs file from Lesson 6, as well 59 | as all of the usual constants definition files. 60 | 61 | This Lesson also uses an image file which you can retrieve from the 62 | NeHe Lesson 11 page at: 63 | 64 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=11 65 | 66 | or from the opengl-lesson11.zip file that will be posted to the 67 | Taygeta Forth Archives site listed at the start of this column. 68 | 69 | For the files from the opengl-lesson11.zip, extract them to wherever 70 | you wish to place them, or extract the above three files and the data 71 | directory into the directory you have placed the previous Lesson 72 | files. 73 | 74 | To use the LibUtil script, set the flag in opengllib-1.11.fs: 75 | 76 | 1 constant UseLibUtil 77 | 78 | and then run the script to install the files to the ~/.gforth dirs: 79 | 80 | cd 81 | ./libutil.sh -ra 82 | ./libutil.sh -i 83 | gforth 84 | include opengl-lesson11.fs 85 | lesson11 86 | 87 | If you prefer not to use the LibUtil script, set the flag to: 88 | 89 | 0 constant UseLibUtil 90 | 91 | and then you can execute the Lesson code with: 92 | 93 | cd 94 | gforth 95 | include opengl-lesson11.fs 96 | lesson11 97 | 98 | ---[ Next Up ]------------------------------------------------------- 99 | 100 | Lesson 12 - Display lists 101 | 102 | ----------------------------------------------------[End Lesson11]--- 103 | 104 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson12/data/cube.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson12/data/cube.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson12/mini-opengl-1.12.fs: -------------------------------------------------------------------------------- 1 | \ =================================================================== 2 | \ File: mini-opengl-1.12.fs 3 | \ Author: Timothy Trussell 4 | \ Date: 07/26/2010 5 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 12 6 | \ Forth System: gforth-0.7.0 7 | \ Assembler: Built-in FORTH assembler 8 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | \ =================================================================== 11 | \ This libcc interface contains the cumulatively added OpenGL code 12 | \ function calls that are required for use with the gforth version of 13 | \ the NeHe OpenGL Tutorial Lessons. 14 | \ =================================================================== 15 | 16 | UseLibUtil [if] 17 | c-library mini_opengl_lib 18 | [else] 19 | c-library mini_opengl_lib12 20 | [then] 21 | 22 | s" GL" add-lib 23 | s" GLU" add-lib 24 | 25 | \c #if defined(__APPLE__) && defined(__MACH__) 26 | \c #include 27 | \c #include 28 | \c #else 29 | \c #include 30 | \c #include 31 | \c #endif 32 | 33 | \ Initial Entries for Lesson 01 34 | c-function gl-clear glClear n -- void 35 | c-function gl-clear-color glClearColor r r r r -- void 36 | c-function gl-clear-depth glClearDepth r -- void 37 | c-function gl-enable glEnable n -- void 38 | c-function gl-depth-func glDepthFunc n -- void 39 | c-function gl-hint glHint n n -- void 40 | c-function gl-load-identity glLoadIdentity -- void 41 | c-function gl-matrix-mode glMatrixMode n -- void 42 | c-function gl-shade-model glShadeModel n -- void 43 | c-function gl-viewport glViewport n n n n -- void 44 | c-function glu-perspective gluPerspective r r r r -- void 45 | 46 | \ Additions for Lesson 02 47 | c-function gl-begin glBegin n -- void 48 | c-function gl-end glEnd -- void 49 | c-function gl-translate-f glTranslatef r r r -- void 50 | c-function gl-vertex-3f glVertex3f r r r -- void 51 | 52 | \ Additions for Lesson 03 53 | c-function gl-color-3f glColor3f r r r -- void 54 | 55 | \ Additions for Lesson 04 56 | c-function gl-rotate-f glRotatef r r r r -- void 57 | 58 | \ Additions for Lesson 05 59 | \ -- none 60 | 61 | \ Additions for Lesson 06 62 | c-function gl-bind-texture glBindTexture n n -- void 63 | c-function gl-gen-textures glGenTextures n a -- void 64 | c-function gl-tex-coord-2f glTexCoord2f r r -- void 65 | c-function gl-tex-image-2d glTexImage2D n n n n n n n n a -- void 66 | c-function gl-tex-parameter-i glTexParameteri n n n -- void 67 | 68 | \ Additions for Lesson 07 69 | c-function gl-disable glDisable n -- void 70 | c-function gl-light-fv glLightfv n n a -- void 71 | c-function gl-normal-3f glNormal3f r r r -- void 72 | c-function glu-build-2d-mipmaps gluBuild2DMipmaps n n n n n n a -- void 73 | 74 | \ Additions for Lesson 08 75 | c-function gl-blend-func glBlendFunc n n -- void 76 | c-function gl-color-4f glColor4f r r r r -- void 77 | 78 | \ Additions for Lesson 09 79 | c-function gl-color-4ub glColor4ub n n n n -- void 80 | 81 | \ Additions for Lesson 10 82 | \ -- none 83 | 84 | \ Additions for Lesson 11 85 | c-function gl-polygon-mode glPolygonMode n n -- void 86 | 87 | \ Additions for Lesson 12 88 | c-function gl-call-list glCallList n -- void 89 | c-function gl-color-3fv glColor3fv a -- void 90 | c-function gl-end-list glEndList -- void 91 | c-function gl-gen-lists glGenLists n -- n 92 | c-function gl-new-list glNewList n n -- void 93 | 94 | end-c-library 95 | 96 | include glconstants.fs 97 | 98 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson12/opengl-lesson12-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson12.zip 3 | Author: Bosco 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/26/2010 6 | Description: Display Lists 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 12 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 12 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson12/opengl-lesson12.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 12 ]--------------[07/26/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson12.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 12 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-call-list ( list -- ) 33 | 34 | Execute a display list 35 | 36 | Parameter is an integer value, representing a "name" 37 | 38 | Description: 39 | 40 | glCallList causes the named display list to be executed. The 41 | commands saved in the display list are executed in order, 42 | just as if they were called without using a display list. If 43 | list has not been defined as a display list, glCallList is 44 | ignored. 45 | 46 | glCallList can appear inside a display list. To avoid the 47 | possibility of infinite recursion resulting from display 48 | lists calling one another, a limit is placed on the nesting 49 | level of display lists during display-list execution. This 50 | limit is at least 64, and it depends on the implementation. 51 | 52 | GL state is not saved and restored across a call to 53 | glCallList. Thus, changes made to GL state during the 54 | execution of a display list remain after execution of the 55 | display list is completed. Use glPushAttrib, glPopAttrib, 56 | glPushMatrix, and glPopMatrix to preserve GL state across 57 | glCallList calls. 58 | 59 | Notes: 60 | 61 | Display lists can be executed between a call to glBegin and 62 | the corresponding call to glEnd, as long as the display list 63 | includes only commands that are allowed in this interval. 64 | 65 | gl-color-3fv ( *v -- ) 66 | 67 | Sets the current color. 68 | 69 | Parameter <*v> is a 32-bit pointer to an array of 32-bit 70 | floating point values (C standard float type), which represents 71 | the red, green and blue elements of a color. 72 | 73 | gl-gen-lists ( range -- list# ) 74 | 75 | Generate a contiguous set of empty display lists 76 | 77 | Parameter is an integer value that specifies the number 78 | of contiguous empty display lists to be generated. 79 | 80 | Return value points to the first list created. 81 | +1 points to the next list. 82 | +2 points to the next... and so on, up to range-1 as the 83 | limit for the number of lists created [0..(range-1)] 84 | 85 | gl-new-list ( list mode -- ) 86 | 87 | Create or replace a display list. 88 | 89 | Parameters and are integer values. 90 | 91 | list: Specifies the display-list "name", which is an integer 92 | value pointing to a list# created by gl-gen-lists. 93 | 94 | mode: Specifies the compilation mode, which can be GL_COMPILE 95 | or GL_COMPILE_AND_EXECUTE. 96 | 97 | gl-end-list ( -- ) 98 | 99 | Ends a display list generation block. 100 | 101 | Parameters: none. 102 | 103 | ---[ Installation ]-------------------------------------------------- 104 | 105 | If you are placing all of the Lessons in one directory, copy these 106 | three files to that directory: 107 | 108 | opengl-lesson12.fs - Code Addendum 1 109 | opengllib-1.12.fs - Code Addendum 2 110 | mini-opengl-1.12.fs - Code Addendum 3 111 | 112 | This Lesson requires the mini-sdl-1.01.fs file from Lesson 6, as well 113 | as all of the usual constants definition files. 114 | 115 | This Lesson also uses an image file which you can retrieve from the 116 | NeHe Lesson 12 page at: 117 | 118 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=12 119 | 120 | or from the opengl-lesson12.zip file that will be posted to the 121 | Taygeta Forth Archives site listed at the start of this column. 122 | 123 | For the files from the opengl-lesson12.zip, extract them to wherever 124 | you wish to place them, or extract the above three files and the data 125 | directory into the directory you have placed the previous Lesson 126 | files. 127 | 128 | To use the LibUtil script, set the flag in opengllib-1.12.fs: 129 | 130 | 1 constant UseLibUtil 131 | 132 | and then run the script to install the files to the ~/.gforth dirs: 133 | 134 | cd 135 | ./libutil.sh -ra 136 | ./libutil.sh -i 137 | gforth 138 | include opengl-lesson12.fs 139 | lesson12 140 | 141 | If you prefer not to use the LibUtil script, set the flag to: 142 | 143 | 0 constant UseLibUtil 144 | 145 | and then you can execute the Lesson code with: 146 | 147 | cd 148 | gforth 149 | include opengl-lesson12.fs 150 | lesson12 151 | 152 | ---[ Next Up ]------------------------------------------------------- 153 | 154 | Lesson 13 - Bitmap fonts 155 | 156 | ----------------------------------------------------[End Lesson12]--- 157 | 158 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson13/mini-opengl-1.13.fs: -------------------------------------------------------------------------------- 1 | \ =================================================================== 2 | \ File: mini-opengl-1.13.fs 3 | \ Author: Timothy Trussell 4 | \ Date: 07/31/2010 5 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 13 6 | \ Forth System: gforth-0.7.0 7 | \ Assembler: Built-in FORTH assembler 8 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | \ =================================================================== 11 | \ This libcc interface contains the cumulatively added OpenGL code 12 | \ function calls that are required for use with the gforth version of 13 | \ the NeHe OpenGL Tutorial Lessons. 14 | \ =================================================================== 15 | 16 | UseLibUtil [if] 17 | c-library mini_opengl_lib 18 | [else] 19 | c-library mini_opengl_lib13 20 | [then] 21 | 22 | s" GL" add-lib 23 | s" GLU" add-lib 24 | 25 | \c #if defined(__APPLE__) && defined(__MACH__) 26 | \c #include 27 | \c #include 28 | \c #include 29 | \c #else 30 | \c #include 31 | \c #include 32 | \c #include 33 | \c #endif 34 | 35 | \ Initial Entries for Lesson 01 36 | c-function gl-clear glClear n -- void 37 | c-function gl-clear-color glClearColor r r r r -- void 38 | c-function gl-clear-depth glClearDepth r -- void 39 | c-function gl-enable glEnable n -- void 40 | c-function gl-depth-func glDepthFunc n -- void 41 | c-function gl-hint glHint n n -- void 42 | c-function gl-load-identity glLoadIdentity -- void 43 | c-function gl-matrix-mode glMatrixMode n -- void 44 | c-function gl-shade-model glShadeModel n -- void 45 | c-function gl-viewport glViewport n n n n -- void 46 | c-function glu-perspective gluPerspective r r r r -- void 47 | 48 | \ Additions for Lesson 02 49 | c-function gl-begin glBegin n -- void 50 | c-function gl-end glEnd -- void 51 | c-function gl-translate-f glTranslatef r r r -- void 52 | c-function gl-vertex-3f glVertex3f r r r -- void 53 | 54 | \ Additions for Lesson 03 55 | c-function gl-color-3f glColor3f r r r -- void 56 | 57 | \ Additions for Lesson 04 58 | c-function gl-rotate-f glRotatef r r r r -- void 59 | 60 | \ Additions for Lesson 05 61 | \ -- none 62 | 63 | \ Additions for Lesson 06 64 | c-function gl-bind-texture glBindTexture n n -- void 65 | c-function gl-gen-textures glGenTextures n a -- void 66 | c-function gl-tex-coord-2f glTexCoord2f r r -- void 67 | c-function gl-tex-image-2d glTexImage2D n n n n n n n n a -- void 68 | c-function gl-tex-parameter-i glTexParameteri n n n -- void 69 | 70 | \ Additions for Lesson 07 71 | c-function gl-disable glDisable n -- void 72 | c-function gl-light-fv glLightfv n n a -- void 73 | c-function gl-normal-3f glNormal3f r r r -- void 74 | c-function glu-build-2d-mipmaps gluBuild2DMipmaps n n n n n n a -- void 75 | 76 | \ Additions for Lesson 08 77 | c-function gl-blend-func glBlendFunc n n -- void 78 | c-function gl-color-4f glColor4f r r r r -- void 79 | 80 | \ Additions for Lesson 09 81 | c-function gl-color-4ub glColor4ub n n n n -- void 82 | 83 | \ Additions for Lesson 10 84 | \ -- none 85 | 86 | \ Additions for Lesson 11 87 | c-function gl-polygon-mode glPolygonMode n n -- void 88 | 89 | \ Additions for Lesson 12 90 | c-function gl-call-list glCallList n -- void 91 | c-function gl-color-3fv glColor3fv a -- void 92 | c-function gl-end-list glEndList -- void 93 | c-function gl-gen-lists glGenLists n -- n 94 | c-function gl-new-list glNewList n n -- void 95 | 96 | \ Additions for Lesson 13 97 | c-function gl-call-lists glCallLists n n a -- void 98 | c-function gl-delete-lists glDeleteLists n n -- void 99 | c-function gl-list-base glListBase n -- void 100 | c-function gl-pop-attrib glPopAttrib -- void 101 | c-function gl-push-attrib glPushAttrib n -- void 102 | c-function gl-raster-pos-2f glRasterPos2f r r -- void 103 | c-function gl-xusexfont glXUseXFont n n n n -- void 104 | c-function x-closedisplay XCloseDisplay a -- n 105 | c-function x-freefont XFreeFont a a -- n 106 | c-function x-loadqueryfont XLoadQueryFont a a -- a 107 | c-function x-opendisplay XOpenDisplay a -- a 108 | 109 | end-c-library 110 | 111 | include glconstants.fs 112 | 113 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson13/opengl-lesson13-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson13.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/31/2010 6 | Description: Bitmap Fonts 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 13 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 13 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson16/data/crate.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson16/data/crate.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson16/mini-opengl-1.16.fs: -------------------------------------------------------------------------------- 1 | \ =================================================================== 2 | \ File: mini-opengl-1.16.fs 3 | \ Author: Timothy Trussell 4 | \ Date: 07/31/2010 5 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 16 6 | \ Forth System: gforth-0.7.0 7 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 8 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 9 | \ =================================================================== 10 | \ This libcc interface contains the cumulatively added OpenGL code 11 | \ function calls that are required for use with the gforth version of 12 | \ the NeHe OpenGL Tutorial Lessons. 13 | \ =================================================================== 14 | 15 | UseLibUtil [if] 16 | c-library mini_opengl_lib 17 | [else] 18 | c-library mini_opengl_lib16 19 | [then] 20 | 21 | s" GL" add-lib 22 | s" GLU" add-lib 23 | 24 | \c #if defined(__APPLE__) && defined(__MACH__) 25 | \c #include 26 | \c #include 27 | \c #include 28 | \c #else 29 | \c #include 30 | \c #include 31 | \c #include 32 | \c #endif 33 | 34 | \ Initial Entries for Lesson 01 35 | c-function gl-clear glClear n -- void 36 | c-function gl-clear-color glClearColor r r r r -- void 37 | c-function gl-clear-depth glClearDepth r -- void 38 | c-function gl-enable glEnable n -- void 39 | c-function gl-depth-func glDepthFunc n -- void 40 | c-function gl-hint glHint n n -- void 41 | c-function gl-load-identity glLoadIdentity -- void 42 | c-function gl-matrix-mode glMatrixMode n -- void 43 | c-function gl-shade-model glShadeModel n -- void 44 | c-function gl-viewport glViewport n n n n -- void 45 | c-function glu-perspective gluPerspective r r r r -- void 46 | 47 | \ Additions for Lesson 02 48 | c-function gl-begin glBegin n -- void 49 | c-function gl-end glEnd -- void 50 | c-function gl-translate-f glTranslatef r r r -- void 51 | c-function gl-vertex-3f glVertex3f r r r -- void 52 | 53 | \ Additions for Lesson 03 54 | c-function gl-color-3f glColor3f r r r -- void 55 | 56 | \ Additions for Lesson 04 57 | c-function gl-rotate-f glRotatef r r r r -- void 58 | 59 | \ Additions for Lesson 05 60 | \ -- none 61 | 62 | \ Additions for Lesson 06 63 | c-function gl-bind-texture glBindTexture n n -- void 64 | c-function gl-gen-textures glGenTextures n a -- void 65 | c-function gl-tex-coord-2f glTexCoord2f r r -- void 66 | c-function gl-tex-image-2d glTexImage2D n n n n n n n n a -- void 67 | c-function gl-tex-parameter-i glTexParameteri n n n -- void 68 | 69 | \ Additions for Lesson 07 70 | c-function gl-disable glDisable n -- void 71 | c-function gl-light-fv glLightfv n n a -- void 72 | c-function gl-normal-3f glNormal3f r r r -- void 73 | c-function glu-build-2d-mipmaps gluBuild2DMipmaps n n n n n n a -- void 74 | 75 | \ Additions for Lesson 08 76 | c-function gl-blend-func glBlendFunc n n -- void 77 | c-function gl-color-4f glColor4f r r r r -- void 78 | 79 | \ Additions for Lesson 09 80 | c-function gl-color-4ub glColor4ub n n n n -- void 81 | 82 | \ Additions for Lesson 10 83 | \ -- none 84 | 85 | \ Additions for Lesson 11 86 | c-function gl-polygon-mode glPolygonMode n n -- void 87 | 88 | \ Additions for Lesson 12 89 | c-function gl-call-list glCallList n -- void 90 | c-function gl-color-3fv glColor3fv a -- void 91 | c-function gl-end-list glEndList -- void 92 | c-function gl-gen-lists glGenLists n -- n 93 | c-function gl-new-list glNewList n n -- void 94 | 95 | \ Additions for Lesson 13 96 | c-function gl-call-lists glCallLists n n a -- void 97 | c-function gl-delete-lists glDeleteLists n n -- void 98 | c-function gl-list-base glListBase n -- void 99 | c-function gl-pop-attrib glPopAttrib -- void 100 | c-function gl-push-attrib glPushAttrib n -- void 101 | c-function gl-raster-pos-2f glRasterPos2f r r -- void 102 | c-function gl-xclosedisplay XCloseDisplay a -- n 103 | c-function gl-xfreefont XFreeFont a a -- n 104 | c-function gl-xloadqueryfont XLoadQueryFont a a -- a 105 | c-function gl-xopendisplay XOpenDisplay a -- a 106 | c-function gl-xusexfont glXUseXFont n n n n -- void 107 | 108 | \ Additions for Lesson 14 109 | \ -- 110 | 111 | \ Additions for Lesson 15 112 | \ -- 113 | 114 | \ Additions for Lesson 16 115 | c-function gl-delete-textures glDeleteTextures n a -- void 116 | c-function gl-fog-i glFogi n n -- void 117 | c-function gl-fog-fv glFogfv n a -- void 118 | c-function gl-fog-f glFogf n r -- void 119 | 120 | end-c-library 121 | 122 | include glconstants.fs 123 | 124 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson16/opengl-lesson16-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson16.zip 3 | Author: Bosco 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/31/2010 6 | Description: Cool looking fog 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 16 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 16 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson16/opengl-lesson16.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 16 ]--------------[07/31/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson16.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 16 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-delete-textures ( n *textures -- ) 33 | 34 | Delete named textures. 35 | 36 | Parameter is an integer value; parameter <*textures> is a 37 | 32-bit pointer to an array of textures to be deleted. 38 | 39 | n: Specifies the number of textures to be deleted. 40 | 41 | *textures: Specifies an array of textures to be deleted. 42 | 43 | gl-fog-i ( pname param -- ) 44 | 45 | Specify fog parameters. 46 | 47 | Parameters and are integer values. 48 | 49 | pname: Specifies a single-valued fog parameter. 50 | GL_FOG_MODE, GL_FOG_DENSITY, GL_FOG_START, GL_FOG_END, and 51 | GL_FOG_INDEX are accepted. 52 | 53 | param: Specifies the value that will be set to. 54 | 55 | gl-fog-fv ( pname *params -- ) 56 | 57 | Specify fog parameters. 58 | 59 | Parameter is an integer value; parameter <*params> is a 60 | 32-bit pointer to an array of 32-bit floating point values. 61 | 62 | pname: Specifies a fog parameter. GL_FOG_MODE, GL_FOG_DENSITY, 63 | GL_FOG_START, GL_FOG_END, GL_FOG_INDEX, and GL_FOG_COLOR 64 | are accepted. 65 | 66 | *params: Specifies the value or values to be assigned to pname. 67 | GL_FOG_COLOR requires an array of four values. All other 68 | parameters accept an array containing only a single value. 69 | 70 | (As the floating point values pointed to by <*params> are to be 71 | passed by address, they must already be in the C/C++ standard 72 | 32-bit format, not the normal gforth 64-bit float values.) 73 | 74 | gl-fog-f ( pname param -- ) 75 | 76 | Specify fog parameters. 77 | 78 | Parameter is integer value; parameter is a 32-bit 79 | floating point value. 80 | 81 | pname: Specifies a single-valued fog parameter. 82 | GL_FOG_MODE, GL_FOG_DENSITY, GL_FOG_START, GL_FOG_END, and 83 | GL_FOG_INDEX are accepted. 84 | 85 | param: Specifies the value that will be set to. 86 | 87 | (In gforth, as this is passed by value, there is no conversion 88 | necessary to make this value into a 32-bit float from the normal 89 | gforth 64-bit floating point value.) 90 | 91 | ---[ Installation ]-------------------------------------------------- 92 | 93 | If you are placing all of the Lessons in one directory, copy these 94 | three files to that directory: 95 | 96 | opengl-lesson16.fs - Code Addendum 1 97 | opengllib-1.16.fs - Code Addendum 2 98 | mini-opengl-1.16.fs - Code Addendum 3 99 | 100 | This Lesson requires the mini-sdl-1.01.fs file from Lesson 6, as well 101 | as all of the usual constants definition files. 102 | 103 | This Lesson also uses an image file which you can retrieve from the 104 | NeHe Lesson 16 page at: 105 | 106 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=16 107 | 108 | or from the opengl-lesson16.zip file that will be posted to the 109 | Taygeta Forth Archives site listed at the start of this column. 110 | 111 | For the files from the opengl-lesson16.zip, extract them to wherever 112 | you wish to place them, or extract the above three files and the data 113 | directory into the directory you have placed the previous Lesson 114 | files. 115 | 116 | To use the LibUtil script, set the flag in opengllib-1.16.fs: 117 | 118 | 1 constant UseLibUtil 119 | 120 | and then run the script to install the files to the ~/.gforth dirs: 121 | 122 | cd 123 | ./libutil.sh -ra 124 | ./libutil.sh -i 125 | gforth 126 | include opengl-lesson16.fs 127 | lesson16 128 | 129 | If you prefer not to use the LibUtil script, set the flag to: 130 | 131 | 0 constant UseLibUtil 132 | 133 | and then you can execute the Lesson code with: 134 | 135 | cd 136 | gforth 137 | include opengl-lesson16.fs 138 | lesson16 139 | 140 | ---[ Next Up ]------------------------------------------------------- 141 | 142 | Lesson 17 - 2D texture mapped fonts 143 | 144 | ----------------------------------------------------[End Lesson16]--- 145 | 146 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson17/data/bumps.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson17/data/bumps.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson17/data/font.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson17/data/font.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson17/mini-opengl-1.17.fs: -------------------------------------------------------------------------------- 1 | \ =================================================================== 2 | \ File: mini-opengl-1.17.fs 3 | \ Author: Timothy Trussell 4 | \ Date: 07/31/2010 5 | \ Description: OpenGL libcc interface for NeHe OpenGL Tutorial 17 6 | \ Forth System: gforth-0.7.0 7 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 8 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 9 | \ =================================================================== 10 | \ This libcc interface contains the cumulatively added OpenGL code 11 | \ function calls that are required for use with the gforth version of 12 | \ the NeHe OpenGL Tutorial Lessons. 13 | \ =================================================================== 14 | 15 | UseLibUtil [if] 16 | c-library mini_opengl_lib 17 | [else] 18 | c-library mini_opengl_lib17 19 | [then] 20 | 21 | s" GL" add-lib 22 | s" GLU" add-lib 23 | 24 | \c #if defined(__APPLE__) && defined(__MACH__) 25 | \c #include 26 | \c #include 27 | \c #include 28 | \c #else 29 | \c #include 30 | \c #include 31 | \c #include 32 | \c #endif 33 | 34 | \ Initial Entries for Lesson 01 35 | c-function gl-clear glClear n -- void 36 | c-function gl-clear-color glClearColor r r r r -- void 37 | c-function gl-clear-depth glClearDepth r -- void 38 | c-function gl-enable glEnable n -- void 39 | c-function gl-depth-func glDepthFunc n -- void 40 | c-function gl-hint glHint n n -- void 41 | c-function gl-load-identity glLoadIdentity -- void 42 | c-function gl-matrix-mode glMatrixMode n -- void 43 | c-function gl-shade-model glShadeModel n -- void 44 | c-function gl-viewport glViewport n n n n -- void 45 | c-function glu-perspective gluPerspective r r r r -- void 46 | 47 | \ Additions for Lesson 02 48 | c-function gl-begin glBegin n -- void 49 | c-function gl-end glEnd -- void 50 | c-function gl-translate-f glTranslatef r r r -- void 51 | c-function gl-vertex-3f glVertex3f r r r -- void 52 | 53 | \ Additions for Lesson 03 54 | c-function gl-color-3f glColor3f r r r -- void 55 | 56 | \ Additions for Lesson 04 57 | c-function gl-rotate-f glRotatef r r r r -- void 58 | 59 | \ Additions for Lesson 05 60 | \ -- none 61 | 62 | \ Additions for Lesson 06 63 | c-function gl-bind-texture glBindTexture n n -- void 64 | c-function gl-gen-textures glGenTextures n a -- void 65 | c-function gl-tex-coord-2f glTexCoord2f r r -- void 66 | c-function gl-tex-image-2d glTexImage2D n n n n n n n n a -- void 67 | c-function gl-tex-parameter-i glTexParameteri n n n -- void 68 | 69 | \ Additions for Lesson 07 70 | c-function gl-disable glDisable n -- void 71 | c-function gl-light-fv glLightfv n n a -- void 72 | c-function gl-normal-3f glNormal3f r r r -- void 73 | c-function glu-build-2d-mipmaps gluBuild2DMipmaps n n n n n n a -- void 74 | 75 | \ Additions for Lesson 08 76 | c-function gl-blend-func glBlendFunc n n -- void 77 | c-function gl-color-4f glColor4f r r r r -- void 78 | 79 | \ Additions for Lesson 09 80 | c-function gl-color-4ub glColor4ub n n n n -- void 81 | 82 | \ Additions for Lesson 10 83 | \ -- none 84 | 85 | \ Additions for Lesson 11 86 | c-function gl-polygon-mode glPolygonMode n n -- void 87 | 88 | \ Additions for Lesson 12 89 | c-function gl-call-list glCallList n -- void 90 | c-function gl-color-3fv glColor3fv a -- void 91 | c-function gl-end-list glEndList -- void 92 | c-function gl-gen-lists glGenLists n -- n 93 | c-function gl-new-list glNewList n n -- void 94 | 95 | \ Additions for Lesson 13 96 | c-function gl-call-lists glCallLists n n a -- void 97 | c-function gl-delete-lists glDeleteLists n n -- void 98 | c-function gl-list-base glListBase n -- void 99 | c-function gl-pop-attrib glPopAttrib -- void 100 | c-function gl-push-attrib glPushAttrib n -- void 101 | c-function gl-raster-pos-2f glRasterPos2f r r -- void 102 | c-function gl-xclosedisplay XCloseDisplay a -- n 103 | c-function gl-xfreefont XFreeFont a a -- n 104 | c-function gl-xloadqueryfont XLoadQueryFont a a -- a 105 | c-function gl-xopendisplay XOpenDisplay a -- a 106 | c-function gl-xusexfont glXUseXFont n n n n -- void 107 | 108 | \ Additions for Lesson 14 109 | \ -- 110 | 111 | \ Additions for Lesson 15 112 | \ -- 113 | 114 | \ Additions for Lesson 16 115 | c-function gl-delete-textures glDeleteTextures n a -- void 116 | c-function gl-fog-i glFogi n n -- void 117 | c-function gl-fog-fv glFogfv n a -- void 118 | c-function gl-fog-f glFogf n r -- void 119 | 120 | \ Additions for Lesson 17 121 | 122 | c-function gl-ortho glOrtho r r r r r r -- void 123 | c-function gl-pop-matrix glPopMatrix -- void 124 | c-function gl-push-matrix glPushMatrix -- void 125 | c-function gl-translate-d glTranslated r r r -- void 126 | c-function gl-vertex-2f glVertex2i r r -- void 127 | c-function gl-vertex-2i glVertex2i n n -- void 128 | 129 | end-c-library 130 | 131 | include glconstants.fs 132 | 133 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson17/opengl-lesson17-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson17.zip 3 | Author: Giuseppe D'Agata 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 07/31/2010 6 | Description: 2D texture mapped fonts 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 17 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 17 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson17/opengl-lesson17.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 17 ]--------------[07/31/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson17.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 17 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-ortho ( left right bottom top zNear zFar -- ) 33 | 34 | Multiply the current matrix with an orthographic matrix 35 | 36 | Parameters are all 32-bit floating point values. 37 | 38 | left, right: Specify the coordinates for the left and right 39 | vertical clipping planes. 40 | 41 | bottom, top: Specify the coordinates for the bottom and top 42 | horizontal clipping planes. 43 | 44 | zNear, zFar: Specify the distances to the nearer and farther 45 | depth clipping planes. These values are negative if the 46 | plane is to be behind the viewer. 47 | 48 | (In gforth, as these are passed by value, there is no conversion 49 | necessary to make these values into 32-bit floats from the normal 50 | gforth 64-bit floating point values.) 51 | 52 | gl-pop-matrix ( -- ) 53 | gl-push-matrix ( -- ) 54 | 55 | Push and pop the current matrix stack. 56 | 57 | Parameters: none. 58 | 59 | Description: There is a stack of matrices for each of the matrix 60 | modes. In GL_MODELVIEW mode, the stack depth is at least 32. In 61 | the other modes, GL_COLOR, const(PROJECTION), and GL_TEXTURE, the 62 | depth is at least 2. The current matrix in any mode is the matrix 63 | on the top of the stack for that mode. 64 | 65 | glPushMatrix pushes the current matrix stack down by one, 66 | duplicating the current matrix. That is, after a glPushMatrix 67 | call, the matrix on top of the stack is identical to the one 68 | below it. 69 | 70 | glPopMatrix pops the current matrix stack, replacing the current 71 | matrix with the one below it on the stack. 72 | 73 | Initially, each of the stacks contains one matrix, an identity 74 | matrix. 75 | 76 | It is an error to push a full matrix stack, or to pop a matrix 77 | stack that contains only a single matrix. In either case, the 78 | error flag is set and no other change is made to GL state. 79 | 80 | gl-translate-d ( x y z -- ) 81 | 82 | Multiply the current matrix by a translation matrix, using 64-bit 83 | C/C++ floating point values. 84 | 85 | Parameters , and are 64-bit floating point values. 86 | 87 | x/y/z: Specify the x, y, and z coordinates of a translation 88 | vector. 89 | 90 | (In gforth these are passed by value and there is no conversion 91 | necessary as they are already in the required 64-bit format.) 92 | 93 | gl-vertex-2f ( x y -- ) 94 | 95 | Specify a vertex. 96 | 97 | Parameters and are 32-bit floating point values. 98 | 99 | x/y: Specify the x,y coordinates of a vertex. 100 | 101 | (In gforth, as these are passed by value, there is no conversion 102 | necessary to make these values into 32-bit floats from the normal 103 | gforth 64-bit floating point values.) 104 | 105 | gl-vertex-2i ( x y -- ) 106 | 107 | Specify a vertex. 108 | 109 | Parameters and are integer values. 110 | 111 | x/y: Specify the x,y coordinates of a vertex. 112 | 113 | ---[ Installation ]-------------------------------------------------- 114 | 115 | If you are placing all of the Lessons in one directory, copy these 116 | three files to that directory: 117 | 118 | opengl-lesson17.fs - Code Addendum 1 119 | opengllib-1.17.fs - Code Addendum 2 120 | mini-opengl-1.17.fs - Code Addendum 3 121 | 122 | This Lesson requires the mini-sdl-1.01.fs file from Lesson 6, as well 123 | as all of the usual constants definition files. 124 | 125 | This Lesson also uses two image files which you can retrieve from the 126 | NeHe Lesson 17 page at: 127 | 128 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17 129 | 130 | or from the opengl-lesson17.zip file that will be posted to the 131 | Taygeta Forth Archives site listed at the start of this column. 132 | 133 | For the files from the opengl-lesson17.zip, extract them to wherever 134 | you wish to place them, or extract the above three files and the data 135 | directory into the directory you have placed the previous Lesson 136 | files. 137 | 138 | To use the LibUtil script, set the flag in opengllib-1.17.fs: 139 | 140 | 1 constant UseLibUtil 141 | 142 | and then run the script to install the files to the ~/.gforth dirs: 143 | 144 | cd 145 | ./libutil.sh -ra 146 | ./libutil.sh -i 147 | gforth 148 | include opengl-lesson17.fs 149 | lesson17 150 | 151 | If you prefer not to use the LibUtil script, set the flag to: 152 | 153 | 0 constant UseLibUtil 154 | 155 | and then you can execute the Lesson code with: 156 | 157 | cd 158 | gforth 159 | include opengl-lesson17.fs 160 | lesson17 161 | 162 | ---[ Next Up ]------------------------------------------------------- 163 | 164 | Lesson 18 - Quadrics 165 | 166 | ----------------------------------------------------[End Lesson17]--- 167 | 168 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson18/data/wall.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson18/data/wall.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson18/opengl-lesson18-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson18.zip 3 | Author: GB Schmick 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 08/01/2010 6 | Description: Quadrics 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 18 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 18 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson19/data/particle.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson19/data/particle.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson19/opengl-lesson19-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson19.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 08/01/2010 6 | Description: Particle Engine Using Triangle Strips 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 19 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 19 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson19/opengl-lesson19.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 19 ]--------------[08/01/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson19.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 19 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-tex-coord-2d ( s t -- ) 33 | 34 | Specifies texture coordinates in two dimensions 35 | 36 | Parameters and are 64-bit doubles (floats). 37 | 38 | The and parameters are the x/y coordinates defining the 39 | placement of the texture being worked with. 40 | 41 | (As gforth floats are normally 64-bits, there is no conversion 42 | necessary as they are in the correct format for C/C++ doubles.) 43 | 44 | ---[ Installation ]-------------------------------------------------- 45 | 46 | If you are placing all of the Lessons in one directory, copy these 47 | three files to that directory: 48 | 49 | opengl-lesson19.fs - Code Addendum 1 50 | opengllib-1.19.fs - Code Addendum 2 51 | mini-opengl-1.19.fs - Code Addendum 3 52 | 53 | This Lesson requires the mini-sdl-1.01.fs file from Lesson 6, as well 54 | as all of the usual constants definition files. 55 | 56 | This Lesson also uses an image file which you can retrieve from the 57 | NeHe Lesson 19 page at: 58 | 59 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=19 60 | 61 | or from the opengl-lesson19.zip file that will be posted to the 62 | Taygeta Forth Archives site listed at the start of this column. 63 | 64 | For the files from the opengl-lesson19.zip, extract them to wherever 65 | you wish to place them, or extract the above three files and the data 66 | directory into the directory you have placed the previous Lesson 67 | files. 68 | 69 | To use the LibUtil script, set the flag in opengllib-1.19.fs: 70 | 71 | 1 constant UseLibUtil 72 | 73 | and then run the script to install the files to the ~/.gforth dirs: 74 | 75 | cd 76 | ./libutil.sh -ra 77 | ./libutil.sh -i 78 | gforth 79 | include opengl-lesson19.fs 80 | lesson19 81 | 82 | If you prefer not to use the LibUtil script, set the flag to: 83 | 84 | 0 constant UseLibUtil 85 | 86 | and then you can execute the Lesson code with: 87 | 88 | cd 89 | gforth 90 | include opengl-lesson19.fs 91 | lesson19 92 | 93 | ---[ Next Up ]------------------------------------------------------- 94 | 95 | Lesson 20 - Masking 96 | 97 | ----------------------------------------------------[End Lesson19]--- 98 | 99 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson20/data/image1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson20/data/image1.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson20/data/image2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson20/data/image2.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson20/data/logo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson20/data/logo.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson20/data/mask1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson20/data/mask1.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson20/data/mask2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson20/data/mask2.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson20/opengl-lesson20-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson20.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 08/01/2010 6 | Description: Masking 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 20 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 20 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson20/opengl-lesson20.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 20 ]--------------[08/01/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson20.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 20 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | There are no new OpenGL additions to the mini-opengl libcc interface 31 | for this lesson. 32 | 33 | ---[ Installation ]-------------------------------------------------- 34 | 35 | If you are placing all of the Lessons in one directory, copy these 36 | three files to that directory: 37 | 38 | opengl-lesson20.fs - Code Addendum 1 39 | opengllib-1.20.fs - Code Addendum 2 40 | mini-opengl-1.20.fs - Code Addendum 3 41 | 42 | This Lesson requires the mini-sdl-1.01.fs file from Lesson 6, as well 43 | as all of the usual constants definition files. 44 | 45 | This Lesson also uses five image files which you can retrieve from 46 | the NeHe Lesson 20 page at: 47 | 48 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=20 49 | 50 | or from the opengl-lesson20.zip file that will be posted to the 51 | Taygeta Forth Archives site listed at the start of this column. 52 | 53 | For the files from the opengl-lesson20.zip, extract them to wherever 54 | you wish to place them, or extract the above three files and the data 55 | directory into the directory you have placed the previous Lesson 56 | files. 57 | 58 | To use the LibUtil script, set the flag in opengllib-1.20.fs: 59 | 60 | 1 constant UseLibUtil 61 | 62 | and then run the script to install the files to the ~/.gforth dirs: 63 | 64 | cd 65 | ./libutil.sh -ra 66 | ./libutil.sh -i 67 | gforth 68 | include opengl-lesson20.fs 69 | lesson20 70 | 71 | If you prefer not to use the LibUtil script, set the flag to: 72 | 73 | 0 constant UseLibUtil 74 | 75 | and then you can execute the Lesson code with: 76 | 77 | cd 78 | gforth 79 | include opengl-lesson20.fs 80 | lesson20 81 | 82 | ---[ Next Up ]------------------------------------------------------- 83 | 84 | Lesson 21 - Lines, timing, ortho and sound 85 | 86 | ----------------------------------------------------[End Lesson20]--- 87 | 88 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson21/data/complete.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson21/data/complete.wav -------------------------------------------------------------------------------- /OpenGL/opengl-lesson21/data/die.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson21/data/die.wav -------------------------------------------------------------------------------- /OpenGL/opengl-lesson21/data/font.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson21/data/font.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson21/data/freeze.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson21/data/freeze.wav -------------------------------------------------------------------------------- /OpenGL/opengl-lesson21/data/hourglass.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson21/data/hourglass.wav -------------------------------------------------------------------------------- /OpenGL/opengl-lesson21/data/image.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson21/data/image.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson21/data/lktheme.mod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson21/data/lktheme.mod -------------------------------------------------------------------------------- /OpenGL/opengl-lesson21/mini-mixer-1.00.fs: -------------------------------------------------------------------------------- 1 | \ =================================================================== 2 | \ Program: mini-mixer-1.00.fs 3 | \ Author: Timothy Trussell 4 | \ Date: 08/01/2010 5 | \ Description: SDL_Mixer libcc interface 6 | \ Forth System: gforth-0.7.0 7 | \ Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 8 | \ C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 9 | \ =================================================================== 10 | \ This libcc interface contains the SDL_Mixer code required for use 11 | \ with the NeHe OpenGL Tutorials. 12 | \ =================================================================== 13 | \ This file should be loaded *after* the mini-sdl-1.xx.fs file, as 14 | \ it requires the definitions in the sdlconstants.fs file. 15 | \ =================================================================== 16 | 17 | UseLibUtil [if] 18 | c-library mini_mixer_lib 19 | [else] 20 | c-library mini_mixer_lib21 21 | [then] 22 | 23 | s" SDL_mixer" add-lib 24 | 25 | \c #include 26 | 27 | \ Initial Entries for Lesson 21 28 | c-function mix-close-audio Mix_CloseAudio -- void 29 | c-function mix-free-chunk Mix_FreeChunk a -- void 30 | c-function mix-free-music Mix_FreeMusic a -- void 31 | c-function mix-halt-channel Mix_HaltChannel n -- n 32 | c-function mix-halt-music Mix_HaltMusic -- n 33 | c-function mix-load-mus Mix_LoadMUS a -- a 34 | c-function mix-load-wav Mix_LoadWAV a -- a 35 | c-function mix-open-audio Mix_OpenAudio n n n n -- n 36 | c-function mix-play-music Mix_PlayMusic a n -- n 37 | c-function mix-play-channel Mix_PlayChannel n a n -- n 38 | 39 | end-c-library 40 | 41 | \ From SDL_audio.h 42 | AUDIO_U16LSB constant AUDIO_U16 43 | AUDIO_S16LSB constant AUDIO_S16 44 | 45 | \ @name Native audio byte ordering 46 | 47 | SDL_BYTEORDER SDL_LIL_ENDIAN = [if] \ requires sdlconstants.fs 48 | AUDIO_U16LSB constant AUDIO_U16SYS 49 | AUDIO_S16LSB constant AUDIO_S16SYS 50 | [else] 51 | AUDIO_U16MSB constant AUDIO_U16SYS 52 | AUDIO_S16MSB constant AUDIO_S16SYS 53 | [then] 54 | 55 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson21/opengl-lesson21-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson21.zip 3 | Author: Jeff Molofee 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 08/01/2110 6 | Description: Lines, timing, ortho and sound 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 21 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 21 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson22/data/base.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson22/data/base.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson22/data/bump.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson22/data/bump.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson22/data/multi_on.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson22/data/multi_on.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson22/data/multi_on_alpha.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson22/data/multi_on_alpha.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson22/data/opengl.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson22/data/opengl.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson22/data/opengl_alpha.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson22/data/opengl_alpha.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson22/opengl-lesson22-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson22.zip 3 | Author: Jens Schneider 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 08/06/2010 6 | Description: Bump mapping (extensions) 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 22 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 22 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson23/data/bg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson23/data/bg.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson23/data/reflect.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson23/data/reflect.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson23/opengl-lesson23-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson23.zip 3 | Author: GB Schmick 4 | Linux Version: Ti Leggett 5 | gForth Version: Timothy Trussell, 08/07/2010 6 | Description: Sphere mapping quadrics 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 23 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 23 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson23/opengl-lesson23.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 23 ]--------------[08/07/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson23.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 23 at 23 | 24 | www.nehe.gamedev.net 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-tex-gen-i ( coord pname param -- ) 33 | 34 | Control the generation of texture coordinates. 35 | 36 | Parameters , and are integer values. 37 | 38 | coord: Specifies a texture coordinate. Must be one of: 39 | GL_S, GL_T, GL_R, or GL_Q 40 | 41 | pname: Specifies the symbolic name of the texture-coordinate 42 | generation function. Must be GL_TEXTURE_GEN_MODE. 43 | 44 | param: Specifies a single-valued texture generation parameter, 45 | one of GL_OBJECT_LINEAR, GL_EYE_LINEAR, or GL_SPHERE_MAP. 46 | 47 | ---[ Installation ]-------------------------------------------------- 48 | 49 | If you are placing all of the Lessons in one directory, copy these 50 | four files to that directory: 51 | 52 | opengl-lesson23.fs - Code Addendum 1 53 | opengllib-1.23.fs - Code Addendum 2 54 | mini-opengl-1.23.fs - Code Addendum 3 55 | 56 | This Lesson requires the mini-sdl-1.01.fs file from Lesson 6, as well 57 | as all of the usual constants definition files. 58 | 59 | This Lesson uses two image files which you can retrieve from the NeHe 60 | Lesson 23 page at: 61 | 62 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=23 63 | 64 | or from the opengl-lesson23.zip file that will be posted to the 65 | Taygeta Forth Archives site listed at the start of this column. 66 | 67 | For the files from the opengl-lesson23.zip, extract them to wherever 68 | you wish to place them, or extract the above three files and the data 69 | directory into the directory you have placed the previous Lesson 70 | files. 71 | 72 | To use the LibUtil script, set the flag in opengllib-1.23.fs: 73 | 74 | 1 constant UseLibUtil 75 | 76 | and then run the script to install the files to the ~/.gforth dirs: 77 | 78 | cd 79 | ./libutil.sh -ra 80 | ./libutil.sh -i 81 | gforth 82 | include opengl-lesson23.fs 83 | lesson23 84 | 85 | If you prefer not to use the LibUtil script, set the flag to: 86 | 87 | 0 constant UseLibUtil 88 | 89 | and then you can execute the Lesson code with: 90 | 91 | cd 92 | gforth 93 | include opengl-lesson23.fs 94 | lesson23 95 | 96 | ---[ Next Up ]------------------------------------------------------- 97 | 98 | Lesson 24 - Tokens, scissor testing, TGA 99 | 100 | ----------------------------------------------------[End Lesson23]--- 101 | 102 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson24/data/font.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson24/data/font.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson24/data/font.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson24/data/font.tga -------------------------------------------------------------------------------- /OpenGL/opengl-lesson24/opengl-lesson24-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson24.zip 3 | Author: Jeff Molofee 4 | Linux Version: DarkAlloy 5 | gForth Version: Timothy Trussell, 05/01/2011 6 | Description: Tokens, extension, scissor testing, TGA 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.31-24 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 24 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 24 code for gforth 18 | 19 | ===================================================================== 20 | 21 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson25/opengl-lesson25-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson25.zip 3 | Author: Piotr Cieslak 4 | Linux Version: DarkAlloy 5 | gForth Version: Timothy Trussell, 05/25/2011 6 | Description: Morphing, loading objects 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.32-31 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 25 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 25 code for gforth 18 | 19 | ===================================================================== 20 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson25/opengl-lesson25.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 25 ]--------------[05/25/2011]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson25.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 25 at 23 | 24 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=25 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | There are no new OpenGL functions implemented in this Lesson. 31 | 32 | ---[ Installation ]-------------------------------------------------- 33 | 34 | If you are placing all of the Lessons in one directory, copy these 35 | files to that directory: 36 | 37 | opengl-lesson25.fs - Code Addendum 1 38 | opengllib-1.25.fs - Code Addendum 2 39 | mini-opengl-1.25.fs - Code Addendum 3 40 | sdlkeysym.fs - Code Addendum 4 -- changed 05/25/11 41 | 42 | This Lesson requires the mini-sdl-1.02.fs file from Lesson 24 as well 43 | as all of the usual constants definition files. 44 | 45 | This Lesson uses three data files which you can retrieve from the 46 | NeHe Lesson 25 page at the above posted web address, or from the 47 | opengl-lesson25.zip file that will be posted to the Taygeta Forth 48 | Archives site listed at the start of this column. 49 | 50 | For the files from the opengl-lesson25.zip, extract them to wherever 51 | you wish to place them, or extract the above files and the data 52 | directory into the directory you have placed the previous Lesson 53 | files. 54 | 55 | To use the LibUtil script, set the flag in opengllib-1.25.fs: 56 | 57 | 1 =: UseLibUtil 58 | 59 | and then run the script to install the files to the ~/.gforth dirs: 60 | 61 | cd 62 | ./libutil.sh -ra 63 | ./libutil.sh -i 64 | gforth 65 | include opengl-lesson25.fs 66 | lesson25 67 | 68 | If you prefer not to use the LibUtil script, set the flag to: 69 | 70 | 0 =: UseLibUtil 71 | 72 | and then you can execute the Lesson code with: 73 | 74 | cd 75 | gforth 76 | include opengl-lesson25.fs 77 | lesson25 78 | 79 | ---[ Errata ]-------------------------------------------------------- 80 | 81 | Found an error in the sdlkeysym.fs file with the definition of the 82 | SDLK_z constant. The correct value is [122], rather than the [121] 83 | that is present in (probably) all previous postings of this file. 84 | 85 | Replace all previous versions with this one. (If you have all of the 86 | Lesson files in one directory, simply replace the old copy with this 87 | new version and you will be set - or change the entry yourself.) 88 | 89 | ---[ Next Up ]------------------------------------------------------- 90 | 91 | Lesson 26 - Clipping & Reflections Using The Stencil Buffer 92 | 93 | ----------------------------------------------------[End Lesson25]--- 94 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson26/data/Ball.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson26/data/Ball.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson26/data/Envroll.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson26/data/Envroll.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson26/data/Envwall.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/OpenGL/opengl-lesson26/data/Envwall.bmp -------------------------------------------------------------------------------- /OpenGL/opengl-lesson26/opengl-lesson26-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson26.zip 3 | Author: Banu Cosmin 4 | Linux Version: Gray Fox 5 | gForth Version: Timothy Trussell, 05/27/2011 6 | Description: Clipping & Reflections Using The Stencil Buffer 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.32-31 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 26 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 26 code for gforth 18 | 19 | ===================================================================== 20 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson27/opengl-lesson27-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: opengl-lesson27.zip 3 | Author: Banu Cosmin 4 | Linux Version: Jeff Pound 5 | gForth Version: Timothy Trussell, 06/16/2011 6 | Description: Shadows 7 | Forth System: gforth-0.7.0 8 | Linux System: Ubuntu v10.04 LTS i386, kernel 2.6.32-32 9 | C++ Compiler: gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 10 | ===================================================================== 11 | NeHe Productions 12 | http://nehe.gamedev.net/ 13 | ===================================================================== 14 | OpenGL Tutorial Lesson 27 15 | ===================================================================== 16 | 17 | Conversion of NeHe's OpenGL Lesson 27 code for gforth 18 | 19 | ===================================================================== 20 | -------------------------------------------------------------------------------- /OpenGL/opengl-lesson27/opengl-lesson27.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: OpenGL Graphics Lesson 27 ]--------------[06/16/2011]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column will be posted to the Taygeta Forth Achive site: 8 | 9 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 10 | 11 | in the file: 12 | 13 | opengl-lesson27.zip 14 | 15 | along with all required source files. 16 | 17 | It may take a little time for the files to be moved to the above 18 | directory, so keep checking until they have been placed there. 19 | 20 | ---[ Where We Are ]-------------------------------------------------- 21 | 22 | Read thru the Tutorial for Lesson 27 at 23 | 24 | http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=27 25 | 26 | for the description of what is going on with this code. 27 | 28 | ---[ Additions ]----------------------------------------------------- 29 | 30 | Additions to the mini-opengl libcc interface for this lesson are: 31 | 32 | gl-cull-face ( mode -- ) 33 | 34 | specify whether front- or back-facing facets can be culled 35 | 36 | Parameter is an integer value. 37 | 38 | mode: Specifies whether front- or back-facing facets are 39 | candidates for culling. 40 | Symbolic constants GL_FRONT, GL_BACK, and GL_FRONT_AND_BACK 41 | are accepted. The initial value is GL_BACK. 42 | 43 | gl-depth-mask ( flag -- ) 44 | 45 | enable or disable writing into the depth buffer 46 | 47 | Parameter is an integer value. 48 | 49 | flag: Specifies whether the depth buffer is enabled for 50 | writing. If flag is GL_FALSE, depth buffer writing is 51 | disabled. Otherwise, it is enabled. Initially, depth buffer 52 | writing is enabled. 53 | 54 | gl-front-face ( mode -- ) 55 | 56 | define front- and back-facing polygons 57 | 58 | Parameter is an integer value. 59 | 60 | mode: Specifies the orientation of front-facing polygons. 61 | GL_CW and GL_CCW are accepted. 62 | The initial value is GL_CCW. 63 | 64 | gl-material-fv ( face pname *params -- ) 65 | 66 | specify material parameters for the lighting model 67 | 68 | Parameters and are integers; <*params> is a 69 | pointer to an array of 32-bit floats (SFLOATs) 70 | 71 | face: Specifies which face or faces are being updated. 72 | Must be one of GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK. 73 | 74 | pname: Specifies the single-valued material parameter of the 75 | face or faces that is being updated. Must be GL_SHININESS. 76 | 77 | *params: Specifies the value that parameter GL_SHININESS will 78 | be set to. 79 | 80 | ---[ Installation ]-------------------------------------------------- 81 | 82 | If you are placing all of the Lessons in one directory, copy these 83 | files to that directory: 84 | 85 | opengl-lesson27.fs - Code Addendum 1 86 | opengllib-1.27.fs - Code Addendum 2 87 | mini-opengl-1.27.fs - Code Addendum 3 88 | 89 | This Lesson requires the mini-sdl-1.02.fs file from Lesson 24 as well 90 | as all of the usual constants definition files. 91 | 92 | The four data files used by the original code have been incorporated 93 | into the source code of this Lesson. 94 | 95 | For the files from the opengl-lesson27.zip, extract them to wherever 96 | you wish to place them, or extract the above files and the data 97 | directory into the directory you have placed the previous Lesson 98 | files. 99 | 100 | To use the LibUtil script, set the flag in opengllib-1.27.fs: 101 | 102 | 1 =: UseLibUtil 103 | 104 | and then run the script to install the files to the ~/.gforth dirs: 105 | 106 | cd 107 | ./libutil.sh -ra 108 | ./libutil.sh -i 109 | gforth 110 | include opengl-lesson27.fs 111 | lesson27 112 | 113 | If you prefer not to use the LibUtil script, set the flag to: 114 | 115 | 0 =: UseLibUtil 116 | 117 | and then you can execute the Lesson code with: 118 | 119 | cd 120 | gforth 121 | include opengl-lesson27.fs 122 | lesson27 123 | 124 | ---[ Next Up ]------------------------------------------------------- 125 | 126 | Lesson 28 - Bezier Patches 127 | 128 | ----------------------------------------------------[End Lesson27]--- 129 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Legacy OpenGL and SDL Graphics Lesson in Gforth. 2 | 3 | This github repo is an unzipped copy of ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ with the agreement of the author. 4 | 5 | I created it as backup and an easier sharing access than zip and ftp. Forth is a very interessig old language and lot of websites are down and their Forth code source lost. Therefore, in my opinion, for perinity, forth code databases need to be duplicated. 6 | -------------------------------------------------------------------------------- /SDL/README.md: -------------------------------------------------------------------------------- 1 | 2 | Please distribute this file with the SDL runtime environment: 3 | 4 | The Simple DirectMedia Layer (SDL for short) is a cross-platfrom library 5 | designed to make it easy to write multi-media software, such as games and 6 | emulators. 7 | 8 | The Simple DirectMedia Layer library source code is available from: 9 | http://www.libsdl.org/ 10 | 11 | This library is distributed under the terms of the GNU LGPL license: 12 | http://www.gnu.org/copyleft/lesser.html 13 | 14 | -------------------------------------------------------------------------------- /SDL/sdl-01-gforth install-and-followups.txt/sdl-01-description.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-01-gforth install-and-followups.txt 3 | Title: gforth: SDL/OpenGL Graphics Part I 4 | Author: Timothy Trussell 5 | Date: 02/05/2010 6 | Description: Installation tutorial for SDL/OpenGL under the Ubuntu 7 | : Linux operating system 8 | ===================================================================== 9 | gforth: SDL/OpenGL Graphics Part I 10 | ===================================================================== 11 | 12 | Tutorial on installing Ubuntu Linux, SDL, OpenGL and gforth, to give 13 | the programming tools necessary to create SDL/OpenGL graphics programs 14 | under gforth. 15 | 16 | The 'prequel' to a series of tutorials on programming in SDL/OpenGL. 17 | 18 | Note- 19 | 20 | I have included the responses from the comp.lang.forth newsgroup that 21 | were posted prior to my placing this file on the Taygeta site. 22 | 23 | ===================================================================== 24 | Timothy Trussell 02/05/2010 25 | ===================================================================== 26 | 27 | -------------------------------------------------------------------------------- /SDL/sdl-16bpp.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 01 ]============================================ 2 | \ gforth/SDL 16-bpp Pixel Demo 3 | \ =================================================================== 4 | \ File Name: sdl-16bpp.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 04/05/2010 7 | \ Description: SDL 16-bpp demo 8 | \ Forth System: gforth-0.7.0 9 | \ Linux System: Ubuntu v9.10 i386, kernel 2.6.31-20 10 | \ C++ Compiler: gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1 11 | \ =================================================================== 12 | \ From the Linux Journal 4401.tgz 13 | \ =================================================================== 14 | 15 | page .( ---[ Loading SDL 16-bpp Demo ]---) cr 16 | 17 | [IFDEF] ---marker--- 18 | ---marker--- 19 | [ENDIF] 20 | 21 | marker ---marker--- 22 | 23 | decimal 24 | 25 | require sdllib.fs 26 | 27 | 0 value demo-raw-pixels 28 | 0 value demo-pixel-color 29 | 0 value demo-offset 30 | 31 | \ ---[ Create-16bpp-Pixel ]------------------------------------------ 32 | \ Maps the passed r/g/b components to the desired 16-bpp value 33 | 34 | : Map-Pixel { *dst _r _g _b -- n } 35 | *dst sdl-surface-format @ _r _g _b sdl-map-rgb 36 | ; 37 | 38 | : demo16 ( -- ) 39 | \ Initialize the graphics display. 40 | 1024x768x16 s" SDL 16-bpp Demo0" InitGraph \ init display 41 | 42 | screen-surface sdl-mustlock if \ Lock the surface if required 43 | screen-surface sdl-locksurface drop 44 | then 45 | 46 | screen-surface sdl-surface-pixels @ to demo-raw-pixels \ save ptr 47 | 48 | \ We can now safely write to the video surface. We'll draw a nice 49 | \ gradient pattern by varying our red and blue components along the 50 | \ X and Y axes. 51 | 52 | window-screenh 0 do 53 | window-screenw 0 do 54 | screen-surface j 0 i Map-Pixel to demo-pixel-color 55 | \ Calculate the memory offset of the pixel we wish to change 56 | screen-surface sdl-surface-pitch sw@ j * i 2 * + to demo-offset 57 | demo-pixel-color demo-raw-pixels demo-offset + w! 58 | loop 59 | loop 60 | 61 | \ Now unlock the surface if required 62 | screen-surface sdl-mustlock if 63 | screen-surface sdl-unlocksurface 64 | then 65 | 66 | \ copy the buffer to the visible screen surface 67 | screen-surface sdl-flip drop 68 | 69 | \ ooohs and aaahs time... 70 | 10 to demo-offset \ to let you use whatever delay you want 71 | cr ." Timer delay: " 72 | demo-offset 0 do 73 | demo-offset i - . 74 | 1000 sdl-delay 75 | loop 76 | 0 . 77 | CloseGraph 78 | ; 79 | 80 | cr .( SDL-16bpp: demo16 ) cr 81 | 82 | -------------------------------------------------------------------------------- /SDL/sdl-tut02/gforth1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/SDL/sdl-tut02/gforth1.bmp -------------------------------------------------------------------------------- /SDL/sdl-tut02/sdl-tut02-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-tut02.zip 3 | Title: gforth: SDL/OpenGL Graphics Part II 4 | Author: Timothy Trussell 5 | Date: 02/07/2010 6 | Description: Displaying a Bitmapped Image 7 | ===================================================================== 8 | gforth: SDL/OpenGL Graphics Part II 9 | ===================================================================== 10 | 11 | Tutorial on displaying a bitmapped image to the display window. 12 | 13 | ===================================================================== 14 | Timothy Trussell 02/07/2010 15 | ===================================================================== 16 | 17 | -------------------------------------------------------------------------------- /SDL/sdl-tut02/sdl.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 02 ]============================================ 2 | \ gforth: SDL/OpenGL Graphics Part II 3 | \ =================================================================== 4 | \ File Name: sdl.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 02/07/2010 7 | \ Description: SDL Interface for gforth sdl-tut02 demo 8 | \ Forth System: gforth-0.7.0 9 | \ Linux System: Ubuntu v9.10 i386, kernel 2.6.31-19 10 | \ C++ Compiler: gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1 11 | \ =================================================================== 12 | \ Requires Code Addendum 03 13 | \ =================================================================== 14 | 15 | \ ---[Note]---------------------------------------------------------- 16 | \ An 'f' as a return value indicates a flag - usually boolean. 17 | \ 0 denote success, -1 denotes failure. 18 | \ Reference the SDL_video.h include file in the C++ source 19 | \ Probably at: /usr/include/SDL/SDL_video.h 20 | \ ------------------------------------------------------[End Note]--- 21 | 22 | \ ---[ gforth Prototypes ]------------------------------------------- 23 | \ sdl-init ( flags -- error code ) 24 | \ sdl-set-video-mode ( width height bpp flags -- *surface ) 25 | \ sdl-quit ( -- ) 26 | \ sdl-loadbmp ( *filename -- *surface ) 27 | \ sdl-freesurface ( *surface -- ) 28 | \ sdl-blitsurface ( *src *srcrect *dst *dstref -- f ) 29 | \ sdl-flip ( *surface -- f ) 30 | \ sdl-delay ( uint32_ms -- ) 31 | \ sdl-show-cursor ( toggle -- status ) 32 | \ sdl-wm-set-caption ( *title *icon -- ) 33 | \ ------------------------------------------------[End Prototypes]--- 34 | 35 | c-library sdl_t02 36 | s" SDL" add-lib 37 | 38 | \c #include 39 | 40 | c-function sdl-init SDL_Init n -- n 41 | c-function sdl-set-video-mode SDL_SetVideoMode n n n n -- a 42 | c-function sdl-quit SDL_Quit -- void 43 | c-function sdl-loadbmp SDL_LoadBMP a -- a 44 | c-function sdl-freesurface SDL_FreeSurface a -- void 45 | c-function sdl-blitsurface SDL_BlitSurface a a a a -- n 46 | c-function sdl-flip SDL_Flip a -- n 47 | c-function sdl-delay SDL_Delay n -- void 48 | 49 | c-function sdl-show-cursor SDL_ShowCursor n -- n 50 | 51 | c-function sdl-wm-set-caption SDL_WM_SetCaption a a -- void 52 | 53 | end-c-library 54 | 55 | \ Transfer the constants used to this file 56 | 57 | include sdlconstants.fs 58 | 59 | -------------------------------------------------------------------------------- /SDL/sdl-tut03/sdl-putpixel.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 01 ]============================================ 2 | \ gforth: SDL/OpenGL Graphics Part III 3 | \ =================================================================== 4 | \ File Name: sdl-putpixel.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 02/18/2010 7 | \ Description: SDL PutPixel primitive 8 | \ Forth System: gforth-0.7.0 9 | \ Linux System: Ubuntu v9.10 i386, kernel 2.6.31-19 10 | \ C++ Compiler: gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1 11 | \ =================================================================== 12 | 13 | \ ---[ Prototypes ]-------------------------------------------------- 14 | \ PutPixel { *dst x y c -- } 15 | \ ------------------------------------------------[End Prototypes]--- 16 | 17 | \ PutPixel accesses the and fields of the sdl-surface 18 | \ structure, which is defined in the sdl.fs file. 19 | 20 | \ defines the window-width of the surface 21 | \ is a pointer to the actual memory for the surface data 22 | 23 | \ Note that the window-width represents is generated by the 24 | \ SDL video subsystem, not by the call to InitGraph which we make to 25 | \ create a display window. 26 | 27 | \ ---[ PutPixel ]---------------------------------------------------- 28 | 29 | : PutPixel { *dst _x _y _pixel -- } 30 | \ Lock the surface if required 31 | *dst sdl-mustlock if 32 | *dst sdl-locksurface drop 33 | then 34 | \ Calculate the target address of the pixel 35 | *dst sdl-surface-pixels @ \ *pixels 32-bit pointer 36 | *dst sdl-surface-pitch sw@ \ *pixels swidth 16-bit value 37 | _y * + \ *pixels[swidth*y] 38 | *dst sdl-surface-format @ \ *pixels[swidth*y] *format 39 | sdl-pixelformat-bytesperpixel \ *pixels[swidth*y] *format->bytepp 40 | C@ \ *pixels[swidth*y] bytepp 41 | dup >R \ *pixels[swidth*y] bytepp 42 | _x * + \ *pixels[ofs] 43 | R> \ *pixels[ofs] bytepp 44 | case \ *pixels[ofs] 45 | 1 of _pixel swap C! endof 46 | 2 of _pixel swap w! endof 47 | 3 of SDL_BYTEORDER SDL_BIG_ENDIAN = if 48 | _pixel 16 RSHIFT over C! 1+ 49 | _pixel 8 RSHIFT over C! 1+ 50 | _pixel swap C! 51 | else 52 | _pixel over C! 1+ 53 | _pixel 8 RSHIFT over C! 1+ 54 | _pixel 16 RSHIFT swap C! 55 | then 56 | endof 57 | 4 of _pixel swap ! endof 58 | endcase 59 | \ Now unlock the surface if required 60 | *dst sdl-mustlock if 61 | *dst sdl-unlocksurface 62 | then 63 | ; 64 | -------------------------------------------------------------------------------- /SDL/sdl-tut03/sdl-tut03-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-tut03.zip 3 | Title: gforth: SDL/OpenGL Graphics Part II 4 | Author: Timothy Trussell 5 | Date: 02/18/2010 6 | Description: Plotting Pixels to SDL Surfaces 7 | ===================================================================== 8 | gforth: SDL/OpenGL Graphics Part III 9 | ===================================================================== 10 | 11 | Tutorial on plotting pixels to the SDL display surfaces 12 | 13 | ===================================================================== 14 | Timothy Trussell 02/17/2010 15 | ===================================================================== 16 | 17 | -------------------------------------------------------------------------------- /SDL/sdl-tut04/sdl-tut04-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-tut04.zip 3 | Title: gforth: SDL/OpenGL Graphics Part IV 4 | Author: Timothy Trussell 5 | Date: 02/22/2010 6 | Description: Plotting Pixels to SDL Surfaces 7 | ===================================================================== 8 | gforth: SDL/OpenGL Graphics Part IV 9 | ===================================================================== 10 | 11 | Expanding on PutPixel. Adding more primitives to our SDL toolbox. 12 | 13 | ===================================================================== 14 | Timothy Trussell 02/22/2010 15 | ===================================================================== 16 | 17 | -------------------------------------------------------------------------------- /SDL/sdl-tut05/sdl-tut05-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-tut05.zip 3 | Title: gforth: SDL/OpenGL Graphics Part V 4 | Author: Timothy Trussell 5 | Date: 02/26/2010 6 | Description: Putting together the Graphics Primitives Library 7 | ===================================================================== 8 | gforth: SDL/OpenGL Graphics Part V 9 | ===================================================================== 10 | 11 | Building the graphics primitives library 12 | 13 | ===================================================================== 14 | Timothy Trussell 02/26/2010 15 | ===================================================================== 16 | 17 | -------------------------------------------------------------------------------- /SDL/sdl-tut05/sdl-tut05.txt: -------------------------------------------------------------------------------- 1 | ---[ gforth: SDL/OpenGL Graphics Part V ]-------------[02/26/2010]--- 2 | 3 | by Timothy Trussell 4 | 5 | ---[ Information ]--------------------------------------------------- 6 | 7 | This column, as with the rest of this series of columns, will be 8 | posted to the Taygeta Forth Achive site: 9 | 10 | ftp://ftp.taygeta.com/pub/Forth/Archive/tutorials/gforth-sdl-opengl/ 11 | 12 | in the file: 13 | 14 | sdl-tut05.zip 15 | 16 | It may take a little time for the files to be moved to the above 17 | directory, so keep checking until they have been placed there. 18 | 19 | ---[ Where We Are ]-------------------------------------------------- 20 | 21 | We have all of primitives needed to put a library together, so we 22 | will go ahead and do that. 23 | 24 | The function listing of our library consists of the following: 25 | 26 | \ ---[ SDL Primitives ]-------------------------------------------- 27 | \ Basic primitive functions library 28 | 29 | \ ------------------- 30 | \ ---[ Prototype Listing ]----------------------------------------- 31 | \ ------------------- 32 | 33 | \ : SDLLib-Version ( -- ) 34 | 35 | \ : Error-End ( f addr n -- ) 36 | \ : Terminate-String ( a n -- a ) 37 | \ : Set-Mode-Parms ( mode -- ) 38 | \ : InitGraph ( mode a n -- ) 39 | \ : CloseGraph ( -- ) 40 | 41 | \ : { *ofs _pixel _bytepp -- } 42 | \ : PutPixel { *dst _x _y _pixel -- } 43 | \ : Line { *dst _x1 _y1 _x2 _y2 _pixel -- } 44 | \ : VLine { *dst _x _y1 _y2 _pixel -- } 45 | \ : HLine { *dst _x1 _x2 _y _pixel -- } 46 | \ : { *dst _x _y _w _h *src tflag -- } 47 | \ : PutImage ( *dst _x _y _w _h *src -- ) 48 | \ : PutSprite ( *dst _x _y _w _h *src -- ) 49 | 50 | \ : Splash-Screen ( -- ) 51 | \ --------------------------------------------[ End Prototypes ]--- 52 | 53 | ---[ Error-End ]--- 54 | 55 | This our SDL error code handler. It is passed a boolean flag and an 56 | error string. If the flag resolves to a 0 value, then the SDL 57 | function completed successfully, and Error-End does nothing. 58 | 59 | If the flag resolves to a non-zero value then the SDL function was 60 | not successful. In this case, we need to shut down the SDL systems, 61 | close the display window, and print the error message to the terminal 62 | window. It then drops out of gforth. 63 | 64 | ---[ Terminate-String ]--- 65 | 66 | The SDL functions require that any strings passed are delimited with 67 | a 0 value. This function converts the normal gforth string to this 68 | format. To do this, the passed string has to have an extra byte at 69 | the end, which will be converted to a zero value. 70 | 71 | Example: 72 | 73 | s" This is to be passed to an SDL function0" Terminate-String 74 | 75 | The address and length of the string is passed to Terminate-String, 76 | which changes the "0" character to an actual zero value, and leaves 77 | just the address of the string on the stack. 78 | 79 | ---[ Set-Mode-Parms ]--- 80 | 81 | This function is a shortcut, to allow you to change the resolution 82 | settings for the display window by changing only one parameter - the 83 | one you use in your main function when calling InitGraph: 84 | 85 | 640x480x8 s" Window-Title0" InitGraph 86 | 87 | It also sets the following user variables - which the SDL library 88 | functions do not see (directly): 89 | 90 | window-screenw 91 | window-screenh 92 | window-screenbpp 93 | 94 | ---[ InitGraph ]--- 95 | 96 | The call to InitGraph has been changed to allow you to set the 97 | window title by passing a string as the second (and third) parameters 98 | to the InitGraph call. If you do not want to display a window title, 99 | simply put two NULL entries as the parameters instead: 100 | 101 | 640x480x8 NULL NULL InitGraph 102 | 103 | If you set the VALUE mouse-cursor-display to TRUE, then InitGraph 104 | will turn off the mouse cursor, so if you happen to run the mouse 105 | over the display window while the program is running. 106 | 107 | ---[ CloseGraph ]--- 108 | 109 | Re-enables the mouse cursor if mouse-cursor-display is TRUE, then 110 | shuts down the SDL subsystems and closes the display window. 111 | 112 | The only surface that is freed when the SDL video subsystem is shut 113 | down is screen-surface, which is allocated during the InitGraph call. 114 | It is the programmers' responsibility to free any additional memory 115 | allocations that the program has made (such as additional surfaces). 116 | 117 | I would suggest the coding of your own version of Error-End, which 118 | will also free allocated memory prior to closing down SDL. 119 | 120 | ---[ Graphics Primitives ]--- 121 | 122 | These primitives were discussed in my last column: 123 | 124 | 125 | PutPixel 126 | Line 127 | VLine 128 | HLine 129 | 130 | PutImage 131 | PutSprite 132 | 133 | and have a few more comments attached to them in this file. 134 | 135 | ---[ Splash Screen ]--- 136 | 137 | The last word in this library is included to show that the basic 138 | functions of the library work, by initializing SDL, opening a display 139 | window, loading and displaying a .BMP image, pausing, and then 140 | closing down everything. 141 | 142 | The archive version (at the Taygeta Forth Archive site) will include 143 | the splash screen, which I am not going to attempt to post with this 144 | column. 145 | 146 | ---[ Wrapping It Up ]------------------------------------------------ 147 | 148 | This completes the basic graphics primitives library, which will let 149 | us run the animation demo that I originally wrote for my Graphics of 150 | the Second Kind, Parts III and IV columns. 151 | 152 | ------------------------------------------[ End of sdl-tut05.txt ]--- 153 | 154 | -------------------------------------------------------------------------------- /SDL/sdl-tut05/sdllib.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/SDL/sdl-tut05/sdllib.bmp -------------------------------------------------------------------------------- /SDL/sdl-tut06/sdl-tut06-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-tut06.zip 3 | Title: gforth: SDL/OpenGL Graphics Part VI 4 | Author: Timothy Trussell 5 | Date: 02/28/2010 6 | Description: Exercising the Graphics Primitives Library 7 | ===================================================================== 8 | gforth: SDL/OpenGL Graphics Part VI 9 | ===================================================================== 10 | 11 | Exercising the graphics primitives library 12 | 13 | ===================================================================== 14 | Timothy Trussell 02/28/2010 15 | ===================================================================== 16 | 17 | -------------------------------------------------------------------------------- /SDL/sdl-tut06/sdllib.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/SDL/sdl-tut06/sdllib.bmp -------------------------------------------------------------------------------- /SDL/sdl-tut07/sdl-ttf-1.00.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 03 ]============================================ 2 | \ gforth: SDL/OpenGL Graphics Part VII 3 | \ =================================================================== 4 | \ File Name: sdl-ttf-1.00.fs 5 | \ Version: 1.00 6 | \ Author: Timothy Trussell 7 | \ Date: 03/24/2010 8 | \ Description: SDL TrueType Font Interface for gforth 9 | \ Forth System: gforth-0.7.0 10 | \ Linux System: Ubuntu v9.10 i386, kernel 2.6.31-20 11 | \ C++ Compiler: gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1 12 | \ =================================================================== 13 | \ SDL_ttf v1.00 Interface for gforth 14 | \ =================================================================== 15 | 16 | \ ---[ Change Log ]-------------------------------------------------- 17 | \ 18 | \ 03/24/2010 Coded SDL_ttf extension library functions. rev 1.00 19 | \ Had to add a C wrapper to get SDL_Color 20 | \ parameters to pass correctly. 21 | \ 22 | \ -----------------------------------------------[End Change Log ]--- 23 | 24 | \ ---[ gforth Prototypes ]------------------------------------------- 25 | 26 | \ ttf-init ( -- f ) 27 | \ ttf-quit ( -- ) 28 | \ ttf-openfont ( *str len ptsize -- *ttf ) 29 | \ ttf-closefont ( *ttf -- ) 30 | \ ttf-ttf-rendertext-solid ( *font *text *fg -- *dst ) 31 | \ ttf-ttf-rendertext-shaded ( *font *text *fg *bg -- *dst ) 32 | \ 33 | \ ------------------------------------------------[End Prototypes]--- 34 | 35 | c-library ttf_lib 36 | s" SDL_ttf" add-lib 37 | 38 | \c #include 39 | \c #include 40 | 41 | \c // SDL_ttf library functions 42 | 43 | c-function ttf-init TTF_Init -- n 44 | c-function ttf-quit TTF_Quit -- void 45 | c-function ttf-openfont TTF_OpenFont a n -- a 46 | c-function ttf-closefont TTF_CloseFont a -- void 47 | 48 | \c SDL_Surface * My_TTF_RT_Solid(TTF_Font *myfont,\ 49 | \c const char *mytext,\ 50 | \c SDL_Color *myfg) 51 | \c { SDL_Color localfg; 52 | \c localfg.r = myfg->r; 53 | \c localfg.g = myfg->g; 54 | \c localfg.b = myfg->b; 55 | \c localfg.unused = 0; 56 | \c return TTF_RenderText_Solid(myfont,mytext,localfg); 57 | \c } 58 | 59 | \c SDL_Surface * My_TTF_RT_Shaded(TTF_Font *myfont,\ 60 | \c const char *mytext,\ 61 | \c SDL_Color *myfg,\ 62 | \c SDL_Color *mybg) 63 | \c { SDL_Color localfg; 64 | \c SDL_Color localbg; 65 | \c localfg.r = myfg->r; localbg.r = mybg->r; 66 | \c localfg.g = myfg->g; localbg.g = mybg->g; 67 | \c localfg.b = myfg->b; localbg.b = mybg->b; 68 | \c localfg.unused = 0; localbg.unused = 0; 69 | \c return TTF_RenderText_Shaded(myfont,mytext,localfg,localbg); 70 | \c } 71 | 72 | c-function ttf-rendertext-solid My_TTF_RT_Solid a a a -- a 73 | c-function ttf-rendertext-shaded My_TTF_RT_Shaded a a a a -- a 74 | 75 | end-c-library 76 | 77 | \ ---[ TTF Constants ]----------------------------------------------- 78 | 79 | %0000 constant TTF_STYLE_NORMAL 80 | %0001 constant TTF_STYLE_BOLD 81 | %0010 constant TTF_STYLE_ITALIC 82 | %0100 constant TTF_STYLE_UNDERLINE 83 | 84 | %sdl-quiet 0= [if] 85 | .( TTF Interface loaded successfully.) cr 86 | [then] 87 | 88 | -------------------------------------------------------------------------------- /SDL/sdl-tut07/sdl-tut07-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-tut07.zip 3 | Title: gforth: SDL/OpenGL Graphics Part VII 4 | Author: Timothy Trussell 5 | Date: 03/27/2010 6 | Description: SDL_ttf Interface/Library Implementation 7 | ===================================================================== 8 | gforth: SDL/OpenGL Graphics Part VII 9 | ===================================================================== 10 | 11 | Adding the SDL_ttf (TrueType Font) extension library to gforth 12 | 13 | Code Addendums included: 14 | 15 | sdllib.fs rev 1.0c 16 | ttflib.fs rev 1.00 17 | 18 | ===================================================================== 19 | Timothy Trussell 03/27/2010 20 | ===================================================================== 21 | 22 | -------------------------------------------------------------------------------- /SDL/sdl-tut07/sdl-tut07.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 01 ]============================================ 2 | \ gforth: SDL/OpenGL Graphics Part VII 3 | \ =================================================================== 4 | \ File Name: sdl-tut07.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 03/27/2010 7 | \ Description: SDL_ttf Fonts Demonstration 8 | \ Forth System: gforth-0.7.0 9 | \ Linux System: Ubuntu v9.10 i386, kernel 2.6.31-20 10 | \ C++ Compiler: gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1 11 | \ =================================================================== 12 | 13 | page .( ---[ Loading gforth: SDL/OpenGL sdl-tut07.fs ]---) cr 14 | 15 | [IFDEF] ---marker--- 16 | ---marker--- 17 | [ENDIF] 18 | 19 | marker ---marker--- 20 | 21 | decimal 22 | 23 | \ ---[ Library Modules ]--------------------------------------------- 24 | \ Needs the v1.0c SDL Library module 25 | 26 | require sdllib.fs 27 | require ttflib.fs 28 | 29 | \ ---[ Variables ]--------------------------------------------------- 30 | 31 | 0 value %quit \ exit flag 32 | 33 | \ ---[ Define an SDL Event ]----------------------------------------- 34 | \ We will use this for polling the SDL Event subsystem 35 | 36 | create event sdl-event% %allot drop 37 | 38 | \ Define White 39 | 40 | create TextColor[] 255 C, 255 C, 255 C, 0 C, 41 | 42 | \ ---[ String Definitions ]------------------------------------------ 43 | 44 | \ ---[ Font Names ]-------------------------------------------------- 45 | \ These are passed to the ttf-openfont function, and therefore need 46 | \ the trailing "0" byte to allow the string to be converted to a 47 | \ zero-delimited C type string. 48 | 49 | \ If you are going to use different fonts, change these names to 50 | \ match the fonts you have. 51 | 52 | 0 [if] 53 | : TTF-N s" ttf-fonts/Times_New_Roman.ttf0" ; \ Linux font names 54 | : TTF-B s" ttf-fonts/Times_New_Roman_Bold.ttf0" ; 55 | : TTF-BI s" ttf-fonts/Times_New_Roman_Bold_Italic.ttf0" ; 56 | : TTF-I s" ttf-fonts/Times_New_Roman_Italic.ttf0" ; 57 | [else] 58 | : TTF-N s" ttf-fonts/times.ttf0" ; \ Windows font names 59 | : TTF-B s" ttf-fonts/timesbd.ttf0" ; 60 | : TTF-BI s" ttf-fonts/timesbi.ttf0" ; 61 | : TTF-I s" ttf-fonts/timesi.ttf0" ; 62 | [then] 63 | 64 | \ ---[ Alphanumeric ]------------------------------------------------ 65 | 66 | : AlphaNs s" ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" ; 67 | 68 | \ ---[ Wait-For-Exit ]----------------------------------------------- 69 | \ Loop until the 'X' block is clicked, or Alt-F4 is pressed 70 | 71 | : Wait-For-Exit ( -- ) 72 | begin 73 | %quit 0= 74 | while 75 | event sdl-pollevent if 76 | event sdl-event-type C@ SDL_QUIT = if 77 | 1 to %quit \ exit on SDL_QUIT 78 | then 79 | then 80 | repeat 81 | ; 82 | 83 | : Click-To-Exit-Message ( -- ) 84 | \ Display this at the bottom of the screen surface 85 | s" Click the 'X' box to exit0" TTF-N 20 window-screenh 1- over - 86 | TextColor[] screen-surface FWriteCenter 87 | ; 88 | 89 | : ttfdemo ( -- ) 90 | 1024x768x16 s" SDL TrueType Font Demo0" InitGraph 91 | ttf-init s" Unable to initialize sdl-ttf system" Error-End 92 | 0 to %quit 93 | \ Display the font path data as the text messages 94 | TTF-N TTF-N 28 0 0 TextColor[] screen-surface FWriteAt 95 | TTF-B TTF-B 28 0 28 TextColor[] screen-surface FWriteAt 96 | TTF-BI TTF-BI 28 0 28 2 * TextColor[] screen-surface FWriteAt 97 | TTF-I TTF-I 28 0 28 3 * TextColor[] screen-surface FWriteAt 98 | AlphaNs TTF-N 28 0 28 6 * TextColor[] screen-surface FWriteAt 99 | AlphaNs TTF-B 28 0 28 7 * TextColor[] screen-surface FWriteAt 100 | AlphaNs TTF-BI 28 0 28 8 * TextColor[] screen-surface FWriteAt 101 | AlphaNs TTF-I 28 0 28 9 * TextColor[] screen-surface FWriteAt 102 | Click-To-Exit-Message \ display the how to exit message 103 | screen-surface sdl-flip drop \ display the image 104 | Wait-For-Exit \ close the window to exit 105 | ttf-quit \ quit the sdl-ttf subsystem 106 | CloseGraph 107 | ; 108 | 109 | cr .( SDL-Tut07: ttfdemo ) cr 110 | 111 | -------------------------------------------------------------------------------- /SDL/sdl-tut07/sdllib-10c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/SDL/sdl-tut07/sdllib-10c.png -------------------------------------------------------------------------------- /SDL/sdl-tut07/ttflib.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 02 ]============================================ 2 | \ gforth: SDL/OpenGL Graphics Part VII 3 | \ =================================================================== 4 | \ File Name: ttflib.fs 5 | \ Version: 1.00 6 | \ Author: Timothy Trussell 7 | \ Date: 03/24/2010 8 | \ Description: TTF Library Routines for gforth 9 | \ Forth System: gforth-0.7.0 10 | \ Linux System: Ubuntu v9.10 i386, kernel 2.6.31-19 11 | \ C++ Compiler: gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1 12 | \ =================================================================== 13 | \ SDL_ttf v1.00 Library for gforth 14 | \ =================================================================== 15 | 16 | \ ---[ Changes Log ]------------------------------------------------- 17 | \ 18 | \ 03/24/2010 Initial Version rev 1.00 19 | 20 | \ ------------------- 21 | \ ---[ Prototype Listing ]------------------------------------------- 22 | \ ------------------- 23 | \ 24 | \ : TTFLib-Version ( -- ) 25 | \ : Load-TTF ( *fname flen ptsize -- *ttf ) 26 | \ : Apply-TTF-Surface ( x y *src *dst -- ) 27 | \ : FRender-Text { *str _len *fname _flen _size *c -- } 28 | \ : FRender-Close ( -- ) 29 | \ : FWriteAt { *str _len *fname _flen _size _x _y *c *dst -- } 30 | \ : FWriteCenter { *str _len *fname _flen _size _y _c *dst -- } 31 | \ 32 | \ ----------------------------------------------[ End Prototypes ]--- 33 | 34 | \ Load the SDL_ttf C Library Interface 35 | 36 | require sdl-ttf-1.00.fs 37 | 38 | \ ---------------- 39 | \ ---[ SDLLib-Version ]---------------------------------------------- 40 | \ ---------------- 41 | 42 | : TTFLib-Version ( -- ) 43 | ." +-------------------------------------------------+" cr 44 | ." | TTFLib v1.00 03/27/2010 by Timothy Trussell |" cr 45 | ." +-------------------------------------------------+" cr 46 | ; 47 | 48 | \ ---[ Load-TTF ]---------------------------------------------------- 49 | \ Passed the name/location of the font to load, followed by the point 50 | \ size to load the font as - basically the pixel height of the font. 51 | 52 | : Load-TTF ( *fname flen ptsize -- *ttf ) 53 | >R Terminate-String R> ttf-openfont dup 54 | 0= s" Unable to load TTF" Error-End 55 | ; 56 | 57 | \ ---[ Apply-TTF-Surface ]------------------------------------------- 58 | \ Copies the src surface to the dst surface, placed at x,y. The full 59 | \ rectangular dimension of the src image is copied to the dst image. 60 | \ Note that this does NOT make the images visible in the display 61 | \ window. sdl-flip does that function. 62 | 63 | create offset% sdl-rect% %allot drop 64 | 65 | : Apply-TTF-Surface ( x y *src *dst -- ) 66 | >R >R 67 | offset% sdl-offset-y w! \ set offsets to rectangle 68 | offset% sdl-offset-x w! 69 | 0 offset% sdl-offset-w w! \ just to be safe 70 | 0 offset% sdl-offset-h w! 71 | R> NULL R> offset% sdl-blitsurface drop \ blit src to dst 72 | ; 73 | 74 | 0 value work-font 75 | 0 value work-surface 76 | 77 | : FRender-Text { *str _len *fname _flen _size *c -- } 78 | *fname _flen _size Load-TTF to work-font \ load the ttf 79 | work-font \ render the text 80 | *str _len Terminate-String 81 | *c 82 | ttf-rendertext-solid dup 0= s" Error Rendering Text" Error-End 83 | to work-surface 84 | ; 85 | 86 | : FRender-Close ( -- ) 87 | work-surface sdl-freesurface 0 to work-surface \ free work surfaces 88 | work-font ttf-closefont 0 to work-font 89 | ; 90 | 91 | \ ---[ FWriteAt ]---------------------------------------------------- 92 | \ This is one way to display the rendered text. 93 | \ For each line of text we load a font into a surface, which is 94 | \ converted to the correct pixel height during the load process. 95 | \ Next, we Render the text, which creates a second surface. 96 | \ This surface is the exact height/width of the rendered text. 97 | \ The data is then copied to the *dst surface. 98 | \ Finally, the surface the font was loaded into, as well as the 99 | \ surface the text was rendered to, are freed, releasing the memory. 100 | \ ------------------------------------------------------------------- 101 | \ Note: 102 | \ The string to be rendered MUST have an extra character, which will 103 | \ be converted to a 0 byte value. 104 | \ ------------------------------------------------------------------- 105 | \ Parameters: 106 | \ 107 | \ *str _len the text to be rendered 108 | \ *fname _flen path/name of the font to use 109 | \ _size pixel height of the font 110 | \ _x, _y address to copy the rendered text to 111 | \ *c color struct 112 | \ *dst destination surface to copy to 113 | \ 114 | \ Examples: 115 | \ 116 | \ s" My text line0" s" ttf-fonts/times.ttf0" 117 | \ 28 0 0 TextColor[] screen-surface FWriteAt 118 | \ 119 | \ s" this is a really long line of text that says nothing at all0" 120 | \ TTFont4 28 0 100 screen-surface FWriteAt 121 | \ ------------------------------------------------------------------- 122 | 123 | : FWriteAt { *str _len *fname _flen _size _x _y *c *dst -- } 124 | *str _len *fname _flen _size *c FRender-Text 125 | _x _y work-surface *dst Apply-TTF-Surface \ copy to dest surface 126 | FRender-Close \ free work surfaces 127 | ; 128 | 129 | \ ---[ FWriteCenter ]------------------------------------------------ 130 | \ Displays the rendered text, centered in the surface, at the y coord 131 | \ specified. Note that the y coord is the top line of the rendered 132 | \ text being displayed. 133 | 134 | : FWriteCenter { *str _len *fname _flen _size _y _c *dst -- } 135 | *str _len *fname _flen _size _c FRender-Text 136 | window-screenw 2/ work-surface sdl-surface-w uw@ 2/ - 137 | _y work-surface *dst Apply-TTF-Surface 138 | FRender-Close \ free work surfaces 139 | ; 140 | 141 | %sdl-quiet 0= [if] 142 | TTFLib-Version 143 | .( TTF Library loaded successfully.) cr 144 | [then] 145 | 146 | -------------------------------------------------------------------------------- /SDL/sdl-tut08/sdl-basicfontdemo.fs: -------------------------------------------------------------------------------- 1 | \ ===[ Code Addendum 01 ]============================================ 2 | \ gforth: SDL/OpenGL Graphics Part VIII 3 | \ =================================================================== 4 | \ File Name: sdl-basicfontdemo.fs 5 | \ Author: Timothy Trussell 6 | \ Date: 03/28/2010 7 | \ Description: Basic Font Demo 8 | \ Forth System: gforth-0.7.0 9 | \ Linux System: Ubuntu v9.10 i386, kernel 2.6.31-20 10 | \ C++ Compiler: gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1 11 | \ =================================================================== 12 | \ Simple demo that displays the 8x16 font data 13 | \ =================================================================== 14 | 15 | page .( ---[ Loading gforth: SDL BasicFont Demo ]---) cr 16 | 17 | [IFDEF] ---marker--- 18 | ---marker--- 19 | [ENDIF] 20 | 21 | marker ---marker--- 22 | 23 | decimal 24 | 25 | \ ---[ Library Modules ]--------------------------------------------- 26 | 27 | require sdl-basicfontlib.fs 28 | 29 | \ ---[ Variables ]--------------------------------------------------- 30 | 31 | \ ---[ Brighter Color Definitions ]---------------------------------- 32 | \ The basic VGA palette colors are too dim, so I tried to find some 33 | \ that were close in the existing SDL palette... 34 | 35 | 0 constant #Black 36 | 3 constant #Blue 37 | 16 constant #Green 38 | 9 constant #Cyan 39 | 128 constant #Red 40 | 162 constant #Magenta 41 | 68 constant #Brown 42 | 109 constant #LightGray 43 | 36 constant #DarkGray 44 | 23 constant #LightBlue 45 | 21 constant #LightGreen 46 | 31 constant #LightCyan 47 | \ constant #LightRed 48 | \ constant #LightMagenta 49 | 248 constant #Yellow 50 | 255 constant #White 51 | 52 | \ ---[ ShowFontStuff ]----------------------------------------------- 53 | \ Array of string data to send to the display surfaces 54 | 55 | create PList$ 56 | s" : font-SetDestSurface ( *dst -- ) " s, 57 | s" : font-getsurface ( -- *dst ) " s, 58 | s" : GetX ( -- cx ) " s, 59 | s" : GetY ( -- cy ) " s, 60 | s" : GetXY ( -- cx cy ) " s, 61 | s" : GotoXY ( x y -- ) " s, 62 | s" : \r ( -- ) " s, 63 | s" : \n ( -- ) " s, 64 | s" : Draw-Font-Char { *dst _x _y *src -- } " s, 65 | s" : Update-Cursor-Position ( -- ) " s, 66 | s" : GPutC { _c -- } " s, 67 | s" : GPutS { *str _len -- } " s, 68 | s" : GWriteC { _x _y _fg _bg _c -- } " s, 69 | s" : GWriteS { _x _y _fg _bg *str _len -- } " s, 70 | s" : GWriteAt ( x y fg bg &str len -- ) " s, 71 | s" : GWriteCenter { _y _fg _bg &str _len -- } " s, 72 | s" : GClearLine { _y _fg _bg -- } " s, 73 | s" : GBox { _x1 _y1 _x2 _y2 _fg _bg _type -- }" s, 74 | s" : GFBox { _x1 _y1 _x2 _y2 _fg _bg _type -- }" s, 75 | s" : font-init ( *dst -- ) " s, 76 | 77 | : max-x font-cursor-max-x ; 78 | : max-y font-cursor-max-y ; 79 | 80 | : Show-Font-Stuff ( -- ) 81 | font-getsurface NULL 0 sdl-fillrect drop \ erase the surface 82 | 0 0 max-x max-y 1- #LightGray #Black 15 GFBox \ draw background 83 | screen-surface sdl-flip drop \ display the line 84 | 10 1 max-x 10 - 3 #White #Cyan 4 GFBox \ title window 85 | 2 #Yellow #Cyan s" SDL BasicFont Graphical Text Demo" GWriteCenter 86 | 3 5 max-x 3 - max-y 2 - #White #Blue 5 GFBox \ main display window 87 | 5 5 #Yellow #Blue s" [ SDL BasicFont Info ]" GWriteAt 88 | 7 6 #White #Blue s" Prototype Listing:" GWriteAt 89 | \ now display the array of strings in PList$ 90 | screen-surface sdl-flip drop \ display the line 91 | 20 0 do 92 | 9 7 i + #White #Blue PList$ i 60 * + dup 1+ swap C@ GWriteAt 93 | screen-surface sdl-flip drop \ display the line 94 | loop 95 | max-y #White #Black GClearLine 96 | max-y #Yellow #Black s" Pausing for 5 seconds" GWriteCenter 97 | screen-surface sdl-flip drop \ display the image 98 | ; 99 | 100 | \ ---[ FontDemo ]---------------------------------------------------- 101 | 102 | : Font-Res ( resolution -- ) 103 | s" SDL BasicFont - 8x16 Font Demo0" InitGraph 104 | screen-surface font-init 105 | Show-Font-Stuff 106 | 5000 sdl-delay 107 | CloseGraph 108 | ; 109 | 110 | : fontdemo ( -- ) 111 | 640x480x8 Font-Res 112 | 800x600x8 Font-Res 113 | 1024x768x8 Font-Res 114 | ; 115 | 116 | cr .( SDL-BasicFontDemo: fontdemo ) cr 117 | -------------------------------------------------------------------------------- /SDL/sdl-tut08/sdl-tut08-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-tut08.zip 3 | Title: gforth: SDL/OpenGL Graphics Part VIII 4 | Author: Timothy Trussell 5 | Date: 03/28/2010 6 | Description: A Basic 8x16 Font Engine for gforth/SDL 7 | ===================================================================== 8 | gforth: SDL/OpenGL Graphics Part VIII 9 | ===================================================================== 10 | 11 | This is a basic font package coded for gforth. It is implemented for 12 | the 256-color resolutions, but could be easily expanded to be used 13 | with the higher color resolutions. 14 | 15 | The sdl-basicfont is a simple text generator, displaying text chars 16 | to an SDL surface. 17 | 18 | ===================================================================== 19 | Timothy Trussell 03/28/2010 20 | ===================================================================== 21 | 22 | -------------------------------------------------------------------------------- /SDL/sdl-tut08/sdllib-10c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/SDL/sdl-tut08/sdllib-10c.png -------------------------------------------------------------------------------- /SDL/sdl-tut09/sdl-tut09-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-tut09.zip 3 | Title: gforth: SDL/OpenGL Graphics Part IX 4 | Author: Timothy Trussell 5 | Date: 04/17/2010 6 | Description: Wu Lines Redux 7 | ===================================================================== 8 | gforth: SDL/OpenGL Graphics Part IX 9 | ===================================================================== 10 | 11 | Updating the Wu lines code for use with SDL 12 | 13 | We finally have a chance to see how the Wu Algorithm looks on a 14 | resolution higher than 320x200, and I must say it looks pretty good. 15 | 16 | Added: Any 24-bpp color value for the line drawing color. No longer 17 | limited to a choice of two colors. Select from 16,777,216 of 18 | your favorite colors. 19 | 20 | Works in 8-, 16-, 24- and 32-bpp resolutions. 21 | 22 | ===================================================================== 23 | Timothy Trussell 04/17/2010 24 | ===================================================================== 25 | 26 | -------------------------------------------------------------------------------- /SDL/sdl-tut09/sdllib-10d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/SDL/sdl-tut09/sdllib-10d.png -------------------------------------------------------------------------------- /SDL/sdl-tut10/sdl-tut10-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-tut10.zip 3 | Title: gforth: SDL/OpenGL Graphics Part X 4 | Author: Timothy Trussell 5 | Date: 05/02/2010 6 | Description: SDL RayCaster - Flat Textures 7 | ===================================================================== 8 | gforth: SDL/OpenGL Graphics Part X 9 | ===================================================================== 10 | 11 | Basic Raycasting Engine 12 | 13 | (really basic) 14 | 15 | ===================================================================== 16 | Timothy Trussell 05/02/2010 17 | ===================================================================== 18 | 19 | -------------------------------------------------------------------------------- /SDL/sdl-tut10/sdllib-10e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/SDL/sdl-tut10/sdllib-10e.png -------------------------------------------------------------------------------- /SDL/sdl-tut11/sdl-tut11-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-tut11.zip 3 | Title: gforth: SDL/OpenGL Graphics Part XI 4 | Author: Timothy Trussell 5 | Date: 05/09/2010 6 | Description: SDL RayCaster2 - Textured Walls 7 | ===================================================================== 8 | gforth: SDL/OpenGL Graphics Part XI 9 | ===================================================================== 10 | 11 | Basic Raycasting Engine 12 | 13 | (slightly less basic) 14 | 15 | ===================================================================== 16 | Timothy Trussell 05/09/2010 17 | ===================================================================== 18 | 19 | -------------------------------------------------------------------------------- /SDL/sdl-tut11/sdllib-10e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/SDL/sdl-tut11/sdllib-10e.png -------------------------------------------------------------------------------- /SDL/sdl-tut11/wolftextures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/SDL/sdl-tut11/wolftextures.png -------------------------------------------------------------------------------- /SDL/sdl-tut12/sdl-tut12-info.txt: -------------------------------------------------------------------------------- 1 | ===================================================================== 2 | File: sdl-tut12.zip 3 | Title: gforth: SDL/OpenGL Graphics Part XII 4 | Author: Timothy Trussell 5 | Date: 06/13/2010 6 | Description: SDL Simple RayCaster 7 | ===================================================================== 8 | gforth: SDL/OpenGL Graphics Part XII 9 | ===================================================================== 10 | 11 | Simple Raycasting Engine 12 | 13 | ===================================================================== 14 | Timothy Trussell 06/13/2010 15 | ===================================================================== 16 | 17 | -------------------------------------------------------------------------------- /SDL/sdl-tut12/sdllib-10f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/SDL/sdl-tut12/sdllib-10f.png -------------------------------------------------------------------------------- /SDL/sdl-tut12/wolftextures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lecrapouille/GraphicsLessonInGforth/fcd24e48be1c63b9460a99e420e4a84f16ab9bbe/SDL/sdl-tut12/wolftextures.png --------------------------------------------------------------------------------