├── README.md ├── apps └── magickview │ ├── flower_jegx.jpg │ ├── lua │ ├── dnd.lua │ ├── frame.lua │ ├── init.lua │ ├── init_mouse_rpi.lua │ └── init_shaders.lua │ ├── main.xml │ ├── readme.md │ └── screenshots │ ├── _._ │ └── geexlab-app-magickview-01.jpg ├── demos ├── conservative-rasterization │ ├── frame.lua │ ├── init.lua │ ├── main.xml │ ├── readme.md │ └── screenshots │ │ ├── geexlab-conservative-rasterization-03.png │ │ └── geexlab-conservative-rasterization-04.png ├── heightmap-normal-computing │ ├── demo.xml │ ├── frame.lua │ ├── lighting_ps.glsl │ ├── lighting_vs.glsl │ ├── readme.md │ └── screenshots │ │ ├── _._ │ │ ├── geexlab-heightmap-normal-computing-demo-01.jpg │ │ └── geexlab-heightmap-normal-computing-demo-02.jpg ├── imgui-lot-of-windows │ ├── main-opengl.xml │ ├── main-vulkan.xml │ ├── readme.md │ └── screenshots │ │ ├── _ │ │ ├── geexlab-lot-of-imgui-windows-demo-opengl-02.jpg │ │ └── geexlab-lot-of-imgui-windows-demo-vulkan-02.jpg ├── loops │ ├── assets │ │ ├── _-_ │ │ ├── shaders │ │ │ ├── _-_ │ │ │ ├── lighting_prog_ps_gl21.glsl │ │ │ ├── lighting_prog_ps_gl32.glsl │ │ │ ├── lighting_prog_vs_gl21.glsl │ │ │ └── lighting_prog_vs_gl32.glsl │ │ └── textures │ │ │ ├── _-_ │ │ │ └── white_black_border.jpg │ ├── loop_099_gl21.xml │ ├── loop_104_gl21.xml │ ├── loops │ │ ├── loop_099.lua │ │ └── loop_104.lua │ ├── lua │ │ ├── _-_ │ │ ├── frame.lua │ │ ├── init.lua │ │ ├── resize.lua │ │ ├── terminate.lua │ │ └── utils.lua │ ├── readme.md │ └── screenshots │ │ ├── _-_ │ │ ├── geexlab-demo-loop-099.jpg │ │ └── geexlab-demo-loop-104.jpg ├── nv-shader-thread-group │ ├── main.xml │ ├── readme.md │ └── screenshots │ │ ├── _-_ │ │ └── geexlab-shader-thread-group-nv-demo-01.png ├── physx3 │ └── image-viewer │ │ ├── data │ │ ├── Concrete_sidewalk_1k_d.jpg │ │ ├── _ │ │ ├── ground061.jpg │ │ └── pexels-photo-289225.jpeg │ │ ├── lua │ │ ├── _ │ │ ├── dnd.lua │ │ ├── frame.lua │ │ └── init.lua │ │ ├── main.xml │ │ ├── readme.md │ │ └── screenshots │ │ ├── _ │ │ ├── geexlab-physx-image-viewer-02.jpg │ │ ├── geexlab-physx-image-viewer-05.jpg │ │ ├── geexlab-physx-image-viewer-06.jpg │ │ ├── geexlab-physx-image-viewer-07.jpg │ │ └── geexlab-physx-image-viewer-08.jpg ├── rings-of-cubes │ ├── assets │ │ ├── shaders │ │ │ ├── lighting_prog_ps_gl21.glsl │ │ │ ├── lighting_prog_ps_gl32.glsl │ │ │ ├── lighting_prog_vs_gl21.glsl │ │ │ ├── lighting_prog_vs_gl32.glsl │ │ │ └── readme │ │ └── textures │ │ │ ├── readme.txt │ │ │ └── white_black_border.jpg │ ├── frame.lua │ ├── init.lua │ ├── main_gl21.xml │ ├── main_gl32.xml │ ├── readme.md │ ├── resize.lua │ ├── screenshots │ │ ├── geexlab-rings-demo-32-cubes-16-rings.jpg │ │ ├── geexlab-rings-demo-64-cubes-16-rings.jpg │ │ └── geexlab-rings-demo-64-cubes-32-rings.jpg │ ├── terminate.lua │ └── utils.lua ├── shader-2d-grid │ ├── readme.md │ ├── screenshots │ │ ├── _ │ │ ├── geexlab-2d-grid-glsl-demo-01.png │ │ └── geexlab-2d-grid-glsl-demo-02.png │ ├── simple-2d-grid-gl21.xml │ └── simple-2d-grid-gl32.xml ├── shader-fire │ ├── assets │ │ ├── 1010.jpg │ │ ├── _._ │ │ ├── distortion.jpg │ │ ├── gradient02.jpg │ │ ├── gradient03.jpg │ │ ├── noise03.jpg │ │ └── noise06a.jpg │ ├── frag.txt │ ├── frame.lua │ ├── main.xml │ ├── readme.md │ └── screenshots │ │ ├── _._ │ │ └── geexlab-simple-fire-shader-glsl-01.jpg ├── shader-wireframe │ ├── demo_gl32.xml │ ├── demo_gles31.xml │ ├── frame.lua │ ├── init.lua │ ├── readme.md │ ├── screenshots │ │ ├── _._ │ │ ├── geexlab-wireframe-shader-demo-opengl-32-01.jpg │ │ ├── geexlab-wireframe-shader-demo-opengl-32-02.jpg │ │ ├── geexlab-wireframe-shader-demo-opengl-32-03.jpg │ │ └── geexlab-wireframe-shader-demo-opengl-es-31-04.jpg │ └── shaders │ │ ├── _._ │ │ ├── gl32_gs.glsl │ │ ├── gl32_ps.glsl │ │ ├── gles3_gs.glsl │ │ └── gles3_ps.glsl └── shadertoy │ ├── common │ ├── _ │ ├── _frame_begin.lua │ ├── _frame_end.lua │ ├── _init.lua │ ├── _readme_utils.txt │ ├── _resize.lua │ ├── _terminate.lua │ └── _vs_gl2.glsl │ ├── data │ ├── _ │ ├── ground010.jpg │ ├── tex01.jpg │ ├── tex02.jpg │ ├── tex03.jpg │ ├── tex05.jpg │ ├── tex06.jpg │ ├── tex09.jpg │ ├── tex10.png │ ├── tex11.png │ ├── tex16.png │ ├── tex17.jpg │ ├── tex18.jpg │ ├── tex19.png │ └── tex21.png │ ├── dual-3d-truchet-tiles-opengl21.xml │ ├── dual-3d-truchet-tiles-vulkan.xml │ ├── ps-gl21-4l2cD3.glsl │ ├── readme.md │ ├── screenshots │ ├── _ │ ├── geexlab-shadertoy-dual-3d-truchet-tiles-vulkan.jpg │ └── shadertoy-dual-3d-truchet-tiles.jpg │ └── spirv │ ├── _ │ ├── s01-vs.spv │ ├── s01-vs.vert │ ├── s03-ps.frag │ └── s03-ps.spv └── learn-pack ├── 01-basic ├── 01-clear-screen │ ├── main.xml │ └── readme.md ├── 02-hello-world │ ├── hello_world_v1.xml │ ├── hello_world_v2.xml │ ├── readme.md │ └── v3 │ │ ├── frame.lua │ │ ├── init.lua │ │ ├── main.xml │ │ ├── readme.md │ │ └── super_init.lua ├── 03-line │ └── main.xml └── 04-triangle │ └── main.xml └── readme.md /README.md: -------------------------------------------------------------------------------- 1 | GeeXLab codes samples and demos 2 | 3 | GeeXLab is a powerful and easy-to-learn cross-platform tool for 3D programming, demos creation, game development, interactive applications, creative coding and prototyping. You can program GeeXLab demos and applications in Lua or in Python. GeeXLab supports OpenGL, OpenGL ES, Vulkan and Direct3D 12. 4 | 5 | Homepage: 6 |
7 | https://geeks3d.com/geexlab/ 8 | 9 | Learning pack: 10 |
11 | https://geeks3d.com/geexlab/gdr/learn-code-samples.php 12 | 13 | Misc demos: 14 |
15 | https://geeks3d.com/geexlab/gdr/demos.php 16 | -------------------------------------------------------------------------------- /apps/magickview/flower_jegx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/apps/magickview/flower_jegx.jpg -------------------------------------------------------------------------------- /apps/magickview/lua/dnd.lua: -------------------------------------------------------------------------------- 1 | 2 | local num_files = gh_utils.drop_files_get_num_files() 3 | if (num_files > 0) then 4 | local full_path = gh_utils.drop_files_get_file_by_index(0) 5 | --print("DND - " .. full_path) 6 | filename_src = full_path 7 | load_image_dnd = 1 8 | load_image = 1 9 | end 10 | 11 | -------------------------------------------------------------------------------- /apps/magickview/lua/init.lua: -------------------------------------------------------------------------------- 1 | 2 | local demo_dir = gh_utils.get_demo_dir() 3 | local lib_dir = gh_utils.get_scripting_libs_dir() 4 | 5 | dofile(lib_dir .. "lua/libfont/libfont1.lua") 6 | dofile(lib_dir .. "lua/imgui.lua") 7 | 8 | 9 | 10 | 11 | 12 | winW, winH = gh_window.getsize(0) 13 | 14 | 15 | camera_ortho = gh_camera.create_ortho(-winW/2, winW/2, -winH/2, winH/2, 1.0, 10.0) 16 | gh_camera.set_viewport(camera_ortho, 0, 0, winW, winH) 17 | gh_camera.set_position(camera_ortho, 0, 0, 4) 18 | 19 | 20 | 21 | 22 | dofile(demo_dir .. "lua/init_shaders.lua") 23 | --vertex_color_prog = gh_node.getid("vertex_color_prog") 24 | --texture_prog = gh_node.getid("texture_prog") 25 | --gh_gpu_program.uniform1i(texture_prog, "tex0", 0) 26 | 27 | 28 | 29 | is_rpi = 0 30 | if (gh_utils.get_platform() == 4) then 31 | is_rpi = 1 32 | end 33 | 34 | 35 | 36 | if (is_rpi == 1) then 37 | dofile(demo_dir .. "lua/init_mouse_rpi.lua") 38 | mouse_init() 39 | end 40 | 41 | 42 | 43 | 44 | quad = gh_mesh.create_quad(256, 256) 45 | 46 | selection_quad = gh_mesh.create_quad(16, 16) 47 | gh_mesh.set_vertices_color(selection_quad, 0.5, 0.5, 0.8, 0.5) 48 | gh_mesh.resize_quad(selection_quad, 0, 0) -- invisible quad 49 | 50 | -- gh_mesh.set_vertex_color(selection_quad, 0, 1.0, 0.0, 0.0, 1.0) 51 | -- gh_mesh.set_vertex_color(selection_quad, 1, 0.0, 1.0, 0.0, 1.0) 52 | -- gh_mesh.set_vertex_color(selection_quad, 2, 0.0, 0.0, 1.0, 1.0) 53 | -- gh_mesh.set_vertex_color(selection_quad, 3, 1.0, 1.0, 0.0, 1.0) 54 | 55 | 56 | tex0 = 0 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | image_negate = 0 67 | image_quantize = 0 68 | image_posterize = 0 69 | image_sketch = 0 70 | image_solarize = 0 71 | image_swirl = 0 72 | image_emboss = 0 73 | image_charcoal = 0 74 | image_crop = 0 75 | image_oil_paint = 0 76 | image_encipher = 0 77 | image_decipher = 0 78 | image_flip = 0 79 | image_flop = 0 80 | image_transpose = 0 81 | image_wave = 0 82 | 83 | image_info = "" 84 | load_image_dnd = 0 85 | load_image = 0 86 | save_image = 0 87 | filename_src = "" 88 | filename_dst = "" 89 | image_src_w = 0 90 | image_src_h = 0 91 | exif_info = {} 92 | exif_num_props = 0 93 | 94 | 95 | need_init_selection_quad = 1 96 | selection_start_x = 0 97 | selection_start_y = 0 98 | selection_end_x = 0 99 | selection_end_y = 0 100 | old_mouse_x = 0 101 | old_mouse_y = 0 102 | 103 | image_selection_start_x = 0 104 | image_selection_start_y = 0 105 | image_selection_end_x = 0 106 | image_selection_end_y = 0 107 | 108 | image_selection_rect = {x=0, y=0, w=0, h=0} 109 | 110 | 111 | image_quad_w = 0 112 | image_quad_h = 0 113 | 114 | 115 | g_is_imgui_window_hovered = 0 116 | 117 | 118 | gh_renderer.set_vsync(1) 119 | 120 | 121 | 122 | 123 | 124 | 125 | ------------------------------------------------------------------ 126 | 127 | function UpdateQuadSize() 128 | if (tex0 > 0) then 129 | local w, h = gh_texture.get_size(tex0) 130 | image_src_w = w 131 | image_src_h = h 132 | ---[[ 133 | if (w > (0.9*winW)) then 134 | local ratio = w/h 135 | w = 0.9*winW 136 | h = w/ratio 137 | end 138 | 139 | if (h > (0.9*winH)) then 140 | local ratio = w/h 141 | h = 0.9*winH 142 | w = h * ratio 143 | end 144 | --]] 145 | 146 | image_quad_w = w 147 | image_quad_h = h 148 | gh_mesh.resize_quad(quad, w, h) 149 | 150 | end 151 | end 152 | 153 | 154 | 155 | function update_exif_data(filename) 156 | -- Read EXIF info 157 | -- 158 | gh_imagemagick.file_exif_to_log(filename) 159 | 160 | local num_props = gh_imagemagick.file_exif_get_num_properties(filename) 161 | for i=1, num_props do 162 | local property_name, property_value = gh_imagemagick.file_exif_get_property(filename, i-1) 163 | exif_info[i] = {name=property_name, value=property_value} 164 | end 165 | exif_num_props = num_props 166 | end 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | ------------------------------------------------------------------ 177 | -- Load a default image 178 | ------------------------------------------------------------------ 179 | 180 | filename_src = demo_dir .. "flower_jegx.jpg" 181 | 182 | local im_width, im_height, im_format = gh_imagemagick.file_ping(filename_src) 183 | image_info = string.format("image info - width:%0.f - height:%0.f - format:%s", im_width, im_height, im_format) 184 | print(image_info) 185 | 186 | -- Read EXIF info 187 | -- 188 | update_exif_data(filename_src) 189 | 190 | 191 | 192 | local PF_U8_RGB = 1 193 | local PF_U8_RGBA = 3 194 | local pixel_format = PF_U8_RGBA 195 | 196 | local gen_mipmaps = 0 197 | local free_cpu_memory = 0 198 | local upload_to_gpu = 1 199 | tex0 = gh_imagemagick.texture_create_from_file(filename_src, pixel_format, gen_mipmaps, free_cpu_memory, upload_to_gpu) 200 | 201 | UpdateQuadSize() 202 | 203 | load_image = 0 204 | 205 | 206 | 207 | -------------------------------------------------------------------------------- /apps/magickview/lua/init_mouse_rpi.lua: -------------------------------------------------------------------------------- 1 | 2 | mouse_texture = 0 3 | mouse_quad = 0 4 | mouse_prog = 0 5 | mouse_quad_width = 20 6 | mouse_quad_height = 20 7 | 8 | function mouse_init_gpu_program() 9 | 10 | local vs_gl3=" \ 11 | in vec4 gxl3d_Position;\ 12 | in vec4 gxl3d_TexCoord0;\ 13 | uniform mat4 gxl3d_ModelViewProjectionMatrix; \ 14 | out vec4 Vertex_UV;\ 15 | void main() \ 16 | { \ 17 | gl_Position = gxl3d_ModelViewProjectionMatrix * gxl3d_Position;\ 18 | Vertex_UV = gxl3d_TexCoord0;\ 19 | }" 20 | 21 | local ps_gl3=" \ 22 | uniform sampler2D tex0;\ 23 | uniform vec4 color;\ 24 | in vec4 Vertex_UV;\ 25 | out vec4 FragColor;\ 26 | void main() \ 27 | { \ 28 | vec2 uv = Vertex_UV.xy;\ 29 | uv.y *= -1.0;\ 30 | vec4 t = texture(tex0,uv);\ 31 | if ((t.r == 1.0) && (t.g < 1.0) && (t.g < 1.0))\ 32 | FragColor = color; \ 33 | else \ 34 | discard;\ 35 | }" 36 | 37 | local vs_gl2=" \ 38 | varying vec4 Vertex_UV;\ 39 | void main() \ 40 | { \ 41 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\ 42 | Vertex_UV = gl_MultiTexCoord0;\ 43 | }" 44 | 45 | local ps_gl2=" \ 46 | uniform sampler2D tex0;\ 47 | uniform vec4 color;\ 48 | varying vec4 Vertex_UV;\ 49 | void main() \ 50 | { \ 51 | vec2 uv = Vertex_UV.xy;\ 52 | uv.y *= -1.0;\ 53 | vec4 t = texture2D(tex0,uv);\ 54 | if ((t.r == 1.0) && (t.g < 1.0) && (t.g < 1.0))\ 55 | gl_FragColor = color; \ 56 | else \ 57 | discard;\ 58 | }" 59 | 60 | local vs_gles2=" \ 61 | attribute vec4 gxl3d_Position;\ 62 | attribute vec4 gxl3d_TexCoord0;\ 63 | uniform mat4 gxl3d_ModelViewProjectionMatrix; \ 64 | varying vec4 Vertex_UV;\ 65 | void main() \ 66 | { \ 67 | gl_Position = gxl3d_ModelViewProjectionMatrix * gxl3d_Position;\ 68 | Vertex_UV = gxl3d_TexCoord0;\ 69 | }" 70 | 71 | local ps_gles2=" \ 72 | uniform sampler2D tex0;\ 73 | uniform highp vec4 color;\ 74 | varying highp vec4 Vertex_UV;\ 75 | void main() \ 76 | { \ 77 | highp vec2 uv = Vertex_UV.xy;\ 78 | uv.y *= -1.0;\ 79 | highp vec4 t = texture2D(tex0,uv);\ 80 | if ((t.r == 1.0) && (t.g < 1.0) && (t.b < 1.0))\ 81 | gl_FragColor = color; \ 82 | else \ 83 | discard;\ 84 | }" 85 | 86 | 87 | if (gh_renderer.is_opengl_es() == 1) then 88 | vs = vs_gles2 89 | ps = ps_gles2 90 | else 91 | vs = vs_gl3 92 | ps = ps_gl3 93 | end 94 | 95 | mouse_prog = gh_gpu_program.create_v2("mouse_prog", vs, ps) 96 | gh_gpu_program.uniform1i(mouse_prog, "tex0", 0) 97 | end 98 | 99 | 100 | 101 | 102 | 103 | function mouse_init() 104 | if (mouse_texture == 0) then 105 | local lib_dir = gh_utils.get_scripting_libs_dir() 106 | local PF_U8_RGBA = 3 107 | mouse_texture = gh_texture.create_from_file(lib_dir .. "common/mouse-pointer-md.png", PF_U8_RGBA, 1) 108 | end 109 | 110 | if (mouse_quad == 0) then 111 | mouse_quad = gh_mesh.create_quad(mouse_quad_width, mouse_quad_height) 112 | end 113 | 114 | if (mouse_prog == 0) then 115 | mouse_init_gpu_program() 116 | end 117 | end 118 | 119 | 120 | function mouse_draw(ortho_cam, x, y) 121 | gh_camera.bind(ortho_cam) 122 | gh_renderer.set_depth_test_state(0) 123 | gh_texture.bind(mouse_texture, 0) 124 | gh_gpu_program.bind(mouse_prog) 125 | gh_gpu_program.uniform4f(mouse_prog, "color", 1.0, 1.0, 1.0, 1.0) 126 | gh_object.set_position(mouse_quad, x + mouse_quad_width/2, y - mouse_quad_height/2, 0) 127 | gh_object.render(mouse_quad) 128 | end 129 | -------------------------------------------------------------------------------- /apps/magickview/lua/init_shaders.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | local vertex_color_vs_gl2="\ 5 | #version 120\ 6 | void main()\ 7 | {\ 8 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \ 9 | gl_FrontColor = gl_Color;\ 10 | }" 11 | 12 | local vertex_color_ps_gl2=" \ 13 | #version 120\ 14 | void main()\ 15 | {\ 16 | gl_FragColor = gl_Color;\ 17 | }" 18 | 19 | 20 | local vertex_color_vs_gles2=" \ 21 | attribute vec4 gxl3d_Position; \ 22 | attribute vec4 gxl3d_Color; \ 23 | uniform mat4 gxl3d_ModelViewProjectionMatrix; \ 24 | varying vec4 Vertex_Color;\ 25 | void main()\ 26 | {\ 27 | gl_Position = gxl3d_ModelViewProjectionMatrix * gxl3d_Position;\ 28 | Vertex_Color = gxl3d_Color;\ 29 | }" 30 | 31 | local vertex_color_ps_gles2=" \ 32 | varying highp vec4 Vertex_Color; \ 33 | void main()\ 34 | {\ 35 | gl_FragColor = Vertex_Color;\ 36 | }" 37 | 38 | 39 | 40 | local vs = "" 41 | local ps = "" 42 | 43 | --[[ 44 | -- TODO 45 | -- 46 | if (gh_renderer.is_opengl_es() == 1) then 47 | vs = vs_gles2 48 | ps = ps_gles2 49 | else 50 | if (gh_renderer.get_api_version_major() < 3) then 51 | vs = vs_gl2 52 | ps = ps_gl2 53 | else 54 | if (gh_renderer.get_api_version_major() == 3) then 55 | if (gh_renderer.get_api_version_minor() < 2) then 56 | vs = vs_gl30 57 | ps = ps_gl30 58 | else 59 | vs = vs_gl32 60 | ps = ps_gl32 61 | end 62 | end 63 | if (gh_renderer.get_api_version_minor() > 3) then 64 | vs = vs_gl32 65 | ps = ps_gl32 66 | end 67 | end 68 | end 69 | --]] 70 | 71 | if (gh_renderer.is_opengl_es() == 1) then 72 | vs = vertex_color_vs_gles2 73 | ps = vertex_color_ps_gles2 74 | else 75 | vs = vertex_color_vs_gl2 76 | ps = vertex_color_ps_gl2 77 | end 78 | 79 | vertex_color_prog = gh_gpu_program.create_v2("vertex_color_prog", vs, ps) 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | local texture_vs_gl2="\ 91 | #version 120\ 92 | void main()\ 93 | {\ 94 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \ 95 | gl_TexCoord[0] = gl_MultiTexCoord0;\ 96 | }" 97 | 98 | local texture_ps_gl2=" \ 99 | #version 120\ 100 | uniform sampler2D tex0;\ 101 | void main()\ 102 | {\ 103 | vec2 uv = gl_TexCoord[0].xy;\ 104 | uv.y *= -1.;\ 105 | vec4 c = texture2D(tex0, uv);\ 106 | gl_FragColor = c;\ 107 | }" 108 | 109 | 110 | local texture_vs_gles2=" \ 111 | attribute vec4 gxl3d_Position; \ 112 | attribute vec4 gxl3d_TexCoord0; \ 113 | uniform mat4 gxl3d_ModelViewProjectionMatrix; // GeeXLab built-in uniform.\ 114 | varying vec4 Vertex_UV;\ 115 | void main()\ 116 | {\ 117 | gl_Position = gxl3d_ModelViewProjectionMatrix * gxl3d_Position;\ 118 | Vertex_UV = gxl3d_TexCoord0;\ 119 | }" 120 | 121 | local texture_ps_gles2=" \ 122 | precision highp float;\ 123 | uniform sampler2D tex0;\ 124 | varying vec4 Vertex_UV;\ 125 | void main()\ 126 | {\ 127 | vec2 uv = Vertex_UV.xy;\ 128 | uv.y *= -1.0;\ 129 | vec4 c = texture2D(tex0, uv);\ 130 | gl_FragColor = c;\ 131 | }" 132 | 133 | 134 | if (gh_renderer.is_opengl_es() == 1) then 135 | vs = texture_vs_gles2 136 | ps = texture_ps_gles2 137 | else 138 | vs = texture_vs_gl2 139 | ps = texture_ps_gl2 140 | end 141 | 142 | texture_prog = gh_gpu_program.create_v2("texture_prog", vs, ps) 143 | 144 | gh_gpu_program.uniform1i(phong_tex_prog, "tex0", 0) 145 | -------------------------------------------------------------------------------- /apps/magickview/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 36 | 37 | 38 | 39 | 40 | 41 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /apps/magickview/readme.md: -------------------------------------------------------------------------------- 1 | MagickView is an tiny image viewer coded with GeeXLab in Lua. Images are loaded with the ImageMagick plugin and converted to textures. You can drag-and-drop images into MagickView or use the Load image button. The ImageMagick plugin supports around 200 images formats (see list here). 2 | 3 | If supported by the image format, EXIF data is displayed. 4 | 5 | MagickView supports Windows, Linux, macOS, Raspberry Pi and Tinker Board. 6 | 7 | MagickView requires GeeXLab: 8 |
9 | - https://www.geeks3d.com/geexlab/downloads/ 10 | 11 | 12 | 13 | 14 | Related articles: 15 |
16 | - https://www.geeks3d.com/hacklab/20180608/how-to-read-exif-data-with-imagemagick-plugin/ 17 | - https://www.geeks3d.com/hacklab/20180402/list-of-image-formats-supported-by-the-imagemagick-plugin/ 18 | 19 | 20 | Screenshots: 21 |
22 | ![alt text](https://github.com/jegx/geexlab/blob/master/apps/magickview/screenshots/geexlab-app-magickview-01.jpg) 23 | -------------------------------------------------------------------------------- /apps/magickview/screenshots/_._: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /apps/magickview/screenshots/geexlab-app-magickview-01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/apps/magickview/screenshots/geexlab-app-magickview-01.jpg -------------------------------------------------------------------------------- /demos/conservative-rasterization/frame.lua: -------------------------------------------------------------------------------- 1 | 2 | local elapsed_time = gh_utils.get_elapsed_time() 3 | 4 | 5 | 6 | local PRIMITIVE_TRIANGLE = 0 7 | local PRIMITIVE_TRIANGLE_STRIP = 1 8 | local PRIMITIVE_LINE = 2 9 | local PRIMITIVE_LINE_STRIP = 3 10 | local PRIMITIVE_LINE_LOOP = 4 11 | local PRIMITIVE_LINE_ADJACENCY = 5 12 | local PRIMITIVE_LINE_STRIP_ADJACENCY = 6 13 | local PRIMITIVE_PATCH = 7 14 | local PRIMITIVE_POINT = 8 15 | 16 | 17 | 18 | 19 | -- Bind the render target. Now the 3D rendering goes to the render 20 | -- target and no longer in regular framebuffer. 21 | -- 22 | gh_render_target.bind(rt01) 23 | 24 | 25 | gh_renderer.set_viewport(0, 0, 32, 32) 26 | gh_renderer.clear_color_depth_buffers(0.4, 0.4, 0.4, 1.0, 1.0) 27 | 28 | gh_renderer.disable_state("GL_CULL_FACE") 29 | 30 | 31 | gh_renderer.wireframe() 32 | 33 | 34 | gh_renderer.set_depth_test_state(0) 35 | gh_gpu_program.bind(cr_prog) 36 | 37 | 38 | -- Rendering with conservative rasterization. 39 | -- 40 | if (show_conservative_raster == 1) then 41 | 42 | -- Update uniforms directly in the renderer. 43 | gh_gpu_program.gpu_uniform1f(cr_prog, "vertexscale", 1.0) 44 | gh_gpu_program.gpu_uniform4f(cr_prog, "pixelcolor", 1.0, 0.5, 0.0, 1.0) 45 | 46 | 47 | gh_renderer.enable_state("GL_CONSERVATIVE_RASTERIZATION_NV") 48 | gh_renderer.conservative_rasterization_set_sub_pixel_precision_bias_nv(xbits, ybits) 49 | 50 | -- Attributeless rendering. 51 | gh_renderer.draw_primitives(PRIMITIVE_TRIANGLE, 0, 3) 52 | 53 | gh_renderer.disable_state("GL_CONSERVATIVE_RASTERIZATION_NV") 54 | end 55 | 56 | 57 | 58 | -- Normal rendering 59 | -- 60 | gh_gpu_program.gpu_uniform4f(cr_prog, "pixelcolor", 1.0, 1.0, 1.0, 1.0) 61 | -- Attributeless rendering. 62 | gh_renderer.draw_primitives(PRIMITIVE_TRIANGLE, 0, 3) 63 | 64 | 65 | 66 | gh_renderer.solid() 67 | 68 | 69 | 70 | 71 | 72 | 73 | -- Back to regular framebuffer. 74 | -- 75 | gh_render_target.unbind(rt01) 76 | 77 | 78 | 79 | 80 | 81 | 82 | gh_renderer.set_viewport(0, 0, winW, winH) 83 | gh_renderer.clear_color_buffer(0.0, 0.0, 0.0, 1.0, 1.0) 84 | 85 | gh_renderer.set_depth_test_state(0) 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -- Binds the render target texture... 95 | -- 96 | gh_texture.rt_color_bind(rt01, 0) 97 | 98 | -- Binding of the render target viewer GPU program. 99 | -- 100 | gh_gpu_program.bind(tex_prog) 101 | gh_gpu_program.gpu_uniform1i(tex_prog, "tex0", 0) 102 | gh_gpu_program.gpu_uniform1f(tex_prog, "vscale", 1.0/render_target_scale) 103 | 104 | 105 | -- Rendering of the postfx fullscreen quad. 106 | -- Attributeless rendering. 107 | -- 108 | gh_renderer.draw_primitives(PRIMITIVE_TRIANGLE_STRIP, 0, 4) 109 | 110 | 111 | 112 | 113 | 114 | 115 | --------------------------------------------------- 116 | -- ImGui interface - Control panel 117 | -- 118 | imgui_frame_begin() 119 | 120 | gh_imgui.set_color(IMGUI_WINDOW_BG_COLOR, 0.1, 0.1, 0.1, 0.6) 121 | 122 | local is_open = imgui_window_begin_v1("Control panel", 400, 300, 20, 20) 123 | if (is_open == 1) then 124 | 125 | 126 | gh_imgui.text_rgba("NVIDIA conservative rasterization", 1.0, 1.0, 0.0, 1.0) 127 | gh_imgui.text_rgba("GL_NV_conservative_raster", 1.0, 0.5, 0.0, 1.0) 128 | gh_imgui.text("Press [ESC] to quit the demo") 129 | 130 | imgui_vertical_space() 131 | imgui_vertical_space() 132 | 133 | gh_imgui.text("conservative_rasterization_get_properties_nv()") 134 | gh_imgui.text("- bias_xbits: " .. bias_xbits) 135 | gh_imgui.text("- bias_ybits: " .. bias_ybits) 136 | gh_imgui.text("- max_bias_bits: " .. max_bias_bits) 137 | 138 | imgui_vertical_space() 139 | imgui_vertical_space() 140 | imgui_vertical_space() 141 | imgui_vertical_space() 142 | 143 | if (show_conservative_raster == 1) then 144 | if (gh_imgui.button("Disable conservative rasterization", 250, 20) == 1) then 145 | show_conservative_raster = 0 146 | end 147 | else 148 | if (gh_imgui.button("Enable conservative rasterization", 250, 20) == 1) then 149 | show_conservative_raster = 1 150 | end 151 | end 152 | 153 | 154 | 155 | imgui_vertical_space() 156 | imgui_vertical_space() 157 | gh_imgui.text("Render target scale factor: ") 158 | render_target_scale = gh_imgui.slider_1f("##render_target_scale", render_target_scale, 1.0, 32.0, 1) 159 | 160 | 161 | --[[ 162 | imgui_vertical_space() 163 | imgui_vertical_space() 164 | gh_imgui.text("Sub pixel precision") 165 | xbits = gh_imgui.slider_1i("xbits##subpixelprecision", xbits, 0, 8) 166 | ybits = gh_imgui.slider_1i("ybits##subpixelprecision", ybits, 0, 8) 167 | --]] 168 | 169 | end 170 | imgui_window_end() 171 | 172 | imgui_frame_end() 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /demos/conservative-rasterization/init.lua: -------------------------------------------------------------------------------- 1 | 2 | local demo_dir = gh_utils.get_demo_dir() 3 | local lib_dir = gh_utils.get_scripting_libs_dir() 4 | dofile(lib_dir .. "lua/imgui.lua") 5 | 6 | 7 | 8 | gh_renderer.set_vsync(1) 9 | 10 | winW, winH = gh_window.getsize(0) 11 | 12 | 13 | 14 | -- Create a render target 15 | -- 16 | -- The simplest way: 17 | --rt01 = gh_render_target.create(32, 32); 18 | 19 | 20 | ---[[ 21 | -- A more complicated way that allows more control: 22 | local num_color_targets = 1 23 | local pf = 3 -- PF_U8_RGBA 24 | local linear_filtering = 0 25 | local clamp_addressing = 1 26 | local samples = 0 27 | local create_depth_texture = 0 28 | rt01 = gh_render_target.create_ex_v4(32, 32, num_color_targets, pf, linear_filtering, clamp_addressing, samples, create_depth_texture); 29 | --]] 30 | 31 | 32 | 33 | GL_NV_conservative_raster_ok = gh_renderer.check_opengl_extension("GL_NV_conservative_raster") 34 | 35 | 36 | -- GLSL shaders loading 37 | -- 38 | tex_prog = gh_node.getid("tex_prog") 39 | cr_prog = gh_node.getid("cr_prog") 40 | 41 | 42 | 43 | 44 | gh_renderer.set_scissor_state(0) 45 | 46 | 47 | 48 | bias_xbits, bias_ybits, max_bias_bits = gh_renderer.conservative_rasterization_get_properties_nv() 49 | print("conservative_rasterization_get_properties_nv()") 50 | print("- bias_xbits = " .. bias_xbits) 51 | print("- bias_ybits = " .. bias_ybits) 52 | print("- max_bias_bits = " .. max_bias_bits) 53 | 54 | xbits = 2 55 | ybits = 2 56 | 57 | show_conservative_raster = 1 58 | render_target_scale = 20.0 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /demos/conservative-rasterization/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | 60 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 78 | 79 | 80 | 108 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /demos/conservative-rasterization/readme.md: -------------------------------------------------------------------------------- 1 | 2 | Simple demo that shows how to enable conservative rasterization on NVIDIA GeForce ot Intel GPUs. 3 | 4 | Complete article: 5 |
6 | https://www.geeks3d.com/hacklab/20180619/demo-conservative-rasterization-nvidia-intel/ 7 | 8 | This demo requires GeeXLab 0.25.3.0+ 9 |
10 | https://www.geeks3d.com/geexlab/downloads/ 11 | 12 | 13 | Screenshots 14 | 15 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/conservative-rasterization/screenshots/geexlab-conservative-rasterization-04.png) 16 | 17 | -------------------------------------------------------------------------------- /demos/conservative-rasterization/screenshots/geexlab-conservative-rasterization-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/conservative-rasterization/screenshots/geexlab-conservative-rasterization-03.png -------------------------------------------------------------------------------- /demos/conservative-rasterization/screenshots/geexlab-conservative-rasterization-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/conservative-rasterization/screenshots/geexlab-conservative-rasterization-04.png -------------------------------------------------------------------------------- /demos/heightmap-normal-computing/demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 10 | 11 | 12 | 13 | 100 | 101 | 102 | 113 | 114 | 115 | 116 | 117 | 138 | 139 | 140 | 141 | 142 | 159 | 160 | 173 | 174 | 175 | 176 | 177 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /demos/heightmap-normal-computing/frame.lua: -------------------------------------------------------------------------------- 1 | 2 | local elapsed_time = gh_utils.get_elapsed_time() 3 | local dt = elapsed_time - last_time 4 | last_time = elapsed_time 5 | 6 | 7 | gh_renderer.set_depth_test_state(1) 8 | 9 | 10 | keyboard_speed = 2.0 11 | gx_camera.set_keyboard_speed(keyboard_speed) 12 | 13 | 14 | gx_camera.update(camera, dt) 15 | gh_camera.bind(camera) 16 | 17 | 18 | local camx, camy, camz = gh_camera.get_position(camera) 19 | 20 | 21 | gh_renderer.clear_color_depth_buffers(0.2, 0.2, 0.2, 1.0, 1.0) 22 | 23 | 24 | 25 | 26 | 27 | local mouse_x, mouse_y = gh_input.mouse_getpos() 28 | local platform_type = gh_utils.get_platform() 29 | if (platform_type == 2) then -- OSX 30 | mouse_y = winH - mouse_y 31 | end 32 | 33 | 34 | 35 | 36 | 37 | 38 | gh_gpu_program.bind(light_prog) 39 | 40 | local lx = 10.0 * math.sin(elapsed_time * 2.0) 41 | local ly = 5.0 42 | local lz = 10.0 * math.cos(elapsed_time * 2.0) 43 | gh_gpu_program.uniform4f(light_prog, "light_position", lx, ly, lz, 1.0) 44 | 45 | 46 | 47 | --gh_renderer.wireframe() 48 | gh_renderer.enable_state("GL_CULL_FACE") 49 | 50 | gh_object.set_position(mesh, 0, 1, 0) 51 | gh_object.set_euler_angles(mesh, 0, 0, 0) 52 | gh_object.render(mesh) 53 | 54 | gh_renderer.disable_state("GL_CULL_FACE") 55 | gh_renderer.solid() 56 | 57 | 58 | 59 | gh_gpu_program.bind(color_prog) 60 | gh_object.set_position(light_sphere, lx, ly, lz) 61 | gh_object.render(light_sphere) 62 | gh_object.render(grid) 63 | 64 | 65 | 66 | 67 | gh_utils.font_render(font_a, 10, 20, 0.2, 1.0, 0.0, 1.0, string.format("GeeXLab - Heightmap normal")) 68 | gh_utils.font_render(font_a, 10, 40, 1.0, 0.4, 0.4, 1.0, string.format("Plane - vertices:%d - faces:%d", num_vertices, num_faces)) 69 | gh_utils.font_render(font_a, 10, 60, 1.0, 0.4, 0.4, 1.0, string.format("Camera - <%.3f ; %.3f ; %.3f>", camx, camy, camz)) 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /demos/heightmap-normal-computing/lighting_ps.glsl: -------------------------------------------------------------------------------- 1 | 2 | #version 150 3 | in vec4 v_normal; 4 | in vec4 v_lightdir; 5 | in vec4 v_eyedir; 6 | out vec4 FragColor; 7 | void main() 8 | { 9 | 10 | vec3 albedo = vec3(0.9, 0.7, 0.5); 11 | vec3 N = normalize(v_normal.xyz); 12 | vec3 L = normalize(v_lightdir.xyz); 13 | float NdotL = max(dot(N, L), 0.0); 14 | vec3 color = albedo * vec3(0.4); 15 | color += albedo * NdotL; 16 | 17 | vec3 E = normalize(v_eyedir.xyz); 18 | vec3 R = reflect(-L, N); 19 | float specular = pow(max(dot(R, E), 0.0), 64.0); 20 | color += vec3(0.8, 0.8, 0.8) * specular; 21 | 22 | 23 | FragColor.rgb = color; 24 | FragColor.a = 1.0; 25 | } 26 | -------------------------------------------------------------------------------- /demos/heightmap-normal-computing/lighting_vs.glsl: -------------------------------------------------------------------------------- 1 | 2 | #version 150 3 | in vec4 gxl3d_Position; 4 | in vec4 gxl3d_TexCoord0; 5 | in vec4 gxl3d_Normal; 6 | out vec4 v_normal; 7 | out vec4 v_lightdir; 8 | out vec4 v_eyedir; 9 | uniform mat4 gxl3d_ProjectionMatrix; // GeeXLab auto-uniform. 10 | uniform mat4 gxl3d_ModelViewMatrix; // GeeXLab auto-uniform. 11 | uniform mat4 gxl3d_ViewMatrix; // GeeXLab auto-uniform. 12 | uniform vec4 light_position; 13 | 14 | 15 | 16 | float f(float x, float z) 17 | { 18 | return sin(x) * cos(z); 19 | } 20 | 21 | 22 | 23 | vec3 calc_normal(float x, float z) 24 | { 25 | float eps = 0.0001; 26 | return normalize(vec3( 27 | f(x-eps, z) - f(x+eps, z), 28 | 2.0*eps, 29 | f(x, z-eps) - f(x, z+eps) 30 | )); 31 | } 32 | 33 | 34 | 35 | void main() 36 | { 37 | vec4 P = gxl3d_Position; 38 | P.y = f(P.x, P.z); 39 | 40 | vec3 N = calc_normal(P.x, P.z); 41 | 42 | vec4 view_position = gxl3d_ModelViewMatrix * P; 43 | gl_Position = gxl3d_ProjectionMatrix * view_position; 44 | 45 | v_normal = gxl3d_ModelViewMatrix * vec4(N, 0.0); 46 | v_eyedir = -view_position; 47 | 48 | vec4 lp = gxl3d_ViewMatrix * light_position; 49 | v_lightdir = lp - view_position; 50 | } 51 | -------------------------------------------------------------------------------- /demos/heightmap-normal-computing/readme.md: -------------------------------------------------------------------------------- 1 | Demo that shows how to compute the normal vector of a procedurally generated heightmap. 2 | 3 | 4 | Article 5 | - https://www.geeks3d.com/hacklab/20180424/demo-heightmap-normal-computing/ 6 | 7 | 8 | This demo requires GeeXLab 9 | - https://www.geeks3d.com/geexlab/downloads/ 10 | 11 | 12 | Screenshots 13 | 14 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/heightmap-normal-computing/screenshots/geexlab-heightmap-normal-computing-demo-01.jpg) 15 | 16 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/heightmap-normal-computing/screenshots/geexlab-heightmap-normal-computing-demo-02.jpg) 17 | -------------------------------------------------------------------------------- /demos/heightmap-normal-computing/screenshots/_._: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/heightmap-normal-computing/screenshots/geexlab-heightmap-normal-computing-demo-01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/heightmap-normal-computing/screenshots/geexlab-heightmap-normal-computing-demo-01.jpg -------------------------------------------------------------------------------- /demos/heightmap-normal-computing/screenshots/geexlab-heightmap-normal-computing-demo-02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/heightmap-normal-computing/screenshots/geexlab-heightmap-normal-computing-demo-02.jpg -------------------------------------------------------------------------------- /demos/imgui-lot-of-windows/main-opengl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 50 | 51 | 52 | 59 | 60 | 61 | 186 | 187 | 188 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /demos/imgui-lot-of-windows/main-vulkan.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 17 | 58 | 59 | 60 | 61 | 62 | 70 | 71 | 72 | 73 | 74 | 219 | 220 | 221 | 228 | 229 | 230 | 231 | -------------------------------------------------------------------------------- /demos/imgui-lot-of-windows/readme.md: -------------------------------------------------------------------------------- 1 | 2 | Small demo / benchmark that renders a lot of ImGui windows in OpenGL and Vulkan. Each window has a size of 100×100 and contains few lines of dynamic text. 3 | 4 | Article: 5 |
6 | https://www.geeks3d.com/hacklab/20180620/lot-of-imgui-windows-opengl-vs-vulkan/ 7 | 8 | This demo requires GeeXLab 0.25.3.0+ 9 |
10 | https://www.geeks3d.com/geexlab/downloads/ 11 | 12 | 13 | Screenshots 14 | 15 | - OpenGL 16 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/imgui-lot-of-windows/screenshots/geexlab-lot-of-imgui-windows-demo-opengl-02.jpg) 17 | 18 | 19 | - Vulkan 20 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/imgui-lot-of-windows/screenshots/geexlab-lot-of-imgui-windows-demo-vulkan-02.jpg) 21 | -------------------------------------------------------------------------------- /demos/imgui-lot-of-windows/screenshots/_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/imgui-lot-of-windows/screenshots/geexlab-lot-of-imgui-windows-demo-opengl-02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/imgui-lot-of-windows/screenshots/geexlab-lot-of-imgui-windows-demo-opengl-02.jpg -------------------------------------------------------------------------------- /demos/imgui-lot-of-windows/screenshots/geexlab-lot-of-imgui-windows-demo-vulkan-02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/imgui-lot-of-windows/screenshots/geexlab-lot-of-imgui-windows-demo-vulkan-02.jpg -------------------------------------------------------------------------------- /demos/loops/assets/_-_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/loops/assets/shaders/_-_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/loops/assets/shaders/lighting_prog_ps_gl21.glsl: -------------------------------------------------------------------------------- 1 | #version 120 2 | uniform sampler2D tex0; 3 | varying vec4 Vertex_C; 4 | varying vec4 Vertex_N; 5 | varying vec4 Vertex_L[2]; 6 | varying vec4 Vertex_E; 7 | varying vec4 Vertex_UV; 8 | uniform vec4 emissive; 9 | uniform vec4 light0_diffuse; 10 | uniform vec4 light1_diffuse; 11 | uniform vec4 light_ambient; 12 | uniform vec4 light_specular; 13 | uniform vec4 material_diffuse; 14 | uniform vec4 material_ambient; 15 | uniform vec4 material_specular; 16 | uniform float material_shininess; 17 | uniform vec4 uv_tiling; 18 | void main() 19 | { 20 | vec2 uv = Vertex_UV.xy * uv_tiling.xy; 21 | vec4 tex_color = texture2D(tex0, uv); 22 | //vec4 tex_color = vec4(1.0); 23 | 24 | float rgb_avg = (tex_color.r+tex_color.g+tex_color.b)/3.0; 25 | 26 | vec3 final_color = material_ambient.rgb * light_ambient.rgb * tex_color.rgb; 27 | vec3 N = normalize(Vertex_N.xyz); 28 | vec3 L = normalize(Vertex_L[0].xyz); 29 | float lambertTerm = dot(N,L); 30 | if (lambertTerm > 0.0) 31 | { 32 | final_color += material_diffuse.rgb * light0_diffuse.rgb * tex_color.rgb * lambertTerm; 33 | vec3 E = normalize(Vertex_E.xyz); 34 | vec3 R = reflect(-L, N); 35 | float specular = pow( max(dot(R, E), 0.0), material_shininess); 36 | final_color += material_specular.rgb * light_specular.rgb * specular; 37 | } 38 | 39 | 40 | L = normalize(Vertex_L[1].xyz); 41 | lambertTerm = dot(N,L); 42 | if (lambertTerm > 0.0) 43 | { 44 | final_color += material_diffuse.rgb * light1_diffuse.rgb * tex_color.rgb * lambertTerm; 45 | vec3 E = normalize(Vertex_E.xyz); 46 | vec3 R = reflect(-L, N); 47 | float specular = pow( max(dot(R, E), 0.0), material_shininess); 48 | final_color += material_specular.rgb * light_specular.rgb * specular; 49 | } 50 | 51 | gl_FragColor.rgb = final_color * Vertex_C.rgb + emissive.rgb; 52 | //gl_FragColor.rgb = vec3(1.0, 0.0, 0.0); 53 | gl_FragColor.a = rgb_avg; 54 | } 55 | -------------------------------------------------------------------------------- /demos/loops/assets/shaders/lighting_prog_ps_gl32.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | uniform sampler2D tex0; 3 | in vec4 Vertex_C; 4 | in vec4 Vertex_N; 5 | in vec4 Vertex_L[2]; 6 | in vec4 Vertex_E; 7 | in vec4 Vertex_UV; 8 | uniform vec4 emissive; 9 | uniform vec4 light0_diffuse; 10 | uniform vec4 light1_diffuse; 11 | uniform vec4 light_ambient; 12 | uniform vec4 light_specular; 13 | uniform vec4 material_diffuse; 14 | uniform vec4 material_ambient; 15 | uniform vec4 material_specular; 16 | uniform float material_shininess; 17 | uniform vec4 uv_tiling; 18 | out vec4 Out_Color; 19 | void main() 20 | { 21 | vec2 uv = Vertex_UV.xy * uv_tiling.xy; 22 | //uv.y *= -1; 23 | vec4 tex_color = texture(tex0, uv); 24 | //vec4 tex_color = vec4(1.0); 25 | 26 | float rgb_avg = (tex_color.r+tex_color.g+tex_color.b)/3.0; 27 | 28 | vec3 final_color = material_ambient.rgb * light_ambient.rgb * tex_color.rgb; 29 | vec3 N = normalize(Vertex_N.xyz); 30 | vec3 L = normalize(Vertex_L[0].xyz); 31 | float lambertTerm = dot(N,L); 32 | if (lambertTerm > 0.0) 33 | { 34 | final_color += material_diffuse.rgb * light0_diffuse.rgb * tex_color.rgb * lambertTerm; 35 | vec3 E = normalize(Vertex_E.xyz); 36 | vec3 R = reflect(-L, N); 37 | float specular = pow( max(dot(R, E), 0.0), material_shininess); 38 | final_color += material_specular.rgb * light_specular.rgb * specular; 39 | } 40 | 41 | 42 | L = normalize(Vertex_L[1].xyz); 43 | lambertTerm = dot(N,L); 44 | if (lambertTerm > 0.0) 45 | { 46 | final_color += material_diffuse.rgb * light1_diffuse.rgb * tex_color.rgb * lambertTerm; 47 | vec3 E = normalize(Vertex_E.xyz); 48 | vec3 R = reflect(-L, N); 49 | float specular = pow( max(dot(R, E), 0.0), material_shininess); 50 | final_color += material_specular.rgb * light_specular.rgb * specular; 51 | } 52 | 53 | Out_Color.rgb = final_color * Vertex_C.rgb + emissive.rgb; 54 | //Out_Color.rgb = vec3(1.0, 0.0, 0.0); 55 | Out_Color.a = rgb_avg; 56 | } 57 | -------------------------------------------------------------------------------- /demos/loops/assets/shaders/lighting_prog_vs_gl21.glsl: -------------------------------------------------------------------------------- 1 | #version 120 2 | uniform mat4 gxl3d_ModelViewProjectionMatrix; // GeeXLab built-in uniform. 3 | uniform mat4 gxl3d_ModelViewMatrix; // GeeXLab built-in uniform. 4 | uniform mat4 gxl3d_ViewMatrix; // GeeXLab built-in uniform. 5 | uniform vec4 light0_position; 6 | uniform vec4 light1_position; 7 | varying vec4 Vertex_C; 8 | varying vec4 Vertex_N; 9 | varying vec4 Vertex_L[2]; 10 | varying vec4 Vertex_E; 11 | varying vec4 Vertex_UV; 12 | void main() 13 | { 14 | gl_Position = gxl3d_ModelViewProjectionMatrix * gl_Vertex; 15 | Vertex_C = gl_Color; 16 | Vertex_UV = gl_MultiTexCoord0; 17 | Vertex_N = gxl3d_ModelViewMatrix * vec4(gl_Normal, 0.0); 18 | vec4 view_vertex = gxl3d_ModelViewMatrix * gl_Vertex; 19 | vec4 LP = gxl3d_ViewMatrix * light0_position; 20 | Vertex_L[0] = LP - view_vertex; 21 | LP = gxl3d_ViewMatrix * light1_position; 22 | Vertex_L[1] = LP - view_vertex; 23 | Vertex_E = -view_vertex; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /demos/loops/assets/shaders/lighting_prog_vs_gl32.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | in vec4 gxl3d_Position; 3 | in vec4 gxl3d_Normal; 4 | in vec4 gxl3d_TexCoord0; 5 | in vec4 gxl3d_Color; 6 | uniform mat4 gxl3d_ModelViewProjectionMatrix; // GeeXLab built-in uniform. 7 | uniform mat4 gxl3d_ModelViewMatrix; // GeeXLab built-in uniform. 8 | uniform mat4 gxl3d_ViewMatrix; // GeeXLab built-in uniform. 9 | uniform vec4 light0_position; 10 | uniform vec4 light1_position; 11 | out vec4 Vertex_C; 12 | out vec4 Vertex_N; 13 | out vec4 Vertex_L[2]; 14 | out vec4 Vertex_E; 15 | out vec4 Vertex_UV; 16 | void main() 17 | { 18 | gl_Position = gxl3d_ModelViewProjectionMatrix * gxl3d_Position; 19 | Vertex_C = gxl3d_Color; 20 | Vertex_UV = gxl3d_TexCoord0; 21 | Vertex_N = gxl3d_ModelViewMatrix * gxl3d_Normal; 22 | vec4 view_vertex = gxl3d_ModelViewMatrix * gxl3d_Position; 23 | vec4 LP = gxl3d_ViewMatrix * light0_position; 24 | Vertex_L[0] = LP - view_vertex; 25 | LP = gxl3d_ViewMatrix * light1_position; 26 | Vertex_L[1] = LP - view_vertex; 27 | Vertex_E = -view_vertex; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /demos/loops/assets/textures/_-_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/loops/assets/textures/white_black_border.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/loops/assets/textures/white_black_border.jpg -------------------------------------------------------------------------------- /demos/loops/loop_099_gl21.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 22 | 23 | 24 | 25 | 22 | 23 | 24 | 25 | 75 | 76 | 77 | 78 | 79 | 80 | 138 | 139 | 140 | 141 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 171 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 212 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | -------------------------------------------------------------------------------- /demos/nv-shader-thread-group/readme.md: -------------------------------------------------------------------------------- 1 | This demo shows how a NVIDIA GPU draws a quad by visualizing some GLSL built-in variables: gl_ThreadInWarpNV, gl_WarpIDNV and gl_SMIDNV (GL_NV_shader_thread_group support is required). 2 | 3 | The article also discusses about SMs, WARPS, threads and how the number of GPU cores can be computed. 4 | 5 | Article + downloads links: 6 | - https://www.geeks3d.com/hacklab/20180705/demo-visualizing-nvidia-gl_threadinwarpnv-gl_warpidnv-and-gl_smidnv-gl_nv_shader_thread_group/ 7 | 8 | Screenshots 9 | 10 | ![screenshot](screenshots/geexlab-shader-thread-group-nv-demo-01.png) 11 | 12 | -------------------------------------------------------------------------------- /demos/nv-shader-thread-group/screenshots/_-_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/nv-shader-thread-group/screenshots/geexlab-shader-thread-group-nv-demo-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/nv-shader-thread-group/screenshots/geexlab-shader-thread-group-nv-demo-01.png -------------------------------------------------------------------------------- /demos/physx3/image-viewer/data/Concrete_sidewalk_1k_d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/physx3/image-viewer/data/Concrete_sidewalk_1k_d.jpg -------------------------------------------------------------------------------- /demos/physx3/image-viewer/data/_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/physx3/image-viewer/data/ground061.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/physx3/image-viewer/data/ground061.jpg -------------------------------------------------------------------------------- /demos/physx3/image-viewer/data/pexels-photo-289225.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/physx3/image-viewer/data/pexels-photo-289225.jpeg -------------------------------------------------------------------------------- /demos/physx3/image-viewer/lua/_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/physx3/image-viewer/lua/dnd.lua: -------------------------------------------------------------------------------- 1 | 2 | local num_files = gh_utils.drop_files_get_num_files() 3 | if (num_files > 0) then 4 | local full_path = gh_utils.drop_files_get_file_by_index(0) 5 | image_filename = full_path 6 | load_image_dnd = 1 7 | end 8 | 9 | -------------------------------------------------------------------------------- /demos/physx3/image-viewer/lua/init.lua: -------------------------------------------------------------------------------- 1 | 2 | local demo_dir = gh_utils.get_demo_dir() 3 | local lib_dir = gh_utils.get_lib_dir() 4 | 5 | dofile(lib_dir .. "lua/gx_cam_lib_v1.lua") 6 | dofile(lib_dir .. "lua/libfont/libfont1.lua") 7 | dofile(lib_dir .. "lua/imgui.lua") 8 | 9 | 10 | 11 | 12 | 13 | 14 | random = function(a, b) 15 | if (a > b) then 16 | local c = b 17 | b = a 18 | a = c 19 | end 20 | local delta = b-a 21 | return (a + math.random()*delta) 22 | end 23 | 24 | 25 | 26 | 27 | mouse_get_position = function() 28 | local mx, my = gh_input.mouse_getpos() 29 | 30 | if (gh_utils.get_platform() == 2) then -- OSX 31 | local w, h = gh_window.getsize(0) 32 | my = h - my 33 | end 34 | 35 | if (gh_utils.get_platform() == 4) then -- RPi 36 | local w, h = gh_window.getsize(0) 37 | mx = mx + w/2 38 | my = -(my - h/2) 39 | end 40 | 41 | return mx, my 42 | end 43 | 44 | 45 | 46 | 47 | 48 | 49 | winW, winH = gh_window.getsize(0) 50 | 51 | 52 | 53 | is_gui_hovered = 0 54 | 55 | 56 | is_windows = 0 57 | 58 | if (gh_utils.get_platform() == 1) then -- return 1 if Windows, 2 if osx, 3 if linux, 4 if rpi and 5 if tinker board 59 | is_windows = 1 60 | end 61 | 62 | 63 | 64 | 65 | 66 | background_color = {r=0.4, g=0.4, b=0.4, a=1.0} 67 | 68 | 69 | 70 | 71 | orbit_mode = 1 72 | keyboard_speed = 10.0 73 | camera_fov = 60.0 74 | camera_lookat_x = 0 75 | camera_lookat_y = 30 76 | camera_lookat_z = 0 77 | 78 | camera = gx_camera.create_perspective(60, 1, 0, 0, winW, winH, 0.1, 1000) 79 | gh_camera.set_position(camera, 0, camera_lookat_y, 50) 80 | 81 | if (orbit_mode == 1) then 82 | gx_camera.init_orientation(camera, camera_lookat_x, camera_lookat_y, camera_lookat_z, 30, 90) 83 | gx_camera.set_mode_orbit() 84 | else 85 | gx_camera.set_mode_fly() 86 | end 87 | 88 | gx_camera.set_orbit_lookat(camera, camera_lookat_x, camera_lookat_y, camera_lookat_z) 89 | gx_camera.set_keyboard_speed(keyboard_speed) 90 | gh_camera.set_fov(camera, camera_fov) 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | phong_prog = gh_node.getid("phong_prog") 100 | gh_gpu_program.uniform4f(phong_prog, "color", 1.0, 1.0, 1.0, 1.0) 101 | 102 | 103 | 104 | 105 | 106 | ground = gh_mesh.create_plane(200, 200, 10, 10) 107 | 108 | 109 | 110 | --flag_support = gh_mesh.create_box(1, 50, 1, 2, 2, 2) 111 | --gh_object.setpos(flag_support, -20, 25, 0) 112 | 113 | flag_support = gh_mesh.create_box(60, 1, 1, 2, 2, 2) 114 | gh_object.setpos(flag_support, 0, 30, 0) 115 | 116 | 117 | 118 | gizmo = gh_object.create() 119 | gh_object.set_display_tripod_state(gizmo, 1) 120 | gh_object.set_display_grid_state(gizmo, 1) 121 | gh_object.set_grid_params(gizmo, 50.0, 50.0, 10, 10, 1, 1) 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | image_filename = "" 130 | load_image_dnd = 0 131 | 132 | 133 | 134 | 135 | local PF_U8_RGB = 1 136 | local PF_U8_RGBA = 3 137 | local PF_F32_RGBA = 6 138 | local pixel_format = PF_U8_RGBA 139 | local gen_mipmaps = 1 140 | local compressed_texture = 0 141 | 142 | --local filename = demo_dir .. "data/Ground_Dirt_1k_d.jpg" 143 | local filename = demo_dir .. "data/Concrete_sidewalk_1k_d.jpg" 144 | ground_tex = gh_texture.create_from_file_v6(filename, pixel_format, gen_mipmaps, compressed_texture) 145 | 146 | filename = demo_dir .. "data/pexels-photo-289225.jpeg" 147 | flag_tex = gh_texture.create_from_file_v6(filename, pixel_format, gen_mipmaps, compressed_texture) 148 | 149 | 150 | local SAMPLER_FILTERING_NEAREST = 1 151 | local SAMPLER_FILTERING_LINEAR = 2 152 | local SAMPLER_FILTERING_TRILINEAR = 3 153 | local SAMPLER_ADDRESSING_WRAP = 1 154 | local SAMPLER_ADDRESSING_CLAMP_TO_EDGE = 2 155 | local SAMPLER_ADDRESSING_MIRROR = 3 156 | gh_texture.bind(ground_tex, 0) 157 | gh_texture.set_sampler_params(ground_tex, SAMPLER_FILTERING_TRILINEAR, SAMPLER_ADDRESSING_WRAP, 16.0) 158 | gh_texture.bind(0, 0) 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | _cloth_run_on_gpu = 0 168 | 169 | px_scene = 0 170 | px_cloth = 0 171 | px_cloth2 = 0 172 | flag_mesh = 0 173 | 174 | 175 | physx_ok = gh_physx3.start() 176 | if (physx_ok == 1) then 177 | gh_utils.trace("PhysX 3 started up ok.") 178 | 179 | 180 | local gpu_physx = gh_physx3.gpu_is_supported() 181 | --gpu_physx = 0 182 | if (gpu_physx == 1) then 183 | gh_utils.trace("PhysX 3 - GPU PhysX supported.") 184 | gh_utils.trace("PhysX 3 - GPU name:" .. gh_physx3.gpu_get_name()) 185 | 186 | local mem_size = gh_physx3.gpu_get_total_memory_size_mb() 187 | gh_utils.trace("PhysX 3 - GPU total memory:" .. mem_size .. "MB") 188 | 189 | gh_utils.trace("PhysX 3 - Dedicated GPU:" .. gh_physx3.gpu_is_dedicated()) 190 | else 191 | gh_utils.trace("PhysX 3 - GPU PhysX NOT supported, CPU PhysX only.") 192 | end 193 | 194 | 195 | 196 | 197 | local gravity = {x=0, y=-9.8, z=0} 198 | 199 | local bounce_threshold_velocity = 2.0 200 | local ccd = 0 201 | local enable_collision_reporting = 0 202 | local enable_stabilization = 1 203 | -- GPU PhysX 204 | px_scene = gh_physx3.create_scene_broadphase_gpu(bounce_threshold_velocity, ccd, enable_collision_reporting, enable_stabilization) 205 | -- CPU PhysX 206 | -- px_scene = gh_physx3.create_scene_broadphase_sap(bounce_threshold_velocity, ccd, enable_collision_reporting, enable_stabilization) 207 | 208 | 209 | gh_physx3.set_scene_gravity(px_scene, gravity.x, gravity.y, gravity.z) 210 | 211 | px_material_plane = gh_physx3.create_material(0.5, 0.5, 0.4) 212 | px_actor_plane = gh_physx3.create_actor_plane(px_scene, 0, 1, 0, 0, px_material_plane) 213 | 214 | 215 | 216 | cloth_vertex_density = 50 217 | local gpu_cloth = 1 218 | _cloth_run_on_gpu = gpu_cloth 219 | 220 | 221 | 222 | local pos = {x=0, y=30, z=0} 223 | local euler_angles = {x=90, y=0, z=0} 224 | -- flag_mesh = gh_mesh.create_plane(40, 25, cloth_vertex_density, cloth_vertex_density) 225 | 226 | local separate_vertex_arrays = 1 227 | local vertex_alignment = 0 228 | local vertex_format = 0 229 | flag_mesh40x25 = gh_mesh.create_plane_v2(50, 30, cloth_vertex_density, cloth_vertex_density, separate_vertex_arrays, vertex_alignment, vertex_format) 230 | 231 | gh_object.setpos(flag_mesh40x25, pos.x, pos.y, pos.z) 232 | gh_object.set_euler_angles(flag_mesh40x25, euler_angles.x, euler_angles.y, euler_angles.z) 233 | 234 | --[[ 235 | local num_vertices = gh_object.get_num_vertices(flag_mesh) 236 | local v = 0 237 | for v=0, num_vertices-1 do 238 | gh_mesh.set_vertex_position_w(flag_mesh, v, 10.8) 239 | end 240 | --]] 241 | 242 | gh_mesh.update_vertex_particle_from_position(flag_mesh40x25) 243 | gh_mesh.set_vertices_particle_w(flag_mesh40x25, 10.01) 244 | local MESH_PLANE_BORDER_TYPE_NEGX = 1 245 | local MESH_PLANE_BORDER_TYPE_POSX = 2 246 | local MESH_PLANE_BORDER_TYPE_NEGZ = 4 247 | local MESH_PLANE_BORDER_TYPE_POSZ = 8 248 | local MESH_PLANE_BORDER_TYPE_NEGY = 16 249 | local MESH_PLANE_BORDER_TYPE_POSY = 32 250 | local two_points = 1 251 | --gh_mesh.vertex_particle_attach_border(flag_mesh40x25, MESH_PLANE_BORDER_TYPE_NEGZ, two_points) 252 | gh_mesh.vertex_particle_attach_border(flag_mesh40x25, MESH_PLANE_BORDER_TYPE_NEGZ, 0) 253 | 254 | -- v = num_vertices/2 255 | -- gh_mesh.set_vertex_position_w(flag_mesh, v, 0.0) -- fixed vertex. 256 | 257 | px_cloth = gh_physx3.cloth_create_from_mesh(px_scene, flag_mesh40x25, gpu_cloth, pos.x, pos.y, pos.z, euler_angles.x, euler_angles.y, euler_angles.z, gravity.x, gravity.y, gravity.z) 258 | if (px_cloth > 0) then 259 | local update_positions = 1 260 | local update_normals = 1 261 | gh_physx3.cloth_update_mesh_vertex_data(px_cloth, flag_mesh40x25, update_positions, update_normals) 262 | --gh_physx3.cloth_set_solver_frequency(px_cloth, 120.0) 263 | --gh_physx3.cloth_set_gpu_state(px_cloth, 1) 264 | 265 | gh_physx3.cloth_set_external_acceleration(px_cloth, 10.0 + random(-5.0, 2.0), 2.0 + random(-2.0, 2.0), 6.0 + random(-4.0, 2.0)) 266 | 267 | end 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | pos.y = 30 279 | 280 | flag_mesh48x72 = gh_mesh.create_plane_v2(30, 40, cloth_vertex_density, cloth_vertex_density, separate_vertex_arrays, vertex_alignment, vertex_format) 281 | 282 | gh_object.setpos(flag_mesh48x72, pos.x, pos.y, pos.z) 283 | gh_object.set_euler_angles(flag_mesh48x72, euler_angles.x, euler_angles.y, euler_angles.z) 284 | 285 | gh_mesh.update_vertex_particle_from_position(flag_mesh48x72) 286 | gh_mesh.set_vertices_particle_w(flag_mesh48x72, 10.01) 287 | --local two_points = 1 288 | --gh_mesh.vertex_particle_attach_border(flag_mesh48x72, MESH_PLANE_BORDER_TYPE_NEGX, two_points) 289 | local two_points = 0 290 | gh_mesh.vertex_particle_attach_border(flag_mesh48x72, MESH_PLANE_BORDER_TYPE_NEGZ, two_points) 291 | 292 | -- v = num_vertices/2 293 | -- gh_mesh.set_vertex_position_w(flag_mesh, v, 0.0) -- fixed vertex. 294 | 295 | px_cloth2 = gh_physx3.cloth_create_from_mesh(px_scene, flag_mesh48x72, gpu_cloth, pos.x, pos.y, pos.z, euler_angles.x, euler_angles.y, euler_angles.z, gravity.x, gravity.y, gravity.z) 296 | if (px_cloth2 > 0) then 297 | local update_positions = 1 298 | local update_normals = 1 299 | gh_physx3.cloth_update_mesh_vertex_data(px_cloth2, flag_mesh48x72, update_positions, update_normals) 300 | --gh_physx3.cloth_set_solver_frequency(px_cloth2, 240.0) 301 | 302 | --gh_physx3.cloth_set_external_acceleration(px_cloth2, 4.0 + random(-2.0, 2.0), 2.0 + random(-2.0, 2.0), 2.0 + random(-4.0, 4.0)) 303 | gh_physx3.cloth_set_external_acceleration(px_cloth2, 10.0 + random(-5.0, 2.0), 2.0 + random(-2.0, 2.0), 6.0 + random(-4.0, 2.0)) 304 | end 305 | 306 | gh_physx3.scene_remove_actor(px_scene, px_cloth2) 307 | --gh_physx3.scene_remove_actor(px_scene, px_cloth) 308 | 309 | 310 | 311 | gh_utils.trace("PhysX 3 scene/materials/actors init ok.") 312 | else 313 | gh_utils.trace("PhysX 3 starting up failed.") 314 | end 315 | 316 | 317 | 318 | 319 | gh_renderer.set_vsync(1) 320 | gh_renderer.set_scissor_state(0) 321 | 322 | last_time = gh_window.timer_get_seconds(0) 323 | 324 | _wireframe = 0 325 | 326 | _update_cloth_normals = 1 327 | _update_cloth_normals_counter = 0 328 | _run_sim_counter = 0 329 | 330 | update_wind_force_time = 0 331 | 332 | _keyboard_last_time = last_time 333 | 334 | 335 | gl_renderer = gh_renderer.get_renderer_model() 336 | gl_version = gh_renderer.get_api_version() 337 | 338 | fps_time = 0 339 | fps = 0 340 | frames = 0 341 | 342 | run_simulation = 1 343 | 344 | show_info = 1 345 | show_ground = 1 346 | 347 | check_dnd_dst = 1 -- 1=flag, 0=ground 348 | 349 | widescreen_flag = 1 350 | 351 | 352 | -------------------------------------------------------------------------------- /demos/physx3/image-viewer/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 27 | 28 | 29 | 30 | 31 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 74 | 0.0) 105 | { 106 | final_color += light_diffuse * material_diffuse * lambertTerm * tex01_color; 107 | 108 | vec4 E = normalize(Vertex_EyeVec); 109 | vec4 R = reflect(-L, N); 110 | float specular = pow( max(dot(R, E), 0.0), material_shininess); 111 | final_color += light_specular * material_specular * specular; 112 | } 113 | 114 | Out_Color.rgb = final_color.rgb * color.rgb; 115 | Out_Color.a = color.a; 116 | } 117 | ]]> 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /demos/physx3/image-viewer/readme.md: -------------------------------------------------------------------------------- 1 | Here is a small image viewer coded in Lua that uses PhysX 3 to display an image on an animated flag. ImageMagick is used to load any image and create a texture that will be mapped on the flag. 2 | 3 | 4 | Load this demo with GeeXLab and drag-and-drop any image into the main window. 5 | 6 | 7 | This demo requires GeeXLab 0.25.3.0+ 8 |
9 | https://www.geeks3d.com/geexlab/downloads/ 10 | 11 | 12 | Article: 13 |
14 | https://www.geeks3d.com/hacklab/20180614/demo-image-viewer-with-physx-3/ 15 | 16 | 17 | 18 | Screenshots 19 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-05.jpg) 20 | 21 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-06.jpg) 22 | 23 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-08.jpg) 24 | 25 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-02.jpg) 26 | 27 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-07.jpg) 28 | 29 | 30 | -------------------------------------------------------------------------------- /demos/physx3/image-viewer/screenshots/_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-02.jpg -------------------------------------------------------------------------------- /demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-05.jpg -------------------------------------------------------------------------------- /demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-06.jpg -------------------------------------------------------------------------------- /demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-07.jpg -------------------------------------------------------------------------------- /demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/physx3/image-viewer/screenshots/geexlab-physx-image-viewer-08.jpg -------------------------------------------------------------------------------- /demos/rings-of-cubes/assets/shaders/lighting_prog_ps_gl21.glsl: -------------------------------------------------------------------------------- 1 | #version 120 2 | uniform sampler2D tex0; 3 | varying vec4 Vertex_C; 4 | varying vec4 Vertex_N; 5 | varying vec4 Vertex_L[2]; 6 | varying vec4 Vertex_E; 7 | varying vec4 Vertex_UV; 8 | uniform vec4 emissive; 9 | uniform vec4 light0_diffuse; 10 | uniform vec4 light1_diffuse; 11 | uniform vec4 light_ambient; 12 | uniform vec4 light_specular; 13 | uniform vec4 material_diffuse; 14 | uniform vec4 material_ambient; 15 | uniform vec4 material_specular; 16 | uniform float material_shininess; 17 | uniform vec4 uv_tiling; 18 | void main() 19 | { 20 | vec2 uv = Vertex_UV.xy * uv_tiling.xy; 21 | vec4 tex_color = texture2D(tex0, uv); 22 | //vec4 tex_color = vec4(1.0); 23 | 24 | float rgb_avg = (tex_color.r+tex_color.g+tex_color.b)/3.0; 25 | 26 | vec3 final_color = material_ambient.rgb * light_ambient.rgb * tex_color.rgb; 27 | vec3 N = normalize(Vertex_N.xyz); 28 | vec3 L = normalize(Vertex_L[0].xyz); 29 | float lambertTerm = dot(N,L); 30 | if (lambertTerm > 0.0) 31 | { 32 | final_color += material_diffuse.rgb * light0_diffuse.rgb * tex_color.rgb * lambertTerm; 33 | vec3 E = normalize(Vertex_E.xyz); 34 | vec3 R = reflect(-L, N); 35 | float specular = pow( max(dot(R, E), 0.0), material_shininess); 36 | final_color += material_specular.rgb * light_specular.rgb * specular; 37 | } 38 | 39 | 40 | L = normalize(Vertex_L[1].xyz); 41 | lambertTerm = dot(N,L); 42 | if (lambertTerm > 0.0) 43 | { 44 | final_color += material_diffuse.rgb * light1_diffuse.rgb * tex_color.rgb * lambertTerm; 45 | vec3 E = normalize(Vertex_E.xyz); 46 | vec3 R = reflect(-L, N); 47 | float specular = pow( max(dot(R, E), 0.0), material_shininess); 48 | final_color += material_specular.rgb * light_specular.rgb * specular; 49 | } 50 | 51 | gl_FragColor.rgb = final_color * Vertex_C.rgb + emissive.rgb; 52 | //gl_FragColor.rgb = vec3(1.0, 0.0, 0.0); 53 | gl_FragColor.a = rgb_avg; 54 | } 55 | -------------------------------------------------------------------------------- /demos/rings-of-cubes/assets/shaders/lighting_prog_ps_gl32.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | uniform sampler2D tex0; 3 | in vec4 Vertex_C; 4 | in vec4 Vertex_N; 5 | in vec4 Vertex_L[2]; 6 | in vec4 Vertex_E; 7 | in vec4 Vertex_UV; 8 | uniform vec4 emissive; 9 | uniform vec4 light0_diffuse; 10 | uniform vec4 light1_diffuse; 11 | uniform vec4 light_ambient; 12 | uniform vec4 light_specular; 13 | uniform vec4 material_diffuse; 14 | uniform vec4 material_ambient; 15 | uniform vec4 material_specular; 16 | uniform float material_shininess; 17 | uniform vec4 uv_tiling; 18 | out vec4 Out_Color; 19 | void main() 20 | { 21 | vec2 uv = Vertex_UV.xy * uv_tiling.xy; 22 | //uv.y *= -1; 23 | vec4 tex_color = texture(tex0, uv); 24 | //vec4 tex_color = vec4(1.0); 25 | 26 | float rgb_avg = (tex_color.r+tex_color.g+tex_color.b)/3.0; 27 | 28 | vec3 final_color = material_ambient.rgb * light_ambient.rgb * tex_color.rgb; 29 | vec3 N = normalize(Vertex_N.xyz); 30 | vec3 L = normalize(Vertex_L[0].xyz); 31 | float lambertTerm = dot(N,L); 32 | if (lambertTerm > 0.0) 33 | { 34 | final_color += material_diffuse.rgb * light0_diffuse.rgb * tex_color.rgb * lambertTerm; 35 | vec3 E = normalize(Vertex_E.xyz); 36 | vec3 R = reflect(-L, N); 37 | float specular = pow( max(dot(R, E), 0.0), material_shininess); 38 | final_color += material_specular.rgb * light_specular.rgb * specular; 39 | } 40 | 41 | 42 | L = normalize(Vertex_L[1].xyz); 43 | lambertTerm = dot(N,L); 44 | if (lambertTerm > 0.0) 45 | { 46 | final_color += material_diffuse.rgb * light1_diffuse.rgb * tex_color.rgb * lambertTerm; 47 | vec3 E = normalize(Vertex_E.xyz); 48 | vec3 R = reflect(-L, N); 49 | float specular = pow( max(dot(R, E), 0.0), material_shininess); 50 | final_color += material_specular.rgb * light_specular.rgb * specular; 51 | } 52 | 53 | Out_Color.rgb = final_color * Vertex_C.rgb + emissive.rgb; 54 | //Out_Color.rgb = vec3(1.0, 0.0, 0.0); 55 | Out_Color.a = rgb_avg; 56 | } 57 | -------------------------------------------------------------------------------- /demos/rings-of-cubes/assets/shaders/lighting_prog_vs_gl21.glsl: -------------------------------------------------------------------------------- 1 | #version 120 2 | uniform mat4 gxl3d_ModelViewProjectionMatrix; // GeeXLab built-in uniform. 3 | uniform mat4 gxl3d_ModelViewMatrix; // GeeXLab built-in uniform. 4 | uniform mat4 gxl3d_ViewMatrix; // GeeXLab built-in uniform. 5 | uniform vec4 light0_position; 6 | uniform vec4 light1_position; 7 | varying vec4 Vertex_C; 8 | varying vec4 Vertex_N; 9 | varying vec4 Vertex_L[2]; 10 | varying vec4 Vertex_E; 11 | varying vec4 Vertex_UV; 12 | void main() 13 | { 14 | gl_Position = gxl3d_ModelViewProjectionMatrix * gl_Vertex; 15 | Vertex_C = gl_Color; 16 | Vertex_UV = gl_MultiTexCoord0; 17 | Vertex_N = gxl3d_ModelViewMatrix * vec4(gl_Normal, 0.0); 18 | vec4 view_vertex = gxl3d_ModelViewMatrix * gl_Vertex; 19 | vec4 LP = gxl3d_ViewMatrix * light0_position; 20 | Vertex_L[0] = LP - view_vertex; 21 | LP = gxl3d_ViewMatrix * light1_position; 22 | Vertex_L[1] = LP - view_vertex; 23 | Vertex_E = -view_vertex; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /demos/rings-of-cubes/assets/shaders/lighting_prog_vs_gl32.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | in vec4 gxl3d_Position; 3 | in vec4 gxl3d_Normal; 4 | in vec4 gxl3d_TexCoord0; 5 | in vec4 gxl3d_Color; 6 | uniform mat4 gxl3d_ModelViewProjectionMatrix; // GeeXLab built-in uniform. 7 | uniform mat4 gxl3d_ModelViewMatrix; // GeeXLab built-in uniform. 8 | uniform mat4 gxl3d_ViewMatrix; // GeeXLab built-in uniform. 9 | uniform vec4 light0_position; 10 | uniform vec4 light1_position; 11 | out vec4 Vertex_C; 12 | out vec4 Vertex_N; 13 | out vec4 Vertex_L[2]; 14 | out vec4 Vertex_E; 15 | out vec4 Vertex_UV; 16 | void main() 17 | { 18 | gl_Position = gxl3d_ModelViewProjectionMatrix * gxl3d_Position; 19 | Vertex_C = gxl3d_Color; 20 | Vertex_UV = gxl3d_TexCoord0; 21 | Vertex_N = gxl3d_ModelViewMatrix * gxl3d_Normal; 22 | vec4 view_vertex = gxl3d_ModelViewMatrix * gxl3d_Position; 23 | vec4 LP = gxl3d_ViewMatrix * light0_position; 24 | Vertex_L[0] = LP - view_vertex; 25 | LP = gxl3d_ViewMatrix * light1_position; 26 | Vertex_L[1] = LP - view_vertex; 27 | Vertex_E = -view_vertex; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /demos/rings-of-cubes/assets/shaders/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/rings-of-cubes/assets/textures/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/rings-of-cubes/assets/textures/white_black_border.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/rings-of-cubes/assets/textures/white_black_border.jpg -------------------------------------------------------------------------------- /demos/rings-of-cubes/frame.lua: -------------------------------------------------------------------------------- 1 | 2 | local elapsed_time = gh_utils.get_elapsed_time() 3 | local dt = gh_utils.get_time_step() 4 | 5 | frames = frames+1 6 | fps_time = fps_time + dt 7 | if (fps_time >= 1.0) then 8 | fps_time = 0 9 | fps = frames 10 | frames = 0 11 | end 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | --------------------------------------------------------------------------------- 20 | -- Background 21 | --------------------------------------------------------------------------------- 22 | 23 | gh_renderer.set_depth_test_state(0) 24 | 25 | gh_camera.bind(camera_ortho) 26 | gh_renderer.clear_color_depth_buffers(0, 0, 0, 0, 1.0) 27 | 28 | gh_renderer.back_face_culling(0) 29 | 30 | 31 | gh_gpu_program.bind(color_prog) 32 | 33 | gh_mesh.set_vertex_color(fullscreen_quad, 0, bkg_color_bottom.r, bkg_color_bottom.g, bkg_color_bottom.b, bkg_color_bottom.a) --bottom-left 34 | gh_mesh.set_vertex_color(fullscreen_quad, 1, bkg_color_top.r, bkg_color_top.g, bkg_color_top.b, bkg_color_top.a) -- top-left 35 | gh_mesh.set_vertex_color(fullscreen_quad, 2, bkg_color_top.r, bkg_color_top.g, bkg_color_top.b, bkg_color_top.a) --top-right 36 | gh_mesh.set_vertex_color(fullscreen_quad, 3, bkg_color_bottom.r, bkg_color_bottom.g, bkg_color_bottom.b, bkg_color_bottom.a) --bottom-right 37 | 38 | gh_object.render(fullscreen_quad) 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | --------------------------------------------------------------------------------- 56 | -- Main rendering 57 | --------------------------------------------------------------------------------- 58 | 59 | gh_renderer.set_depth_test_state(1) 60 | 61 | 62 | 63 | --------------------------------------------- 64 | -- Apply 3D camera settings 65 | -- 66 | if (imgui_window_hovered == 0) then 67 | gh_camera.set_fov(camera, camera_fov) 68 | gx_camera.set_keyboard_speed(keyboard_speed) 69 | gx_camera.update(camera, dt) 70 | end 71 | gh_camera.bind(camera) 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -- The lighting shader ------------------------------ 81 | -- 82 | local prog = lighting_prog 83 | gh_gpu_program.bind(prog) 84 | gh_gpu_program.uniform1i(prog, "tex0", 0) 85 | 86 | 87 | local cx, cy, cz = gh_camera.get_position(camera) 88 | --gh_gpu_program.uniform4f(prog, "light_position0", cx, cy, cz, 1.0) 89 | 90 | 91 | --local light0_pos = {x=15.0, y=1.0, z=1.0} 92 | --local light1_pos = {x=-15.0, y=1.0, z=10.0} 93 | local light0_pos = {x=8.0, y=4.0, z=8.0} 94 | local light1_pos = {x=-8.0, y=11.0, z=-1.0} 95 | 96 | 97 | gh_gpu_program.uniform4f(prog, "light_ambient", 0.2, 0.2, 0.2, 1.0) 98 | gh_gpu_program.uniform4f(prog, "light_specular", 0.6, 0.6, 0.6, 1.0) 99 | 100 | gh_gpu_program.uniform4f(prog, "light0_position", light0_pos.x, light0_pos.y, light0_pos.z, 1.0) 101 | gh_gpu_program.uniform4f(prog, "light0_diffuse", 1.0, 1.0, 1.0, 1.0) 102 | 103 | gh_gpu_program.uniform4f(prog, "light1_position", light1_pos.x, light1_pos.y, light1_pos.z, 1.0) 104 | gh_gpu_program.uniform4f(prog, "light1_diffuse", 1.0, 1.0, 1.0, 1.0) 105 | 106 | gh_gpu_program.uniform4f(prog, "uv_tiling", 1.0, 1.0, 0.0, 1.0) 107 | 108 | 109 | gh_gpu_program.uniform4f(prog, "material_diffuse", 1.0, 1.0, 1.0, 1.0) 110 | gh_gpu_program.uniform4f(prog, "material_ambient", 1.0, 1.0, 1.0, 1.0) 111 | gh_gpu_program.uniform4f(prog, "material_specular", 0.1, 0.1, 0.1, 1.0) 112 | gh_gpu_program.uniform1f(prog, "material_shininess", 24.0) 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | gh_renderer.back_face_culling(1) 121 | 122 | if (tex0 > 0) then 123 | gh_gpu_program.uniform1i(prog, "tex0", 0) 124 | gh_texture.bind(tex0, 0) 125 | end 126 | 127 | 128 | if (wireframe == 1) then 129 | gh_renderer.wireframe() 130 | end 131 | 132 | 133 | 134 | -- The RINGS ------------------------------------------ 135 | -- Thanks to the hierarchy that allows to group objects together, we can easily rotate 136 | -- a ring made up of several cubes. And several rings need to be rotated... 137 | -- 138 | -- 139 | local ang_step = TAU / num_rings 140 | 141 | local time = elapsed_time 142 | 143 | ring_radius = 4.0 144 | 145 | for i=0, num_rings-1 do 146 | 147 | local pivot = pivots[i+1] 148 | local ring = rings[i+1] 149 | 150 | local ang = i * ang_step 151 | 152 | local px = ring_radius * math.cos(ang) 153 | local py = ring_radius * math.sin(ang) 154 | local pz = 0 155 | 156 | 157 | local yaw = ang + PI/2.0 + 0.2 158 | local ang_deg = yaw * 180.0 / 3.14159265 159 | 160 | gh_object.set_position(pivot, px, py, pz) 161 | gh_object.set_euler_angles(pivot, 0, 0, ang_deg) 162 | gh_object.set_euler_angles(ring, 0, -time*angular_speed, 0) 163 | end 164 | 165 | gh_object.render(main_object) 166 | 167 | 168 | 169 | 170 | if (wireframe == 1) then 171 | gh_renderer.solid() 172 | end 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | -- Display light spheres just to see the position of lights ----------------------- 182 | -- 183 | if (show_light_sphere == 1) then 184 | gh_gpu_program.bind(color_prog) 185 | gh_object.set_position(light_sphere, light0_pos.x, light0_pos.y, light0_pos.z) 186 | gh_object.render(light_sphere) 187 | gh_object.set_position(light_sphere, light1_pos.x, light1_pos.y, light1_pos.z) 188 | gh_object.render(light_sphere) 189 | end 190 | 191 | 192 | 193 | -- Reference grid ------------------ 194 | -- 195 | if (show_ref_grid == 1) then 196 | gh_gpu_program.bind(color_prog) 197 | gh_object.render(grid) 198 | end 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | --------------------------------------------------------------------------------- 211 | -- ImGui interface / control panel 212 | --------------------------------------------------------------------------------- 213 | ---[[ 214 | gh_imgui.set_color(IMGUI_WINDOW_BG_COLOR, 0.4, 0.4, 0.6, 0.25) 215 | 216 | if (imgui_begin(350, winH) == 1) then 217 | 218 | local window_w = gh_imgui.get_content_region_available_width() 219 | 220 | 221 | local widget_width = window_w * 0.95 222 | gh_imgui.push_item_width(widget_width) 223 | 224 | 225 | gh_imgui.text_rgba(string.format("FPS:%d (dt:%.2f msec)", fps, dt*1000), 1.0, 1.0, 1.0, 1.0) 226 | 227 | gh_imgui.text_rgba("GL_RENDERER: ", 1.0, 1.0, 1.0, 1.0) 228 | gh_imgui.widget(IMGUI_WIDGET_SAME_LINE) 229 | gh_imgui.text_rgba(gl_renderer, 1.0, 1.0, 0.0, 1.0) 230 | 231 | gh_imgui.text_rgba("GL_VERSION: ", 1.0, 1.0, 1.0, 1.0) 232 | gh_imgui.widget(IMGUI_WIDGET_SAME_LINE) 233 | gh_imgui.text_rgba(gl_version, 1.0, 0.7, 0.0, 1.0) 234 | 235 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 236 | gh_imgui.widget(IMGUI_WIDGET_SEPARATOR) 237 | 238 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 239 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 240 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 241 | 242 | 243 | 244 | --[[ 245 | local button_width = 208 246 | if (gh_imgui.button("myKoolButton", button_width, 20) == 1) then 247 | -- do something 248 | end 249 | --]] 250 | 251 | 252 | 253 | 254 | 255 | 256 | gh_imgui.text("Background top color:") 257 | bkg_color_top.r, bkg_color_top.g, bkg_color_top.b, bkg_color_top.a = gh_imgui.color_edit_rgba("##coloredit-bkg_color_top", bkg_color_top.r, bkg_color_top.g, bkg_color_top.b, bkg_color_top.a) 258 | 259 | gh_imgui.text("Background bottom color:") 260 | bkg_color_bottom.r, bkg_color_bottom.g, bkg_color_bottom.b, bkg_color_bottom.a = gh_imgui.color_edit_rgba("##coloredit-bkg_color_bottom", bkg_color_bottom.r, bkg_color_bottom.g, bkg_color_bottom.b, bkg_color_bottom.a) 261 | 262 | 263 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 264 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 265 | 266 | --use_textures = gh_imgui.checkbox("Use textures", use_textures) 267 | if (is_rpi == 0) then 268 | show_ref_grid = gh_imgui.checkbox("Show reference grid", show_ref_grid) 269 | end 270 | show_light_sphere = gh_imgui.checkbox("Show light sphere", show_light_sphere) 271 | wireframe = gh_imgui.checkbox("Wireframe", wireframe) 272 | 273 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 274 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 275 | gh_imgui.text(string.format("Camera: <%.3f ; %.3f ; %.3f>", cx, cy, cz)) 276 | 277 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 278 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 279 | 280 | 281 | gh_imgui.widget(IMGUI_WIDGET_SEPARATOR) 282 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 283 | gh_imgui.widget(IMGUI_WIDGET_VERTICAL_SPACING) 284 | 285 | local min_value = 1.0 286 | local max_value = 100.0 287 | local power = 1.0 -- Use power!=1.0 for logarithmic sliders. 288 | gh_imgui.text("Angular speed") 289 | angular_speed = gh_imgui.slider_1f("##angular_speed", angular_speed, min_value, max_value, power) 290 | 291 | 292 | 293 | gh_imgui.pop_item_width() 294 | 295 | end 296 | 297 | imgui_end() 298 | -------------------------------------------------------------------------------- /demos/rings-of-cubes/main_gl21.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 31 | 32 | 33 | 34 | 35 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 97 | 98 | 99 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 123 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /demos/shader-2d-grid/simple-2d-grid-gl32.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 28 | 29 | 30 | 31 | 32 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 113 | 114 | 115 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 154 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /demos/shader-fire/assets/1010.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shader-fire/assets/1010.jpg -------------------------------------------------------------------------------- /demos/shader-fire/assets/_._: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/shader-fire/assets/distortion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shader-fire/assets/distortion.jpg -------------------------------------------------------------------------------- /demos/shader-fire/assets/gradient02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shader-fire/assets/gradient02.jpg -------------------------------------------------------------------------------- /demos/shader-fire/assets/gradient03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shader-fire/assets/gradient03.jpg -------------------------------------------------------------------------------- /demos/shader-fire/assets/noise03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shader-fire/assets/noise03.jpg -------------------------------------------------------------------------------- /demos/shader-fire/assets/noise06a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shader-fire/assets/noise06a.jpg -------------------------------------------------------------------------------- /demos/shader-fire/frag.txt: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | uniform sampler2D tex_noise; 4 | uniform sampler2D tex_gradient; 5 | uniform sampler2D tex_gradient_color; 6 | uniform sampler2D tex_distortion; 7 | uniform sampler2D tex_color; 8 | uniform float alpha_threshold; 9 | uniform float time; 10 | uniform float speed; 11 | 12 | void main (void) 13 | { 14 | //float wobble = (1.0+sin(time*1.5))*0.5; 15 | 16 | vec2 uv = gl_TexCoord[0].xy * vec2(4.0, 1.0); 17 | 18 | vec2 uv_noise = uv * 0.3; 19 | 20 | uv_noise.y -= time * speed; 21 | 22 | vec2 uv_grad = uv * vec2(1.0, 1.0); 23 | 24 | vec2 uv_distor = uv; 25 | vec3 tdistortion = texture2D(tex_distortion,uv_distor).rgb * 0.015; 26 | 27 | vec2 uv_noise_distor = vec2(uv_noise.x + tdistortion.g, uv_noise.y + tdistortion.r); 28 | vec3 tnoise = texture2D(tex_noise, uv_noise_distor).rgb; 29 | tnoise *= 1.75; 30 | 31 | 32 | float tgradient = 1.0-texture2D(tex_gradient,uv_grad).r; 33 | 34 | vec3 tgradientcolor = texture2D(tex_gradient_color,uv_grad).rgb; 35 | 36 | vec3 tcolor = texture2D(tex_color,uv_noise_distor*3.0).rgb * vec3(2.0, 1.6, 1.2); 37 | 38 | 39 | float alpha0 = (tnoise.x + tnoise.y + tnoise.z) / 3.0; 40 | 41 | float flamewob = ((1.0 + (sin(time + uv.x*8.0) * cos(time - uv.x*5.0)))*0.5) * 0.30; 42 | //float flamewob = 0.0; 43 | 44 | float thres = alpha_threshold * tgradient *2.15 + flamewob; 45 | 46 | float alpha = 1.0-smoothstep(thres-0.15, thres+0.3, alpha0); 47 | 48 | 49 | //vec3 color = tgradientcolor * tcolor + (alpha-alpha0); 50 | //vec3 color = tcolor + tcolor * (alpha0-alpha)*0.65; 51 | 52 | vec3 flame = clamp(tnoise * 2.1, 0.0, 1.0) * tgradientcolor; 53 | vec3 color = mix(tcolor, flame, (alpha-alpha0)*1.5); 54 | 55 | 56 | gl_FragColor = vec4(color, alpha); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /demos/shader-fire/frame.lua: -------------------------------------------------------------------------------- 1 | 2 | local elapsed_time = gh_utils.get_elapsed_time() 3 | 4 | gh_camera.bind(camera_ortho) 5 | gh_renderer.clear_color_depth_buffers(0.0, 0.0, 0.0, 1.0, 1.0) 6 | 7 | 8 | local BLEND_FACTOR_ZERO = 0 9 | local BLEND_FACTOR_ONE = 1 10 | local BLEND_FACTOR_SRC_ALPHA = 2 11 | local BLEND_FACTOR_ONE_MINUS_DST_ALPHA = 3 12 | local BLEND_FACTOR_ONE_MINUS_DST_COLOR = 4 13 | local BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = 5 14 | local BLEND_FACTOR_DST_COLOR = 6 15 | local BLEND_FACTOR_DST_ALPHA = 7 16 | local BLEND_FACTOR_SRC_COLOR = 8 17 | local BLEND_FACTOR_ONE_MINUS_SRC_COLOR = 9 18 | 19 | gh_renderer.set_blending_state(1) 20 | gh_renderer.set_blending_factors(BLEND_FACTOR_SRC_ALPHA, BLEND_FACTOR_ONE) 21 | 22 | 23 | gh_texture.bind(tex_noise, 0) 24 | gh_texture.bind(tex_gradient, 1) 25 | gh_texture.bind(tex_gradient_color, 2) 26 | gh_texture.bind(tex_distortion, 3) 27 | gh_texture.bind(tex_color, 4) 28 | gh_gpu_program.bind(texture_prog) 29 | gh_gpu_program.uniform1f(texture_prog, "time", elapsed_time) 30 | gh_gpu_program.uniform1f(texture_prog, "speed", 0.25) 31 | gh_gpu_program.uniform1f(texture_prog, "alpha_threshold", 0.4) 32 | gh_object.render(quad) 33 | 34 | 35 | gh_renderer.set_blending_state(0) 36 | 37 | -------------------------------------------------------------------------------- /demos/shader-fire/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 55 | 56 | 57 | 58 | 59 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /demos/shader-fire/readme.md: -------------------------------------------------------------------------------- 1 |

Fire Shader

2 | 3 | Fire shader for OpenGL 2.1 capable systems (Windows, Linux, macOS and Raspberry Pi). 4 | 5 | Article: 6 | - https://www.geeks3d.com/hacklab/20180504/demo-fire-shader/ 7 | 8 | This demo requires GeeXLab: 9 | - https://www.geeks3d.com/geexlab/downloads/ 10 | 11 | 12 | Screenshots: 13 | 14 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/shader-fire/screenshots/geexlab-simple-fire-shader-glsl-01.jpg) 15 | 16 | -------------------------------------------------------------------------------- /demos/shader-fire/screenshots/_._: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/shader-fire/screenshots/geexlab-simple-fire-shader-glsl-01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shader-fire/screenshots/geexlab-simple-fire-shader-glsl-01.jpg -------------------------------------------------------------------------------- /demos/shader-wireframe/demo_gl32.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 28 | 29 | 30 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 47 | 48 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /demos/shader-wireframe/demo_gles31.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 26 | 27 | 28 | 29 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 45 | 46 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /demos/shader-wireframe/frame.lua: -------------------------------------------------------------------------------- 1 | 2 | local elapsed_time = gh_utils.get_elapsed_time() 3 | local dt = gh_utils.get_time_step() 4 | 5 | frames = frames+1 6 | fps_time = fps_time + dt 7 | if (fps_time >= 1.0) then 8 | fps_time = 0 9 | fps = frames 10 | frames = 0 11 | end 12 | 13 | 14 | if (win_hovered == 0) then 15 | gx_camera.update(camera, dt) 16 | end 17 | gh_camera.bind(camera) 18 | 19 | 20 | 21 | gh_renderer.set_depth_test_state(1) 22 | 23 | 24 | gh_renderer.clear_color_depth_buffers(0.3, 0.3, 0.3, 1, 1.0) 25 | 26 | 27 | 28 | gh_gpu_program.bind(wireframe_prog) 29 | --gh_gpu_program.uniform3f(wireframe_prog, "WIRE_COL", 0.0, 0.0, 0.0, 1.0) 30 | --gh_gpu_program.uniform3f(wireframe_prog, "FILL_COL", 1.0, 0.5, 0.0, 1.0) 31 | --gh_gpu_program.uniform2f(wireframe_prog, "WIN_SCALE", 20, 20) 32 | 33 | 34 | 35 | gh_gpu_program.uniform3f(wireframe_prog, "WIRE_COL", wire_color.r, wire_color.g, wire_color.b, 1.0) 36 | gh_gpu_program.uniform3f(wireframe_prog, "FILL_COL", fill_color.r, fill_color.g, fill_color.b, 1.0) 37 | gh_gpu_program.uniform2f(wireframe_prog, "WIN_SCALE", 25, 25) 38 | 39 | 40 | 41 | --gh_texture.bind(tex0, 0) 42 | gh_object.render(sphere) 43 | gh_object.render(torus) 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | --gx_camera.draw_ref_grid(20, 20, 20, 20) 52 | gx_camera.draw_tripod(camera) 53 | 54 | 55 | 56 | 57 | 58 | 59 | ---[[ 60 | libfont_clear() 61 | 62 | local y_offset = 40 63 | 64 | libfont_print(20, y_offset, 1, 0.5, 0, 1, "Wireframe shader") 65 | y_offset = y_offset + 20 66 | 67 | y_offset = y_offset + 20 68 | libfont_print(20, y_offset, 1, 1, 0, 1, "FPS: " .. fps) 69 | y_offset = y_offset + 20 70 | 71 | y_offset = y_offset + 20 72 | libfont_print(20, y_offset, 1, 1, 0, 1, "GL_RENDERER") 73 | y_offset = y_offset + 20 74 | libfont_print(20, y_offset, 1, 1, 1, 1, "> " .. gl_renderer) 75 | y_offset = y_offset + 20 76 | 77 | libfont_print(20, y_offset, 1, 1, 0, 1, "GL_VERSION") 78 | y_offset = y_offset + 20 79 | libfont_print(20, y_offset, 1, 1, 1, 1, "> " .. gl_version) 80 | y_offset = y_offset + 20 81 | 82 | 83 | libfont_render() 84 | --]] 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | imgui_frame_begin() 97 | 98 | --gh_imgui.set_color(IMGUI_TITLE_BG_COLOR, 0.4, 0.4, 0.4, 0.90) 99 | 100 | gh_imgui.set_color(IMGUI_WINDOW_BG_COLOR, 0.1, 0.1, 0.1, 0.6) 101 | 102 | 103 | local pos_size_flag_always = 1 -- Always set the pos and/or size 104 | local pos_size_flag_once = 2 -- Set the pos and/or size once per runtime session (only the first call with succeed) 105 | local pos_size_flag_first_use_ever = 4 -- Set the pos and/or size if the window has no saved data (if doesn't exist in the .ini file) 106 | local pos_size_flag_appearing = 8 -- Set the pos and/or size if the window is appearing after being hidden/inactive (or the first time) 107 | 108 | local window_flags = ImGuiWindowFlags_NoResize 109 | 110 | local is_open = gh_imgui.window_begin("Control panel", 300, 200, 10, 200, window_flags, pos_size_flag_once, pos_size_flag_once) 111 | --local is_open = imgui_window_begin_v1("Control panel", 360, 560, 20, 20) 112 | if (is_open == 1) then 113 | 114 | 115 | 116 | win_hovered = gh_imgui.is_window_hovered() 117 | 118 | 119 | local window_w = gh_imgui.get_content_region_available_width() 120 | 121 | local widget_width = window_w * 1.0 122 | 123 | 124 | gh_imgui.text("Press [ESC] to quit the demo") 125 | 126 | ---[[ 127 | 128 | imgui_vertical_space() 129 | imgui_vertical_space() 130 | 131 | 132 | gh_imgui.push_item_width(widget_width) 133 | 134 | --[[ 135 | gh_imgui.text("Simulation speed factor") 136 | local min_value = 1.0 137 | local max_value = 200.0 138 | local power = 1.0 139 | g_simulation_speed_factor = gh_imgui.slider_1f("##simspeed", g_simulation_speed_factor, min_value, max_value, power) 140 | 141 | imgui_vertical_space() 142 | imgui_vertical_space() 143 | --]] 144 | 145 | 146 | imgui_vertical_space() 147 | imgui_vertical_space() 148 | 149 | local dummy_a = 1.0 150 | 151 | gh_imgui.text("Wire color") 152 | wire_color.r, wire_color.g, wire_color.b, dummy_a = gh_imgui.color_edit_rgba("##colorpicker-wire", wire_color.r, wire_color.g, wire_color.b, dummy_a) 153 | 154 | imgui_vertical_space() 155 | imgui_vertical_space() 156 | 157 | gh_imgui.text("Fill color") 158 | fill_color.r, fill_color.g, fill_color.b, dummy_a = gh_imgui.color_edit_rgba("##colorpicker-fill", fill_color.r, fill_color.g, fill_color.b, dummy_a) 159 | 160 | 161 | gh_imgui.pop_item_width() 162 | --]] 163 | 164 | 165 | end 166 | 167 | imgui_window_end() 168 | 169 | imgui_frame_end() 170 | -- 171 | -- ImGui end --------------------------------------------------------------- 172 | ---------------------------------------------------------------------------- 173 | --]] 174 | -------------------------------------------------------------------------------- /demos/shader-wireframe/init.lua: -------------------------------------------------------------------------------- 1 | 2 | local demo_dir = gh_utils.get_demo_dir() 3 | 4 | local lib_dir = gh_utils.get_scripting_libs_dir() 5 | dofile(lib_dir .. "lua/gx_cam_lib_v1.lua") 6 | dofile(lib_dir .. "lua/libfont/libfont1.lua") 7 | dofile(lib_dir .. "lua/imgui.lua") 8 | 9 | 10 | winW, winH = gh_window.getsize(0) 11 | 12 | 13 | 14 | 15 | --[[ 16 | local aspect = winW / winH 17 | camera = gh_camera.create_persp(60, aspect, 0.1, 1000.0) 18 | gh_camera.set_viewport(camera, 0, 0, winW, winH) 19 | gh_camera.set_position(camera, 0, 0.2, 0.4) 20 | gh_camera.set_lookat(camera, 0, 0, 0, 1) 21 | gh_camera.setupvec(camera, 0, 1, 0, 0) 22 | --]] 23 | 24 | 25 | 26 | 27 | 28 | orbit_mode = 1 29 | keyboard_speed = 10.0 30 | camera_fov = 60.0 31 | camera_lookat_x = 0 32 | camera_lookat_y = 0 33 | camera_lookat_z = 0 34 | 35 | camera = gx_camera.create_perspective(60, 1, 0, 0, winW, winH, 1, 1000) 36 | gh_camera.set_position(camera, 0, 0, 15) 37 | gx_camera.init_orientation(camera, 0, 0, 0, 30, 90) 38 | 39 | if (orbit_mode == 1) then 40 | gx_camera.set_mode_orbit() 41 | else 42 | gx_camera.set_mode_fly() 43 | end 44 | 45 | gx_camera.set_orbit_lookat(camera, camera_lookat_x, camera_lookat_y, camera_lookat_z) 46 | gx_camera.set_keyboard_speed(keyboard_speed) 47 | gh_camera.set_fov(camera, camera_fov) 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | wire_color = {r=1.0, g=1.0, b=1.0, a=1.0} 58 | fill_color = {r=1.0, g=0.5, b=0.0, a=1.0} 59 | 60 | 61 | wireframe_prog = gh_node.getid("wireframe_prog") 62 | 63 | 64 | win_hovered = 0 65 | 66 | 67 | 68 | 69 | 70 | ---[[ 71 | local radius = 8.0 72 | local section_radius = 1.0 73 | local subdivisions = 20 74 | torus = gh_mesh.create_torus(radius, section_radius, subdivisions) 75 | gh_object.set_position(torus, 0, 0, 0) 76 | --]] 77 | 78 | 79 | local radius = 5 80 | local subdivisions = 30 81 | sphere = gh_mesh.create_sphere(radius, subdivisions, subdivisions) 82 | gh_object.set_position(sphere, 0, 0, 0) 83 | gh_object.set_euler_angles(sphere, 90, 0, 0) 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | gh_renderer.set_vsync(0) 93 | 94 | last_time = gh_utils.get_elapsed_time() 95 | 96 | 97 | gl_renderer = gh_renderer.get_renderer_model() 98 | gl_version = gh_renderer.get_api_version() 99 | 100 | 101 | fps_time = 0 102 | fps = 0 103 | frames = 0 104 | 105 | -------------------------------------------------------------------------------- /demos/shader-wireframe/readme.md: -------------------------------------------------------------------------------- 1 |

Wireframe shader demo

2 | 3 | Wireframe shader based on a geometry shader. This shader supports indexed meshes. 4 | 5 | This demo requires an OpenGL 3.2 support (Windows, Linux and macOS) 6 | or an OpenGL ES 3.1 support (ASUS Tinker Board). 7 | 8 | 9 | Article: 10 | - https://www.geeks3d.com/hacklab/20180514/demo-wireframe-shader-opengl-3-2-and-opengl-es-3-1/ 11 | 12 | 13 | 14 | Screenshots 15 |
16 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-32-01.jpg) 17 | 18 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-es-31-04.jpg) 19 | 20 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-32-02.jpg) 21 | 22 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-32-03.jpg) 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /demos/shader-wireframe/screenshots/_._: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-32-01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-32-01.jpg -------------------------------------------------------------------------------- /demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-32-02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-32-02.jpg -------------------------------------------------------------------------------- /demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-32-03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-32-03.jpg -------------------------------------------------------------------------------- /demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-es-31-04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shader-wireframe/screenshots/geexlab-wireframe-shader-demo-opengl-es-31-04.jpg -------------------------------------------------------------------------------- /demos/shader-wireframe/shaders/_._: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/shader-wireframe/shaders/gl32_gs.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | layout(triangles) in; 3 | layout(triangle_strip, max_vertices=3) out; 4 | uniform mat4 gxl3d_ModelViewProjectionMatrix; // GeeXLab auto uniform 5 | uniform vec2 WIN_SCALE; 6 | 7 | out vec3 dist; 8 | 9 | void main() 10 | { 11 | vec4 p0_3d = gl_in[0].gl_Position; 12 | vec4 p1_3d = gl_in[1].gl_Position; 13 | vec4 p2_3d = gl_in[2].gl_Position; 14 | 15 | // Compute the vertex position in the usual fashion. 16 | p0_3d = gxl3d_ModelViewProjectionMatrix * p0_3d; 17 | // 2D position 18 | vec2 p0 = p0_3d.xy / p0_3d.w; 19 | 20 | // Compute the vertex position in the usual fashion. 21 | p1_3d = gxl3d_ModelViewProjectionMatrix * p1_3d; 22 | // 2D position 23 | vec2 p1 = p1_3d.xy / p1_3d.w; 24 | 25 | // Compute the vertex position in the usual fashion. 26 | p2_3d = gxl3d_ModelViewProjectionMatrix * p2_3d; 27 | // 2D position 28 | vec2 p2 = p2_3d.xy / p2_3d.w; 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | // Project p1 and p2 and compute the vectors v1 = p1-p0 37 | // and v2 = p2-p0 38 | vec2 v10 = WIN_SCALE*(p1 - p0); 39 | vec2 v20 = WIN_SCALE*(p2 - p0); 40 | 41 | // Compute 2D area of triangle. 42 | float area0 = abs(v10.x*v20.y - v10.y*v20.x); 43 | 44 | // Compute distance from vertex to line in 2D coords 45 | float h0 = area0/length(v10-v20); 46 | 47 | dist = vec3(h0, 0.0, 0.0); 48 | 49 | // Quick fix to defy perspective correction 50 | dist *= p0_3d.w; 51 | 52 | gl_Position = p0_3d; 53 | 54 | EmitVertex(); 55 | 56 | 57 | 58 | 59 | 60 | 61 | // Project p0 and p2 and compute the vectors v01 = p0-p1 62 | // and v21 = p2-p1 63 | vec2 v01 = WIN_SCALE*(p0 - p1); 64 | vec2 v21 = WIN_SCALE*(p2 - p1); 65 | 66 | // Compute 2D area of triangle. 67 | float area1 = abs(v01.x*v21.y - v01.y*v21.x); 68 | 69 | // Compute distance from vertex to line in 2D coords 70 | float h1 = area1/length(v01-v21); 71 | 72 | 73 | dist = vec3(0.0, h1, 0.0); 74 | 75 | // Quick fix to defy perspective correction 76 | dist *= p1_3d.w; 77 | 78 | gl_Position = p1_3d; 79 | 80 | EmitVertex(); 81 | 82 | 83 | 84 | 85 | // Project p0 and p1 and compute the vectors v02 = p0-p2 86 | // and v12 = p1-p2 87 | vec2 v02 = WIN_SCALE*(p0 - p2); 88 | vec2 v12 = WIN_SCALE*(p1 - p2); 89 | 90 | // Compute 2D area of triangle. 91 | float area2 = abs(v02.x*v12.y - v02.y*v12.x); 92 | 93 | // Compute distance from vertex to line in 2D coords 94 | float h2 = area2/length(v02-v12); 95 | 96 | dist = vec3(0.0, 0.0, h2); 97 | 98 | // Quick fix to defy perspective correction 99 | dist *= p2_3d.w; 100 | 101 | gl_Position = p2_3d; 102 | 103 | 104 | EmitVertex(); 105 | 106 | EndPrimitive(); 107 | 108 | } 109 | 110 | 111 | -------------------------------------------------------------------------------- /demos/shader-wireframe/shaders/gl32_ps.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec3 WIRE_COL; 4 | uniform vec3 FILL_COL; 5 | in vec3 dist; 6 | out vec4 FragColor; 7 | void main() 8 | { 9 | // Undo perspective correction. 10 | //vec3 dist_vec = dist * gl_FragCoord.w; 11 | 12 | // Wireframe rendering is better like this: 13 | vec3 dist_vec = dist; 14 | 15 | // Compute the shortest distance to the edge 16 | float d = min(dist_vec[0], min(dist_vec[1], dist_vec[2])); 17 | 18 | // Compute line intensity and then fragment color 19 | float I = exp2(-2.0*d*d); 20 | 21 | FragColor.rgb = I*WIRE_COL + (1.0 - I)*FILL_COL; 22 | FragColor.a = 1.0; 23 | } 24 | -------------------------------------------------------------------------------- /demos/shader-wireframe/shaders/gles3_gs.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | #extension GL_EXT_geometry_shader: require 3 | 4 | precision highp float; 5 | 6 | layout(triangles) in; 7 | layout(triangle_strip, max_vertices=3) out; 8 | uniform mat4 gxl3d_ModelViewProjectionMatrix; // GeeXLab auto uniform 9 | uniform vec2 WIN_SCALE; 10 | 11 | out vec3 dist; 12 | 13 | void main() 14 | { 15 | vec4 p0_3d = gl_in[0].gl_Position; 16 | vec4 p1_3d = gl_in[1].gl_Position; 17 | vec4 p2_3d = gl_in[2].gl_Position; 18 | 19 | // Compute the vertex position in the usual fashion. 20 | p0_3d = gxl3d_ModelViewProjectionMatrix * p0_3d; 21 | // 2D position 22 | vec2 p0 = p0_3d.xy / p0_3d.w; 23 | 24 | // Compute the vertex position in the usual fashion. 25 | p1_3d = gxl3d_ModelViewProjectionMatrix * p1_3d; 26 | // 2D position 27 | vec2 p1 = p1_3d.xy / p1_3d.w; 28 | 29 | // Compute the vertex position in the usual fashion. 30 | p2_3d = gxl3d_ModelViewProjectionMatrix * p2_3d; 31 | // 2D position 32 | vec2 p2 = p2_3d.xy / p2_3d.w; 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | // Project p1 and p2 and compute the vectors v1 = p1-p0 41 | // and v2 = p2-p0 42 | vec2 v10 = WIN_SCALE*(p1 - p0); 43 | vec2 v20 = WIN_SCALE*(p2 - p0); 44 | 45 | // Compute 2D area of triangle. 46 | float area0 = abs(v10.x*v20.y - v10.y*v20.x); 47 | 48 | // Compute distance from vertex to line in 2D coords 49 | float h0 = area0/length(v10-v20); 50 | 51 | dist = vec3(h0, 0.0, 0.0); 52 | 53 | // Quick fix to defy perspective correction 54 | dist *= p0_3d.w; 55 | 56 | gl_Position = p0_3d; 57 | 58 | EmitVertex(); 59 | 60 | 61 | 62 | 63 | 64 | 65 | // Project p0 and p2 and compute the vectors v01 = p0-p1 66 | // and v21 = p2-p1 67 | vec2 v01 = WIN_SCALE*(p0 - p1); 68 | vec2 v21 = WIN_SCALE*(p2 - p1); 69 | 70 | // Compute 2D area of triangle. 71 | float area1 = abs(v01.x*v21.y - v01.y*v21.x); 72 | 73 | // Compute distance from vertex to line in 2D coords 74 | float h1 = area1/length(v01-v21); 75 | 76 | 77 | dist = vec3(0.0, h1, 0.0); 78 | 79 | // Quick fix to defy perspective correction 80 | dist *= p1_3d.w; 81 | 82 | gl_Position = p1_3d; 83 | 84 | EmitVertex(); 85 | 86 | 87 | 88 | 89 | // Project p0 and p1 and compute the vectors v02 = p0-p2 90 | // and v12 = p1-p2 91 | vec2 v02 = WIN_SCALE*(p0 - p2); 92 | vec2 v12 = WIN_SCALE*(p1 - p2); 93 | 94 | // Compute 2D area of triangle. 95 | float area2 = abs(v02.x*v12.y - v02.y*v12.x); 96 | 97 | // Compute distance from vertex to line in 2D coords 98 | float h2 = area2/length(v02-v12); 99 | 100 | dist = vec3(0.0, 0.0, h2); 101 | 102 | // Quick fix to defy perspective correction 103 | dist *= p2_3d.w; 104 | 105 | gl_Position = p2_3d; 106 | 107 | 108 | EmitVertex(); 109 | 110 | EndPrimitive(); 111 | 112 | } 113 | -------------------------------------------------------------------------------- /demos/shader-wireframe/shaders/gles3_ps.glsl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | precision highp float; 3 | 4 | uniform vec3 WIRE_COL; 5 | uniform vec3 FILL_COL; 6 | in vec3 dist; 7 | out vec4 FragColor; 8 | void main() 9 | { 10 | // Undo perspective correction. 11 | //vec3 dist_vec = dist * gl_FragCoord.w; 12 | 13 | // Wireframe rendering is better like this: 14 | vec3 dist_vec = dist; 15 | 16 | // Compute the shortest distance to the edge 17 | float d = min(dist_vec[0], min(dist_vec[1], dist_vec[2])); 18 | 19 | // Compute line intensity and then fragment color 20 | float I = exp2(-2.0*d*d); 21 | 22 | FragColor.rgb = I*WIRE_COL + (1.0 - I)*FILL_COL; 23 | FragColor.a = 1.0; 24 | } 25 | -------------------------------------------------------------------------------- /demos/shadertoy/common/_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/shadertoy/common/_frame_begin.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | kx_frame_begin(0.0, 0.0, 0.0) 4 | 5 | kx_check_input() 6 | 7 | 8 | local elapsed_time = kx_gettime() 9 | 10 | local mx, my = kx_mouse_get_position() 11 | my = winH - my 12 | 13 | gh_camera.bind(camera_ortho) 14 | 15 | gh_renderer.set_depth_test_state(0) 16 | 17 | gh_gpu_program.bind(shadertoy_prog) 18 | gh_gpu_program.uniform3f(shadertoy_prog, "iResolution", winW, winH, 0.0) 19 | gh_gpu_program.uniform1f(shadertoy_prog, "iGlobalTime", elapsed_time) 20 | gh_gpu_program.uniform1f(shadertoy_prog, "iTime", elapsed_time) 21 | gh_gpu_program.uniform4f(shadertoy_prog, "iMouse", mx, my, 0, 0) 22 | 23 | 24 | -------------------------------------------------------------------------------- /demos/shadertoy/common/_frame_end.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | gh_object.render(g_quad) 4 | 5 | 6 | local show_osi = kx_get_osi_state() 7 | 8 | kx_frame_end(show_osi) 9 | -------------------------------------------------------------------------------- /demos/shadertoy/common/_init.lua: -------------------------------------------------------------------------------- 1 | 2 | local lib_dir = gh_utils.get_scripting_libs_dir() 3 | local framework_dir = lib_dir .. "lua/framework_v1/" 4 | dofile(framework_dir .. "kx.lua") 5 | 6 | 7 | kx_init_begin(framework_dir) 8 | 9 | kx_set_demo_caption("Shadertoy demo") 10 | 11 | 12 | 13 | 14 | 15 | 16 | winW, winH = gh_window.getsize(0) 17 | g_quad = gh_mesh.create_quad(winW, winH) 18 | 19 | 20 | camera_ortho = kx_get_ortho_camera() 21 | 22 | shadertoy_prog = gh_node.getid("shadertoy_prog") 23 | 24 | 25 | 26 | kx_init_end() 27 | 28 | -------------------------------------------------------------------------------- /demos/shadertoy/common/_readme_utils.txt: -------------------------------------------------------------------------------- 1 | 2 | Loading a texture (INIT script) 3 | -------------------------------------------------------------- 4 | 5 | local demo_dir = gh_utils.get_demo_dir() 6 | local abs_path = 0 7 | local PF_U8_RGB = 1 8 | local PF_U8_RGBA = 3 9 | local pixel_format = PF_U8_RGBA 10 | local gen_mipmaps = 1 11 | local compressed_texture = 0 12 | tex0 = gh_texture.create_from_file_v6(demo_dir .. "./data/tex17.jpg", pixel_format, gen_mipmaps, compressed_texture) 13 | 14 | 15 | 16 | Binding a texture (FRAME script) 17 | -------------------------------------------------------------- 18 | 19 | gh_texture.bind(tex0, 0) 20 | gh_gpu_program.uniform1i(shadertoy_prog, "iChannel0", 0) 21 | 22 | 23 | 24 | Texture in the pixel shader 25 | ----------------------------- 26 | 27 | uniform sampler2D iChannel0; 28 | 29 | vec4 c = texture2D(iChannel0, uv); 30 | -------------------------------------------------------------------------------- /demos/shadertoy/common/_resize.lua: -------------------------------------------------------------------------------- 1 | 2 | kx_resize() 3 | 4 | winW, winH = gh_window.getsize(0) 5 | gh_mesh.update_quad_size(g_quad, winW, winH) 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demos/shadertoy/common/_terminate.lua: -------------------------------------------------------------------------------- 1 | 2 | kx_terminate() 3 | 4 | -------------------------------------------------------------------------------- /demos/shadertoy/common/_vs_gl2.glsl: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | gl_TexCoord[0] = gl_MultiTexCoord0; 4 | gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex; 5 | } 6 | -------------------------------------------------------------------------------- /demos/shadertoy/data/_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/shadertoy/data/ground010.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/ground010.jpg -------------------------------------------------------------------------------- /demos/shadertoy/data/tex01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex01.jpg -------------------------------------------------------------------------------- /demos/shadertoy/data/tex02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex02.jpg -------------------------------------------------------------------------------- /demos/shadertoy/data/tex03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex03.jpg -------------------------------------------------------------------------------- /demos/shadertoy/data/tex05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex05.jpg -------------------------------------------------------------------------------- /demos/shadertoy/data/tex06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex06.jpg -------------------------------------------------------------------------------- /demos/shadertoy/data/tex09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex09.jpg -------------------------------------------------------------------------------- /demos/shadertoy/data/tex10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex10.png -------------------------------------------------------------------------------- /demos/shadertoy/data/tex11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex11.png -------------------------------------------------------------------------------- /demos/shadertoy/data/tex16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex16.png -------------------------------------------------------------------------------- /demos/shadertoy/data/tex17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex17.jpg -------------------------------------------------------------------------------- /demos/shadertoy/data/tex18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex18.jpg -------------------------------------------------------------------------------- /demos/shadertoy/data/tex19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex19.png -------------------------------------------------------------------------------- /demos/shadertoy/data/tex21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/data/tex21.png -------------------------------------------------------------------------------- /demos/shadertoy/dual-3d-truchet-tiles-opengl21.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 39 | 40 | 41 | 42 | 50 | 169 | 170 | 171 | 172 | 173 | 181 | 182 | 183 | 184 | 185 | 217 | 218 | 219 | 229 | 230 | 231 | 232 | -------------------------------------------------------------------------------- /demos/shadertoy/readme.md: -------------------------------------------------------------------------------- 1 | 2 | Some Shadertoy demos converted to GeeXLab 3 | 4 | 5 | dual-3d-truchet-tiles-opengl21.xml (OpenGL 2.1) 6 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/shadertoy/screenshots/shadertoy-dual-3d-truchet-tiles.jpg) 7 | 8 | dual-3d-truchet-tiles-vulkan.xml (Vulkan) 9 | ![alt text](https://github.com/jegx/geexlab/blob/master/demos/shadertoy/screenshots/geexlab-shadertoy-dual-3d-truchet-tiles-vulkan.jpg) 10 | -------------------------------------------------------------------------------- /demos/shadertoy/screenshots/_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/shadertoy/screenshots/geexlab-shadertoy-dual-3d-truchet-tiles-vulkan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/screenshots/geexlab-shadertoy-dual-3d-truchet-tiles-vulkan.jpg -------------------------------------------------------------------------------- /demos/shadertoy/screenshots/shadertoy-dual-3d-truchet-tiles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/screenshots/shadertoy-dual-3d-truchet-tiles.jpg -------------------------------------------------------------------------------- /demos/shadertoy/spirv/_: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/shadertoy/spirv/s01-vs.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/spirv/s01-vs.spv -------------------------------------------------------------------------------- /demos/shadertoy/spirv/s01-vs.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #extension GL_ARB_separate_shader_objects : enable 4 | #extension GL_ARB_shading_language_420pack : enable 5 | 6 | 7 | layout (std140, binding = 0) uniform uniforms_t 8 | { 9 | mat4 ViewProjectionMatrix; 10 | mat4 ModelMatrix; 11 | vec4 param1; 12 | } ub; 13 | 14 | 15 | layout (location = 0) in vec4 vposition; 16 | layout (location = 1) in vec4 vtexcoord; 17 | layout (location = 2) in vec4 vnormal; 18 | layout (location = 3) in vec4 vcolor; 19 | 20 | layout (location = 0) out vec4 v_color; 21 | layout (location = 1) out vec4 v_texcoord; 22 | 23 | out gl_PerVertex 24 | { 25 | vec4 gl_Position; 26 | 27 | }; 28 | 29 | void main() 30 | { 31 | vec4 P = ub.ModelMatrix * vposition; 32 | //vec4 P = vposition; 33 | gl_Position = ub.ViewProjectionMatrix * P; 34 | 35 | // GL->VK conventions 36 | gl_Position.y = -gl_Position.y; 37 | gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0; 38 | 39 | v_color = vcolor; 40 | v_texcoord = vtexcoord; 41 | } 42 | -------------------------------------------------------------------------------- /demos/shadertoy/spirv/s03-ps.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jegx/geexlab/ef7cfb6c7de4d0f18d5a8c948b65580a2087f8c0/demos/shadertoy/spirv/s03-ps.spv -------------------------------------------------------------------------------- /learn-pack/01-basic/01-clear-screen/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 25 | 33 | 34 | 35 | 36 | 37 | 38 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /learn-pack/01-basic/01-clear-screen/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /learn-pack/01-basic/02-hello-world/hello_world_v1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 16 | 17 | 18 | 19 | 35 | 36 | 37 | 38 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /learn-pack/01-basic/02-hello-world/hello_world_v2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 37 | 38 | 39 | 40 | 41 | 100 | 101 | 102 | 103 | 104 | 105 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /learn-pack/01-basic/02-hello-world/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /learn-pack/01-basic/02-hello-world/v3/frame.lua: -------------------------------------------------------------------------------- 1 | 2 | local elapsed_time = gh_utils.get_elapsed_time() 3 | 4 | 5 | -- Clear the background with an uniform color. 6 | -- Each channel of an RGB color ranges from 0.0 to 1.0. 7 | -- Some examples: 8 | -- white color = [1.0, 1.0, 1.0] 9 | -- red color = [1.0, 0.0, 0.0] 10 | -- green color = [0.0, 1.0, 0.0] 11 | -- bleu color = [0.0, 0.0, 1.0] 12 | -- 13 | gh_renderer.clear_color_buffer(0.0, 0.2, 0.2, 1.0) 14 | 15 | 16 | -- Font position is relative to screen coordinates. The position (0, 0) is the top-left corner. 17 | -- The position of the center of the screen is (screen_width/2, screen_height/2) 18 | -- 19 | local x = 10 20 | local y = 100 21 | 22 | gh_utils.font_render(font, x, y, 0.2, 1.0, 0.0, 1.0, "Hello World from GeeXLab!") 23 | gh_utils.font_render(font, 10, y+40, 0.6, 0.6, 0.6, 1.0, string.format("Elapsed time: %.3f sec.", elapsed_time)) 24 | 25 | gh_utils.font_render(font, 10, y+60, 0.9, 0.5, 0.1, 1.0, string.format("Window size: %d x %d", winW, winH)) 26 | 27 | 28 | 29 | -- Move a text around the screen center 30 | -- 31 | x = winW/2 + 20 * math.sin(elapsed_time * 2.0) 32 | y = winH/2 + 20 * math.cos(elapsed_time * 2.0) 33 | gh_utils.font_render(font, x, y, 1.0, 1.0, 0.1, 1.0, string.format("", x, y)) 34 | 35 | 36 | 37 | -- Text at the four corners of the screen. 38 | -- 39 | 40 | x = 5 41 | y = 0 42 | gh_utils.font_render(font, x, y, 1.0, 1.0, 0.1, 1.0, string.format("[x:%.0f - y:%.0f]", x-5, y)) 43 | 44 | x = winW-85 45 | y = 0 46 | gh_utils.font_render(font, x, y, 1.0, 1.0, 0.1, 1.0, string.format("[x:%.0f - y:%.0f]", x+85, y)) 47 | 48 | x = winW-105 49 | y = winH-20 50 | gh_utils.font_render(font, x, y, 1.0, 1.0, 0.1, 1.0, string.format("[x:%.0f - y:%.0f]", x+105, y+20)) 51 | 52 | x = 5 53 | y = winH-20 54 | gh_utils.font_render(font, x, y, 1.0, 1.0, 0.1, 1.0, string.format("[x:%.0f - y:%.0f]", x-5, y+20)) 55 | 56 | -------------------------------------------------------------------------------- /learn-pack/01-basic/02-hello-world/v3/init.lua: -------------------------------------------------------------------------------- 1 | 2 | -- Gets the size of the 3D window. 3 | -- winW, winH are global. 4 | -- 5 | winW, winH = gh_window.getsize(0) 6 | 7 | 8 | local demo_dir = gh_utils.get_demo_dir() 9 | dofile(demo_dir .. "super_init.lua") 10 | 11 | 12 | 13 | 14 | -- A font for displaying some information. 15 | -- This kind of font works only with OpenGL 2.1 16 | -- or OpenGL 3.2+ with compatibility profile. This font 17 | -- does not work on macOS with OpenGL 3.2+ because macOS 18 | -- uses core profile. Look at gh_font lib for better font support 19 | -- (an example is available in learn/01-basic/text-ttf-font/ folder 20 | -- of the code sample pack). 21 | -- 22 | font = gh_utils.font_create("Tahoma", 14) 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /learn-pack/01-basic/02-hello-world/v3/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /learn-pack/01-basic/02-hello-world/v3/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /learn-pack/01-basic/02-hello-world/v3/super_init.lua: -------------------------------------------------------------------------------- 1 | 2 | gh_utils.trace("Super INIT") 3 | gh_utils.trace(string.format("<%d x %d>", winW, winH)) 4 | 5 | -- Enables vertical synchronization. 6 | gh_renderer.vsync(1) -------------------------------------------------------------------------------- /learn-pack/01-basic/03-line/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 62 | 63 | 112 | 113 | 114 | 132 | 133 | 134 | 135 | 136 | 137 | 140 | 141 | 148 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /learn-pack/01-basic/04-triangle/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 94 | 95 | 120 | 121 | 122 | 140 | 141 | 142 | 143 | 144 | 145 | 149 | 150 | 159 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /learn-pack/readme.md: -------------------------------------------------------------------------------- 1 |

GeeXLab Learning Pack

2 | 3 | The learn-pack contains code samples sorted by difficulty. 4 | This demo pack is a nice way to discover GeeXLab. You can see it 5 | as an entry point to GeeXlab programming. Once you will be 6 | more comfortable with these samples, you will be able to browse 7 | the whole code sample pack without fear. 8 | 9 | Demos of this learning pack rely on OpenGL 2.1. Why OpenGL 2.1? 10 | Because it's the only 3D API available on all platforms supported 11 | by GeeXLab: Windows, Linux, macOS and above all Raspberry Pi. 12 | 13 | The learn/01-basic/ folder covers all fundamental demos that are 14 | the base blocks for other more advanced demos. Each demo in this 15 | folder is based on concepts introduced in previous demos. 16 | 17 | The learn/01-intermediate/ folder covers more interesting features 18 | and effects like lighting shaders, simple physics, webcam, post 19 | processing or particles. 20 | 21 | A learn/03-advanced/ and maybe a learn/04-graphics-hackers/ 22 | subpacks are planned... 23 | 24 | --------------------------------------------------------------------------------