├── .DS_Store ├── .gitignore ├── README.md ├── Samples ├── red │ ├── clipboard.red │ ├── compiled_OSX │ │ ├── clipboard.app │ │ │ └── Contents │ │ │ │ ├── Info.plist │ │ │ │ └── MacOS │ │ │ │ └── clipboard │ │ ├── simple.app │ │ │ └── Contents │ │ │ │ ├── Info.plist │ │ │ │ └── MacOS │ │ │ │ └── simple │ │ └── triangle.app │ │ │ └── Contents │ │ │ ├── Info.plist │ │ │ └── MacOS │ │ │ └── triangle │ ├── defaults.red │ ├── simple.red │ └── triangle.red └── redS │ ├── accuracy.reds │ ├── clipboard.reds │ ├── defaults.reds │ ├── events.reds │ ├── fsaa.reds │ ├── gamma.reds │ ├── glfwinfo.reds │ ├── modes.reds │ ├── peter.reds │ ├── quad.reds │ ├── sharing.reds │ ├── simple.reds │ ├── splitview.reds │ ├── tearing.reds │ ├── title.reds │ ├── triangle.reds │ └── windows.reds ├── dll ├── libglfw.3.2.dylib ├── libglfw.3.dylib └── libglfw.dylib ├── lib ├── .DS_Store ├── Tools │ ├── .DS_Store │ ├── C-library.reds │ └── math.reds ├── glfw3.reds ├── glu.reds ├── opgl.reds └── rpointers.reds └── samples ├── .DS_Store ├── red ├── .DS_Store └── compiled_OSX │ ├── .DS_Store │ └── defaults └── redS ├── .DS_Store ├── compiled_OSX ├── .DS_Store ├── accuracy ├── clipboard ├── defaults ├── events ├── fsaa ├── gamma ├── glfwinfo ├── modes ├── peter ├── quad ├── sharing ├── simple ├── splitview ├── tearing ├── test ├── title ├── triangle └── windows └── test.reds /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | README.TXT 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GLFW Binding for Red Language 2 | ## [http://www.glfw.org/](http://www.glfw.org/) 3 | 4 | ## [http://www.red-lang.org](http://www.red-lang.org) 5 | 6 | 7 | This binding has been extensively tested with macOS Sierra, High Sierra, Mojave, and works fine under macOS. 8 | Please adapt path to libraries according your main OS. 9 | This version can be used with glfw 3.2.0 library. 10 | 11 | ### This version requires red 0.6.4. 12 | 13 | Have also a look here ([https://github.com/red/code/tree/master/Library/GLFW]()) for a similar lib developped by talented Red user. 14 | 15 | 16 | ## NEW VERSION JANUARY 2021 17 | Compiled with Red 0.6.4 for macOS built 25-Dec-2020/0:08:25+01:00 commit #98f31b5 18 | 19 | ## Warning 20 | You must use 32-bit version of dynamically linked libraries. 21 | 22 | ### glfw3.reds 23 | The binding for Red/System. 24 | 25 | ### opgl.reds 26 | 27 | A quick done binding to OpenGL to be used with Red since GLFW requires OpenGL. 28 | 29 | ### glu.reds 30 | Gives access to OpenGL Utility Toolkit. 31 | 32 | ## ** 33 | opgl.reds and glu.reds were done mainly for testing purpose and should be improved ASAP. 34 | You can also use use Kaj de Vos's wrapping for opengl. 35 | (http://red.esperconsultancy.nl/Red-OpenGL/timeline) 36 | ## ** 37 | 38 | ### Tools dir 39 | Includes some useful libs 40 | C-Library.reds and math.reds by Kaj de Vos (http://red.esperconsultancy.nl/Red-C-library/timeline). 41 | 42 | ### Samples dir 43 | Includes some samples in Red and Red/System adapted from orignal codes in C. 44 | -------------------------------------------------------------------------------- /Samples/red/clipboard.red: -------------------------------------------------------------------------------- 1 | Red [ 2 | Title: "GLFW Binding: clipboard" 3 | Author: "F. Jouen" 4 | Rights: "Copyright (c) 2013-2014 F. Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;======================================================================== 9 | ; 10 | ; This program is used to test the clipboard functionality. 11 | ; original program Copyright (c) Camilla Berglund 12 | ;======================================================================== 13 | ; how to use Red/System code inside Red 14 | 15 | #system [ 16 | #include %../../lib/glfw3.reds ; this lib also includes opgl.reds 17 | ; for error callback code pointer 18 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 19 | print [ description " " stderr] 20 | ] 21 | key_callback: func [ 22 | [calling] 23 | window [GLFWwindow] 24 | key [integer!] 25 | scancode [integer!] 26 | action [integer!] 27 | mods [integer!] /local string l] [ 28 | 29 | if (action <> GLFW_PRESS) [exit]; 30 | switch key [ 31 | GLFW_KEY_ESCAPE [glfwSetWindowShouldClose window GL_TRUE ] 32 | GLFW_KEY_V [ 33 | if (mods = GLFW_MOD_CONTROL) [ 34 | string: glfwGetClipboardString window 35 | l: length? string 36 | either l > 1 [print ["Clipboard contains " string newline]] 37 | [print ["Clipboard does not contain a string" newline]] 38 | ] 39 | ] 40 | GLFW_KEY_C [ 41 | if (mods = GLFW_MOD_CONTROL) [ 42 | string: "Hello GLFW World!" 43 | glfwSetClipboardString window string 44 | print ["Setting clipboard to " string newline] 45 | ] 46 | ] 47 | default [print ""] 48 | ] 49 | ] 50 | framebuffer_size_callback: func [[calling] window [GLFWwindow] width [integer!] height [integer!]] [ 51 | glViewport 0 0 width height 52 | ] 53 | window: declare pointer! [integer!] 54 | ] 55 | 56 | 57 | initgl: routine [txt [string!] return: [integer!]] [ 58 | glfwSetErrorCallback :error_callback 59 | if glfwInit = 0 [glfwTerminate] ; exit 60 | window: glfwCreateWindow 400 400 as c-string! string/rs-head txt NULL NULL 61 | if window = null [glfwTerminate] 62 | glfwMakeContextCurrent window 63 | glfwSwapInterval 1 64 | glfwSetKeyCallback window :key_callback 65 | glfwSetFramebufferSizeCallback window :framebuffer_size_callback 66 | glMatrixMode GL_PROJECTION 67 | glOrtho -1.0 1.0 -1.0 1.0 -1.0 1.0 68 | glMatrixMode GL_MODELVIEW 69 | glClearColor 0.5 0.5 0.5 0.0 70 | return 1 71 | ] 72 | 73 | closegl: routine [] [ 74 | glfwDestroyWindow window 75 | glfwTerminate 76 | ] 77 | 78 | render: routine [return: [integer!]] [ 79 | glClear GL_COLOR_BUFFER_BIT 80 | glColor3f 0.8 0.2 0.4 81 | glRectf -0.5 -0.5 0.5 0.5 82 | glfwSwapBuffers window 83 | glfwWaitEvents 84 | glfwWindowShouldClose window ; 1 for window close request 85 | ] 86 | 87 | 88 | initgl "Clipboard Test [CTRL-C CTRL-V]" 89 | rep: 0 90 | until [ 91 | rep: render 92 | rep = 1 93 | ] 94 | closegl 95 | quit -------------------------------------------------------------------------------- /Samples/red/compiled_OSX/clipboard.app/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | clipboard 9 | CFBundleIconFile 10 | AppIcon 11 | CFBundlePackageType 12 | APPL 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1.0.0 19 | CFBundleIdentifier 20 | org.redlang.clipboard 21 | LSMinimumSystemVersion 22 | 10.8.0 23 | NSHighResolutionCapable 24 | YES 25 | 26 | 27 | -------------------------------------------------------------------------------- /Samples/red/compiled_OSX/clipboard.app/Contents/MacOS/clipboard: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/Samples/red/compiled_OSX/clipboard.app/Contents/MacOS/clipboard -------------------------------------------------------------------------------- /Samples/red/compiled_OSX/simple.app/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | simple 9 | CFBundleIconFile 10 | AppIcon 11 | CFBundlePackageType 12 | APPL 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1.0.0 19 | CFBundleIdentifier 20 | org.redlang.simple 21 | LSMinimumSystemVersion 22 | 10.8.0 23 | NSHighResolutionCapable 24 | YES 25 | 26 | 27 | -------------------------------------------------------------------------------- /Samples/red/compiled_OSX/simple.app/Contents/MacOS/simple: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/Samples/red/compiled_OSX/simple.app/Contents/MacOS/simple -------------------------------------------------------------------------------- /Samples/red/compiled_OSX/triangle.app/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | triangle 9 | CFBundleIconFile 10 | AppIcon 11 | CFBundlePackageType 12 | APPL 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1.0.0 19 | CFBundleIdentifier 20 | org.redlang.triangle 21 | LSMinimumSystemVersion 22 | 10.8.0 23 | NSHighResolutionCapable 24 | YES 25 | 26 | 27 | -------------------------------------------------------------------------------- /Samples/red/compiled_OSX/triangle.app/Contents/MacOS/triangle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/Samples/red/compiled_OSX/triangle.app/Contents/MacOS/triangle -------------------------------------------------------------------------------- /Samples/red/defaults.red: -------------------------------------------------------------------------------- 1 | Red [ 2 | Title: "GLFW Binding: defaults" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;======================================================================== 9 | ; 10 | ; This test creates a windowed mode window with all window hints set to 11 | ; default values and then reports the actual attributes of the created 12 | ; window and context 13 | ; original program Copyright (c) Camilla Berglund 14 | ;======================================================================== 15 | 16 | ; how to use Red/System code inside Red 17 | 18 | #system [ 19 | #include %../../lib/glfw3.reds ; this lib also includes opgl.reds 20 | 21 | AttribGL!: alias struct! [ 22 | attrib [integer!] 23 | ext [c-string!] 24 | name [c-string!] 25 | ] 26 | 27 | AttribGLFW!: alias struct! [ 28 | attrib [integer!] 29 | name [c-string!] 30 | ] 31 | 32 | gl_attribs: declare struct! [ 33 | gl1 [AttribGL!] 34 | gl2 [AttribGL!] 35 | gl3 [AttribGL!] 36 | gl4 [AttribGL!] 37 | gl5 [AttribGL!] 38 | gl6 [AttribGL!] 39 | gl7 [AttribGL!] 40 | gl8 [AttribGL!] 41 | gl9 [AttribGL!] 42 | ] 43 | 44 | 45 | glfw_attribs: declare struct! [ 46 | glw1 [AttribGLFW!] 47 | glw2 [AttribGLFW!] 48 | glw3 [AttribGLFW!] 49 | glw4 [AttribGLFW!] 50 | glw5 [AttribGLFW!] 51 | glw6 [AttribGLFW!] 52 | ] 53 | 54 | gl_attribs/gl1: declare AttribGL! 55 | gl_attribs/gl2: declare AttribGL! 56 | gl_attribs/gl3: declare AttribGL! 57 | gl_attribs/gl4: declare AttribGL! 58 | gl_attribs/gl5: declare AttribGL! 59 | gl_attribs/gl6: declare AttribGL! 60 | gl_attribs/gl7: declare AttribGL! 61 | gl_attribs/gl8: declare AttribGL! 62 | gl_attribs/gl9: declare AttribGL! 63 | 64 | gl_attribs/gl1/attrib: GL_RED_BITS 65 | gl_attribs/gl1/ext: null 66 | gl_attribs/gl1/name: "red bits" 67 | 68 | gl_attribs/gl2/attrib: GL_GREEN_BITS 69 | gl_attribs/gl2/ext: null 70 | gl_attribs/gl2/name: "green bits" 71 | 72 | gl_attribs/gl3/attrib: GL_BLUE_BITS 73 | gl_attribs/gl3/ext: null 74 | gl_attribs/gl3/name: "blue bits" 75 | 76 | gl_attribs/gl4/attrib: GL_ALPHA_BITS 77 | gl_attribs/gl4/ext: null 78 | gl_attribs/gl4/name: "alpha bits" 79 | 80 | gl_attribs/gl5/attrib: GL_DEPTH_BITS 81 | gl_attribs/gl5/ext: null 82 | gl_attribs/gl5/name: "depth bits" 83 | 84 | gl_attribs/gl6/attrib: GL_STENCIL_BITS 85 | gl_attribs/gl6/ext: null 86 | gl_attribs/gl6/name: "stencil bits" 87 | 88 | gl_attribs/gl7/attrib: GL_STEREO 89 | gl_attribs/gl7/ext: null 90 | gl_attribs/gl7/name: "stereo" 91 | 92 | gl_attribs/gl8/attrib: 000080A9h;GL_SAMPLES_ARB 93 | gl_attribs/gl8/ext: null 94 | gl_attribs/gl8/name: "FSAA samples" "GL_ARB_multisample" 95 | 96 | gl_attribs/gl9/attrib: 0 97 | gl_attribs/gl9/ext: null 98 | gl_attribs/gl9/name: null 99 | 100 | 101 | glfw_attribs/glw1: declare AttribGLFW! 102 | glfw_attribs/glw2: declare AttribGLFW! 103 | glfw_attribs/glw3: declare AttribGLFW! 104 | glfw_attribs/glw4: declare AttribGLFW! 105 | glfw_attribs/glw5: declare AttribGLFW! 106 | glfw_attribs/glw6: declare AttribGLFW! 107 | 108 | 109 | glfw_attribs/glw1/attrib: GLFW_CONTEXT_VERSION_MAJOR 110 | glfw_attribs/glw1/name: "Context version major" 111 | 112 | glfw_attribs/glw2/attrib: GLFW_CONTEXT_VERSION_MINOR 113 | glfw_attribs/glw2/name: "Context version minor" 114 | 115 | glfw_attribs/glw3/attrib: GLFW_OPENGL_FORWARD_COMPAT 116 | glfw_attribs/glw3/name: "OpenGL forward compatible" 117 | 118 | glfw_attribs/glw4/attrib: GLFW_OPENGL_DEBUG_CONTEXT 119 | glfw_attribs/glw4/name: "OpenGL debug context" 120 | 121 | glfw_attribs/glw5/attrib: GLFW_OPENGL_PROFILE 122 | glfw_attribs/glw5/name: "OpenGL profile" 123 | 124 | glfw_attribs/glw6/attrib: 0 125 | glfw_attribs/glw6/name: "" 126 | 127 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 128 | print [ description " " stderr] 129 | ] 130 | window: declare pointer! [integer!] 131 | ] 132 | 133 | 134 | defaults: routine [/local width height &width &height c p value &value] [ 135 | 136 | width: 640 137 | height: 480 138 | &width: :width; pointer! 139 | &height: :height ;pointer! 140 | glfwSetErrorCallback :error_callback 141 | if glfwInit = 0 [glfwTerminate] ; exit 142 | glfwWindowHint GLFW_VISIBLE GL_FALSE 143 | window: glfwCreateWindow width height "Defaults" NULL NULL 144 | glfwMakeContextCurrent window 145 | glfwGetWindowSize window &width &height 146 | print ["framebuffer size: " width " x " height newline] 147 | c: 1 148 | p: as int-ptr! glfw_attribs/glw1 149 | until [ 150 | if c = 2 [p: as int-ptr! glfw_attribs/glw2] ;????? 151 | print [ as c-string! p/2 ": " glfwGetWindowAttrib window p/1 newline ] 152 | p: p + 2 153 | c: c + 1 154 | c = 6 155 | ] 156 | c: 1 157 | p: as int-ptr! gl_attribs/gl1 158 | value: 0 &value: :value ; pointer 159 | until [ 160 | if p/2 <> 0 [if (glfwExtensionSupported as c-string! p/2) = GL_FALSE [print ""]] 161 | glGetIntegerv p/1 &value 162 | print [as c-string! p/3 ": " &value/value newline ] 163 | p: p + 3 ; incremente pointer 164 | c: c + 1 165 | c = 9 166 | ] 167 | glfwDestroyWindow window 168 | window: null 169 | glfwTerminate 170 | ] 171 | ; main program 172 | defaults 173 | 174 | 175 | -------------------------------------------------------------------------------- /Samples/red/simple.red: -------------------------------------------------------------------------------- 1 | Red [ 2 | Title: "GLFW Binding: Animated triangle" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ; Simple GLFW example 9 | ; Origimal program Copyright (c) Camilla Berglund 10 | 11 | ; how to use Red/System code inside Red 12 | 13 | #system [ 14 | #include %../../lib/glfw3.reds ; this lib also includes opgl.reds 15 | ; for error callback code pointer 16 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 17 | print [ description " " stderr] 18 | ] 19 | 20 | key_callback: func [ 21 | [calling] 22 | window [GLFWwindow] 23 | key [integer!] 24 | scancode [integer!] 25 | action [integer!] 26 | mods [integer!]] [ 27 | if (key = GLFW_KEY_ESCAPE) and (action = GLFW_PRESS) [glfwSetWindowShouldClose window GL_TRUE ] 28 | ] 29 | ratio: declare float! 30 | angle: declare float! 31 | width: declare integer! 32 | height: declare integer! 33 | fwidth: declare float! 34 | fheight: declare float! 35 | window: declare pointer! [integer!] 36 | &width: declare pointer! [integer!] 37 | &height: declare pointer! [integer!] 38 | ] 39 | 40 | 41 | 42 | initgl: routine [txt [string!] return: [integer!]] [ 43 | ratio: 0.0 44 | angle: 0.0 45 | width: 640 46 | height: 480 47 | fwidth: 640.0 48 | fheight: 480.0 49 | if glfwInit = 0 [glfwTerminate] 50 | window: glfwCreateWindow 640 480 as c-string! string/rs-head txt NULL NULL 51 | glfwMakeContextCurrent window 52 | glfwSetErrorCallback :error_callback 53 | glfwSetKeyCallback window :key_callback 54 | return 1 55 | ] 56 | 57 | render: routine [return: [integer!]] [ 58 | &width/value: width; pointer! 59 | &height/value: height ;pointer! 60 | glfwGetFramebufferSize window &width &height 61 | fwidth: as float! &width/value 62 | fheight: as float! &height/value 63 | ratio: fwidth / fheight 64 | glViewport 0 0 width height 65 | glClearColor 0.0 0.0 0.0 0.0 66 | glClear GL_COLOR_BUFFER_BIT 67 | glMatrixMode GL_PROJECTION 68 | glLoadIdentity 69 | glOrtho 0.0 - ratio ratio -1.0 1.0 1.0 -1.0 70 | glMatrixMode GL_MODELVIEW 71 | glLoadIdentity 72 | 73 | angle: glfwGetTime * 36.00 74 | glRotatef as float32! angle 0.0 0.0 1.0 75 | 76 | glBegin GL_TRIANGLES 77 | glColor3f 1.0 0.0 0.0 glVertex3f -0.6 -0.4 0.0 ;first point of triangle is red 78 | glColor3f 0.0 1.0 0.0 glVertex3f 0.6 -0.4 0.0 ;second point of triangle is green 79 | glColor3f 0.0 0.0 1.0 glVertex3f 0.0 0.6 0.0 ;third point of triangle is blue 80 | glEnd 81 | glfwSwapBuffers window 82 | glfwPollEvents 83 | glfwWindowShouldClose window ; 1 for window close request 84 | ] 85 | 86 | closegl: routine [] [ 87 | glfwDestroyWindow window 88 | glfwTerminate 89 | ] 90 | 91 | 92 | ;Main program 93 | 94 | initgl "Animated OpenGL Triangle with Red and GLFW [ESC to Quit]" 95 | rep: 0 96 | until [ 97 | rep: render 98 | rep = 1 99 | ] 100 | closegl 101 | quit -------------------------------------------------------------------------------- /Samples/red/triangle.red: -------------------------------------------------------------------------------- 1 | Red [ 2 | Title: "GLFW Binding: Triangle" 3 | Author: "Francois Jouen" 4 | Rights: "Copyright (c) 2014 Francois Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ; how to use Red/System code inside Red 9 | ; use #system [library] to make import 10 | ; functions are replaced by routines because we are using Red/S code inside the function 11 | ; lastly red strings must be converted in c-strings red/System (Thanks to Jocko for as c-string! string/rs-head txt) 12 | 13 | #system [ 14 | #include %../../lib/glfw3.reds ; this lib also includes opgl.reds 15 | ; for error callback code pointer 16 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 17 | print [ description " " stderr] 18 | ] 19 | window: declare pointer! [integer!] 20 | ] 21 | 22 | 23 | initgl: routine [txt [string!] return: [integer!]] [ 24 | if glfwInit = 0 [glfwTerminate return 0] 25 | window: glfwCreateWindow 800 600 as c-string! string/rs-head txt NULL NULL 26 | glfwMakeContextCurrent window 27 | glfwSetErrorCallback :error_callback 28 | return 1 29 | ] 30 | 31 | closegl: routine [] [ 32 | glfwDestroyWindow window 33 | glfwTerminate 34 | ] 35 | 36 | render: routine [return: [integer!] ] [ 37 | glClear GL_COLOR_BUFFER_BIT 38 | glBegin GL_TRIANGLES 39 | glColor3ub 255 0 0 glVertex2d -0.75 -0.75 40 | glColor3ub 0 255 0 glVertex2d 0.0 0.75 41 | glColor3ub 0 0 255 glVertex2d 0.75 -0.75 42 | glEnd 43 | glFlush 44 | glfwSwapBuffers window 45 | glfwPollEvents 46 | glfwWindowShouldClose window ; 1 for window close request 47 | ] 48 | 49 | 50 | ;Main program 51 | 52 | 53 | initgl "A Simple OpenGL Triangle with Red and GLFW" 54 | rep: 0 55 | until [ 56 | rep: render 57 | rep = 1 58 | ] 59 | closegl 60 | quit 61 | 62 | -------------------------------------------------------------------------------- /Samples/redS/accuracy.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: Accuracy" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | 9 | ;======================================================================== 10 | ; 11 | ; This test came about as the result of bug #1867804 12 | ; 13 | ; No sign of said bug has so far been detected 14 | ; original program Copyright (c) Camilla Berglund 15 | ;======================================================================== 16 | 17 | #include %../../lib/glfw3.reds 18 | 19 | cursor_x: 0.0 20 | cursor_y: 0.0 21 | window_width: 640 22 | window_height: 480 23 | width: 0 24 | height: 0 25 | &width: :width; pointer! 26 | &height: :height ;pointer! 27 | swap_interval: 1 28 | title: "" 29 | w: 0.0 30 | h: 0.0 31 | l: 0 32 | 33 | set_swap_interval: func [window [GLFWwindow] interval [integer!] /local title][ 34 | either interval = 0 [title: "Cursor Inaccuracy Detector interval 0"] 35 | [title: "Cursor Inaccuracy Detector interval 1"] 36 | 37 | swap_interval: interval 38 | glfwSwapInterval swap_interval 39 | glfwSetWindowTitle window title 40 | ] 41 | 42 | 43 | 44 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 45 | print ["Error: " error " " description newline] 46 | ] 47 | 48 | framebuffer_size_callback: func [ 49 | [calling] 50 | window [GLFWwindow] width [integer!] height [integer!]][ 51 | window_width: width 52 | window_height: height 53 | glViewport 0 0 window_width window_height 54 | glMatrixMode GL_PROJECTION 55 | glLoadIdentity 56 | ;glOrtho 0.0 int-to-float window_width 0.0 int-to-float window_height 0.0 1.0 57 | gluOrtho2D 0.0 as float! window_width 0.0 as float! window_height ; for clipping 58 | ] 59 | 60 | cursor_position_callback: func [ 61 | [calling] 62 | window [GLFWwindow] x [float!] y [float!]][ 63 | cursor_x: x 64 | cursor_y: y 65 | ] 66 | 67 | key_callback: func [ 68 | [calling] 69 | window [GLFWwindow] 70 | key [integer!] 71 | scancode [integer!] 72 | action [integer!] 73 | mods [integer!]] [ 74 | if (key = GLFW_KEY_SPACE) and (action = GLFW_PRESS) [set_swap_interval window (1 - swap_interval)] 75 | ] 76 | 77 | glfwSetErrorCallback :error_callback 78 | if glfwInit = 0 [glfwTerminate] 79 | window: glfwCreateWindow window_width window_height " " NULL NULL 80 | glfwSetCursorPosCallback window :cursor_position_callback 81 | glfwSetFramebufferSizeCallback window :framebuffer_size_callback 82 | glfwSetKeyCallback window :key_callback 83 | glfwMakeContextCurrent window 84 | glfwGetFramebufferSize window &width &height 85 | framebuffer_size_callback window width height 86 | set_swap_interval window swap_interval 87 | 88 | while [(glfwWindowShouldClose window) = GL_FALSE] [ 89 | glClear GL_COLOR_BUFFER_BIT 90 | glBegin GL_LINES 91 | h: as float! window_height 92 | w: as float! window_width 93 | glVertex2f 0.0 as float32! h - cursor_y 94 | glVertex2f as float32! w as float32! h - cursor_y 95 | glVertex2f as float32! cursor_x 0.0 96 | glVertex2f as float32! cursor_x as float32! h 97 | glEnd 98 | 99 | glfwSwapBuffers window 100 | glfwPollEvents 101 | ] 102 | 103 | glfwDestroyWindow window 104 | glfwTerminate -------------------------------------------------------------------------------- /Samples/redS/clipboard.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: clipboard" 3 | Author: "F. Jouen" 4 | Rights: "Copyright (c) 2013-2014 F. Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;======================================================================== 9 | ; 10 | ; This program is used to test the clipboard functionality. 11 | ; original program Copyright (c) Camilla Berglund 12 | ;======================================================================== 13 | 14 | #include %../../lib/glfw3.reds 15 | 16 | 17 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 18 | print [ description " " stderr] 19 | ] 20 | 21 | key_callback: func [ 22 | [calling] 23 | window [GLFWwindow] 24 | key [integer!] 25 | scancode [integer!] 26 | action [integer!] 27 | mods [integer!] /local string l] [ 28 | 29 | if (action <> GLFW_PRESS) [exit]; 30 | 31 | switch key [ 32 | GLFW_KEY_ESCAPE [glfwSetWindowShouldClose window GL_TRUE ] 33 | GLFW_KEY_V [ 34 | if (mods = GLFW_MOD_CONTROL) [ 35 | string: glfwGetClipboardString window 36 | l: length? string 37 | either l > 1 [print ["Clipboard contains " string newline]] 38 | [print ["Clipboard does not contain a string" newline]] 39 | ] 40 | ] 41 | GLFW_KEY_C [ 42 | if (mods = GLFW_MOD_CONTROL) [ 43 | string: "Hello GLFW World!" 44 | glfwSetClipboardString window string 45 | print ["Setting clipboard to " string newline] 46 | ] 47 | ] 48 | default [print ""] 49 | ] 50 | ] 51 | 52 | framebuffer_size_callback: func [[calling] window [GLFWwindow] width [integer!] height [integer!]] [ 53 | glViewport 0 0 width height 54 | ] 55 | 56 | ;main 57 | glfwSetErrorCallback :error_callback 58 | if glfwInit = 0 [glfwTerminate] ; exit 59 | window: glfwCreateWindow 400 400 "Clipboard Test [CTRL-C CTRL-V]" NULL NULL 60 | if window = null [glfwTerminate] 61 | glfwMakeContextCurrent window 62 | glfwSwapInterval 1 63 | glfwSetKeyCallback window :key_callback 64 | glfwSetFramebufferSizeCallback window :framebuffer_size_callback 65 | glMatrixMode GL_PROJECTION 66 | glOrtho -1.0 1.0 -1.0 1.0 -1.0 1.0 67 | glMatrixMode GL_MODELVIEW 68 | glClearColor 0.5 0.5 0.5 0.0 69 | 70 | while [(glfwWindowShouldClose window) = GL_FALSE] [ 71 | glClear GL_COLOR_BUFFER_BIT 72 | glColor3f 0.8 0.2 0.4 73 | glRectf -0.5 -0.5 0.5 0.5 74 | glfwSwapBuffers window 75 | glfwWaitEvents 76 | 77 | ] 78 | glfwDestroyWindow window 79 | glfwTerminate 80 | 81 | -------------------------------------------------------------------------------- /Samples/redS/defaults.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: defaults" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;======================================================================== 9 | ; 10 | ; This test creates a windowed mode window with all window hints set to 11 | ; default values and then reports the actual attributes of the created 12 | ; window and context 13 | ; original program Copyright (c) Camilla Berglund 14 | ;======================================================================== 15 | 16 | #include %../../lib/glfw3.reds 17 | 18 | 19 | width: 640 20 | height: 480 21 | &width: :width; pointer! 22 | &height: :height ;pointer! 23 | c: 1 24 | 25 | 26 | AttribGL!: alias struct! [ 27 | attrib [integer!] 28 | ext [c-string!] 29 | name [c-string!] 30 | ] 31 | 32 | AttribGLFW!: alias struct! [ 33 | attrib [integer!] 34 | name [c-string!] 35 | ] 36 | 37 | gl_attribs: declare struct! [ 38 | gl1 [AttribGL!] 39 | gl2 [AttribGL!] 40 | gl3 [AttribGL!] 41 | gl4 [AttribGL!] 42 | gl5 [AttribGL!] 43 | gl6 [AttribGL!] 44 | gl7 [AttribGL!] 45 | gl8 [AttribGL!] 46 | gl9 [AttribGL!] 47 | ] 48 | 49 | 50 | glfw_attribs: declare struct! [ 51 | glw1 [AttribGLFW!] 52 | glw2 [AttribGLFW!] 53 | glw3 [AttribGLFW!] 54 | glw4 [AttribGLFW!] 55 | glw5 [AttribGLFW!] 56 | glw6 [AttribGLFW!] 57 | ] 58 | 59 | 60 | 61 | gl_attribs/gl1: declare AttribGL! 62 | gl_attribs/gl2: declare AttribGL! 63 | gl_attribs/gl3: declare AttribGL! 64 | gl_attribs/gl4: declare AttribGL! 65 | gl_attribs/gl5: declare AttribGL! 66 | gl_attribs/gl6: declare AttribGL! 67 | gl_attribs/gl7: declare AttribGL! 68 | gl_attribs/gl8: declare AttribGL! 69 | gl_attribs/gl9: declare AttribGL! 70 | 71 | 72 | 73 | gl_attribs/gl1/attrib: GL_RED_BITS 74 | gl_attribs/gl1/ext: null 75 | gl_attribs/gl1/name: "red bits" 76 | 77 | gl_attribs/gl2/attrib: GL_GREEN_BITS 78 | gl_attribs/gl2/ext: null 79 | gl_attribs/gl2/name: "green bits" 80 | 81 | gl_attribs/gl3/attrib: GL_BLUE_BITS 82 | gl_attribs/gl3/ext: null 83 | gl_attribs/gl3/name: "blue bits" 84 | 85 | gl_attribs/gl4/attrib: GL_ALPHA_BITS 86 | gl_attribs/gl4/ext: null 87 | gl_attribs/gl4/name: "alpha bits" 88 | 89 | gl_attribs/gl5/attrib: GL_DEPTH_BITS 90 | gl_attribs/gl5/ext: null 91 | gl_attribs/gl5/name: "depth bits" 92 | 93 | gl_attribs/gl6/attrib: GL_STENCIL_BITS 94 | gl_attribs/gl6/ext: null 95 | gl_attribs/gl6/name: "stencil bits" 96 | 97 | gl_attribs/gl7/attrib: GL_STEREO 98 | gl_attribs/gl7/ext: null 99 | gl_attribs/gl7/name: "stereo" 100 | 101 | gl_attribs/gl8/attrib: 000080A9h;GL_SAMPLES_ARB 102 | gl_attribs/gl8/ext: null 103 | gl_attribs/gl8/name: "FSAA samples" "GL_ARB_multisample" 104 | 105 | gl_attribs/gl9/attrib: 0 106 | gl_attribs/gl9/ext: null 107 | gl_attribs/gl9/name: null 108 | 109 | 110 | glfw_attribs/glw1: declare AttribGLFW! 111 | glfw_attribs/glw2: declare AttribGLFW! 112 | glfw_attribs/glw3: declare AttribGLFW! 113 | glfw_attribs/glw4: declare AttribGLFW! 114 | glfw_attribs/glw5: declare AttribGLFW! 115 | glfw_attribs/glw6: declare AttribGLFW! 116 | 117 | 118 | glfw_attribs/glw1/attrib: GLFW_CONTEXT_VERSION_MAJOR 119 | glfw_attribs/glw1/name: "Context version major" 120 | 121 | glfw_attribs/glw2/attrib: GLFW_CONTEXT_VERSION_MINOR 122 | glfw_attribs/glw2/name: "Context version minor" 123 | 124 | glfw_attribs/glw3/attrib: GLFW_OPENGL_FORWARD_COMPAT 125 | glfw_attribs/glw3/name: "OpenGL forward compatible" 126 | 127 | glfw_attribs/glw4/attrib: GLFW_OPENGL_DEBUG_CONTEXT 128 | glfw_attribs/glw4/name: "OpenGL debug context" 129 | 130 | glfw_attribs/glw5/attrib: GLFW_OPENGL_PROFILE 131 | glfw_attribs/glw5/name: "OpenGL profile" 132 | 133 | glfw_attribs/glw6/attrib: 0 134 | glfw_attribs/glw6/name: "" 135 | 136 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 137 | print [ description " " stderr] 138 | ] 139 | 140 | ; main program 141 | glfwSetErrorCallback :error_callback 142 | if glfwInit = 0 [glfwTerminate] ; exit 143 | glfwWindowHint GLFW_VISIBLE GL_FALSE 144 | window: glfwCreateWindow 640 480 "Defaults" NULL NULL 145 | glfwMakeContextCurrent window 146 | glfwGetWindowSize window &width &height 147 | print ["framebuffer size: " width " x " height newline] 148 | c: 1 149 | p: as int-ptr! glfw_attribs/glw1 150 | until [ 151 | if c = 2 [p: as int-ptr! glfw_attribs/glw2] ;????? 152 | print [as c-string! p/2 ": " glfwGetWindowAttrib window p/1 newline ] 153 | p: p + 2 154 | c: c + 1 155 | c = 6 156 | ] 157 | c: 1 158 | p: as int-ptr! gl_attribs/gl1 159 | value: 0 &value: :value ; pointer 160 | until [ 161 | if p/2 <> 0 [if (glfwExtensionSupported as c-string! p/2) = GL_FALSE [print ""]] 162 | glGetIntegerv p/1 &value 163 | print [as c-string! p/3 ": " &value/value newline ] 164 | p: p + 3 ; incremente pointer 165 | c: c + 1 166 | c = 9 167 | ] 168 | 169 | glfwDestroyWindow window 170 | window: null 171 | glfwTerminate 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | -------------------------------------------------------------------------------- /Samples/redS/events.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: events" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | 9 | 10 | 11 | ;======================================================================== 12 | ; 13 | ; This test hooks every available callback and outputs their arguments 14 | ; 15 | ; Log messages go to stdout, error messages to stderr 16 | ; 17 | ; Every event also gets a (sequential) number to aid discussion of logs 18 | ; original program Copyright (c) Camilla Berglund 19 | ;======================================================================== 20 | 21 | #include %../../lib/glfw3.reds 22 | 23 | ;These must match the input mode defaults 24 | closeable: GL_TRUE 25 | 26 | ;Event index 27 | counter: 0 28 | str: "" 29 | name: "" 30 | 31 | width: 640 32 | height: 480 33 | &width: :width; pointer! 34 | &height: :height ;pointer! 35 | 36 | 37 | get_key_name: func [key [integer!] return: [c-string!]][ 38 | switch key [ 39 | GLFW_KEY_A [return "A" ] 40 | GLFW_KEY_B [return "B"] 41 | GLFW_KEY_C [return "C"] 42 | GLFW_KEY_D [return "D"] 43 | GLFW_KEY_E [return "E"] 44 | GLFW_KEY_F [return "F"] 45 | GLFW_KEY_G [return "G"] 46 | GLFW_KEY_H [return "H"] 47 | GLFW_KEY_I [return "I"] 48 | GLFW_KEY_J [return "J"] 49 | GLFW_KEY_K [return "K"] 50 | GLFW_KEY_L [return "L"] 51 | GLFW_KEY_M [return "M"] 52 | GLFW_KEY_N [return "N"] 53 | GLFW_KEY_O [return "O"] 54 | GLFW_KEY_P [return "P"] 55 | GLFW_KEY_Q [return "Q"] 56 | GLFW_KEY_R [return "R"] 57 | GLFW_KEY_S [return "S"] 58 | GLFW_KEY_T [return "T"] 59 | GLFW_KEY_U [return "U"] 60 | GLFW_KEY_V [return "V"] 61 | GLFW_KEY_W [return "W"] 62 | GLFW_KEY_X [return "X"] 63 | GLFW_KEY_Y [return "Y"] 64 | GLFW_KEY_Z [return "Z"] 65 | GLFW_KEY_1 [return "1"] 66 | GLFW_KEY_2 [return "2"] 67 | GLFW_KEY_3 [return "3"] 68 | GLFW_KEY_4 [return "4"] 69 | GLFW_KEY_5 [return "5"] 70 | GLFW_KEY_6 [return "6"] 71 | GLFW_KEY_7 [return "7"] 72 | GLFW_KEY_8 [return "8"] 73 | GLFW_KEY_9 [return "9"] 74 | GLFW_KEY_0 [return "0"] 75 | GLFW_KEY_SPACE [return "SPACE"] 76 | GLFW_KEY_MINUS [return "MINUS"] 77 | GLFW_KEY_EQUAL [return "EQUAL"] 78 | GLFW_KEY_LEFT_BRACKET [return "LEFT BRACKET"] 79 | GLFW_KEY_RIGHT_BRACKET [return "RIGHT BRACKET"] 80 | GLFW_KEY_BACKSLASH [return "BACKSLASH"] 81 | GLFW_KEY_SEMICOLON [return "SEMICOLON"] 82 | GLFW_KEY_APOSTROPHE [return "APOSTROPHE"] 83 | GLFW_KEY_GRAVE_ACCENT [return "GRAVE ACCENT"] 84 | GLFW_KEY_COMMA [return "COMMA"] 85 | GLFW_KEY_PERIOD [return "PERIOD"] 86 | GLFW_KEY_SLASH [return "SLASH"] 87 | GLFW_KEY_WORLD_1 [return "WORLD 1"] 88 | GLFW_KEY_WORLD_2 [return "WORLD 2"] 89 | 90 | ; Function keys 91 | GLFW_KEY_ESCAPE [return "ESCAPE"] 92 | GLFW_KEY_F1 [return "F1"] 93 | GLFW_KEY_F2 [return "F2"] 94 | GLFW_KEY_F3 [return "F3"] 95 | GLFW_KEY_F4 [return "F4"] 96 | GLFW_KEY_F5 [return "F5"] 97 | GLFW_KEY_F6 [return "F6"] 98 | GLFW_KEY_F7 [return "F7"] 99 | GLFW_KEY_F8 [return "F8"] 100 | GLFW_KEY_F9 [return "F9"] 101 | GLFW_KEY_F10 [return "F10"] 102 | GLFW_KEY_F11 [return "F11"] 103 | GLFW_KEY_F12 [return "F12"] 104 | GLFW_KEY_F13 [return "F13"] 105 | GLFW_KEY_F14 [return "F14"] 106 | GLFW_KEY_F15 [return "F15"] 107 | GLFW_KEY_F16 [return "F16"] 108 | GLFW_KEY_F17 [return "F17"] 109 | GLFW_KEY_F18 [return "F18"] 110 | GLFW_KEY_F19 [return "F19"] 111 | GLFW_KEY_F20 [return "F20"] 112 | GLFW_KEY_F21 [return "F21"] 113 | GLFW_KEY_F22 [return "F22"] 114 | GLFW_KEY_F23 [return "F23"] 115 | GLFW_KEY_F24 [return "F24"] 116 | GLFW_KEY_F25 [return "F25"] 117 | GLFW_KEY_UP [return "UP"] 118 | GLFW_KEY_DOWN [return "DOWN"] 119 | GLFW_KEY_LEFT [return "LEFT"] 120 | GLFW_KEY_RIGHT [return "RIGHT"] 121 | GLFW_KEY_LEFT_SHIFT [return "LEFT SHIFT"] 122 | GLFW_KEY_RIGHT_SHIFT [return "RIGHT SHIFT"] 123 | GLFW_KEY_LEFT_CONTROL [return "LEFT CONTROL"] 124 | GLFW_KEY_RIGHT_CONTROL [return "RIGHT CONTROL"] 125 | GLFW_KEY_LEFT_ALT [return "LEFT ALT"] 126 | GLFW_KEY_RIGHT_ALT [return "RIGHT ALT"] 127 | GLFW_KEY_TAB [return "TAB"] 128 | GLFW_KEY_ENTER [return "ENTER"] 129 | GLFW_KEY_BACKSPACE [return "BACKSPACE"] 130 | GLFW_KEY_INSERT [return "INSERT"] 131 | GLFW_KEY_DELETE [return "DELETE"] 132 | GLFW_KEY_PAGE_UP [return "PAGE UP"] 133 | GLFW_KEY_PAGE_DOWN [return "PAGE DOWN"] 134 | GLFW_KEY_HOME [return "HOME"] 135 | GLFW_KEY_END [return "END"] 136 | GLFW_KEY_KP_0 [return "KEYPAD 0"] 137 | GLFW_KEY_KP_1 [return "KEYPAD 1"] 138 | GLFW_KEY_KP_2 [return "KEYPAD 2"] 139 | GLFW_KEY_KP_3 [return "KEYPAD 3"] 140 | GLFW_KEY_KP_4 [return "KEYPAD 4"] 141 | GLFW_KEY_KP_5 [return "KEYPAD 5"] 142 | GLFW_KEY_KP_6 [return "KEYPAD 6"] 143 | GLFW_KEY_KP_7 [return "KEYPAD 7"] 144 | GLFW_KEY_KP_8 [return "KEYPAD 8"] 145 | GLFW_KEY_KP_9 [return "KEYPAD 9"] 146 | GLFW_KEY_KP_DIVIDE [return "KEYPAD DIVIDE"] 147 | GLFW_KEY_KP_MULTIPLY [return "KEYPAD MULTPLY"] 148 | GLFW_KEY_KP_SUBTRACT [return "KEYPAD SUBTRACT"] 149 | GLFW_KEY_KP_ADD [return "KEYPAD ADD"] 150 | GLFW_KEY_KP_DECIMAL [return "KEYPAD DECIMAL"] 151 | GLFW_KEY_KP_EQUAL [return "KEYPAD EQUAL"] 152 | GLFW_KEY_KP_ENTER [return "KEYPAD ENTER"] 153 | GLFW_KEY_PRINT_SCREEN [return "PRINT SCREEN"] 154 | GLFW_KEY_NUM_LOCK [return "NUM LOCK"] 155 | GLFW_KEY_CAPS_LOCK [return "CAPS LOCK"] 156 | GLFW_KEY_SCROLL_LOCK [return "SCROLL LOCK"] 157 | GLFW_KEY_PAUSE [return "PAUSE"] 158 | GLFW_KEY_LEFT_SUPER [return "LEFT SUPER"] 159 | GLFW_KEY_RIGHT_SUPER [return "RIGHT SUPER"] 160 | GLFW_KEY_MENU [return "MENU"] 161 | GLFW_KEY_UNKNOWN [return "UNKNOWN"] 162 | default [return null] 163 | ] 164 | ] 165 | 166 | get_action_name: func [action [integer!] return: [c-string!]][ 167 | switch action [ 168 | GLFW_PRESS [return "pressed"] 169 | GLFW_RELEASE [return "released"] 170 | GLFW_REPEAT [return "repeated"] 171 | ] 172 | "caused unknown action" 173 | ] 174 | 175 | get_button_name: func [button [integer!] return: [c-string!]][ 176 | switch button [ 177 | GLFW_MOUSE_BUTTON_LEFT [return "left"] 178 | GLFW_MOUSE_BUTTON_RIGHT [return "right"] 179 | GLFW_MOUSE_BUTTON_MIDDLE [return "middle"] 180 | ] 181 | null 182 | ] 183 | 184 | 185 | 186 | get_mods_name: func [mods [integer!] return: [c-string!] /local name [c-string!]][ 187 | name: " " 188 | if (mods) AND (GLFW_MOD_SHIFT) = 1 [name: " shift"] 189 | if (mods) AND (GLFW_MOD_CONTROL) = 2 [name: " control"] 190 | if (mods) AND (GLFW_MOD_CONTROL) = 4 [name: " alt"] 191 | if (mods) AND (GLFW_MOD_SUPER) = 8 [name: " super"] 192 | name 193 | ] 194 | 195 | 196 | ; ////revoir 197 | get_character_string: func [character [integer!] return: [c-string!] /local result length][ 198 | ;// This assumes UTF-8, which is stupid 199 | result: "" 200 | length: 0 201 | ;length: wctomb result character ; in c-lib TBD 202 | if length = -1 [length: 0] 203 | return result 204 | ] 205 | 206 | ;//// Fin 207 | 208 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 209 | print [ description " " stderr] 210 | ] 211 | 212 | 213 | window_pos_callback: func [[calling] window [GLFWwindow] x [integer!] y [integer!]] [ 214 | counter: counter + 1 215 | print [ counter " at " glfwGetTime " : Window position: " x " " y newline] 216 | ] 217 | 218 | window_size_callback: func [[calling] window [GLFWwindow] width [integer!] height [integer!]] [ 219 | counter: counter + 1 220 | print [ counter " at " glfwGetTime " : Window size: " width " " height newline] 221 | ] 222 | 223 | framebuffer_size_callback: func [[calling] window [GLFWwindow] width [integer!] height [integer!]] [ 224 | counter: counter + 1 225 | print [ counter " at " glfwGetTime " : Framebuffer size: " width " " height newline] 226 | ] 227 | 228 | window_close_callback: func [[calling] window [GLFWwindow]] [ 229 | counter: counter + 1 230 | print [ counter " at " glfwGetTime " : Window close" newline] 231 | ] 232 | 233 | window_refresh_callback: func [[calling] window [GLFWwindow]] [ 234 | counter: counter + 1 235 | print [ counter " at " glfwGetTime " : Window refresh" newline] 236 | if glfwGetCurrentContext <> NULL 237 | [ 238 | glClear GL_COLOR_BUFFER_BIT 239 | glfwSwapBuffers window 240 | ] 241 | ] 242 | 243 | 244 | window_focus_callback: func [[calling] window [GLFWwindow] focused [integer!] /local str] [ 245 | counter: counter + 1 246 | either focused = 1 [str: "focused" ] [str: "defocused"] 247 | print [ counter " at " glfwGetTime " : Window was " str newline] 248 | ] 249 | 250 | 251 | 252 | 253 | window_iconify_callback: func [[calling] window [GLFWwindow] iconified [integer!] /local str] [ 254 | counter: counter + 1 255 | either iconified = 1 [str: "iconified" ] [str: "restored"] 256 | print [ counter " at " glfwGetTime " : Window was " str newline] 257 | ] 258 | 259 | 260 | 261 | 262 | mouse_button_callback: func [[calling] window [GLFWwindow] button [integer!] action [integer!] mods [integer!]/local name] [ 263 | counter: counter + 1 264 | name: get_button_name button 265 | print [ counter " at " glfwGetTime " : Mousse button " button " " ] 266 | if name <> null [print [name]] 267 | if mods <> 0 [print ["with " get_mods_name mods]] 268 | print [ " was " get_action_name action newline] 269 | ] 270 | 271 | cursor_position_callback: func [[calling] window [GLFWwindow] x [float!] y [float!]] [ 272 | counter: counter + 1 273 | print [ counter " at " glfwGetTime " : Cursor position: " x " " y newline] 274 | ] 275 | 276 | cursor_enter_callback: func [[calling] window [GLFWwindow] entered [integer!] /local str] [ 277 | counter: counter + 1 278 | either entered = 1 [str: "entered" ] [str: "left"] 279 | print [ counter " at " glfwGetTime " : Cursor " str " window" newline] 280 | ] 281 | 282 | scroll_callback: func [[calling] window [GLFWwindow] x [float!] y [float!]] [ 283 | counter: counter + 1 284 | print [ counter " at " glfwGetTime " : Scroll: " x " " y newline] 285 | ] 286 | 287 | 288 | key_callback: func [ 289 | [calling] 290 | window [GLFWwindow] 291 | key [integer!] 292 | scancode [integer!] 293 | action [integer!] 294 | mods [integer!]] [ 295 | str: "" 296 | counter: counter + 1 297 | name: get_key_name key 298 | print [ counter " at " glfwGetTime " : scancode: " key " " scancode " "] 299 | if name <> null [print [name]] 300 | if mods <> 0 [print ["with " get_mods_name mods]] 301 | print [ " was " get_action_name action newline] 302 | 303 | ;if (action <> GLFW_PRESS) [exit]; 304 | 305 | if (key = GLFW_KEY_C) [ 306 | closeable: not closeable 307 | either closeable = 1 [str: "enabled" ] [str: "disabled" ] 308 | print ["closing " str newline] 309 | ] 310 | ] 311 | 312 | 313 | char_callback: func [[calling] window [GLFWwindow] character [integer!] /local str] [ 314 | counter: counter + 1 315 | str: get_character_string character 316 | print [ counter " at " glfwGetTime " : Character: " character " " str " input" newline] 317 | ] 318 | 319 | 320 | monitor_callback: func [[calling] monitor [GLFWmonitor] event [integer!] /local mode widthMM heightMM &w &h x y &x &y] [ 321 | widthMM: 0 322 | heightMM: 0 323 | &w: :widthMM; pointer! 324 | &h: :widthMM ;pointer! 325 | x: 0 326 | y: 0 327 | &x: :x ; pointer! 328 | &y: :y ; pointer! 329 | counter: counter + 1 330 | either (event = GLFW_CONNECTED) [ 331 | mode: glfwGetVideoMode monitor 332 | glfwGetMonitorPos monitor &x &y 333 | glfwGetMonitorPhysicalSize monitor &w &h 334 | print [ counter " at " glfwGetTime " : Monitor : " glfwGetMonitorName monitor " " ] 335 | print [mode/width "x" mode/height "at " x " " y "[" &w " " &h " mm was connected" newline] 336 | 337 | ] 338 | [ print [counter " at " glfwGetTime " : Monitor : " glfwGetMonitorName monitor " was disconnected" newline ]] 339 | 340 | 341 | ] 342 | 343 | 344 | ;monitor_callback(GLFWmonitor* monitor, int event) 345 | 346 | ;Main 347 | 348 | glfwSetErrorCallback :error_callback 349 | if glfwInit = 0 [glfwTerminate] ; exit 350 | print ["Library initialized" newline] 351 | window: glfwCreateWindow width height "Event Linter" NULL NULL 352 | 353 | 354 | ;glfwSetMonitorCallback :monitor_callback 355 | glfwSetWindowPosCallback window :window_pos_callback 356 | glfwSetWindowSizeCallback window :window_size_callback 357 | glfwSetFramebufferSizeCallback window :framebuffer_size_callback 358 | glfwSetWindowCloseCallback window :window_close_callback 359 | glfwSetWindowRefreshCallback window :window_refresh_callback 360 | glfwSetWindowFocusCallback window :window_focus_callback 361 | glfwSetWindowIconifyCallback window :window_iconify_callback 362 | glfwSetMouseButtonCallback window :mouse_button_callback 363 | glfwSetCursorPosCallback window :cursor_position_callback 364 | glfwSetCursorEnterCallback window :cursor_enter_callback 365 | glfwSetScrollCallback window :scroll_callback 366 | glfwSetKeyCallback window :key_callback 367 | glfwSetCharCallback window :char_callback 368 | 369 | 370 | glfwMakeContextCurrent window 371 | glfwSwapInterval 1 372 | glfwGetWindowSize window &width &height 373 | print ["Window size should be " width " x " height newline] 374 | print ["Main loop starting" newline] 375 | while [(glfwWindowShouldClose window) = GL_FALSE] [glfwWaitEvents] 376 | 377 | glfwDestroyWindow window 378 | glfwTerminate 379 | 380 | 381 | 382 | 383 | 384 | 385 | -------------------------------------------------------------------------------- /Samples/redS/fsaa.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: fsaa" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013+2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;======================================================================== 9 | ; 10 | ; This test renders two high contrast, slowly rotating quads, one aliased 11 | ; and one (hopefully) anti-aliased, thus allowing for visual verification 12 | ; of whether FSAA is indeed enabled 13 | ; original program Copyright (c) Camilla Berglund 14 | ;======================================================================== 15 | 16 | #include %../../lib/glfw3.reds 17 | 18 | 19 | time: 0.0 20 | 21 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 22 | print [ description " " stderr] 23 | ] 24 | 25 | framebuffer_size_callback: func [[calling] window [GLFWwindow] width [integer!] height [integer!]] [ 26 | glViewport 0 0 width height 27 | ] 28 | 29 | key_callback: func [ 30 | [calling] 31 | window [GLFWwindow] 32 | key [integer!] 33 | scancode [integer!] 34 | action [integer!] 35 | mods [integer!]] [ 36 | 37 | if (action <> GLFW_PRESS) [exit]; 38 | if (key = GLFW_KEY_SPACE) [glfwSetTime 0.0 exit] 39 | if (key = GLFW_KEY_ESCAPE) [glfwSetWindowShouldClose window GL_TRUE ] 40 | ] 41 | 42 | ; main 43 | samples: 4 44 | &samples: :samples 45 | glfwSetErrorCallback :error_callback 46 | if glfwInit = 0 [glfwTerminate] ; exit 47 | either samples <> 0 [print ["Requesting FSAA with " samples " samples" newline]] 48 | [print ["Requesting that FSAA not be available" newline]] 49 | glfwWindowHint GLFW_SAMPLES samples 50 | window: glfwCreateWindow 800 400 "Aliasing Detector" NULL NULL 51 | glfwSetKeyCallback window :key_callback 52 | glfwSetFramebufferSizeCallback window :framebuffer_size_callback 53 | 54 | glfwMakeContextCurrent window 55 | glfwSwapInterval 1 56 | 57 | if (glfwExtensionSupported "GL_ARB_multisample") = 0 [glfwTerminate] 58 | ; GL_SAMPLES_ARB = 32937 59 | glGetIntegerv 32937 &samples 60 | either samples <> 0 [print ["Context reports FSAA is available with " samples " samples" newline]] 61 | [print ["Context reports FSAA is unavailable" newline]] 62 | glMatrixMode GL_PROJECTION 63 | glOrtho 0.0 1.0 -1.0 1.0 1.0 -1.0 64 | 65 | glMatrixMode GL_MODELVIEW 66 | while [(glfwWindowShouldClose window) = GL_FALSE] [ 67 | time: glfwGetTime 68 | glClear GL_COLOR_BUFFER_BIT 69 | glLoadIdentity 70 | glTranslatef 0.25 0.25 0.0 71 | glRotatef as float32! time as float32! 0.0 as float32! 0.0 as float32! 1.0 72 | glDisable 32925; GL_MULTISAMPLE_ARB 73 | glRectf -0.15 -0.15 0.15 0.15 74 | 75 | glLoadIdentity 76 | glTranslatef 0.75 0.25 0.0 77 | glRotatef as float32! time as float32! 0.0 as float32! 0.0 as float32! 1.0 78 | glEnable 32925; GL_MULTISAMPLE_ARB 79 | glRectf -0.15 -0.15 0.15 0.15 80 | glfwSwapBuffers window 81 | glfwPollEvents 82 | ] 83 | glfwDestroyWindow window 84 | glfwTerminate 85 | -------------------------------------------------------------------------------- /Samples/redS/gamma.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: gamma" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | 9 | ;======================================================================== 10 | ; 11 | ; This program is used to test the gamma correction functionality for 12 | ; both fullscreen and windowed mode windows 13 | ; original program Copyright (c) Camilla Berglund 14 | ;======================================================================== 15 | 16 | 17 | #include %../../lib/glfw3.reds 18 | 19 | 20 | 21 | STEP_SIZE: 0.1 22 | width: 200 23 | height: 200 24 | &width: :width; pointer! 25 | &height: :height ;pointer! 26 | gamma_value: 0.0 27 | 28 | set_gamma: func [window [GLFWwindow] value [float!] /local monitor ] [ 29 | monitor: glfwGetWindowMonitor window 30 | if (monitor = null) [monitor: glfwGetPrimaryMonitor] 31 | gamma_value: value 32 | print ["Gamma : " gamma_value newline] 33 | glfwSetGamma monitor as float32! gamma_value 34 | ] 35 | 36 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 37 | print [ description " " stderr] 38 | ] 39 | 40 | key_callback: func [ 41 | [calling] 42 | window [GLFWwindow] 43 | key [integer!] 44 | scancode [integer!] 45 | action [integer!] 46 | mods [integer!]] [ 47 | if (key = GLFW_KEY_ESCAPE) and (action = GLFW_PRESS) [glfwSetWindowShouldClose window GL_TRUE ] 48 | if (key = GLFW_KEY_UP) and (action = GLFW_PRESS) [set_gamma window gamma_value + STEP_SIZE] 49 | if (key = GLFW_KEY_DOWN) and (action = GLFW_PRESS) [ 50 | if (gamma_value - STEP_SIZE > 0.0) [set_gamma window gamma_value - STEP_SIZE] 51 | ] 52 | ] 53 | 54 | framebuffer_size_callback: func [[calling] window [GLFWwindow] width [integer!] height [integer!]] 55 | [ 56 | glViewport 0 0 width height 57 | 58 | ] 59 | 60 | 61 | ; Main Program 62 | 63 | isMonitor: false ; true for the whole monitor false for a window 64 | glfwSetErrorCallback :error_callback 65 | if glfwInit = 0 [glfwTerminate] ; exit 66 | monitor: glfwGetPrimaryMonitor 67 | mode: glfwGetVideoMode monitor 68 | either isMonitor [width: mode/width height: mode/height] [width: 400 height: 400] 69 | window: glfwCreateWindow width height "Gamma Test [ Up and Down for gamma ESC to Quit]" NULL NULL 70 | set_gamma window 1.0 71 | glfwMakeContextCurrent window 72 | glfwSwapInterval 1 73 | glfwSetKeyCallback window :key_callback 74 | glfwSetFramebufferSizeCallback window :framebuffer_size_callback 75 | glMatrixMode GL_PROJECTION 76 | glOrtho -1.0 1.0 -1.0 1.0 -1.0 1.0 77 | glMatrixMode GL_MODELVIEW 78 | glClearColor 0.5 0.5 0.5 0.0 79 | 80 | while [(glfwWindowShouldClose window) = GL_FALSE] [ 81 | glClear GL_COLOR_BUFFER_BIT 82 | glColor3f 0.8 0.2 0.4 83 | glRectf -0.5 -0.5 0.5 0.5 84 | glfwSwapBuffers window 85 | glfwWaitEvents 86 | ] 87 | 88 | glfwDestroyWindow window 89 | glfwTerminate 90 | -------------------------------------------------------------------------------- /Samples/redS/glfwinfo.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: glwinfo" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;======================================================================== 9 | ; 10 | ; This test is a pale imitation of glxinfo(1), except not really 11 | ; 12 | ; It dumps GLFW and OpenGL version information 13 | ; original program Copyright (c) Camilla Berglund 14 | ;======================================================================== 15 | 16 | #include %../../lib/glfw3.reds 17 | 18 | ;in gl3.h 19 | #define GL_CONTEXT_CORE_PROFILE_BIT 00000001h 20 | #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 00000002h 21 | #define GL_CONTEXT_FLAGS 0000821Eh 22 | #define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 00000001h 23 | #define GL_CONTEXT_PROFILE_MASK 00009126h 24 | 25 | ; in glxx.h 26 | 27 | #define GL_LOSE_CONTEXT_ON_RESET_ARB 00008252h 28 | #define GL_RESET_NOTIFICATION_STRATEGY_ARB 00008256h 29 | #define GL_NO_RESET_NOTIFICATION_ARB 00008261h 30 | #define GL_CONTEXT_FLAG_DEBUG_BIT 00000002h 31 | #define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 00000004h 32 | 33 | #define GL_NUM_EXTENSIONS 0000821Dh 34 | 35 | #define API_OPENGL "gl" 36 | #define API_OPENGL_ES "es" 37 | 38 | #define PROFILE_NAME_CORE "core" 39 | #define PROFILE_NAME_COMPAT "compat" 40 | 41 | #define STRATEGY_NAME_NONE "none" 42 | #define STRATEGY_NAME_LOSE "lose" 43 | 44 | ;window: declare pointer! [integer!] 45 | 46 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 47 | ;write-form [stderr "Error: %s\n" description] 48 | print ["Error: " error " " description newline] 49 | throw error 50 | ] 51 | 52 | get_client_api_name: func [api [integer!] return: [c-string!]] [ 53 | either (api = GLFW_OPENGL_API) [return "OpenGL"] ["OpenGL ES"] 54 | "Unknown API" 55 | 56 | ] 57 | 58 | get_profile_name_gl: func [mask [GLint] return: [c-string!]] [ 59 | if (mask AND GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) <> 0 [return PROFILE_NAME_COMPAT] 60 | if (mask AND GL_CONTEXT_CORE_PROFILE_BIT) <> 0 [return PROFILE_NAME_CORE] 61 | "unknown" 62 | ] 63 | 64 | 65 | get_profile_name_glfw: func [profile [integer!] return: [c-string!]] [ 66 | if profile = GLFW_OPENGL_COMPAT_PROFILE [return PROFILE_NAME_COMPAT] 67 | if profile = GLFW_OPENGL_CORE_PROFILE [return PROFILE_NAME_CORE] 68 | "unknown" 69 | ] 70 | 71 | get_strategy_name_gl: func [strategy [GLint] return: [c-string!]] [ 72 | if strategy = GL_LOSE_CONTEXT_ON_RESET_ARB [return STRATEGY_NAME_LOSE] 73 | if strategy = GL_NO_RESET_NOTIFICATION_ARB [return STRATEGY_NAME_NONE] 74 | return "unknown" 75 | ] 76 | 77 | 78 | get_strategy_name_glfw: func [strategy [integer!] return: [c-string!]] [ 79 | if strategy = GLFW_LOSE_CONTEXT_ON_RESET [return STRATEGY_NAME_LOSE] 80 | if strategy = GLFW_NO_RESET_NOTIFICATION [return STRATEGY_NAME_NONE] 81 | return "unknown" 82 | ] 83 | 84 | list_extensions: func [api [integer!] major [integer!] minor [integer!] /local i c count glGetStringi extensions length &count ][ 85 | print [get_client_api_name api " context supported extensions: " newline] 86 | count: 0 &count: :count 87 | i: 0 88 | either (api = GLFW_OPENGL_API) AND (major > 2) [ 89 | glGetStringi: glfwGetProcAddress "glGetStringi" 90 | if glGetStringi = null [glfwTerminate] 91 | glGetIntegerv GL_NUM_EXTENSIONS &count 92 | until [ 93 | print [glGetStringi GL_EXTENSIONS i] 94 | i: i + 1 95 | i < count 96 | ] 97 | print [newline] 98 | ] 99 | [ 100 | extensions: glGetString GL_EXTENSIONS ; contrôler glGetString dans opengl! 101 | length: length? as c-string! extensions 102 | ; parse string is necessary 103 | i: 1 104 | until [ 105 | c: extensions/i 106 | either c = #" " [print [newline]] [print [c]] ; find " " 107 | i: i + 1 108 | i = length 109 | ] 110 | ] 111 | ] 112 | 113 | valid_version: func [ return: [logic! ]/local major minor &major &minor revision &revision] [ 114 | major: 0 &major: :major 115 | minor: 0 &minor: :minor 116 | revision: 0 &revision: :revision 117 | glfwGetVersion &major &minor &revision 118 | print ["GLFW header version: " GLFW_VERSION_MAJOR "." GLFW_VERSION_MINOR "." GLFW_VERSION_REVISION newline] 119 | print["GLFW library version: " major "." minor "." revision newline ] 120 | 121 | if ( major <> GLFW_VERSION_MAJOR) [ 122 | print ["*** ERROR: GLFW major version mismatch! ***" newline] 123 | return as logic! GL_FALSE 124 | ] 125 | 126 | if (minor <> GLFW_VERSION_MINOR) OR (revision <> GLFW_VERSION_REVISION) [ 127 | print ["*** WARNING: GLFW version mismatch! " newline] 128 | ] 129 | print ["GLFW library version string: " glfwGetVersionString newline] 130 | 131 | true 132 | ] 133 | 134 | 135 | initgl: func [return: [integer!]] [ 136 | if glfwInit = 0 [glfwTerminate] 137 | window: glfwCreateWindow 200 200 "Version" NULL NULL 138 | glfwMakeContextCurrent window 139 | glfwSetErrorCallback :error_callback 140 | return 1 141 | ] 142 | 143 | 144 | ; main 145 | ;Initialize GLFW and create window 146 | initgl 147 | 148 | ; flag tests 149 | api: 0 profile: 0 strategy: 0 major: 1 minor: 0 revision: 0 150 | debug: GL_TRUE forward: GL_TRUE list: GL_TRUE 151 | ; pointers 152 | flags: 0 153 | mask: 0 154 | strategy: 0 155 | &flags: declare pointer! [integer!] 156 | &mask: declare pointer! [integer!] 157 | &strategy: declare pointer! [integer!] 158 | 159 | ; we dont use argument list on command-line (ch = getopt(argc, argv, "a:dfhlm:n:p:r:") 160 | ; please use test flags 161 | 162 | robustness: 0 163 | 164 | print [newline] 165 | if (valid_version = false) [glfwTerminate] 166 | 167 | window: glfwCreateWindow 200 200 "Version" NULL NULL 168 | glfwMakeContextCurrent window 169 | 170 | 171 | 172 | 173 | 174 | if (major <> 1) OR (minor <> 0) 175 | [ 176 | glfwWindowHint GLFW_CONTEXT_VERSION_MAJOR major 177 | glfwWindowHint GLFW_CONTEXT_VERSION_MINOR minor 178 | ] 179 | 180 | ; test: api = GLFW_OPENGL_API or GLFW_OPENGL_ES_API 181 | if (api <> 0) [glfwWindowHint GLFW_CLIENT_API api] 182 | 183 | ; test: debug true or false 184 | if (debug = GL_TRUE) [glfwWindowHint GLFW_OPENGL_DEBUG_CONTEXT GL_TRUE] 185 | 186 | ; test: debug true or false 187 | if (forward = GL_TRUE) [glfwWindowHint GLFW_OPENGL_FORWARD_COMPAT GL_TRUE] 188 | 189 | ; test: 0 or !0 190 | if (profile <> 0) [glfwWindowHint GLFW_OPENGL_PROFILE profile] 191 | 192 | ; test: 0 or !0 193 | if (strategy <> 0) [glfwWindowHint GLFW_CONTEXT_ROBUSTNESS strategy] 194 | 195 | glfwWindowHint GLFW_VISIBLE GL_FALSE 196 | 197 | api: glfwGetWindowAttrib window GLFW_CLIENT_API 198 | major: glfwGetWindowAttrib window GLFW_CONTEXT_VERSION_MAJOR 199 | minor: glfwGetWindowAttrib window GLFW_CONTEXT_VERSION_MINOR 200 | revision: glfwGetWindowAttrib window GLFW_CONTEXT_REVISION 201 | 202 | print[get_client_api_name api " context version string: " as c-string! glGetString GL_VERSION newline ] 203 | print[get_client_api_name api " context version parsed by GLFW: " major "." minor "." revision newline] 204 | 205 | if (api = GLFW_OPENGL_API) [ 206 | if (major >= 3) [ 207 | glGetIntegerv GL_CONTEXT_FLAGS &flags 208 | print[get_client_api_name api " context flags (0x%08x):" flags] 209 | if (flags AND GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) <> 0 [print [" forward-compatible"]] 210 | if (flags AND GL_CONTEXT_FLAG_DEBUG_BIT) <> 0 [print [" debug"]] 211 | if (flags AND GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB) <> 0 [print [" robustness"]] 212 | print [newline] 213 | print [ get_client_api_name api " context flags parsed by GLFW:" newline] 214 | if (glfwGetWindowAttrib window GLFW_OPENGL_FORWARD_COMPAT) <> 0 [print [" forward-compatible"]] 215 | if (glfwGetWindowAttrib window GLFW_OPENGL_DEBUG_CONTEXT) <> 0 [print [" debug"]] 216 | if (glfwGetWindowAttrib window GLFW_CONTEXT_ROBUSTNESS) <> GLFW_NO_ROBUSTNESS [print [" robustness"]] 217 | print [newline] 218 | ] 219 | if (major > 3) OR ((major = 3) AND (minor >= 2)) [ 220 | profile: glfwGetWindowAttrib window GLFW_OPENGL_PROFILE 221 | glGetIntegerv GL_CONTEXT_PROFILE_MASK &mask 222 | print [get_client_api_name api " profile mask (0x%08x): " mask " " get_profile_name_gl mask newline] 223 | print [get_client_api_name api " profile mask parsed by GLFW: " get_profile_name_glfw profile newline] 224 | ] 225 | if (glfwExtensionSupported "GL_ARB_robustness") <> 0 [ 226 | glGetIntegerv GL_RESET_NOTIFICATION_STRATEGY_ARB &strategy 227 | print[get_client_api_name api " robustness strategy (0x%08x): " strategy get_strategy_name_gl strategy newline] 228 | robustness: glfwGetWindowAttrib window GLFW_CONTEXT_ROBUSTNESS 229 | print [get_client_api_name api " robustness strategy parsed by GLFW: " get_strategy_name_glfw robustness newline] 230 | ] 231 | ] 232 | 233 | print [get_client_api_name api " context renderer string: " as c-string! glGetString GL_RENDERER newline] 234 | print [get_client_api_name api " context vendor string: " as c-string! glGetString GL_VENDOR newline] 235 | 236 | glfwTerminate 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | -------------------------------------------------------------------------------- /Samples/redS/modes.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: modes" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;======================================================================== 9 | ; 10 | ; This test enumerates or verifies video modes 11 | ; original program Copyright (c) Camilla Berglund 12 | ;======================================================================== 13 | 14 | 15 | #include %../../lib/glfw3.reds 16 | 17 | 18 | listModes: function [monitor [GLFWmonitor] 19 | /local c xpos ypos width height depth count modes pmodes nmodes p currentMode 20 | dpi gamma] [ 21 | xpos: declare pointer! [integer!] 22 | ypos: declare pointer! [integer!] 23 | width: declare pointer! [integer!] 24 | height: declare pointer! [integer!] 25 | count: declare pointer! [integer!] 26 | c: 1 27 | depth: 0 28 | p: glfwGetPrimaryMonitor 29 | 30 | 31 | print ["Name: " glfwGetMonitorName monitor] 32 | either (as c-string! p/value) = (glfwGetMonitorName monitor) [print " (Primary)"] [print " (Secondary)"] 33 | print [newline] 34 | glfwGetMonitorPos monitor xpos ypos 35 | glfwGetMonitorPhysicalSize monitor width height 36 | currentMode: glfwGetVideoMode monitor 37 | print ["Virtual position: " xpos/value " " ypos/value newline] 38 | dpi: currentMode/width / (width/value * 10 / 254 ) ; 2.54 cm for an inch 39 | print ["Physical size: "width/value " x " height/value " mm (" dpi " dpi)" newline] 40 | modes: glfwGetVideoModes monitor count ; modes are in the array of count size 41 | pmodes: as [pointer![integer!]] modes ; make a pointer to the array 42 | nmodes: count/value ; number of modes 43 | print [count/value " possible modes" newline] 44 | until [ 45 | ; get the values 46 | depth: pmodes/3 * 3 47 | print [ c " : " pmodes/1 " x " pmodes/2 " x " depth " (" pmodes/3 " " pmodes/4 " " pmodes/5 ") " pmodes/6 " Hz"newline] 48 | ; increase pointer address to the element in the array 49 | pmodes: pmodes + 6 ; 6 integer values 50 | c: c + 1 51 | c > nmodes 52 | ] 53 | print ["First Mode : " modes/width " " modes/height " " modes/redBits " " modes/greenBits " " modes/blueBits " " modes/refreshRate " Hz"newline] 54 | currentMode: glfwGetVideoMode monitor 55 | print ["Current Mode: " currentMode/width " " currentMode/height " " currentMode/redBits " " currentMode/greenBits " " currentMode/blueBits " " currentMode/refreshRate newline] 56 | gamma: glfwGetGammaRamp monitor 57 | print ["Current Gamma: " gamma/red/value " " gamma/green/value " " gamma/blue/value " "gamma/size newline] 58 | print [newline] 59 | ] 60 | 61 | 62 | ; main program 63 | 64 | 65 | print newline 66 | 67 | Print ["Red is talking to GLFW and OpenGL" newline] 68 | 69 | t: glfwInit 70 | if t = 1 [print "GLFW Library successfully initialized" newline] 71 | print newline 72 | print ["Time elapsed since GLFW Library initialization : " glfwGetTime newline] 73 | print ["Version: " glfwGetVersionString newline] 74 | nbMon: declare pointer! [integer!] 75 | cmonitors: glfwGetMonitors nbMon 76 | ; get the number of connected monitors (here 2) and the array return by glfwGetMonitors 77 | 78 | print ["Number of connected monitors: " nbMon/value newline] 79 | 80 | print [cmonitors " " cmonitors + 4 newline] 81 | 82 | 83 | 84 | print newline 85 | i: 1 86 | m: declare pointer![integer!] 87 | until [ 88 | m: as [pointer![integer!]] cmonitors/i 89 | 90 | listModes m 91 | i: i + 1 92 | i > nbMon/value 93 | ] 94 | 95 | glfwWaitEvents 96 | print ["Time elapsed since GLFW Library initialization : " glfwGetTime newline] 97 | glfwTerminate 98 | 99 | 100 | -------------------------------------------------------------------------------- /Samples/redS/peter.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: peter" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;======================================================================== 9 | ; 10 | ; This test came about as the result of bugs #1262764, #1726540 and 11 | ; #1726592, all reported by the user peterpp, hence the name 12 | ; 13 | ; The utility of this test outside of these bugs is uncertain 14 | ; original program Copyright (c) Camilla Berglund 15 | ;======================================================================== 16 | 17 | #include %../../lib/glfw3.reds 18 | 19 | rreopen: GL_FALSE 20 | cursor_x: 0.0 21 | cursor_y: 0.0 22 | &cursor_x: declare pointer! [float!] &cursor_x/value: cursor_x 23 | &cursor_y: declare pointer! [float!] &cursor_y/value: cursor_y 24 | 25 | 26 | toggle_cursor: func [window [GLFWwindow]][ 27 | either (glfwGetInputMode window GLFW_CURSOR) = GLFW_CURSOR_DISABLED [ 28 | print["Released cursor" newline] 29 | glfwSetInputMode window GLFW_CURSOR GLFW_CURSOR_NORMAL] 30 | [print["Captured cursor" newline] 31 | glfwSetInputMode window GLFW_CURSOR GLFW_CURSOR_DISABLED 32 | ] 33 | ] 34 | 35 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 36 | print ["Error: " error " " description newline] 37 | throw error 38 | ] 39 | 40 | cursor_position_callback: func [[calling] window [GLFWwindow] x [float!] y [float!]] [ 41 | print ["Cursor moved to: " x " " y " " x - cursor_x " " y - cursor_y newline] 42 | cursor_x: x 43 | cursor_y: y 44 | ] 45 | 46 | key_callback: func [ 47 | [calling] 48 | window [GLFWwindow] 49 | key [integer!] 50 | scancode [integer!] 51 | action [integer!] 52 | mods [integer!]] [ 53 | switch key [ 54 | GLFW_KEY_SPACE [if (action = GLFW_PRESS) [toggle_cursor window]] 55 | GLFW_KEY_R [if (action = GLFW_PRESS) [rreopen: GL_TRUE]] 56 | GLFW_KEY_ESCAPE [if (action = GLFW_PRESS) [glfwSetWindowShouldClose window GL_TRUE ]] 57 | ] 58 | ] 59 | 60 | framebuffer_size_callback: func [ [calling] window [GLFWwindow] width [integer!] height [integer!]][ 61 | glViewport 0 0 width height 62 | ] 63 | 64 | 65 | open_window: func [return: [GLFWwindow]][ 66 | window: glfwCreateWindow 640 480 "Peter Detector" NULL NULL 67 | if (window = NULL) [return NULL] 68 | 69 | glfwMakeContextCurrent window 70 | glfwSwapInterval 1 71 | 72 | glfwGetCursorPos window &cursor_x &cursor_y 73 | print ["Cursor position: " cursor_x " " cursor_y newline] 74 | 75 | glfwSetFramebufferSizeCallback window :framebuffer_size_callback 76 | glfwSetCursorPosCallback window :cursor_position_callback 77 | glfwSetKeyCallback window :key_callback 78 | 79 | window 80 | ] 81 | 82 | if glfwInit = 0 [glfwTerminate] ; exit 83 | glfwSetErrorCallback :error_callback 84 | window: open_window 85 | if (window = NULL) [glfwTerminate] 86 | glClearColor 0.0 0.0 0.0 0.0 87 | while [(glfwWindowShouldClose window) = GL_FALSE] [ 88 | glClear GL_COLOR_BUFFER_BIT 89 | glfwSwapBuffers window 90 | glfwWaitEvents 91 | if (rreopen = GL_TRUE) [ 92 | glfwDestroyWindow window 93 | window: open_window 94 | if (window = NULL) [glfwTerminate] 95 | rreopen: GL_FALSE 96 | ] 97 | ] 98 | 99 | 100 | glfwTerminate 101 | 102 | -------------------------------------------------------------------------------- /Samples/redS/quad.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: Quad" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ; just as simple demo to draw forms 9 | 10 | 11 | #include %../../lib/glfw3.reds 12 | 13 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 14 | print [ description " " stderr] 15 | ] 16 | key_callback: func [ 17 | [calling] 18 | window [GLFWwindow] 19 | key [integer!] 20 | scancode [integer!] 21 | action [integer!] 22 | mods [integer!]] [ 23 | if (key = GLFW_KEY_ESCAPE) and (action = GLFW_PRESS) [glfwSetWindowShouldClose window GL_TRUE ] 24 | ] 25 | 26 | 27 | glfwInit 28 | 29 | window: glfwCreateWindow 800 600 "A Simple OpenGL Quad with Red and GLFW [ESC to Quit]" NULL NULL 30 | glfwMakeContextCurrent window 31 | glfwSetErrorCallback :error_callback 32 | glfwSetKeyCallback window :key_callback 33 | 34 | while [(glfwWindowShouldClose window) = GL_FALSE] [ 35 | glClearColor 0.0 0.0 0.0 0.0 36 | glClear GL_COLOR_BUFFER_BIT 37 | glBegin GL_QUADS 38 | glColor3ub 0 0 255 39 | glVertex2d -0.75 -0.75 40 | glVertex2d -0.75 0.75 41 | glColor3ub 255 0 0 42 | glVertex2d 0.75 0.75 43 | glVertex2d 0.75 -0.75 44 | glEnd 45 | glFlush 46 | glfwSwapBuffers window 47 | glfwPollEvents 48 | ] 49 | 50 | glfwDestroyWindow window 51 | glfwTerminate -------------------------------------------------------------------------------- /Samples/redS/sharing.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: Splitview" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https:;github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;======================================================================== 9 | ; This program is used to test sharing of objects between contextsed 10 | ; Orginal program by Camilla Berglund 11 | ;======================================================================== 12 | 13 | 14 | #include %../../lib/glfw3.reds 15 | #include %../../lib/Tools/C-library.reds 16 | 17 | #define WIDTH 400 18 | #define HEIGHT 400 19 | #define OFFSET 50 20 | 21 | x: 0 y: 0 w: WIDTH 22 | &x: :x 23 | &y: :y 24 | &width: :w 25 | 26 | 27 | ; An array to 2 windows 28 | windows: declare struct! [ 29 | w1 [pointer! [integer!]] 30 | w2 [pointer! [integer!]] 31 | ] 32 | 33 | ; reserved memory 34 | windows/w1: null 35 | windows/w2: null 36 | 37 | window: declare pointer! [integer!] ; a pointer to an element of the array 38 | 39 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 40 | print ["Error: " error " " description newline] 41 | throw error 42 | ] 43 | 44 | key_callback: func [ 45 | [calling] 46 | window [GLFWwindow] 47 | key [integer!] 48 | scancode [integer!] 49 | action [integer!] 50 | mods [integer!]] [ 51 | if (key = GLFW_KEY_ESCAPE) and (action = GLFW_PRESS) [glfwSetWindowShouldClose window GL_TRUE ] 52 | ] 53 | 54 | open_window: func [title [c-string!] share [GLFWwindow] posx [integer!] posY [integer!] 55 | return: [int-ptr!] /local w p][ 56 | p: declare pointer! [integer!] 57 | glfwWindowHint GLFW_VISIBLE GL_FALSE 58 | window: glfwCreateWindow WIDTH HEIGHT title NULL share 59 | w: as integer! window 60 | if w = 0 [p: null return p] 61 | glfwMakeContextCurrent window 62 | glfwSwapInterval 1 63 | glfwSetWindowPos window posX posY 64 | glfwShowWindow window 65 | glfwSetKeyCallback window :key_callback 66 | return window 67 | ] 68 | 69 | 70 | create_texture: func [return: [integer!] /local size pixels ct x y texture &texture ][ 71 | ;char pixels[256 * 256] 72 | pixels: allocate (256 * 256) 73 | texture: 0 74 | &texture: :texture 75 | glGenTextures 1 &texture 76 | glBindTexture GL_TEXTURE_2D texture 77 | 78 | y: 0 79 | until [ 80 | x: 0 81 | until [ 82 | ct: y * 256 + x 83 | pixels/ct: as byte! (random % 256) 84 | x: x + 1 85 | x >= 255 86 | ] 87 | y: y + 1 88 | y >= 255 89 | ] 90 | 91 | glTexImage2D GL_TEXTURE_2D 0 GL_LUMINANCE 256 256 0 GL_LUMINANCE GL_UNSIGNED_BYTE pixels 92 | glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER GL_LINEAR 93 | glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER GL_LINEAR 94 | return texture 95 | ] 96 | 97 | 98 | 99 | draw_quad: func [texture [integer!] /local w h &w &h] [ 100 | w: 0 h: 0 101 | &w: :w 102 | &h: :h 103 | glfwGetFramebufferSize glfwGetCurrentContext &w &h 104 | glViewport 0 0 w h 105 | glMatrixMode GL_PROJECTION 106 | glLoadIdentity 107 | gluOrtho2D 0.0 1.0 0.0 1.0 108 | glEnable GL_TEXTURE_2D 109 | glBindTexture GL_TEXTURE_2D texture 110 | glTexEnvi GL_TEXTURE_ENV GL_TEXTURE_ENV_MODE GL_MODULATE 111 | glBegin GL_QUADS 112 | glTexCoord2f 0.0 0.0 113 | glVertex2f 0.0 0.0 114 | 115 | glTexCoord2f 1.0 0.0 116 | glVertex2f 1.0 0.0 117 | 118 | glTexCoord2f 1.0 1.0 119 | glVertex2f 1.0 1.0 120 | 121 | glTexCoord2f 0.0 1.0 122 | glVertex2f 0.0 1.0 123 | glEnd 124 | ] 125 | 126 | 127 | ;main 128 | 129 | 130 | if glfwInit = 0 [glfwTerminate] 131 | 132 | windows/w1: open_window "First" NULL OFFSET OFFSET 133 | 134 | ; This is the one and only time we create a texture 135 | ; It is created inside the first context, created above 136 | ; It will then be shared with the second context, created below 137 | 138 | texture: create_texture 139 | 140 | 141 | glfwGetWindowPos windows/w1 &x &y 142 | glfwGetWindowSize windows/w1 &width NULL 143 | 144 | windows/w2: open_window "Second" windows/w1 x + w + OFFSET y 145 | 146 | glfwMakeContextCurrent windows/w1 147 | glColor3f 0.6 0.0 0.6 148 | glfwMakeContextCurrent windows/w2 149 | glColor3f 0.6 0.6 0.0 150 | 151 | glfwMakeContextCurrent windows/w1 152 | while [((glfwWindowShouldClose windows/w1) = GL_FALSE) AND ((glfwWindowShouldClose windows/w2) = GL_FALSE)] [ 153 | glfwMakeContextCurrent windows/w1 154 | draw_quad texture 155 | glfwMakeContextCurrent windows/w2 156 | draw_quad texture 157 | glfwSwapBuffers windows/w1 158 | glfwSwapBuffers windows/w2 159 | glfwWaitEvents 160 | ] 161 | 162 | glfwTerminate 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /Samples/redS/simple.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: Animated triangle" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;Simple GLFW example 9 | ; Origimal program Copyright (c) Camilla Berglund 10 | 11 | #include %../../lib/glfw3.reds 12 | 13 | ratio: 0.0 14 | angle: 0.0 15 | width: 0 16 | height: 0 17 | fwidth: 0.0 18 | fheight: 0.0 19 | 20 | &width: :width; pointer! 21 | &height: :height ;pointer! 22 | 23 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 24 | print [ description " " stderr] 25 | ] 26 | 27 | key_callback: func [ 28 | [calling] 29 | window [GLFWwindow] 30 | key [integer!] 31 | scancode [integer!] 32 | action [integer!] 33 | mods [integer!]] [ 34 | if (key = GLFW_KEY_ESCAPE) and (action = GLFW_PRESS) [glfwSetWindowShouldClose window GL_TRUE ] 35 | ] 36 | 37 | 38 | 39 | if glfwInit = 0 [glfwTerminate] ; exit 40 | 41 | window: glfwCreateWindow 640 480 "Animated OpenGL Triangle with Red and GLFW [ESC to Quit]" NULL NULL 42 | if window = null [glfwTerminate] 43 | glfwMakeContextCurrent window 44 | glfwSetErrorCallback :error_callback 45 | glfwSetKeyCallback window :key_callback 46 | 47 | while [(glfwWindowShouldClose window) = GL_FALSE] [ 48 | glfwGetFramebufferSize window &width &height 49 | 50 | fwidth: as float! &width/value 51 | fheight: as float! &height/value 52 | ratio: fwidth / fheight 53 | 54 | glViewport 0 0 width height 55 | glClearColor 0.0 0.0 0.0 0.0 56 | glClear GL_COLOR_BUFFER_BIT 57 | glMatrixMode GL_PROJECTION 58 | glLoadIdentity 59 | glOrtho 0.0 - ratio ratio -1.0 1.0 1.0 -1.0 60 | glMatrixMode GL_MODELVIEW 61 | glLoadIdentity 62 | 63 | angle: glfwGetTime * 36.00 64 | 65 | glRotatef as float32! angle 0.0 0.0 1.0 66 | 67 | glBegin GL_TRIANGLES 68 | glColor3f 1.0 0.0 0.0 glVertex3f -0.6 -0.4 0.0 ;first point of triangle is red 69 | glColor3f 0.0 1.0 0.0 glVertex3f 0.6 -0.4 0.0 ;second point of triangle is green 70 | glColor3f 0.0 0.0 1.0 glVertex3f 0.0 0.6 0.0 ;third point of triangle is blue 71 | glEnd 72 | 73 | 74 | glfwSwapBuffers window 75 | glfwPollEvents 76 | 77 | ] 78 | glfwDestroyWindow window 79 | glfwTerminate 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /Samples/redS/splitview.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: Splitview" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | 9 | ;======================================================================== 10 | ;This is an example program for the GLFW library 11 | ; see splitview.c for orginal program 12 | ;======================================================================== 13 | 14 | 15 | #include %../../lib/glfw3.reds 16 | #include %../../lib/Tools/math.reds 17 | 18 | #define M_PI 3.14159265358979323846 19 | ;======================================================================== 20 | ; Global variables 21 | ;======================================================================== 22 | 23 | ;Mouse position 24 | xpos: 0.0 ypos: 0.0 25 | 26 | ; Window size 27 | width: 0 28 | height: 0 29 | 30 | ; Active view: 0: none 1: upper left 2: upper right 3: lower left 4: lower right 31 | active_view: 0 32 | 33 | 34 | ; Rotation around each axis 35 | rot_x: 0 rot_y: 0 rot_z: 0 36 | 37 | ; Do redraw? 38 | do_redraw: 1 39 | 40 | &width: :width; pointer! 41 | &height: :height ;pointer! 42 | 43 | 44 | xt: 0.0 45 | yt: 0.0 46 | zt: 0.0 47 | xp: 0 48 | yp: 0 49 | a1: 0.0 50 | a2: 0.0 51 | a3: 0.0 52 | a4: 0.0 53 | 54 | 55 | model_shininess: as float32! 20.0 56 | ; specific to Red use structure to create array 57 | model_diffuse: declare struct! [ 58 | f1 [float32!] 59 | f2 [float32!] 60 | f3 [float32!] 61 | f4 [float32!] 62 | ] 63 | 64 | model_specular: declare struct! [ 65 | f1 [float32!] 66 | f2 [float32!] 67 | f3 [float32!] 68 | f4 [float32!] 69 | ] 70 | 71 | 72 | light_position: declare struct! [ 73 | f1 [float32!] 74 | f2 [float32!] 75 | f3 [float32!] 76 | f4 [float32!] 77 | ] 78 | 79 | light_diffuse: declare struct! [ 80 | f1 [float32!] 81 | f2 [float32!] 82 | f3 [float32!] 83 | f4 [float32!] 84 | ] 85 | 86 | light_specular: declare struct! [ 87 | f1 [float32!] 88 | f2 [float32!] 89 | f3 [float32!] 90 | f4 [float32!] 91 | ] 92 | 93 | light_ambient: declare struct! [ 94 | f1 [float32!] 95 | f2 [float32!] 96 | f3 [float32!] 97 | f4 [float32!] 98 | ] 99 | 100 | ;======================================================================== 101 | ; Draw a solid torus (use a display list for the model) 102 | ;======================================================================== 103 | #define TORUS_MAJOR 1.5 ; R 104 | #define TORUS_MINOR 0.5 ; r 105 | #define TORUS_MAJOR_RES 32.0 106 | #define TORUS_MINOR_RES 32.0 107 | #define fTORUS_MAJOR_RES 32.0 108 | #define fTORUS_MINOR_RES 32.0 109 | 110 | 111 | drawTorus: func [ /local torus_list i j k s t x y z nx ny nz scale twopi 112 | left right ] [ 113 | s: 0.0 t: 0.0 x: 0.0 y: 0.0 114 | nx: 0.0 ny: 0.0 nz: 0.0 115 | torus_list: 0 116 | either as logic! not torus_list [ 117 | ;Start recording displaylist 118 | torus_list: glGenLists 1 119 | glNewList torus_list GL_COMPILE_AND_EXECUTE 120 | ;// Draw torus 121 | twopi: 2.0 * M_PI 122 | i: 0 123 | while [(as float! i) <= TORUS_MINOR_RES] [ 124 | j: 0 125 | glBegin GL_QUAD_STRIP 126 | while [(as float! j) <= TORUS_MAJOR_RES] [ 127 | k: 1 128 | until [ 129 | left: as float! (i + k) 130 | right: TORUS_MINOR_RES 131 | s: fmod left right + 0.5 132 | left: as float! j 133 | right: TORUS_MAJOR_RES 134 | t: fmod left right 135 | ;Calculate point on surface 136 | 137 | a1: cosine-radians s * twopi / fTORUS_MINOR_RES 138 | a2: cosine-radians t * twopi / fTORUS_MAJOR_RES 139 | a3: sine-radians s * twopi / fTORUS_MINOR_RES 140 | a4: sine-radians t * twopi / fTORUS_MAJOR_RES 141 | 142 | ;The general equations for such a torus are 143 | ;f(u, v) = [ (R + r*cos(v))*cos(u), (R + r*cos(v))*sin(u),r*sin(v) ] 144 | 145 | x: (TORUS_MAJOR + (TORUS_MINOR * a1)) * a2 146 | y: TORUS_MINOR * a3 147 | z: (TORUS_MAJOR + (TORUS_MINOR * a1)) * a4 148 | 149 | ;Calculate surface normal 150 | nx: x - TORUS_MAJOR * a2 151 | ny: y 152 | nz: z - TORUS_MAJOR * a4 153 | scale: 1.0 / square-root ((nx * nx) + (ny * ny) + (nz * nz)) 154 | nx: nx * scale 155 | ny: ny * scale 156 | nz: nz * scale 157 | glNormal3d nx ny nz 158 | glVertex3d x y z 159 | k: k - 1 160 | k < 0 161 | ] 162 | j: j + 1 163 | ] 164 | glEnd 165 | i: i + 1 166 | ] 167 | ;Stop recording displaylist 168 | glEndList 169 | ] [ 170 | ;Playback displaylist 171 | glCallList torus_list 172 | ] 173 | ] 174 | 175 | drawScene: func [] [ 176 | model_diffuse/f1: as float32! 1.0 177 | model_diffuse/f2: as float32! 0.8 178 | model_diffuse/f3: as float32! 0.8 179 | model_diffuse/f4: as float32! 1.0 180 | 181 | 182 | 183 | model_specular/f1: as float32! 0.6 184 | model_specular/f2: as float32! 0.6 185 | model_specular/f3: as float32! 0.6 186 | model_specular/f4: as float32! 1.0 187 | 188 | 189 | 190 | glPushMatrix 191 | 192 | ;Rotate the object 193 | glRotated 0.5 * as float! rot_x 1.0 0.0 0.0 194 | glRotated 0.5 * as float! rot_y 0.0 1.0 0.0 195 | glRotated 0.5 * as float! rot_z 0.0 0.0 1.0 196 | 197 | ;Set model color (used for orthogonal views, lighting disabled) 198 | glColor4fv as float32-ptr! model_diffuse 199 | ;Set model material (used for perspective view, lighting enabled) 200 | glMaterialfv GL_FRONT GL_DIFFUSE as float32-ptr! model_diffuse 201 | glMaterialfv GL_FRONT GL_SPECULAR as float32-ptr! model_specular 202 | glMaterialf GL_FRONT GL_SHININESS model_shininess 203 | 204 | ;Draw torus 205 | drawTorus 206 | 207 | glPopMatrix 208 | 209 | ] 210 | 211 | drawGrid: func [scale [float!] steps [integer!] /local f s i x y -y -x][ 212 | glPushMatrix 213 | ;Set background to some dark bluish grey 214 | glClearColor 0.05 0.05 0.2 0.0 215 | glClear GL_COLOR_BUFFER_BIT 216 | ;Setup modelview matrix (flat XY view) 217 | glLoadIdentity 218 | gluLookAt 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 219 | 220 | ;We don't want to update the Z-buffer 221 | glDepthMask as logic! GL_FALSE 222 | ;Set grid color 223 | glColor3f 0.0 0.5 0.5 224 | 225 | 226 | f: scale * 0.5 227 | s: as float! (steps - 1) 228 | 229 | glBegin GL_LINES 230 | ;Horizontal lines 231 | 232 | x: as float32! f * s 233 | y: as float32! 0.0 - (f * s) 234 | -x: as float32! (0.0 - x) 235 | i: 0 236 | until [ 237 | glVertex3f -x y 0.0 238 | glVertex3f x y 0.0 239 | y: y + scale 240 | i: i + 1 241 | i = steps 242 | ] 243 | 244 | ; vertical lines 245 | x: as float32! 0.0 - (f * s) 246 | y: as float32! f * s 247 | -y: as float32! (0.0 - y) 248 | i: 0 249 | until [ 250 | 251 | glVertex3f x -y 0.0 252 | glVertex3f x y 0.0 253 | x: x + scale 254 | i: i + 1 255 | i = steps 256 | ] 257 | 258 | glEnd 259 | ;enable Z-buffer writing again 260 | glDepthMask as logic! GL_TRUE 261 | glPopMatrix 262 | ] 263 | 264 | ;Draw all views 265 | drawAllViews: func [/local aspect] [ 266 | 267 | light_position/f1: as float32! 0.0 268 | light_position/f2: as float32! 8.0 269 | light_position/f3: as float32! 8.0 270 | light_position/f4: as float32! 1.0 271 | 272 | light_diffuse/f1: as float32! 1.0 273 | light_diffuse/f2: as float32! 1.0 274 | light_diffuse/f3: as float32! 1.0 275 | light_diffuse/f4: as float32! 1.0 276 | 277 | 278 | 279 | light_specular/f1: as float32! 1.0 280 | light_specular/f2: as float32! 1.0 281 | light_specular/f3: as float32! 1.0 282 | light_specular/f4: as float32! 1.0 283 | 284 | 285 | light_ambient/f1: as float32! 0.2 286 | light_ambient/f2: as float32! 0.2 287 | light_ambient/f3: as float32! 0.3 288 | light_ambient/f4: as float32! 1.0 289 | 290 | ;Calculate aspect of window 291 | aspect: 1.0 292 | either (height > 0) [aspect: as float! width / height] [aspect: 1.0] 293 | 294 | ;Clear screen 295 | glClearColor 0.0 0.0 0.0 0.0 296 | glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT 297 | 298 | ;Enable scissor test 299 | glEnable GL_SCISSOR_TEST 300 | ;Enable depth test 301 | glEnable GL_DEPTH_TEST 302 | glDepthFunc GL_LEQUAL 303 | 304 | ;** ORTHOGONAL VIEWS ** 305 | ;For orthogonal views, use wireframe rendering 306 | glPolygonMode GL_FRONT_AND_BACK GL_LINE 307 | 308 | ;Enable line anti-aliasing 309 | glEnable GL_LINE_SMOOTH 310 | glEnable GL_BLEND 311 | glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA 312 | 313 | 314 | ;Setup orthogonal projection matrix 315 | glMatrixMode GL_PROJECTION 316 | glLoadIdentity 317 | glOrtho -3.0 * aspect 3.0 * aspect -3.0 3.0 1.0 50.0 318 | 319 | ;Upper left view (1: TOP VIEW) 320 | glViewport 0 height / 2 width / 2 height / 2 321 | glScissor 0 height / 2 width / 2 height / 2 322 | glMatrixMode GL_MODELVIEW 323 | glLoadIdentity 324 | gluLookAt 0.0 10.0 1E-3 0.0 0.0 0.0 0.0 1.0 0.0 325 | drawGrid 0.5 12 326 | drawScene 327 | 328 | ;Lower left view (3: FRONT VIEW) 329 | glViewport 0 0 width / 2 height / 2 330 | glScissor 0 0 width / 2 height / 2 331 | glMatrixMode GL_MODELVIEW 332 | glLoadIdentity 333 | gluLookAt 0.0 0.0 10.0 0.0 0.0 0.0 0.0 1.0 0.0 334 | drawGrid 0.5 12 335 | drawScene 336 | 337 | ;Lower right view (4: SIDE VIEW) 338 | glViewport width / 2 0 width / 2 height / 2 339 | glScissor width / 2 0 width / 2 height / 2 340 | glMatrixMode GL_MODELVIEW 341 | glLoadIdentity 342 | gluLookAt 10.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 343 | drawGrid 0.5 12 344 | drawScene 345 | 346 | ;Disable line anti-aliasing 347 | glDisable GL_LINE_SMOOTH 348 | glDisable GL_BLEND 349 | 350 | ;PERSPECTIVE VIEW 2** 351 | ;For perspective view, use solid rendering 352 | glPolygonMode GL_FRONT_AND_BACK GL_FILL 353 | 354 | ;Enable face culling (faster rendering) 355 | glEnable GL_CULL_FACE 356 | glCullFace GL_BACK 357 | glFrontFace GL_CW 358 | 359 | ;Setup perspective projection matrix 360 | glMatrixMode GL_PROJECTION 361 | glLoadIdentity 362 | gluPerspective 65.0 aspect 1.0 50.0 363 | 364 | ;Upper right view (PERSPECTIVE VIEW) 365 | glViewport width / 2 height / 2 width / 2 height / 2 366 | glScissor width / 2 height / 2 width / 2 height / 2 367 | glMatrixMode GL_MODELVIEW 368 | glLoadIdentity 369 | gluLookAt 3.0 1.5 3.0 0.0 0.0 0.0 0.0 1.0 0.0 370 | 371 | ;Configure and enable light source 1 372 | glLightfv GL_LIGHT1 GL_POSITION as float32-ptr! light_position 373 | glLightfv GL_LIGHT1 GL_AMBIENT as float32-ptr! light_ambient 374 | glLightfv GL_LIGHT1 GL_DIFFUSE as float32-ptr! light_diffuse 375 | glLightfv GL_LIGHT1 GL_SPECULAR as float32-ptr! light_specular 376 | glEnable GL_LIGHT1 377 | glEnable GL_LIGHTING 378 | 379 | ;Draw scene 380 | drawScene 381 | 382 | ;Disable lighting 383 | glDisable(GL_LIGHTING); 384 | 385 | ;Disable face culling 386 | glDisable(GL_CULL_FACE); 387 | 388 | ;Disable depth test 389 | glDisable(GL_DEPTH_TEST); 390 | 391 | ;Disable scissor test 392 | glDisable(GL_SCISSOR_TEST) 393 | 394 | 395 | ;Draw a border around the active view 396 | if (active_view > 0) and (active_view <> 2) [ 397 | glViewport 0 0 width height 398 | glMatrixMode GL_PROJECTION 399 | glLoadIdentity 400 | glOrtho 0.0 2.0 0.0 2.0 0.0 1.0 401 | glMatrixMode GL_MODELVIEW 402 | glLoadIdentity 403 | switch active_view[ 404 | 1 [xt: 0.0 yt: 1.0] 405 | 3 [xt: 0.0 yt: 0.0] 406 | 4 [xt: 1.0 yt: 0.0] 407 | ] 408 | zt: 0.0 409 | glTranslatef as float32! xt as float32! yt as float32! zt 410 | glColor3f 1.0 1.0 0.6 411 | glBegin GL_LINE_STRIP 412 | glVertex2i 0 0 413 | glVertex2i 1 0 414 | glVertex2i 1 1 415 | glVertex2i 0 1 416 | glVertex2i 0 0 417 | glEnd 418 | ] 419 | 420 | 421 | ] 422 | 423 | 424 | ;======================================================================== 425 | ;Framebuffer size callback function 426 | 427 | 428 | framebufferSizeFun: func [ 429 | [calling] 430 | window [GLFWwindow] w [integer!] h [integer!]][ 431 | width: w 432 | either h > 0 [height: h][height: 1] 433 | do_redraw: 1 434 | ] 435 | 436 | ;Window refresh callback function 437 | windowRefreshFun: func [ 438 | [calling] 439 | window [GLFWwindow]] [ 440 | do_redraw: 1 441 | ] 442 | 443 | ;Mouse position callback function 444 | cursorPosFun: func [ 445 | [calling] 446 | window [GLFWwindow] x [float!] y [float!]] [ 447 | ;Depending on which view was selected, rotate around different axes 448 | xp: as integer! (x - xpos) 449 | yp: as integer! (y - ypos) 450 | switch active_view [ 451 | 1 [rot_x: rot_x + yp rot_z: rot_z + xp] 452 | 3 [rot_x: rot_x + yp rot_y: rot_z + xp] 453 | 4 [rot_y: rot_y + xp rot_z: rot_z + yp] 454 | default [] 455 | ] 456 | do_redraw: 1 457 | ;Remember cursor position 458 | xpos: x 459 | ypos: y 460 | ] 461 | ;Mouse button callback function 462 | mouseButtonFun: func [ 463 | [calling] 464 | window [GLFWwindow] button [integer!] action [integer!] mods [integer!] /local x y] [ 465 | either button = (GLFW_MOUSE_BUTTON_LEFT) AND (action = GLFW_PRESS) [ 466 | active_view: 1 467 | x: as float! width / 2 468 | y: as float! height / 2 469 | if xpos >= x [active_view: active_view + 1] 470 | if ypos >= y [active_view: active_view + 2] 471 | 472 | ] 473 | [if button = (GLFW_MOUSE_BUTTON_LEFT) [active_view: 0]] 474 | do_redraw: 1 475 | ] 476 | 477 | ; key callback function 478 | 479 | key_callback: func [ 480 | [calling] 481 | window [GLFWwindow] 482 | key [integer!] 483 | scancode [integer!] 484 | action [integer!] 485 | mods [integer!]] [ 486 | if (key = GLFW_KEY_ESCAPE) and (action = GLFW_PRESS) [glfwSetWindowShouldClose window GL_TRUE ] 487 | ] 488 | 489 | ; main 490 | if glfwInit = 0 [glfwTerminate] 491 | window: glfwCreateWindow 500 500 "Split view demo" NULL NULL 492 | 493 | ;Set callback functions 494 | glfwSetFramebufferSizeCallback window :framebufferSizeFun 495 | glfwSetWindowRefreshCallback window :windowRefreshFun 496 | glfwSetCursorPosCallback window :cursorPosFun 497 | glfwSetMouseButtonCallback window :mouseButtonFun 498 | glfwSetKeyCallback window :key_callback 499 | 500 | ;Enable vsync 501 | glfwMakeContextCurrent window 502 | glfwSwapInterval 1 503 | 504 | glfwGetFramebufferSize window &width &height 505 | framebufferSizeFun window width height 506 | 507 | ; main loop 508 | while [(glfwWindowShouldClose window) = GL_FALSE] [ 509 | ;Only redraw if we need to 510 | if do_redraw = 1 [ 511 | ;Draw all views 512 | drawAllViews 513 | ;Swap buffers 514 | glfwSwapBuffers window 515 | do_redraw = 0 516 | ] 517 | glfwWaitEvents 518 | ] 519 | ;Close OpenGL window and terminate GLFW 520 | glfwTerminate -------------------------------------------------------------------------------- /Samples/redS/tearing.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: Splitview" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https:;github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;======================================================================== 9 | ; 10 | ; This test renders a high contrast, horizontally moving bar, allowing for 11 | ; visual verification of whether the set swap interval is indeed obeyed 12 | ; Orginal program by Camilla Berglund 13 | ;======================================================================== 14 | 15 | #include %../../lib/glfw3.reds 16 | #include %../../lib/Tools/math.reds 17 | #include %../../lib/Tools/C-library.reds 18 | 19 | swap_interval: 0 20 | frame_rate: 0.0 21 | last_time: 0.0 22 | current_time: 0.0 23 | position: 0.0 24 | frame_count: 0.0 25 | 26 | 27 | 28 | update_window_title: func [window [GLFWwindow] /local title] [ 29 | title: as c-string! allocate 256 30 | format-any [title "Tearing detector (interval %i, %0.1f Hz)" swap_interval frame_rate] 31 | glfwSetWindowTitle window title 32 | ] 33 | 34 | set_swap_interval: func [window [GLFWwindow] interval [integer!]] [ 35 | swap_interval: interval 36 | glfwSwapInterval swap_interval 37 | update_window_title window 38 | ] 39 | 40 | error_callback: func [[cdecl] error [integer!] description [c-string!]] [ 41 | print ["Error: " error " " description newline] 42 | throw error ; stderr 43 | ] 44 | 45 | framebuffer_size_callback: func [ [cdecl] window [GLFWwindow] width [integer!] height [integer!]][ 46 | glViewport 0 0 width height 47 | ] 48 | 49 | key_callback: func [ 50 | [cdecl] 51 | window [GLFWwindow] 52 | key [integer!] 53 | scancode [integer!] 54 | action [integer!] 55 | mods [integer!]] [ 56 | if (key = GLFW_KEY_SPACE) and (action = GLFW_PRESS) [ 57 | set_swap_interval window 1 - swap_interval] 58 | ] 59 | 60 | ;main 61 | 62 | glfwSetErrorCallback :error_callback 63 | if glfwInit = 0 [glfwTerminate] ; exit 64 | window: glfwCreateWindow 640 480 "Version" NULL NULL 65 | glfwMakeContextCurrent window 66 | set_swap_interval window 0 67 | last_time: glfwGetTime 68 | frame_rate: 0.0 69 | glfwSetFramebufferSizeCallback window :framebuffer_size_callback 70 | glfwSetKeyCallback window :key_callback 71 | glMatrixMode GL_PROJECTION 72 | glOrtho -1.0 1.0 -1.0 1.0 1.0 -1.0 73 | glMatrixMode GL_MODELVIEW 74 | 75 | while [(glfwWindowShouldClose window) = GL_FALSE] [ 76 | glClear GL_COLOR_BUFFER_BIT 77 | position: cosine-radians (glfwGetTime * 4.0) * 0.75 78 | glRectd position - 0.25 -1.0 position + 0.25 1.0 79 | glfwSwapBuffers window 80 | glfwPollEvents 81 | frame_count: frame_count + 1.0 82 | current_time: glfwGetTime 83 | if (current_time - last_time > 1.0) 84 | [ 85 | frame_rate: frame_count / (current_time - last_time) 86 | frame_count: 0.0 87 | last_time: current_time 88 | update_window_title window 89 | ] 90 | ] 91 | glfwTerminate 92 | -------------------------------------------------------------------------------- /Samples/redS/title.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: Title" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | 9 | #include %../../lib/glfw3.reds 10 | 11 | glfwInit 12 | ;Create a windowed mode window and its OpenGL context 13 | window: glfwCreateWindow 640 480 "Français English 日本語 русский язык 官話" NULL NULL 14 | 15 | ;Make the window's context current 16 | glfwMakeContextCurrent window 17 | glBegin 0 18 | glViewport 0 0 640 480 ; cool opengl est accessible mais pas utile ici 19 | ;Loop until the user closes the window 20 | while [(glfwWindowShouldClose window) = GL_FALSE] [ 21 | ;Render here 22 | ;Swap front and back buffers ; 23 | glfwSwapBuffers window 24 | ;Poll for and process events 25 | glfwPollEvents 26 | ] 27 | 28 | glfwTerminate -------------------------------------------------------------------------------- /Samples/redS/triangle.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: Triangle" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ; just as simple demo to draw triangle 9 | #include %../../lib/glfw3.reds 10 | window: declare pointer! [integer!] 11 | 12 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 13 | print [ description " " stderr] 14 | ] 15 | 16 | initgl: func [return: [integer!]] [ 17 | if glfwInit = 0 [glfwTerminate] 18 | window: glfwCreateWindow 800 600 "A Simple OpenGL Triangle with Red/System and GLFW" NULL NULL 19 | glfwMakeContextCurrent window 20 | glfwSetErrorCallback :error_callback 21 | return 1 22 | ] 23 | 24 | closegl: func [] [ 25 | glfwDestroyWindow window 26 | glfwTerminate 27 | ] 28 | 29 | render: func [ /local rep [integer!]] [ 30 | rep: 0 31 | until [ 32 | ;glClearColor 0.0 0.0 0.0 0.0 33 | glClear GL_COLOR_BUFFER_BIT 34 | glBegin GL_TRIANGLES 35 | glColor3ub 255 0 0 glVertex2d -0.75 -0.75 36 | glColor3ub 0 255 0 glVertex2d 0.0 0.75 37 | glColor3ub 0 0 255 glVertex2d 0.75 -0.75 38 | glEnd 39 | glFlush 40 | glfwSwapBuffers window 41 | glfwPollEvents 42 | rep: glfwWindowShouldClose window 43 | rep = 1 44 | ] 45 | ] 46 | 47 | ; main program 48 | initgl 49 | render 50 | closegl 51 | 52 | 53 | -------------------------------------------------------------------------------- /Samples/redS/windows.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding: Simple multi-window test" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ;======================================================================== 9 | ; 10 | ; This test creates four windows and clears each in a different color 11 | ; Orginal program by Camilla Berglund 12 | ;======================================================================== 13 | 14 | #include %../../lib/glfw3.reds 15 | 16 | i: 1 17 | c1: 0.0 18 | c2: 0.0 19 | c3: 0.0 20 | 21 | 22 | running: GL_TRUE 23 | 24 | 25 | ; An array for 4 windows title 26 | titles: declare struct! [ 27 | t1 [c-string!] 28 | t2 [c-string!] 29 | t3 [c-string!] 30 | t4 [c-string!] 31 | ] 32 | titles/t1: "Foo" 33 | titles/t2: "Bar" 34 | titles/t3: "Baz" 35 | titles/t4: "Quux" 36 | 37 | ptitles: as int-ptr! titles ; a pointer to the array 38 | 39 | ; An array to 4 windows 40 | windows: declare struct! [ 41 | w1 [pointer! [integer!]] 42 | w2 [pointer! [integer!]] 43 | w3 [pointer! [integer!]] 44 | w4 [pointer! [integer!]] 45 | ] 46 | 47 | ; just reserved memory 48 | windows/w1: null 49 | windows/w2: null 50 | windows/w3: null 51 | windows/w4: null 52 | 53 | pwindows: as int-ptr! windows ; a pointer to the array 54 | window: declare pointer! [integer!] ; a pointer to an element of the array 55 | 56 | 57 | 58 | error_callback: func [[calling] error [integer!] description [c-string!]] [ 59 | print ["Error: " error " " description newline] 60 | throw error ; stderr 61 | ] 62 | 63 | ; main 64 | glfwSetErrorCallback :error_callback 65 | if glfwInit = 0 [glfwTerminate] ; exit 66 | 67 | until [ 68 | pwindows/i: as integer! glfwCreateWindow 200 200 as c-string! ptitles/i NULL NULL 69 | window: as int-ptr! pwindows/i 70 | glfwMakeContextCurrent window 71 | c1: as float! ((i - 1) and 1) 72 | c2: as float! ((i - 1) >> 1) 73 | either i - 1 = 0 [c3: 1.0 ] [c3: 0.0] 74 | glClearColor as float32! c1 as float32! c2 as float32! c3 1.0 75 | glfwSetWindowPos window 100 + ((i - 1 AND 1) * 300) 100 + ((i - 1 >> 1) * 300) 76 | glfwShowWindow window 77 | i: i + 1 78 | i > 4 79 | ] 80 | 81 | while [running = 1][ 82 | i: 1 83 | until [ 84 | window: as int-ptr! pwindows/i 85 | glfwMakeContextCurrent window 86 | glClear GL_COLOR_BUFFER_BIT 87 | glfwSwapBuffers window 88 | if (glfwWindowShouldClose window) = GL_TRUE [running: GL_FALSE] 89 | i: i + 1 90 | i > 4 91 | ] 92 | glfwPollEvents 93 | ] 94 | 95 | glfwTerminate -------------------------------------------------------------------------------- /dll/libglfw.3.2.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/dll/libglfw.3.2.dylib -------------------------------------------------------------------------------- /dll/libglfw.3.dylib: -------------------------------------------------------------------------------- 1 | libglfw.3.2.dylib -------------------------------------------------------------------------------- /dll/libglfw.dylib: -------------------------------------------------------------------------------- 1 | libglfw.3.dylib -------------------------------------------------------------------------------- /lib/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/lib/.DS_Store -------------------------------------------------------------------------------- /lib/Tools/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/lib/Tools/.DS_Store -------------------------------------------------------------------------------- /lib/Tools/C-library.reds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/lib/Tools/C-library.reds -------------------------------------------------------------------------------- /lib/Tools/math.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "C Math Library Binding" 3 | Author: "Kaj de Vos" 4 | Rights: "Copyright (c) 2011,2012 Kaj de Vos. All rights reserved." 5 | License: { 6 | Redistribution and use in source and binary forms, with or without modification, 7 | are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | } 26 | Needs: "Red/System >= 0.2.4" 27 | Tabs: 4 28 | ] 29 | 30 | 31 | #include %C-library.reds 32 | 33 | 34 | #switch OS [ 35 | Windows [#define math-library LIBC-file] 36 | macOS [#define math-library "libm.dylib"] ; TODO: check this 37 | Linux [#define math-library "libm.so.6"] 38 | #default [#define math-library "libm.so.2"] ; GNU, Syllable 39 | ] 40 | #import [math-library cdecl [ 41 | fraction: "modf" [ ; Integral and fractional parts 42 | value [float!] 43 | integral [handle!] ; float-reference! 44 | return: [float!] 45 | ] 46 | ;--added by fj 47 | round-trunc: "trunc" [ ; Smallest integer not less 48 | value [float!] 49 | return: [float!] 50 | ] 51 | 52 | round-ceiling: "ceil" [ ; Smallest integer not less 53 | value [float!] 54 | return: [float!] 55 | ] 56 | round-floor: "floor" [ ; Largest integer not greater 57 | value [float!] 58 | return: [float!] 59 | ] 60 | 61 | float-absolute: "fabs" [ 62 | value [float!] 63 | return: [float!] 64 | ] 65 | float-remainder: "fmod" [ 66 | dividend [float!] 67 | divisor [float!] 68 | return: [float!] 69 | ] 70 | 71 | float-power: "pow" [ ; Number raised to exponent 72 | number [float!] 73 | exponent [float!] 74 | return: [float!] 75 | ] 76 | square-root: "sqrt" [ 77 | value [float!] 78 | return: [float!] 79 | ] 80 | 81 | exp: "exp" [ ; Exponential 82 | power [float!] 83 | return: [float!] 84 | ] 85 | ;--supported by red 86 | _log-e: "log" [ ; Natural logarithm 87 | value [float!] 88 | return: [float!] 89 | ] 90 | _log-10: "log10" [ ; Base 10 logarithm 91 | value [float!] 92 | return: [float!] 93 | ] 94 | ;-end 95 | 96 | sine-radians: "sin" [ 97 | value [float!] 98 | return: [float!] 99 | ] 100 | cosine-radians: "cos" [ 101 | value [float!] 102 | return: [float!] 103 | ] 104 | tangent-radians: "tan" [ 105 | value [float!] 106 | return: [float!] 107 | ] 108 | 109 | arcsine-radians: "asin" [ 110 | value [float!] 111 | return: [float!] 112 | ] 113 | arccosine-radians: "acos" [ 114 | value [float!] 115 | return: [float!] 116 | ] 117 | arctangent-radians: "atan" [ 118 | value [float!] 119 | return: [float!] 120 | ] 121 | arctangent-2-radians: "atan2" [ 122 | y [float!] 123 | x [float!] 124 | return: [float!] 125 | ] 126 | 127 | hyper-sine-radians: "sinh" [ ; Hyperbolic sine 128 | value [float!] 129 | return: [float!] 130 | ] 131 | hyper-cosine-radians: "cosh" [ ; Hyperbolic cosine 132 | value [float!] 133 | return: [float!] 134 | ] 135 | hyper-tangent-radians: "tanh" [ ; Hyperbolic tangent 136 | value [float!] 137 | return: [float!] 138 | ] 139 | 140 | ld-exp: "ldexp" [ ; x * 2**n 141 | significand [float!] 142 | exponent [integer!] 143 | return: [float!] 144 | ] 145 | fraction-exponent: "frexp" [ ; Split into normalised fraction (significand) and power of 2. 146 | value [float!] 147 | exponent [integer-reference!] 148 | return: [float!] 149 | ] 150 | ]] 151 | -------------------------------------------------------------------------------- /lib/glfw3.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW3 Binding" 3 | Author: "F.Jouen" 4 | Rights: "Copyright (c) 2013-2017 Francois Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ; cette version fonctionne avec Red-061 et master 9 | 10 | #define importMode cdecl 11 | 12 | ; adapt libraries paths for your own use :) 13 | ; this will be changed in future for relative paths 14 | #switch OS [ 15 | macOS [#define glfw3 "/usr/local/lib32/GLFW/libglfw.dylib"] 16 | Windows [#define glfw3 "c:\glfw\bin\glfw.dll"] 17 | Linux [#define glfw3 #define glfw3lib "/usr/lib/libglfw.so"] 18 | ] 19 | 20 | 21 | #include %rpointers.reds 22 | #include %glu.reds 23 | 24 | 25 | #define GLFW_VERSION_MAJOR 3 26 | #define GLFW_VERSION_MINOR 2 27 | #define GLFW_VERSION_REVISION 1 28 | #define GLFW_RELEASE 0 29 | #define GLFW_PRESS 1 30 | #define GLFW_REPEAT 2 31 | 32 | ; The unknown key 33 | #define GLFW_KEY_UNKNOWN -1 34 | 35 | ; Printable keys 36 | #define GLFW_KEY_SPACE 32 37 | #define GLFW_KEY_APOSTROPHE 39 ; ' 38 | #define GLFW_KEY_COMMA 44 ; , 39 | #define GLFW_KEY_MINUS 45 ; - 40 | #define GLFW_KEY_PERIOD 46 ; . 41 | #define GLFW_KEY_SLASH 47 ; / 42 | #define GLFW_KEY_0 48 43 | #define GLFW_KEY_1 49 44 | #define GLFW_KEY_2 50 45 | #define GLFW_KEY_3 51 46 | #define GLFW_KEY_4 52 47 | #define GLFW_KEY_5 53 48 | #define GLFW_KEY_6 54 49 | #define GLFW_KEY_7 55 50 | #define GLFW_KEY_8 56 51 | #define GLFW_KEY_9 57 52 | #define GLFW_KEY_SEMICOLON 59 ; ; 53 | #define GLFW_KEY_EQUAL 61 ; = 54 | #define GLFW_KEY_A 65 55 | #define GLFW_KEY_B 66 56 | #define GLFW_KEY_C 67 57 | #define GLFW_KEY_D 68 58 | #define GLFW_KEY_E 69 59 | #define GLFW_KEY_F 70 60 | #define GLFW_KEY_G 71 61 | #define GLFW_KEY_H 72 62 | #define GLFW_KEY_I 73 63 | #define GLFW_KEY_J 74 64 | #define GLFW_KEY_K 75 65 | #define GLFW_KEY_L 76 66 | #define GLFW_KEY_M 77 67 | #define GLFW_KEY_N 78 68 | #define GLFW_KEY_O 79 69 | #define GLFW_KEY_P 80 70 | #define GLFW_KEY_Q 81 71 | #define GLFW_KEY_R 82 72 | #define GLFW_KEY_S 83 73 | #define GLFW_KEY_T 84 74 | #define GLFW_KEY_U 85 75 | #define GLFW_KEY_V 86 76 | #define GLFW_KEY_W 87 77 | #define GLFW_KEY_X 88 78 | #define GLFW_KEY_Y 89 79 | #define GLFW_KEY_Z 90 80 | #define GLFW_KEY_LEFT_BRACKET 91 ; [ 81 | #define GLFW_KEY_BACKSLASH 92 ; \ 82 | #define GLFW_KEY_RIGHT_BRACKET 93 ; ] 83 | #define GLFW_KEY_GRAVE_ACCENT 96 ; ` 84 | #define GLFW_KEY_WORLD_1 161 ; non-US #1 85 | #define GLFW_KEY_WORLD_2 162 ; non-US #2 86 | 87 | ;Function keys 88 | #define GLFW_KEY_ESCAPE 256 89 | #define GLFW_KEY_ENTER 257 90 | #define GLFW_KEY_TAB 258 91 | #define GLFW_KEY_BACKSPACE 259 92 | #define GLFW_KEY_INSERT 260 93 | #define GLFW_KEY_DELETE 261 94 | #define GLFW_KEY_RIGHT 262 95 | #define GLFW_KEY_LEFT 263 96 | #define GLFW_KEY_DOWN 264 97 | #define GLFW_KEY_UP 265 98 | #define GLFW_KEY_PAGE_UP 266 99 | #define GLFW_KEY_PAGE_DOWN 267 100 | #define GLFW_KEY_HOME 268 101 | #define GLFW_KEY_END 269 102 | #define GLFW_KEY_CAPS_LOCK 280 103 | #define GLFW_KEY_SCROLL_LOCK 281 104 | #define GLFW_KEY_NUM_LOCK 282 105 | #define GLFW_KEY_PRINT_SCREEN 283 106 | #define GLFW_KEY_PAUSE 284 107 | #define GLFW_KEY_F1 290 108 | #define GLFW_KEY_F2 291 109 | #define GLFW_KEY_F3 292 110 | #define GLFW_KEY_F4 293 111 | #define GLFW_KEY_F5 294 112 | #define GLFW_KEY_F6 295 113 | #define GLFW_KEY_F7 296 114 | #define GLFW_KEY_F8 297 115 | #define GLFW_KEY_F9 298 116 | #define GLFW_KEY_F10 299 117 | #define GLFW_KEY_F11 300 118 | #define GLFW_KEY_F12 301 119 | #define GLFW_KEY_F13 302 120 | #define GLFW_KEY_F14 303 121 | #define GLFW_KEY_F15 304 122 | #define GLFW_KEY_F16 305 123 | #define GLFW_KEY_F17 306 124 | #define GLFW_KEY_F18 307 125 | #define GLFW_KEY_F19 308 126 | #define GLFW_KEY_F20 309 127 | #define GLFW_KEY_F21 310 128 | #define GLFW_KEY_F22 311 129 | #define GLFW_KEY_F23 312 130 | #define GLFW_KEY_F24 313 131 | #define GLFW_KEY_F25 314 132 | #define GLFW_KEY_KP_0 320 133 | #define GLFW_KEY_KP_1 321 134 | #define GLFW_KEY_KP_2 322 135 | #define GLFW_KEY_KP_3 323 136 | #define GLFW_KEY_KP_4 324 137 | #define GLFW_KEY_KP_5 325 138 | #define GLFW_KEY_KP_6 326 139 | #define GLFW_KEY_KP_7 327 140 | #define GLFW_KEY_KP_8 328 141 | #define GLFW_KEY_KP_9 329 142 | #define GLFW_KEY_KP_DECIMAL 330 143 | #define GLFW_KEY_KP_DIVIDE 331 144 | #define GLFW_KEY_KP_MULTIPLY 332 145 | #define GLFW_KEY_KP_SUBTRACT 333 146 | #define GLFW_KEY_KP_ADD 334 147 | #define GLFW_KEY_KP_ENTER 335 148 | #define GLFW_KEY_KP_EQUAL 336 149 | #define GLFW_KEY_LEFT_SHIFT 340 150 | #define GLFW_KEY_LEFT_CONTROL 341 151 | #define GLFW_KEY_LEFT_ALT 342 152 | #define GLFW_KEY_LEFT_SUPER 343 153 | #define GLFW_KEY_RIGHT_SHIFT 344 154 | #define GLFW_KEY_RIGHT_CONTROL 345 155 | #define GLFW_KEY_RIGHT_ALT 346 156 | #define GLFW_KEY_RIGHT_SUPER 347 157 | #define GLFW_KEY_MENU 348 158 | #define GLFW_KEY_LAST GLFW_KEY_MENU 159 | #define GLFW_MOD_SHIFT 00000001h ; shift key 160 | #define GLFW_MOD_CONTROL 00000002h ; control key 161 | #define GLFW_MOD_ALT 00000004h ; alt key 162 | #define GLFW_MOD_SUPER 00000008h ; super key 163 | 164 | ;mouse buttons 165 | #define GLFW_MOUSE_BUTTON_1 0 166 | #define GLFW_MOUSE_BUTTON_2 1 167 | #define GLFW_MOUSE_BUTTON_3 2 168 | #define GLFW_MOUSE_BUTTON_4 3 169 | #define GLFW_MOUSE_BUTTON_5 4 170 | #define GLFW_MOUSE_BUTTON_6 5 171 | #define GLFW_MOUSE_BUTTON_7 6 172 | #define GLFW_MOUSE_BUTTON_8 7 173 | #define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8 174 | #define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1 175 | #define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2 176 | #define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3 177 | 178 | ;joystick buttons 179 | #define GLFW_JOYSTICK_1 0 180 | #define GLFW_JOYSTICK_2 1 181 | #define GLFW_JOYSTICK_3 2 182 | #define GLFW_JOYSTICK_4 3 183 | #define GLFW_JOYSTICK_5 4 184 | #define GLFW_JOYSTICK_6 5 185 | #define GLFW_JOYSTICK_7 6 186 | #define GLFW_JOYSTICK_8 7 187 | #define GLFW_JOYSTICK_9 8 188 | #define GLFW_JOYSTICK_10 9 189 | #define GLFW_JOYSTICK_11 10 190 | #define GLFW_JOYSTICK_12 11 191 | #define GLFW_JOYSTICK_13 12 192 | #define GLFW_JOYSTICK_14 13 193 | #define GLFW_JOYSTICK_15 14 194 | #define GLFW_JOYSTICK_16 15 195 | #define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16 196 | 197 | ; errors 198 | #define GLFW_NOT_INITIALIZED 00010001h ;GLFW has not been initialized. 199 | #define GLFW_NO_CURRENT_CONTEXT 00010002h ;No context is current for this thread. 200 | #define GLFW_INVALID_ENUM 00010003h ;One of the enum parameters for the function was given an invalid enum. 201 | #define GLFW_INVALID_VALUE 00010004h ;One of the parameters for the function was given an invalid value. 202 | #define GLFW_OUT_OF_MEMORY 00010005h ;A memory allocation failed. 203 | #define GLFW_API_UNAVAILABLE 00010006h ;GLFW could not find support for the requested client API on the system. 204 | #define GLFW_VERSION_UNAVAILABLE 00010007h ;The requested client API version is not available. 205 | #define GLFW_PLATFORM_ERROR 00010008h ;A platform-specific error occurred that does not match any of the more specific categories. 206 | #define GLFW_FORMAT_UNAVAILABLE 00010009h ;the clipboard did not contain data in the requested format. 207 | 208 | #define GLFW_FOCUSED 00020001h 209 | #define GLFW_ICONIFIED 00020002h 210 | #define GLFW_RESIZABLE 00020003h 211 | #define GLFW_VISIBLE 00020004h 212 | #define GLFW_DECORATED 00020005h 213 | 214 | #define GLFW_RED_BITS 00021001h 215 | #define GLFW_GREEN_BITS 00021002h 216 | #define GLFW_BLUE_BITS 00021003h 217 | #define GLFW_ALPHA_BITS 00021004h 218 | #define GLFW_DEPTH_BITS 00021005h 219 | #define GLFW_STENCIL_BITS 00021006h 220 | #define GLFW_ACCUM_RED_BITS 00021007h 221 | #define GLFW_ACCUM_GREEN_BITS 00021008h 222 | #define GLFW_ACCUM_BLUE_BITS 00021009h 223 | #define GLFW_ACCUM_ALPHA_BITS 0002100Ah 224 | #define GLFW_AUX_BUFFERS 0002100Bh 225 | #define GLFW_STEREO 0002100Ch 226 | #define GLFW_SAMPLES 0002100Dh 227 | #define GLFW_SRGB_CAPABLE 0002100Eh 228 | #define GLFW_REFRESH_RATE 0002100Fh 229 | 230 | #define GLFW_CLIENT_API 00022001h 231 | #define GLFW_CONTEXT_VERSION_MAJOR 00022002h 232 | #define GLFW_CONTEXT_VERSION_MINOR 00022003h 233 | #define GLFW_CONTEXT_REVISION 00022004h 234 | #define GLFW_CONTEXT_ROBUSTNESS 00022005h 235 | #define GLFW_OPENGL_FORWARD_COMPAT 00022006h 236 | #define GLFW_OPENGL_DEBUG_CONTEXT 00022007h 237 | #define GLFW_OPENGL_PROFILE 00022008h 238 | 239 | #define GLFW_OPENGL_API 00030001h 240 | #define GLFW_OPENGL_ES_API 00030002h 241 | 242 | #define GLFW_NO_ROBUSTNESS 0 243 | #define GLFW_NO_RESET_NOTIFICATION 00031001h 244 | #define GLFW_LOSE_CONTEXT_ON_RESET 00031002h 245 | 246 | #define GLFW_OPENGL_ANY_PROFILE 0 247 | #define GLFW_OPENGL_CORE_PROFILE 00032001h 248 | #define GLFW_OPENGL_COMPAT_PROFILE 00032002h 249 | 250 | #define GLFW_CURSOR 00033001h 251 | #define GLFW_STICKY_KEYS 00033002h 252 | #define GLFW_STICKY_MOUSE_BUTTONS 00033003h 253 | 254 | #define GLFW_CURSOR_NORMAL 00034001h 255 | #define GLFW_CURSOR_HIDDEN 00034002h 256 | #define GLFW_CURSOR_DISABLED 00034003h 257 | 258 | #define GLFW_ANY_RELEASE_BEHAVIOR 0 259 | #define GLFW_RELEASE_BEHAVIOR_FLUSH 00035001h 260 | #define GLFW_RELEASE_BEHAVIOR_NONE 00035002h 261 | 262 | #define GLFW_NATIVE_CONTEXT_API 00036001h 263 | #define GLFW_EGL_CONTEXT_API 00036002h 264 | 265 | #define GLFW_ARROW_CURSOR 00036001h 266 | #define GLFW_IBEAM_CURSOR 00036002h 267 | #define GLFW_CROSSHAIR_CURSOR 00036003h 268 | #define GLFW_HAND_CURSOR 00036004h 269 | #define GLFW_HRESIZE_CURSOR 00036005h 270 | #define GLFW_VRESIZE_CURSOR 00036006h 271 | 272 | #define GLFW_CONNECTED 00040001h 273 | #define GLFW_DISCONNECTED 00040002h 274 | 275 | #define GLFW_DONT_CARE -1 276 | 277 | ; GLFW API types 278 | ;opaques structures 279 | #define GLFWmonitor int-ptr! 280 | #define GLFWwindow int-ptr! 281 | #define GLFWcursor int-ptr! 282 | #define VkInstance int-ptr! 283 | #define VkPhysicalDevice int-ptr! 284 | 285 | ;red/system aliases to functions / by convention use ! suffix 286 | GLFWglproc!: alias function! [] 287 | GLFWvkproc!: alias function! [] 288 | GLFWerrorfun!: alias function! [ n[integer!] s [c-string!]] 289 | GLFWwindowposfun!: alias function! [w [GLFWwindow] n1 [integer!] n2 [integer!]] 290 | GLFWwindowsizefun!: alias function! [w [GLFWwindow] n1 [integer!] n2 [integer!]] 291 | GLFWwindowclosefun!: alias function! [w [GLFWwindow]] 292 | GLFWwindowrefreshfun!: alias function! [w [GLFWwindow]] 293 | GLFWwindowfocusfun!: alias function! [w [GLFWwindow] n[integer!]] 294 | GLFWwindowiconifyfun!: alias function! [w [GLFWwindow] n[integer!]] 295 | GLFWframebuffersizefun!: alias function! [w [GLFWwindow] n1 [integer!] n2 [integer!]] 296 | GLFWmousebuttonfun!: alias function! [w [GLFWwindow] n1 [integer!] n2 [integer!] n3 [integer!]] 297 | GLFWcursorposfun!: alias function! [w [GLFWwindow] n1 [float!] n2 [float!]] 298 | GLFWcursorenterfun!: alias function! [w [GLFWwindow] n1 [integer!]] 299 | GLFWscrollfun!: alias function! [w [GLFWwindow] n1 [float!] n2 [float!]] 300 | GLFWkeyfun!: alias function! [w [GLFWwindow] n1 [integer!] n2 [integer!] n3 [integer!] n4 [integer!]] 301 | GLFWcharfun!: alias function! [w [GLFWwindow] b [integer!] ] 302 | GLFWcharmodsfun!: alias function! [w [GLFWwindow] n1 [integer!] n2 [integer!]] 303 | GLFWdropfun!: alias function! [w [GLFWwindow] n1 [integer!] s [c-string!]] 304 | GLFWmonitorfun!: alias function! [w [GLFWwindow] n [integer!] ] 305 | GLFWjoystickfun!: alias function! [n1 [integer!] n2 [integer!]] 306 | 307 | GLFWvidmode: alias struct! [ 308 | width [integer!] 309 | height [integer!] 310 | redBits [integer!] 311 | greenBits [integer!] 312 | blueBits [integer!] 313 | refreshRate [integer!] 314 | ] 315 | 316 | GLFWgammaramp: alias struct! [ 317 | red [int-ptr!] 318 | green [int-ptr!] 319 | blue [int-ptr!] 320 | size [integer!] 321 | ] 322 | 323 | ; old version not supported now 324 | GLFWimage: alias struct! [ 325 | width [integer!] 326 | height [integer!] 327 | BytesPerPixel [integer!] 328 | *Data [int-ptr!] 329 | ] 330 | 331 | #import [ 332 | glfw3 importmode [ 333 | glfwInit: "glfwInit" [ 334 | "Initializes the GLFW library. return `GL_TRUE` if successful, or `GL_FALSE` if an error occurred." 335 | return: [integer!] 336 | ] 337 | glfwTerminate: "glfwTerminate" [ 338 | "Terminates the GLFW library." 339 | return: [integer!] 340 | ] 341 | glfwGetVersion: "glfwGetVersion" [ 342 | "Retrieves the version of the GLFW library." 343 | major [int-ptr!] 344 | minor [int-ptr!] 345 | rev [int-ptr!] 346 | ] 347 | glfwGetVersionString: "glfwGetVersionString" [ 348 | "Returns a string describing the compile-time configuration." 349 | return: [c-string!] 350 | ] 351 | glfwSetErrorCallback: "glfwSetErrorCallback" [ 352 | "Sets the error callback." 353 | cbfun [GLFWerrorfun!] 354 | return: [GLFWerrorfun!] 355 | ] 356 | 357 | glfwGetMonitors: "glfwGetMonitors" [ 358 | "Returns the currently connected monitors." 359 | count [int-ptr!] 360 | return: [GLFWmonitor] 361 | ] 362 | glfwGetPrimaryMonitor: "glfwGetPrimaryMonitor" [ 363 | "Returns the primary monitor." 364 | return: [GLFWmonitor] 365 | ] 366 | glfwGetMonitorPos: "glfwGetMonitorPos" [ 367 | "Returns the position of the monitor's viewport on the virtual screen." 368 | monitor [GLFWmonitor] 369 | xpos [int-ptr!] 370 | ypos [int-ptr!] 371 | ] 372 | glfwGetMonitorPhysicalSize: "glfwGetMonitorPhysicalSize" [ 373 | "Returns the physical size of the monitor." 374 | monitor [GLFWmonitor] 375 | width [int-ptr!] 376 | height [int-ptr!] 377 | ] 378 | 379 | glfwGetMonitorName: "glfwGetMonitorName" [ 380 | "Returns the name of the specified monitor." 381 | monitor [GLFWmonitor] 382 | return: [c-string!] 383 | ] 384 | glfwSetMonitorCallback: "glfwSetMonitorCallback" [ 385 | "Sets the monitor configuration callback." 386 | cbfun [GLFWmonitorfun!] 387 | return: [GLFWmonitorfun!] 388 | ] 389 | 390 | glfwGetVideoModes: "glfwGetVideoModes" [ 391 | "Returns the available video modes for the specified monitor." 392 | monitor [GLFWmonitor] 393 | count [int-ptr!] 394 | return: [GLFWvidmode] 395 | ] 396 | 397 | glfwGetVideoMode: "glfwGetVideoMode" [ 398 | "Returns the current mode of the specified monitor." 399 | monitor [GLFWmonitor] 400 | return: [GLFWvidmode] 401 | ] 402 | glfwSetGamma: "glfwSetGamma" [ 403 | "Generates a gamma ramp and sets it for the specified monitor." 404 | monitor [GLFWmonitor] 405 | gamma [Float32!] 406 | ] 407 | glfwGetGammaRamp: "glfwGetGammaRamp" [ 408 | "Retrieves the current gamma ramp for the specified monitor." 409 | monitor [GLFWmonitor] 410 | return: [GLFWgammaramp] 411 | ] 412 | 413 | glfwSetGammaRamp: "glfwSetGammaRamp" [ 414 | "Sets the current gamma ramp for the specified monitor." 415 | monitor [GLFWmonitor] 416 | ramp [GLFWgammaramp] 417 | ] 418 | glfwDefaultWindowHints: "glfwDefaultWindowHints" [ 419 | "Resets all window hints to their default values." 420 | return: [integer!] 421 | ] 422 | glfwWindowHint: "glfwWindowHint" [ 423 | "Sets the specified window hint to the desired value." 424 | target [integer!] 425 | hint [integer!] 426 | ] 427 | glfwCreateWindow: "glfwCreateWindow" [ 428 | "Creates a window and its associated context." 429 | width [integer!] 430 | height [integer!] 431 | title [c-string!] 432 | monitor [GLFWmonitor] 433 | share [GLFWwindow] 434 | return: [GLFWwindow] 435 | ] 436 | glfwDestroyWindow: "glfwDestroyWindow" [ 437 | "Destroys the specified window and its context." 438 | window [GLFWwindow] 439 | ] 440 | glfwWindowShouldClose: "glfwWindowShouldClose" [ 441 | "Checks the close flag of the specified window." 442 | window [GLFWwindow] 443 | return: [integer!] 444 | ] 445 | 446 | glfwSetWindowShouldClose: "glfwSetWindowShouldClose" [ 447 | "Sets the close flag of the specified window." 448 | window [GLFWwindow] 449 | value [integer!] 450 | ] 451 | glfwSetWindowTitle: "glfwSetWindowTitle" [ 452 | "Sets the title of the specified window." 453 | window [GLFWwindow] 454 | title [c-string!] 455 | ] 456 | 457 | glfwSetWindowIcon: "glfwSetWindowIcon" [ 458 | "Sets the icon for the specified window" 459 | window [GLFWwindow] 460 | count [integer!] 461 | images [GLFWimage] 462 | ] 463 | 464 | glfwGetWindowPos: "glfwGetWindowPos" [ 465 | "Retrieves the position of the client area of the specified window." 466 | window [GLFWwindow] 467 | xpos [int-ptr!] 468 | ypos [int-ptr!] 469 | ] 470 | 471 | glfwSetWindowPos: "glfwSetWindowPos" [ 472 | "Sets the position of the client area of the specified window." 473 | window [GLFWwindow] 474 | xpos [integer!] 475 | ypos [integer!] 476 | ] 477 | 478 | glfwGetWindowSize: "glfwGetWindowSize" [ 479 | "Retrieves the size of the client area of the specified window." 480 | window [GLFWwindow] 481 | width [int-ptr!] 482 | height [int-ptr!] 483 | ] 484 | 485 | glfwSetWindowSize: "glfwSetWindowSize" [ 486 | "Sets the size of the client area of the specified window." 487 | window [GLFWwindow] 488 | width [integer!] 489 | height [integer!] 490 | ] 491 | 492 | glfwSetWindowSizeLimits: "glfwSetWindowSizeLimits" [ 493 | "Sets the size limits of the specified window.." 494 | window [GLFWwindow] 495 | minwidth [integer!] 496 | minheight [integer!] 497 | maxwidth [integer!] 498 | maxheight [integer!] 499 | ] 500 | glfwSetWindowAspectRatio: "glfwSetWindowAspectRatio" [ 501 | "Sets the aspect ratio of the specified window" 502 | window [GLFWwindow] 503 | numer [integer!] 504 | denom [integer!] 505 | ] 506 | glfwGetFramebufferSize: "glfwGetFramebufferSize" [ 507 | "Retrieves the size of the framebuffer of the specified window." 508 | window [GLFWwindow] 509 | width [int-ptr!] 510 | height [int-ptr!] 511 | ] 512 | 513 | glfwGetWindowFrameSize: "glfwGetWindowFrameSize" [ 514 | "Retrieves the size of the frame of the window." 515 | window [GLFWwindow] 516 | left [int-ptr!] 517 | top [int-ptr!] 518 | right [int-ptr!] 519 | bottom [int-ptr!] 520 | ] 521 | 522 | 523 | glfwIconifyWindow: "glfwIconifyWindow" [ 524 | "Iconifies the specified window." 525 | window [GLFWwindow] 526 | ] 527 | glfwRestoreWindow: "glfwRestoreWindow" [ 528 | "Restores the specified window." 529 | window [GLFWwindow] 530 | ] 531 | 532 | glfwMaximizeWindow: "glfwMaximizeWindow" [ 533 | "Maximizes the specified window" 534 | window [GLFWwindow] 535 | ] 536 | 537 | 538 | glfwShowWindow: "glfwShowWindow" [ 539 | "Makes the specified window visible." 540 | window [GLFWwindow] 541 | ] 542 | 543 | glfwHideWindow: "glfwHideWindow" [ 544 | "Hides the specified window." 545 | window [GLFWwindow] 546 | ] 547 | 548 | glfwFocusWindow: "glfwFocusWindow" [ 549 | "Brings the specified window to front and sets input focus." 550 | window [GLFWwindow] 551 | ] 552 | glfwGetWindowMonitor: "glfwGetWindowMonitor" [ 553 | "Returns the monitor that the window uses for full screen mode." 554 | window [GLFWwindow] 555 | return: [GLFWmonitor] 556 | ] 557 | 558 | glfwSetWindowMonitor: "glfwSetWindowMonitor" [ 559 | "Sets the mode, monitor, video mode and placement of a window." 560 | window [GLFWwindow] 561 | monitor [GLFWmonitor] 562 | xpos [integer!] 563 | ypos [integer!] 564 | width [integer!] 565 | height [integer!] 566 | refreshRa [integer!] 567 | ] 568 | glfwGetWindowAttrib: "glfwGetWindowAttrib" [ 569 | "Returns an attribute of the specified window." 570 | window [GLFWwindow] 571 | attrib [integer!] 572 | return: [integer!] 573 | ] 574 | 575 | glfwSetWindowUserPointer: "glfwSetWindowUserPointer" [ 576 | "Sets the user pointer of the specified window." 577 | window [GLFWwindow] 578 | pointer [byte-ptr!] ;void* pointer 579 | ] 580 | 581 | glfwGetWindowUserPointer: "glfwGetWindowUserPointer" [ 582 | ;Returns the user pointer of the specified window. 583 | window [GLFWwindow] 584 | ] 585 | glfwSetWindowPosCallback: "glfwSetWindowPosCallback" [ 586 | "Sets the position callback for the specified window." 587 | window [GLFWwindow] 588 | cbfun [GLFWwindowposfun!] 589 | return: [GLFWwindowposfun!] 590 | ] 591 | 592 | glfwSetWindowSizeCallback: "glfwSetWindowSizeCallback" [ 593 | "Sets the size callback for the specified window." 594 | window [GLFWwindow] 595 | cbfun [GLFWwindowsizefun!] 596 | return: [GLFWwindowsizefun!] 597 | ] 598 | 599 | glfwSetWindowCloseCallback: "glfwSetWindowCloseCallback" [ 600 | "Sets the close callback for the specified window." 601 | window [GLFWwindow] 602 | cbfun [GLFWwindowclosefun!] 603 | return: [GLFWwindowclosefun!] 604 | ] 605 | 606 | 607 | glfwSetWindowFocusCallback: "glfwSetWindowFocusCallback" [ 608 | "Sets the focus callback for the specified window." 609 | window [GLFWwindow] 610 | cbfun [GLFWwindowfocusfun!] 611 | return: [GLFWwindowfocusfun!] 612 | ] 613 | 614 | glfwSetWindowRefreshCallback: "glfwSetWindowRefreshCallback" [ 615 | "Sets the refresh callback for the specified window" 616 | window [GLFWwindow] 617 | cbfun [GLFWwindowrefreshfun!] 618 | return: [GLFWwindowrefreshfun!] 619 | ] 620 | 621 | glfwSetWindowIconifyCallback: "glfwSetWindowIconifyCallback" [ 622 | "Sets the iconify callback for the specified window." 623 | window [GLFWwindow] 624 | cbfun [GLFWwindowiconifyfun!] 625 | return: [GLFWwindowiconifyfun!] 626 | ] 627 | 628 | glfwSetFramebufferSizeCallback: "glfwSetFramebufferSizeCallback" [ 629 | "Sets the framebuffer resize callback for the specified window." 630 | window [GLFWwindow] 631 | cbfun [GLFWframebuffersizefun!] 632 | return: [GLFWframebuffersizefun!] 633 | ] 634 | glfwPollEvents: "glfwPollEvents" [ 635 | "Processes all pending events." 636 | return: [integer!] 637 | ] 638 | glfwWaitEvents: "glfwWaitEvents" [ 639 | "Waits until events are pending and processes them." 640 | return: [integer!] 641 | ] 642 | glfwWaitEventsTimeout: "glfwWaitEventsTimeout" [ 643 | "Waits with timeout until events are queued and processes them." 644 | timeout [float!] 645 | return: [integer!] 646 | ] 647 | glfwPostEmptyEvent: "glfwPostEmptyEvent" [ 648 | "Posts an empty event to the event queue." 649 | return: [integer!] 650 | ] 651 | glfwGetInputMode: "glfwGetInputMode" [ 652 | "Returns the value of an input option for the specified window." 653 | window [GLFWwindow] 654 | mode [integer!] 655 | return: [integer!] 656 | ] 657 | 658 | glfwSetInputMode: "glfwSetInputMode" [ 659 | "Sets an input option for the specified window." 660 | window [GLFWwindow] 661 | mode [integer!] 662 | value [integer!] 663 | ] 664 | glfwGetKeyName: "glfwGetKeyName" [ 665 | "Returns the localized name of the specified printable key." 666 | int [integer!] 667 | scancode [integer!] 668 | return: [c-string!] 669 | ] 670 | glfwGetKey: "glfwGetKey" [ 671 | "Returns the last reported state of a keyboard key for the specified window." 672 | window [GLFWwindow] 673 | key [integer!] 674 | return: [integer!] 675 | ] 676 | glfwGetMouseButton: "glfwGetMouseButton" [ 677 | "Returns the last reported state of a mouse button for the specified window." 678 | window [GLFWwindow] 679 | button [integer!] 680 | return: [integer!] 681 | ] 682 | 683 | glfwGetCursorPos: "glfwGetCursorPos" [ 684 | "Retrieves the last reported cursor position, relative to the client area of the window." 685 | window [GLFWwindow] 686 | xpos [float-ptr!] ;double* 687 | ypos [float-ptr!] ;double* 688 | ] 689 | glfwSetCursorPos: "glfwSetCursorPos" [ 690 | "Sets the position of the cursor, relative to the client area of the window." 691 | window [GLFWwindow] 692 | xpos [Float32!] 693 | ypos [Float32!] 694 | ] 695 | 696 | glfwCreateCursor: "glfwCreateCursor" [ 697 | "Creates a custom cursor." 698 | image [GLFWimage] 699 | xhot [integer!] 700 | yhot [integer!] 701 | return: [GLFWcursor] 702 | ] 703 | glfwCreateStandardCursor: "glfwCreateStandardCursor" [ 704 | "Creates a cursor with a standard shape." 705 | shape [integer!] 706 | return: [GLFWcursor] 707 | ] 708 | glfwDestroyCursor: "glfwDestroyCursor" [ 709 | "Destroys a cursor." 710 | cursor [GLFWcursor] 711 | ] 712 | 713 | glfwSetCursor: "glfwSetCursor" [ 714 | "Sets the cursor for the window." 715 | window [GLFWwindow] 716 | cursor [GLFWcursor] 717 | ] 718 | glfwSetKeyCallback: "glfwSetKeyCallback" [ 719 | "Sets the key callback." 720 | window [GLFWwindow] 721 | cbfun [GLFWkeyfun!] 722 | return: [GLFWkeyfun!] 723 | ] 724 | glfwSetCharCallback: "glfwSetCharCallback" [ 725 | "Sets the Unicode character callback." 726 | window [GLFWwindow] 727 | cbfun [GLFWcharfun!] 728 | return: [GLFWcharfun!] 729 | ] 730 | glfwSetCharModsCallback: "glfwSetCharModsCallback" [ 731 | "Sets the Unicode character with modifiers callback" 732 | window [GLFWwindow] 733 | cbfun [GLFWcharfun!] 734 | return: [GLFWcharmodsfun!] 735 | ] 736 | glfwSetMouseButtonCallback: "glfwSetMouseButtonCallback" [ 737 | "Sets the mouse button callback." 738 | window [GLFWwindow] 739 | cbfun [GLFWmousebuttonfun!] 740 | return: [GLFWmousebuttonfun!] 741 | ] 742 | glfwSetCursorPosCallback: "glfwSetCursorPosCallback" [ 743 | "Sets the position of the cursor, relative to the client area of the window" 744 | window [GLFWwindow] 745 | cbfun [GLFWcursorposfun!] 746 | return: [GLFWcursorposfun!] 747 | ] 748 | glfwSetCursorEnterCallback: "glfwSetCursorEnterCallback" [ 749 | "Sets the key callback." 750 | window [GLFWwindow] 751 | cbfun [GLFWcursorenterfun!] 752 | return: [GLFWcursorenterfun!] 753 | ] 754 | glfwSetScrollCallback: "glfwSetScrollCallback" [ 755 | "Sets the scroll callback." 756 | window [GLFWwindow] 757 | cbfun [GLFWscrollfun!] 758 | return: [GLFWscrollfun!] 759 | ] 760 | 761 | glfwSetDropCallback: "glfwSetDropCallback" [ 762 | "Sets the file drop callback." 763 | window [GLFWwindow] 764 | cbfun [GLFWdropfun!] 765 | return: [GLFWdropfun!] 766 | ] 767 | glfwJoystickPresent: "glfwJoystickPresent" [ 768 | "Returns whether the specified joystick is present." 769 | joy [integer!] 770 | return: [integer!] 771 | ] 772 | 773 | glfwGetJoystickAxes: "glfwGetJoystickAxes" [ 774 | "Returns the values of all axes of the specified joystick." 775 | joy [integer!] 776 | count [int-ptr!] 777 | return: [float32-ptr!] 778 | ] 779 | 780 | glfwGetJoystickButtons: "glfwGetJoystickButtons" [ 781 | "Returns the state of all buttons of the specified joystick" 782 | joy [integer!] 783 | count [int-ptr!] 784 | return: [byte-ptr!] 785 | ] 786 | glfwGetJoystickName: "glfwGetJoystickName" [ 787 | "This function returns the name, encoded as UTF-8, of the specified joystick." 788 | joy [integer!] 789 | return: [c-string!] 790 | ] 791 | glfwSetJoystickCallback: "glfwSetJoystickCallback" [ 792 | "Sets the joystick configuration callback." 793 | cbfun [GLFWjoystickfun!] 794 | return: [GLFWjoystickfun!] 795 | ] 796 | glfwSetClipboardString: "glfwSetClipboardString" [ 797 | "ets the clipboard to the specified string." 798 | window [GLFWwindow] 799 | string [c-string!] ; pointer 800 | ] 801 | 802 | glfwGetClipboardString: "glfwGetClipboardString" [ 803 | "Retrieves the contents of the clipboard as a string." 804 | window [GLFWwindow] 805 | return: [c-string!] 806 | ] 807 | glfwGetTime: "glfwGetTime" [ 808 | "Returns the value of the GLFW timer." 809 | return: [Float!] 810 | ] 811 | 812 | glfwSetTime: "glfwSetTime" [ 813 | "Sets the GLFW timer." 814 | time [Float!] 815 | ] 816 | 817 | glfwGetTimerValue: "glfwGetTimerValue" [ 818 | " Returns the current value of the raw timer." 819 | return: [integer!] 820 | ] 821 | 822 | glfwGetTimerFrequency: "glfwGetTimerFrequency" [ 823 | "Returns the frequency, in Hz, of the raw timer." 824 | return: [integer!] 825 | ] 826 | glfwMakeContextCurrent: "glfwMakeContextCurrent" [ 827 | "Makes the context of the specified window current for the calling thread." 828 | window [GLFWwindow] 829 | ] 830 | 831 | glfwGetCurrentContext: "glfwGetCurrentContext" [ 832 | "Returns the window whose context is current on the calling thread." 833 | return: [GLFWwindow] 834 | ] 835 | 836 | glfwSwapBuffers: "glfwSwapBuffers" [ 837 | "Swaps the front and back buffers of the specified window." 838 | window [GLFWwindow] 839 | ] 840 | glfwSwapInterval: "glfwSwapInterval" [ 841 | "Sets the swap interval for the current context.(vsync)" 842 | interval [integer!] 843 | ] 844 | 845 | glfwExtensionSupported: "glfwExtensionSupported" [ 846 | "Returns whether the specified extension is available." 847 | extension [c-string!] 848 | return: [integer!] 849 | ] 850 | 851 | glfwGetProcAddress: "glfwGetProcAddress" [ 852 | "Returns the address of the specified function for the current context." 853 | procname [c-string!] 854 | return: [int-ptr!] 855 | ] 856 | glfwVulkanSupported: "glfwVulkanSupported" [ 857 | "Returns whether the Vulkan loader has been found." 858 | return: [integer!] 859 | ] 860 | 861 | glfwGetRequiredInstanceExtensions: "glfwGetRequiredInstanceExtensions" [ 862 | "Returns the Vulkan instance extensions required by GLFW." 863 | count [integer!] 864 | return: [c-string!] 865 | ] 866 | glfwGetInstanceProcAddress: "glfwGetInstanceProcAddress" [ 867 | "Returns the address of the specified Vulkan instance function." 868 | instance [VkInstance] 869 | procname [c-string!] 870 | return: [GLFWvkproc!] 871 | ] 872 | glfwGetPhysicalDevicePresentationSupport: "glfwGetPhysicalDevicePresentationSupport" [ 873 | "Returns whether the specified queue family can present images." 874 | instance [VkInstance] 875 | device [VkPhysicalDevice] 876 | queuefamily [integer!] 877 | return: [integer!] 878 | ] 879 | glfwCreateWindowSurface: "glfwCreateWindowSurface" [ 880 | instance [VkInstance] 881 | window [GLFWwindow] 882 | allocator [int-ptr!] 883 | surface [int-ptr!] 884 | return: [int-ptr!] 885 | ] 886 | ;***************************************************** 887 | ; glfw3native functions ; see glfw3native.h for detail 888 | ; be sure of what you 're doing 889 | ;***************************************************** 890 | 891 | glfwGetWin32Adapter: "glfwGetWin32Adapter" [ 892 | "Returns the adapter device name of the specified monitor." 893 | monitor [GLFWmonitor] 894 | return: [c-string!] 895 | ] 896 | glfwGetWin32Monitor: "glfwGetWin32Monitor" [ 897 | "Returns the display device name of the specified monitor." 898 | monitor [GLFWmonitor] 899 | return: [c-string!] 900 | ] 901 | ;#if defined(GLFW_EXPOSE_NATIVE_WIN32) 902 | glfwGetWin32Window: "glfwGetWin32Window" [ 903 | window [GLFWwindow] 904 | return: [byte-ptr!] ;HWND 905 | ] 906 | ;#if defined(GLFW_EXPOSE_NATIVE_WGL) 907 | glfwGetWGLContext: "glfwGetWGLContext" [ 908 | window [GLFWwindow] 909 | return: [byte-ptr!] ;HGLRC 910 | ] 911 | ;#if defined(GLFW_EXPOSE_NATIVE_COCOA) 912 | glfwGetCocoaMonitor: "glfwGetCocoaMonitor" [ 913 | monitor [GLFWmonitor] 914 | return: [byte-ptr!] ;CGDirectDisplayID 915 | ] 916 | ;#if defined(GLFW_EXPOSE_NATIVE_COCOA) 917 | glfwGetCocoaWindow: "glfwGetCocoaWindow" [ 918 | window [GLFWwindow] 919 | return: [byte-ptr!] ;id 920 | ] 921 | ;#if defined(GLFW_EXPOSE_NATIVE_NSGL) 922 | glfwGetNSGLContext: "glfwGetNSGLContext" [ 923 | window [GLFWwindow] 924 | return: [byte-ptr!] ;id 925 | ] 926 | ;#if defined(GLFW_EXPOSE_NATIVE_X11) 927 | glfwGetX11Display: "glfwGetX11Display" [ 928 | return: [byte-ptr!] ;Display* 929 | ] 930 | glfwGetX11Adapter: "glfwGetX11Adapter" [ 931 | monitor [GLFWmonitor] 932 | return: [byte-ptr!] 933 | ] 934 | glfwGetX11Monitor: "glfwGetX11Monitor" [ 935 | monitor [GLFWmonitor] 936 | return: [byte-ptr!] 937 | ] 938 | glfwGetX11Window: "glfwGetX11Window" [ 939 | window [GLFWwindow] 940 | return: [byte-ptr!] ;window 941 | ] 942 | ;#if defined(GLFW_EXPOSE_NATIVE_GLX) 943 | glfwGetGLXContext: "glfwGetGLXContext" [ 944 | window [GLFWwindow] 945 | return: [byte-ptr!] ;GLXContext 946 | ] 947 | glfwGetGLXWindow: "glfwGetGLXWindow" [ 948 | window [GLFWwindow] 949 | return: [byte-ptr!] ;GLXContext 950 | ] 951 | 952 | ;#if defined(GLFW_EXPOSE_NATIVE_WAYLAND) 953 | glfwGetWaylandDisplay: "glfwGetWaylandDisplay" [ 954 | return: [byte-ptr!] 955 | ] 956 | glfwGetWaylandMonitor: "glfwGetWaylandMonitor" [ 957 | monitor [GLFWmonitor] 958 | return: [byte-ptr!] 959 | ] 960 | glfwGetWaylandWindow: "glfwGetWaylandWindow" [ 961 | window [GLFWwindow] 962 | return: [byte-ptr!] 963 | ] 964 | ;#if defined(GLFW_EXPOSE_NATIVE_MIR) 965 | glfwGetMirDisplay: "glfwGetMirDisplay" [ 966 | return: [byte-ptr!] 967 | ] 968 | glfwGetMirMonitor: "glfwGetMirMonitor" [ 969 | monitor [GLFWmonitor] 970 | return: [byte-ptr!] 971 | ] 972 | glfwGetMirWindow: "glfwGetMirWindow" [ 973 | window [GLFWwindow] 974 | return: [byte-ptr!] 975 | ] 976 | 977 | ;#if defined(GLFW_EXPOSE_NATIVE_EGL) 978 | glfwGetEGLDisplay: "glfwGetEGLDisplay" [ 979 | return: [byte-ptr!] ;EGLDisplay 980 | ] 981 | glfwGetEGLContext: "glfwGetEGLContext" [ 982 | window [GLFWwindow] 983 | return: [byte-ptr!] ;EGLContext 984 | ] 985 | 986 | glfwGetEGLSurface: "glfwGetEGLSurface" [ 987 | window [GLFWwindow] 988 | return: [byte-ptr!] ;EGLSurface 989 | ] 990 | ] 991 | ] 992 | -------------------------------------------------------------------------------- /lib/glu.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "OpenGL Binding" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013-2014 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | 9 | ; please update paths according to your OS 10 | #switch OS [ 11 | macOS [#define glulib "/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib"] 12 | Windows [#define glulib "glu32.dll"] 13 | Linux [#define glulib "/usr/lib/libGLU.so.1"] 14 | #default [#define glulib "/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib"] 15 | ] 16 | 17 | 18 | ;*********************************************************** 19 | 20 | #include %opgl.reds 21 | 22 | ; Extensions 23 | #define GLU_EXT_object_space_tess 1 24 | #define GLU_EXT_nurbs_tessellator 1 25 | 26 | ; Boolean 27 | #define GLU_FALSE 0 28 | #define GLU_TRUE 1 29 | 30 | ; Version 31 | #define GLU_VERSION_1_1 1 32 | #define GLU_VERSION_1_2 1 33 | #define GLU_VERSION_1_3 1 34 | 35 | ; StringName 36 | #define GLU_VERSION 100800 37 | #define GLU_EXTENSIONS 100801 38 | 39 | ; ErrorCode 40 | #define GLU_INVALID_ENUM 100900 41 | #define GLU_INVALID_VALUE 100901 42 | #define GLU_OUT_OF_MEMORY 100902 43 | #define GLU_INCOMPATIBLE_GL_VERSION 100903 44 | #define GLU_INVALID_OPERATION 100904 45 | 46 | 47 | ; NurbsDisplay 48 | ; GLU_FILL 49 | #define GLU_OUTLINE_POLYGON 100240 50 | #define GLU_OUTLINE_PATCH 100241 51 | 52 | ; NurbsCallback 53 | #define GLU_NURBS_ERROR 100103 54 | #define GLU_ERROR 100103 55 | #define GLU_NURBS_BEGIN 100164 56 | #define GLU_NURBS_BEGIN_EXT 100164 57 | #define GLU_NURBS_VERTEX 100165 58 | #define GLU_NURBS_VERTEX_EXT 100165 59 | #define GLU_NURBS_NORMAL 100166 60 | #define GLU_NURBS_NORMAL_EXT 100166 61 | #define GLU_NURBS_COLOR 100167 62 | #define GLU_NURBS_COLOR_EXT 100167 63 | #define GLU_NURBS_TEXTURE_COORD 100168 64 | #define GLU_NURBS_TEX_COORD_EXT 100168 65 | #define GLU_NURBS_END 100169 66 | #define GLU_NURBS_END_EXT 100169 67 | #define GLU_NURBS_BEGIN_DATA 100170 68 | #define GLU_NURBS_BEGIN_DATA_EXT 100170 69 | #define GLU_NURBS_VERTEX_DATA 100171 70 | #define GLU_NURBS_VERTEX_DATA_EXT 100171 71 | #define GLU_NURBS_NORMAL_DATA 100172 72 | #define GLU_NURBS_NORMAL_DATA_EXT 100172 73 | #define GLU_NURBS_COLOR_DATA 100173 74 | #define GLU_NURBS_COLOR_DATA_EXT 100173 75 | #define GLU_NURBS_TEXTURE_COORD_DATA 100174 76 | #define GLU_NURBS_TEX_COORD_DATA_EXT 100174 77 | #define GLU_NURBS_END_DATA 100175 78 | #define GLU_NURBS_END_DATA_EXT 100175 79 | 80 | ; NurbsError 81 | #define GLU_NURBS_ERROR1 100251 ; spline order un-supported 82 | #define GLU_NURBS_ERROR2 100252 ; too few knots 83 | #define GLU_NURBS_ERROR3 100253 ; valid knot range is empty 84 | #define GLU_NURBS_ERROR4 100254 ; decreasing knot sequence 85 | #define GLU_NURBS_ERROR5 100255 ; knot multiplicity > spline order 86 | #define GLU_NURBS_ERROR6 100256 ; endcurve() must follow bgncurve() 87 | #define GLU_NURBS_ERROR7 100257 ; bgncurve() must precede endcurve() 88 | #define GLU_NURBS_ERROR8 100258 ; ctrlarray or knot vector is NULL 89 | #define GLU_NURBS_ERROR9 100259 ; can't draw pwlcurves 90 | #define GLU_NURBS_ERROR10 100260 ; missing gluNurbsCurve() 91 | #define GLU_NURBS_ERROR11 100261 ; missing gluNurbsSurface() 92 | #define GLU_NURBS_ERROR12 100262 ; endtrim() must precede endsurface() 93 | #define GLU_NURBS_ERROR13 100263 ; bgnsurface() must precede endsurface() 94 | #define GLU_NURBS_ERROR14 100264 ; curve of improper type passed as trim curve 95 | #define GLU_NURBS_ERROR15 100265 ; bgnsurface() must precede bgntrim() 96 | #define GLU_NURBS_ERROR16 100266 ; endtrim() must follow bgntrim() 97 | #define GLU_NURBS_ERROR17 100267 ; bgntrim() must precede endtrim() 98 | #define GLU_NURBS_ERROR18 100268 ; invalid or missing trim curve 99 | #define GLU_NURBS_ERROR19 100269 ; bgntrim() must precede pwlcurve() 100 | #define GLU_NURBS_ERROR20 100270 ; pwlcurve referenced twice 101 | #define GLU_NURBS_ERROR21 100271 ; pwlcurve and nurbscurve mixed 102 | #define GLU_NURBS_ERROR22 100272 ; improper usage of trim data type 103 | #define GLU_NURBS_ERROR23 100273 ; nurbscurve referenced twice 104 | #define GLU_NURBS_ERROR24 100274 ; nurbscurve and pwlcurve mixed 105 | #define GLU_NURBS_ERROR25 100275 ; nurbssurface referenced twice 106 | #define GLU_NURBS_ERROR26 100276 ; invalid property 107 | #define GLU_NURBS_ERROR27 100277 ; endsurface() must follow bgnsurface() 108 | #define GLU_NURBS_ERROR28 100278 ; intersecting or misoriented trim curves 109 | #define GLU_NURBS_ERROR29 100279 ; intersecting trim curves 110 | #define GLU_NURBS_ERROR30 100280 ; UNUSED 111 | #define GLU_NURBS_ERROR31 100281 ; unconnected trim curves 112 | #define GLU_NURBS_ERROR32 100282 ; unknown knot error 113 | #define GLU_NURBS_ERROR33 100283 ; negative vertex count encountered 114 | #define GLU_NURBS_ERROR34 100284 ; negative byte-stride 115 | #define GLU_NURBS_ERROR35 100285 ; unknown type descriptor 116 | #define GLU_NURBS_ERROR36 100286 ; null control point reference 117 | #define GLU_NURBS_ERROR37 100287 ; duplicate point on pwlcurve 118 | 119 | ; NurbsProperty 120 | #define GLU_AUTO_LOAD_MATRIX 100200 121 | #define GLU_CULLING 100201 122 | #define GLU_SAMPLING_TOLERANCE 100203 123 | #define GLU_DISPLAY_MODE 100204 124 | #define GLU_PARAMETRIC_TOLERANCE 100202 125 | #define GLU_SAMPLING_METHOD 100205 126 | #define GLU_U_STEP 100206 127 | #define GLU_V_STEP 100207 128 | #define GLU_NURBS_MODE 100160 129 | #define GLU_NURBS_MODE_EXT 100160 130 | #define GLU_NURBS_TESSELLATOR 100161 131 | #define GLU_NURBS_TESSELLATOR_EXT 100161 132 | #define GLU_NURBS_RENDERER 100162 133 | #define GLU_NURBS_RENDERER_EXT 100162 134 | 135 | ; NurbsSampling 136 | #define GLU_OBJECT_PARAMETRIC_ERROR 100208 137 | #define GLU_OBJECT_PARAMETRIC_ERROR_EXT 100208 138 | #define GLU_OBJECT_PATH_LENGTH 100209 139 | #define GLU_OBJECT_PATH_LENGTH_EXT 100209 140 | #define GLU_PATH_LENGTH 100215 141 | #define GLU_PARAMETRIC_ERROR 100216 142 | #define GLU_DOMAIN_DISTANCE 100217 143 | 144 | ; NurbsTrim 145 | #define GLU_MAP1_TRIM_2 100210 146 | #define GLU_MAP1_TRIM_3 100211 147 | 148 | ; QuadricDrawStyle 149 | #define GLU_POINT 100010 150 | #define GLU_LINE 100011 151 | #define GLU_FILL 100012 152 | #define GLU_SILHOUETTE 100013 153 | 154 | ; QuadricCallback 155 | ; GLU_ERROR 156 | 157 | ; QuadricNormal 158 | #define GLU_SMOOTH 100000 159 | #define GLU_FLAT 100001 160 | #define GLU_NONE 100002 161 | 162 | ; QuadricOrientation 163 | #define GLU_OUTSIDE 100020 164 | #define GLU_INSIDE 100021 165 | 166 | ; TessCallback 167 | #define GLU_TESS_BEGIN 100100 168 | #define GLU_BEGIN 100100 169 | #define GLU_TESS_VERTEX 100101 170 | #define GLU_VERTEX 100101 171 | #define GLU_TESS_END 100102 172 | #define GLU_END 100102 173 | #define GLU_TESS_ERROR 100103 174 | #define GLU_TESS_EDGE_FLAG 100104 175 | #define GLU_EDGE_FLAG 100104 176 | #define GLU_TESS_COMBINE 100105 177 | #define GLU_TESS_BEGIN_DATA 100106 178 | #define GLU_TESS_VERTEX_DATA 100107 179 | #define GLU_TESS_END_DATA 100108 180 | #define GLU_TESS_ERROR_DATA 100109 181 | #define GLU_TESS_EDGE_FLAG_DATA 100110 182 | #define GLU_TESS_COMBINE_DATA 100111 183 | 184 | ; TessContour 185 | #define GLU_CW 100120 186 | #define GLU_CCW 100121 187 | #define GLU_INTERIOR 100122 188 | #define GLU_EXTERIOR 100123 189 | #define GLU_UNKNOWN 100124 190 | 191 | ; TessProperty 192 | #define GLU_TESS_WINDING_RULE 100140 193 | #define GLU_TESS_BOUNDARY_ONLY 100141 194 | #define GLU_TESS_TOLERANCE 100142 195 | 196 | ; TessError 197 | #define GLU_TESS_ERROR1 100151 198 | #define GLU_TESS_ERROR2 100152 199 | #define GLU_TESS_ERROR3 100153 200 | #define GLU_TESS_ERROR4 100154 201 | #define GLU_TESS_ERROR5 100155 202 | #define GLU_TESS_ERROR6 100156 203 | #define GLU_TESS_ERROR7 100157 204 | #define GLU_TESS_ERROR8 100158 205 | #define GLU_TESS_MISSING_BEGIN_POLYGON 100151 206 | #define GLU_TESS_MISSING_BEGIN_CONTOUR 100152 207 | #define GLU_TESS_MISSING_END_POLYGON 100153 208 | #define GLU_TESS_MISSING_END_CONTOUR 100154 209 | #define GLU_TESS_COORD_TOO_LARGE 100155 210 | #define GLU_TESS_NEED_COMBINE_CALLBACK 100156 211 | 212 | ; TessWinding 213 | #define GLU_TESS_WINDING_ODD 100130 214 | #define GLU_TESS_WINDING_NONZERO 100131 215 | #define GLU_TESS_WINDING_POSITIVE 100132 216 | #define GLU_TESS_WINDING_NEGATIVE 100133 217 | #define GLU_TESS_WINDING_ABS_GEQ_TWO 100134 218 | 219 | ;*********************************************************** 220 | 221 | #import [ 222 | glulib calling [ 223 | gluBeginCurve: "gluBeginCurve" [ 224 | nurb [int-ptr!] ;GLUnurbs* 225 | ] 226 | 227 | gluBeginPolygon: "gluBeginPolygon" [ 228 | tess [int-ptr!] ;GLUtesselator* 229 | ] 230 | 231 | gluBeginSurface: "gluBeginSurface" [ 232 | nurb [int-ptr!] ;GLUnurbs* 233 | ] 234 | 235 | gluBeginTrim: "gluBeginTrim" [ 236 | nurb [int-ptr!] ;GLUnurbs* 237 | ] 238 | 239 | gluBuild1DMipmapLevels: "gluBuild1DMipmapLevels" [ 240 | target [GLenum] 241 | internalFormat [GLint] 242 | width [GLsizei] 243 | format [GLenum] 244 | type [GLenum] 245 | level [GLint] 246 | base [GLint] 247 | max [GLint] 248 | data [int-ptr!] ;void* 249 | return: [GLint] 250 | ] 251 | 252 | gluBuild1DMipmaps: "gluBuild1DMipmaps" [ 253 | target [GLenum] 254 | internalFormat [GLint] 255 | width [GLsizei] 256 | format [GLenum] 257 | type [GLenum] 258 | data [int-ptr!] ;void* 259 | return: [GLint] 260 | ] 261 | 262 | gluBuild2DMipmapLevels: "gluBuild2DMipmapLevels" [ 263 | target [GLenum] 264 | internalFormat [GLint] 265 | width [GLsizei] 266 | height [GLsizei] 267 | format [GLenum] 268 | type [GLenum] 269 | level [GLint] 270 | base [GLint] 271 | max [GLint] 272 | data [int-ptr!] ;void* 273 | return: [GLint] 274 | ] 275 | 276 | gluBuild2DMipmaps: "gluBuild2DMipmaps" [ 277 | target [GLenum] 278 | internalFormat [GLint] 279 | width [GLsizei] 280 | height [GLsizei] 281 | format [GLenum] 282 | type [GLenum] 283 | data [int-ptr!] ;void* 284 | return: [GLint] 285 | ] 286 | 287 | gluBuild3DMipmapLevels: "gluBuild3DMipmapLevels" [ 288 | target [GLenum] 289 | internalFormat [GLint] 290 | width [GLsizei] 291 | height [GLsizei] 292 | depth [GLsizei] 293 | format [GLenum] 294 | type [GLenum] 295 | level [GLint] 296 | base [GLint] 297 | max [GLint] 298 | data [int-ptr!] ;void* 299 | return: [GLint] 300 | ] 301 | 302 | gluBuild3DMipmaps: "gluBuild3DMipmaps" [ 303 | target [GLenum] 304 | internalFormat [GLint] 305 | width [GLsizei] 306 | height [GLsizei] 307 | depth [GLsizei] 308 | format [GLenum] 309 | type [GLenum] 310 | data [int-ptr!] ;void* 311 | return: [GLint] 312 | ] 313 | 314 | gluCheckExtension: "gluCheckExtension" [ 315 | extName [GLubyte] 316 | extString [GLubyte] 317 | return: [GLboolean] 318 | ] 319 | 320 | gluCylinder: "gluCylinder" [ 321 | quad [int-ptr!];GLUquadric* 322 | base [GLdouble] 323 | top [GLdouble] 324 | height [GLdouble] 325 | slices [GLint] 326 | stacks [GLint] 327 | ] 328 | 329 | gluDeleteNurbsRenderer: "gluDeleteNurbsRenderer" [ 330 | nurb [int-ptr!] ;GLUnurbs* 331 | ] 332 | 333 | gluDeleteQuadric: "gluDeleteQuadric" [ 334 | quad [int-ptr!];GLUquadric* 335 | ] 336 | 337 | 338 | gluDeleteTess: "gluDeleteTess" [ 339 | tess [int-ptr!] ;GLUtesselator* 340 | ] 341 | 342 | gluDisk: "gluDisk" [ 343 | quad [int-ptr!];GLUquadric* 344 | inner [GLdouble] 345 | outer [GLdouble] 346 | slices [GLint] 347 | loops [GLint] 348 | ] 349 | 350 | gluEndCurve: "gluEndCurve" [ 351 | nurb [int-ptr!] ; GLUnurbs* 352 | ] 353 | 354 | gluEndPolygon: "gluEndPolygon" [ 355 | tess [int-ptr!] ; GLUtesselator* 356 | ] 357 | 358 | gluEndSurface: "gluEndSurface" [ 359 | nurb [int-ptr!] ; GLUnurbs* 360 | ] 361 | 362 | gluEndTrim: "gluEndTrim" [ 363 | nurb [int-ptr!] ; GLUnurbs* 364 | ] 365 | 366 | gluErrorString: "gluErrorString" [ 367 | error [GLenum] 368 | return: [int-ptr!] ;GLubyte* 369 | ] 370 | 371 | gluGetNurbsProperty: "gluGetNurbsProperty" [ 372 | nurb [int-ptr!] ; GLUnurbs* 373 | property [GLenum] 374 | data [float-ptr!] ;GLfloat* 375 | ] 376 | 377 | gluGetString: "gluGetString" [ 378 | name [GLenum] 379 | return: [int-ptr!] ;GLubyte * 380 | ] 381 | 382 | gluGetTessProperty: "gluGetTessProperty" [ 383 | tess [int-ptr!] ; GLUtesselator* 384 | which [GLenum] 385 | data [Float-ptr!];GLdouble* 386 | ] 387 | 388 | gluLoadSamplingMatrices: "gluLoadSamplingMatrices" [ 389 | nurb [int-ptr!] ; GLUnurbs* 390 | GLfloat [float-ptr!] ; GLfloat* 391 | perspective [float-ptr!] ; GLfloat* 392 | view [int-ptr!] ; GLint* 393 | ] 394 | 395 | gluLookAt: "gluLookAt" [ 396 | eyeX [GLdouble] 397 | eyeY [GLdouble] 398 | eyeZ [GLdouble] 399 | centerX [GLdouble] 400 | centerY [GLdouble] 401 | centerZ [GLdouble] 402 | upX [GLdouble] 403 | upY [GLdouble] 404 | upZ [GLdouble] 405 | ] 406 | 407 | gluNewNurbsRenderer: "gluNewNurbsRenderer" [ 408 | return: [int-ptr!] ; GLUnurbs* 409 | ] 410 | 411 | gluNewQuadric: "gluNewQuadric" [ 412 | return: [int-ptr!];GLUquadric* 413 | ] 414 | 415 | 416 | gluNewTess: "gluNewTess" [ 417 | return: [int-ptr!] ; GLUtesselator* 418 | ] 419 | 420 | gluNextContour: "gluNextContour" [ 421 | tess [int-ptr!] ; GLUtesselator* 422 | type [GLenum] 423 | ] 424 | 425 | gluNurbsCallback: "gluNurbsCallback" [ 426 | nurb [int-ptr!] ; GLUnurbs* 427 | which [GLenum] 428 | CallBackFunc [int-ptr!] ;pointer to ccallback 429 | ] 430 | 431 | gluNurbsCallbackData: "gluNurbsCallbackData" [ 432 | nurb [int-ptr!] ; GLUnurbs* 433 | userData [int-ptr!];GLdata* 434 | ] 435 | 436 | gluNurbsCallbackDataEXT: "gluNurbsCallbackDataEXT" [ 437 | nurb [int-ptr!] ; GLUnurbs* 438 | userData [int-ptr!];GLdata* 439 | ] 440 | 441 | gluNurbsCurve: "gluNurbsCurve" [ 442 | nurb [int-ptr!] ; GLUnurbs* 443 | knotCount [GLint] 444 | *knots [float32-ptr!];GLfloat 445 | stride [GLint] 446 | *control [float32-ptr!];GLfloat 447 | order [GLint] 448 | type [GLenum] 449 | ] 450 | 451 | gluNurbsProperty: "gluNurbsProperty" [ 452 | nurb [int-ptr!] ; GLUnurbs* 453 | property [GLenum] 454 | value [GLfloat] 455 | ] 456 | 457 | gluNurbsSurface: "gluNurbsSurface" [ 458 | nurb [int-ptr!] ; GLUnurbs* 459 | sKnotCount [GLint] 460 | sKnots [float32-ptr!];GLfloat 461 | tKnotCount [GLint] 462 | tKnots [float32-ptr!];GLfloat 463 | sStride [GLint] 464 | tStride [GLint] 465 | control [float32-ptr!];GLfloat 466 | sOrder [GLint] 467 | tOrder [GLint] 468 | type [GLenum] 469 | ] 470 | 471 | 472 | gluOrtho2D: "gluOrtho2D" [ 473 | left [GLdouble] 474 | right [GLdouble] 475 | bottom [GLdouble] 476 | top [GLdouble] 477 | ] 478 | 479 | gluPartialDisk: "gluPartialDisk" [ 480 | quad [int-ptr!];GLUquadric* 481 | inner [GLdouble] 482 | outer [GLdouble] 483 | slices [GLint] 484 | loops [GLint] 485 | start [GLdouble] 486 | sweep [GLdouble] 487 | ] 488 | 489 | gluPerspective: "gluPerspective" [ 490 | fovy [GLdouble] 491 | aspect [GLdouble] 492 | zNear [GLdouble] 493 | zFar [GLdouble] 494 | ] 495 | 496 | gluPickMatrix: "gluPickMatrix" [ 497 | x [GLdouble] 498 | y [GLdouble] 499 | delX [GLdouble] 500 | delY [GLdouble] 501 | *viewport [int-ptr!] 502 | ] 503 | 504 | gluProject: "gluProject" [ 505 | objX [GLdouble] 506 | objY [GLdouble] 507 | objZ [GLdouble] 508 | *model [float-ptr!] 509 | *proj [float-ptr!] 510 | *view [int-ptr!] 511 | winX [float-ptr!] 512 | winY [float-ptr!] 513 | winZ [float-ptr!] 514 | none [float-ptr!] 515 | return: [GLint] 516 | ] 517 | 518 | gluPwlCurve: "gluPwlCurve" [ 519 | nurb [int-ptr!] ; GLUnurbs* 520 | count [GLint] 521 | data [float-ptr!];[GLfloat*] 522 | stride [GLint] 523 | type [GLenum] 524 | ] 525 | 526 | 527 | gluQuadricCallback: "gluQuadricCallback" [ 528 | quad [int-ptr!];[GLUquadric*] 529 | which [GLenum] 530 | *CallBackFunc [byte-ptr!] 531 | ] 532 | 533 | gluQuadricDrawStyle: "gluQuadricDrawStyle" [ 534 | quad [int-ptr!];[GLUquadric*] 535 | draw [GLenum] 536 | ] 537 | 538 | gluQuadricNormals: "gluQuadricNormals" [ 539 | quad [int-ptr!];[GLUquadric*] 540 | normal [GLenum] 541 | ] 542 | 543 | gluQuadricOrientation: "gluQuadricOrientation" [ 544 | quad [int-ptr!];[GLUquadric*] 545 | orientation [GLenum] 546 | ] 547 | 548 | gluQuadricTexture: "gluQuadricTexture" [ 549 | quad [int-ptr!];[GLUquadric*] 550 | texture [GLboolean] 551 | ] 552 | ;GLint gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, 553 | ;const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut) 554 | 555 | gluScaleImage: "gluScaleImage" [ 556 | format [GLenum] 557 | wIn [GLsizei] 558 | hIn [GLsizei] 559 | typeIn [GLenum] 560 | *dataIn [int-ptr!] 561 | wOut [GLsizei] 562 | hOut [GLsizei] 563 | typeOut [GLenum] 564 | dataOut [byte-ptr!] ;*void 565 | return: [GLint] 566 | ] 567 | 568 | gluSphere: "gluSphere" [ 569 | quad [int-ptr!];[GLUquadric*] 570 | radius [GLdouble] 571 | slices [GLint] 572 | stacks [GLint] 573 | ] 574 | 575 | gluTessBeginContour: "gluTessBeginContour" [ 576 | tess [int-ptr!] ; GLUtesselator* 577 | ] 578 | 579 | gluTessBeginPolygon: "gluTessBeginPolygon" [ 580 | tess [int-ptr!] ; GLUtesselator* 581 | data [byte-ptr!] ;[GLdata*] 582 | ] 583 | 584 | gluTessCallback: "gluTessCallback" [ 585 | tess [int-ptr!] ; GLUtesselator* 586 | which [GLenum] 587 | CallBackFunc [byte-ptr!];[GLdata] 588 | ] 589 | 590 | gluTessEndContour: "gluTessEndContour" [ 591 | tess [int-ptr!] ; GLUtesselator* 592 | ] 593 | 594 | gluTessEndPolygon: "gluTessEndPolygon" [ 595 | tess [int-ptr!] ; GLUtesselator* 596 | ] 597 | 598 | gluTessNormal: "gluTessNormal" [ 599 | tess [int-ptr!] ; GLUtesselator* 600 | valueX [GLdouble] 601 | valueY [GLdouble] 602 | valueZ [GLdouble] 603 | ] 604 | 605 | gluTessProperty: "gluTessProperty" [ 606 | tess [int-ptr!] ; GLUtesselator* 607 | which [GLenum] 608 | data [GLdouble] 609 | ] 610 | 611 | gluTessVertex: "gluTessVertex" [ 612 | tess [int-ptr!] ; GLUtesselator* 613 | *location [float-ptr!];[GLdouble] 614 | data [int-ptr!];[GLdata*] 615 | ] 616 | 617 | gluUnProject: "gluUnProject" [ 618 | winX [GLdouble] 619 | winY [GLdouble] 620 | winZ [GLdouble] 621 | *model [float-ptr!] 622 | *proj [float-ptr!] 623 | *view [int-ptr!] 624 | objX [float-ptr!] 625 | objY [float-ptr!] 626 | objZ [float-ptr!] 627 | return: [GLint] 628 | ] 629 | 630 | 631 | gluUnProject4: "gluUnProject4" [ 632 | winX [GLdouble] 633 | winY [GLdouble] 634 | winZ [GLdouble] 635 | clipW [GLdouble] 636 | *model [float-ptr!] 637 | *proj [float-ptr!] 638 | *view [int-ptr!] 639 | nearPlane [GLdouble] 640 | farPlane [GLdouble] 641 | objX [float-ptr!] 642 | objY [float-ptr!] 643 | objZ [float-ptr!] 644 | return: [GLint] 645 | ] 646 | 647 | ] 648 | ] 649 | 650 | 651 | 652 | -------------------------------------------------------------------------------- /lib/rpointers.reds: -------------------------------------------------------------------------------- 1 | Red/System [ 2 | Title: "GLFW Binding" 3 | Author: "François Jouen" 4 | Rights: "Copyright (c) 2013 François Jouen. All rights reserved." 5 | License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" 6 | ] 7 | 8 | ; *************** some pointers we need with Red/System ************************* 9 | ; * pointers 10 | 11 | ;int-ptr! is defined by red ; equivalent to C's byte * 12 | ;byte-ptr is defined by ; equivalent to C's int * 13 | ;#define float32-ptr! [pointer! [float32!]] ; equivalent to C's float * 14 | ; for 0.6.1 15 | ;#define float-ptr! [pointer! [Float!]] ; equivalent to C's double * 16 | 17 | ;** pointers 18 | #define double-byte-ptr! [struct! [ptr [byte-ptr!]]] ; equivalent to C's byte ** 19 | #define double-int-ptr! [struct! [ptr [int-ptr!]]] ; equivalent to C's int ** 20 | #define double-float-ptr! [struct! [ptr [float-ptr!]]] ; equivalent to C's double ** 21 | #define p-buffer! [struct! [buffer [c-string!]]] ; equivalent to C's char ** 22 | 23 | ; *************** ************************************* ************************* 24 | -------------------------------------------------------------------------------- /samples/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/.DS_Store -------------------------------------------------------------------------------- /samples/red/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/red/.DS_Store -------------------------------------------------------------------------------- /samples/red/compiled_OSX/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/red/compiled_OSX/.DS_Store -------------------------------------------------------------------------------- /samples/red/compiled_OSX/defaults: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/red/compiled_OSX/defaults -------------------------------------------------------------------------------- /samples/redS/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/.DS_Store -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/.DS_Store -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/accuracy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/accuracy -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/clipboard: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/clipboard -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/defaults: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/defaults -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/events: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/events -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/fsaa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/fsaa -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/gamma: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/gamma -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/glfwinfo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/glfwinfo -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/modes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/modes -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/peter: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/peter -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/quad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/quad -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/sharing: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/sharing -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/simple: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/simple -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/splitview: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/splitview -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/tearing: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/tearing -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/test -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/title: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/title -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/triangle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/triangle -------------------------------------------------------------------------------- /samples/redS/compiled_OSX/windows: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldci/glfw-red/79c8c123f67219d826bd61844b636290be7fe637/samples/redS/compiled_OSX/windows -------------------------------------------------------------------------------- /samples/redS/test.reds: -------------------------------------------------------------------------------- 1 | Red/System [ Title: "GLFW3 Binding: test" Author: "F.Jouen" Rights: "Copyright (c) 2013-2017 Francois Jouen. All rights reserved." License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt" ] #include %../../lib/glfw3.reds print [glfwInit lf] print ["Lib is : " glfw3 lf] print ["Major Version: " GLFW_VERSION_MAJOR lf] print ["Minor Version: " GLFW_VERSION_MINOR lf] print ["Version: " glfwGetVersionString lf] monitor: glfwGetPrimaryMonitor print ["Monitor: " glfwGetMonitorName monitor lf] width: declare pointer! [integer!] height: declare pointer! [integer!] glfwGetMonitorPhysicalSize monitor width height print ["Monitor Size: " width/value "x" height/value lf] print ["Timer Frequency: " glfwGetTimerFrequency lf] print ["Vulkan supported: " glfwVulkanSupported lf] glfwTerminate --------------------------------------------------------------------------------