├── LICENSE ├── README.md ├── examples ├── .gitignore ├── DirectX11 │ ├── im3d.hlsl │ ├── im3d_directx11.cpp │ ├── imgui.hlsl │ ├── model.hlsl │ ├── premake5.lua │ ├── vs2017 │ │ ├── im3d_directx11.sln │ │ ├── im3d_directx11.vcxproj │ │ └── im3d_directx11.vcxproj.filters │ └── vs2019 │ │ ├── im3d_directx11.sln │ │ ├── im3d_directx11.vcxproj │ │ └── im3d_directx11.vcxproj.filters ├── MultiContext │ ├── gmake │ │ ├── Makefile │ │ └── im3d_multicontext.make │ ├── im3d.glsl │ ├── im3d_multicontext.cpp │ ├── imgui.glsl │ ├── model.glsl │ ├── premake5.lua │ ├── vs2017 │ │ ├── im3d_multicontext.sln │ │ ├── im3d_multicontext.vcxproj │ │ └── im3d_multicontext.vcxproj.filters │ └── vs2019 │ │ ├── im3d_multicontext.sln │ │ ├── im3d_multicontext.vcxproj │ │ └── im3d_multicontext.vcxproj.filters ├── OpenGL31 │ ├── gmake │ │ ├── Makefile │ │ ├── im3d_opengl3.make │ │ └── im3d_opengl31.make │ ├── im3d.glsl │ ├── im3d_opengl31.cpp │ ├── imgui.glsl │ ├── model.glsl │ ├── premake5.lua │ ├── vs2017 │ │ ├── im3d_opengl31.sln │ │ ├── im3d_opengl31.vcxproj │ │ └── im3d_opengl31.vcxproj.filters │ └── vs2019 │ │ ├── im3d_opengl31.sln │ │ ├── im3d_opengl31.vcxproj │ │ └── im3d_opengl31.vcxproj.filters ├── OpenGL33 │ ├── gmake │ │ ├── Makefile │ │ ├── im3d_opengl3.make │ │ └── im3d_opengl33.make │ ├── im3d.glsl │ ├── im3d_opengl33.cpp │ ├── imgui.glsl │ ├── model.glsl │ ├── premake5.lua │ ├── vs2017 │ │ ├── im3d_opengl33.sln │ │ ├── im3d_opengl33.vcxproj │ │ └── im3d_opengl33.vcxproj.filters │ └── vs2019 │ │ ├── im3d_opengl33.sln │ │ ├── im3d_opengl33.vcxproj │ │ └── im3d_opengl33.vcxproj.filters └── common │ ├── GL │ ├── eglew.h │ ├── glew.c │ ├── glew.h │ ├── glxew.h │ └── wglew.h │ ├── im3d_example.cpp │ ├── im3d_example.h │ ├── imgui │ ├── LICENSE.txt │ ├── imconfig.h │ ├── imgui.cpp │ ├── imgui.h │ ├── imgui_demo.cpp │ ├── imgui_draw.cpp │ ├── imgui_internal.h │ ├── imgui_widgets.cpp │ ├── imstb_rectpack.h │ ├── imstb_textedit.h │ └── imstb_truetype.h │ ├── main.cpp │ └── teapot.h ├── im3d.cpp ├── im3d.h ├── im3d_config.h └── im3d_math.h /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2025 John Chapman 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Im3d is a small, self-contained library for immediate mode rendering of basic primitives (points, lines, triangles), plus an immediate mode UI which provides 3d manipulation 'gizmos' and other tools. It is platform and graphics API agnostic and designed to be compatible with VR. 2 | 3 | Im3d outputs vertex buffers for rendering by the application. Im3d does not affect the system graphics state directly, therefore Im3d calls can be made from anywhere in the application code. This is useful for graphics debugging, 3d data visualization, writing CAD & game development tools, etc. 4 | 5 | ![Demo Screenshot 1](https://github.com/john-chapman/im3d/wiki/images/im3d_demo1.jpg) 6 | ![Demo Screenshot 2](https://github.com/john-chapman/im3d/wiki/images/im3d_demo2.jpg) 7 | ![Demo Screenshot 3](https://github.com/john-chapman/im3d/wiki/images/im3d_demo3.jpg) 8 | 9 | The API design follows OpenGL immediate mode in that it functions as a state machine: 10 | 11 | ```C++ 12 | Im3d::PushDrawState(); 13 | Im3d::SetSize(2.0f); 14 | Im3d::BeginLineLoop(); 15 | Im3d::Vertex(0.0f, 0.0f, 0.0f, Im3d::Color_Magenta); 16 | Im3d::Vertex(1.0f, 1.0f, 0.0f, Im3d::Color_Yellow); 17 | Im3d::Vertex(2.0f, 2.0f, 0.0f, Im3d::Color_Cyan); 18 | Im3d::End(); 19 | Im3d::PopDrawState(); 20 | ``` 21 | *A key point to note is that there is no view-projection matrix here - the requirement for VR support precludes this. Instead, all vertices are specified in world space and the view-projection transform is applied at draw time (in the shader).* 22 | 23 | The UI system follows the immediate mode paradigm in that no UI state is retained; you can create gizmos from anywhere in the code: 24 | 25 | ```C++ 26 | static mat4 transform; 27 | if (Im3d::Gizmo("UnifiedGizmo", &transform)) { 28 | // transform was modified, do something with the matrix 29 | } 30 | ``` 31 | ![Translation Gizmo](https://github.com/john-chapman/im3d/wiki/images/im3d_translation.gif) 32 | ![Rotation Gizmo](https://github.com/john-chapman/im3d/wiki/images/im3d_rotation.gif) 33 | ![Scale Gizmo](https://github.com/john-chapman/im3d/wiki/images/im3d_scale.gif) 34 | 35 | See [here](https://github.com/john-chapman/im3d/blob/master/examples/common/main.cpp) for more complete examples. 36 | 37 | ### Integration 38 | Im3d has no dependencies other than the C standard lib. A C++11 compatible compiler is required. 39 | 40 | Integration is straightforward: 41 | 42 | - Copy the files from the root of this repo and add them to the application project. 43 | - Modify `im3d_config.h` if necessary (e.g. provide a custom `malloc`/`free`, set the vertex data alignment, matrix layout, etc.). It's also possible to `#define IM3D_CONFIG "myfilename.h"` from your build system to avoid modifying this file directly. 44 | 45 | At runtime, the application should then proceed as follows: 46 | 47 | - At startup, initialize the graphics resources (shaders, etc.) required to actually draw the Im3d vertex buffers. 48 | - Each frame, fill the `Im3d::AppData` struct, providing user input and other context data, then call `Im3d::NewFrame()`. 49 | - Towards the end of the frame, call `Im3d::EndFrame()` to finalize draw lists, then access the draw lists for rendering via `Im3d::GetDrawListCount()`, `Im3d::GetDrawLists()[i]`. 50 | 51 | More detailed and API-specific integration examples are available in [examples/](https://github.com/john-chapman/im3d/tree/master/examples). 52 | 53 | ### Frequently Asked Questions (FAQ) 54 | 55 | **Where is the documentation?** 56 | 57 | - [im3d.h](https://github.com/john-chapman/im3d/tree/master/im3d.h) contains the main API documentation. 58 | - [examples/common/main.cpp](https://github.com/john-chapman/im3d/tree/master/examples/common/main.cpp) contains usage examples for most features, especially how to use the `Gizmo*()` API. 59 | - [examples/](https://github.com/john-chapman/im3d/tree/master/examples) contains reference implementations with lots of comments. 60 | - [Im3d wiki](https://github.com/john-chapman/im3d/wiki) provides overviews and additional detail for specific/advanced functionality. 61 | 62 | 63 | **Are geometry shaders required?** 64 | 65 | No, the application is free to render the vertex data in any conceivable manner. Geometry shaders are the easiest way to expand points/lines into triangle strips for rendering, but there are alternatives: 66 | 67 | - Use instanced rendering to draw 1 triangle strip per point/line primitive and do point/line expansion in the vertex shader, manually fetching the vertex data from a constant buffer. See [examples/OpenGL31](https://github.com/john-chapman/im3d/tree/master/examples/OpenGL31) for a reference implementation. 68 | - Rasterize points/lines directly. If the target graphics API doesn't support per-vertex point size/line width this won't draw as nicely but may be good enough. 69 | - Expand points/lines manually on the CPU and draw the converted vertex data as a single large triangle strip. This would obviate the need for shaders entirely, however the performance may be suboptimal. 70 | 71 | 72 | **How can I update to the latest version?** 73 | 74 | - Check which version you currently have; `IM3D_VERSION` is defined at the top of [im3d.h](https://github.com/john-chapman/im3d/tree/master/im3d.h). 75 | - Examine the change log in the latest version of [im3d.cpp](https://github.com/john-chapman/im3d/tree/master/im3d.cpp) to see if there have been any API-breaking changes which require modifications on the application side. 76 | - Overwrite everything, but don't forget to merge changes into `im3d_config.h` if you have made any modifications to your copy. 77 | 78 | **Is Im3d thread safe?** 79 | 80 | Im3d provides no thread safety mechanism per se, however per-thread contexts are fully supported and can be used to make Im3d API calls from multiple threads. See [wiki/Multiple-Contexts](https://github.com/john-chapman/im3d/wiki/Multiple-Contexts) for more info. 81 | -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.ini 3 | 4 | # Visual Studio 5 | **.ilk 6 | **.pdb 7 | **.exp 8 | **.lib 9 | **/vs*/** 10 | !**/vs*/*.sln 11 | !**/vs*/*.vcxproj 12 | !**/vs*/*.filters 13 | 14 | # GNU Makefiles 15 | **/gmake/obj/** -------------------------------------------------------------------------------- /examples/DirectX11/im3d.hlsl: -------------------------------------------------------------------------------- 1 | #if !defined(POINTS) && !defined(LINES) && !defined(TRIANGLES) 2 | #error No primitive type defined 3 | #endif 4 | #if !defined(VERTEX_SHADER) && !defined(GEOMETRY_SHADER) && !defined(PIXEL_SHADER) 5 | #error No shader stage defined 6 | #endif 7 | 8 | struct VS_OUTPUT 9 | { 10 | linear float4 m_position : SV_POSITION; 11 | linear float4 m_color : COLOR; 12 | linear float2 m_uv : TEXCOORD; 13 | noperspective float m_size : SIZE; 14 | noperspective float m_edgeDistance : EDGE_DISTANCE; 15 | }; 16 | 17 | #define kAntialiasing 2.0 18 | 19 | #ifdef VERTEX_SHADER 20 | cbuffer cbContextData : register(b0) 21 | { 22 | float4x4 uViewProjMatrix; 23 | float2 uViewport; 24 | }; 25 | 26 | struct VS_INPUT 27 | { 28 | float4 m_positionSize : POSITION_SIZE; 29 | float4 m_color : COLOR; 30 | }; 31 | 32 | VS_OUTPUT main(VS_INPUT _in) 33 | { 34 | VS_OUTPUT ret; 35 | ret.m_color = _in.m_color.abgr; // swizzle to correct endianness 36 | #if !defined(TRIANGLES) 37 | ret.m_color.a *= smoothstep(0.0, 1.0, _in.m_positionSize.w / kAntialiasing); 38 | #endif 39 | ret.m_size = max(_in.m_positionSize.w, kAntialiasing); 40 | ret.m_position = mul(uViewProjMatrix, float4(_in.m_positionSize.xyz, 1.0)); 41 | return ret; 42 | } 43 | #endif 44 | 45 | #ifdef GEOMETRY_SHADER 46 | cbuffer cbContextData : register(b0) 47 | { 48 | float4x4 uViewProjMatrix; 49 | float2 uViewport; 50 | }; 51 | 52 | #if defined(POINTS) 53 | // expand point -> triangle strip (quad) 54 | [maxvertexcount(4)] 55 | void main(point VS_OUTPUT _in[1], inout TriangleStream out_) 56 | { 57 | VS_OUTPUT ret; 58 | 59 | float2 scale = 1.0 / uViewport * _in[0].m_size; 60 | ret.m_size = _in[0].m_size; 61 | ret.m_color = _in[0].m_color; 62 | ret.m_edgeDistance = _in[0].m_edgeDistance; 63 | 64 | ret.m_position = float4(_in[0].m_position.xy + float2(-1.0, -1.0) * scale * _in[0].m_position.w, _in[0].m_position.zw); 65 | ret.m_uv = float2(0.0, 0.0); 66 | out_.Append(ret); 67 | 68 | ret.m_position = float4(_in[0].m_position.xy + float2( 1.0, -1.0) * scale * _in[0].m_position.w, _in[0].m_position.zw); 69 | ret.m_uv = float2(1.0, 0.0); 70 | out_.Append(ret); 71 | 72 | ret.m_position = float4(_in[0].m_position.xy + float2(-1.0, 1.0) * scale * _in[0].m_position.w, _in[0].m_position.zw); 73 | ret.m_uv = float2(0.0, 1.0); 74 | out_.Append(ret); 75 | 76 | ret.m_position = float4(_in[0].m_position.xy + float2( 1.0, 1.0) * scale * _in[0].m_position.w, _in[0].m_position.zw); 77 | ret.m_uv = float2(1.0, 1.0); 78 | out_.Append(ret); 79 | } 80 | 81 | #elif defined(LINES) 82 | // expand line -> triangle strip 83 | [maxvertexcount(4)] 84 | void main(line VS_OUTPUT _in[2], inout TriangleStream out_) 85 | { 86 | float2 pos0 = _in[0].m_position.xy / _in[0].m_position.w; 87 | float2 pos1 = _in[1].m_position.xy / _in[1].m_position.w; 88 | 89 | float2 dir = pos0 - pos1; 90 | dir = normalize(float2(dir.x, dir.y * uViewport.y / uViewport.x)); // correct for aspect ratio 91 | float2 tng0 = float2(-dir.y, dir.x); 92 | float2 tng1 = tng0 * _in[1].m_size / uViewport; 93 | tng0 = tng0 * _in[0].m_size / uViewport; 94 | 95 | VS_OUTPUT ret; 96 | 97 | // line start 98 | ret.m_size = _in[0].m_size; 99 | ret.m_color = _in[0].m_color; 100 | ret.m_uv = float2(0.0, 0.0); 101 | ret.m_position = float4((pos0 - tng0) * _in[0].m_position.w, _in[0].m_position.zw); 102 | ret.m_edgeDistance = -_in[0].m_size; 103 | out_.Append(ret); 104 | ret.m_position = float4((pos0 + tng0) * _in[0].m_position.w, _in[0].m_position.zw); 105 | ret.m_edgeDistance = _in[0].m_size; 106 | out_.Append(ret); 107 | 108 | // line end 109 | ret.m_size = _in[1].m_size; 110 | ret.m_color = _in[1].m_color; 111 | ret.m_uv = float2(1.0, 1.0); 112 | ret.m_position = float4((pos1 - tng1) * _in[1].m_position.w, _in[1].m_position.zw); 113 | ret.m_edgeDistance = -_in[1].m_size; 114 | out_.Append(ret); 115 | ret.m_position = float4((pos1 + tng1) * _in[1].m_position.w, _in[1].m_position.zw); 116 | ret.m_edgeDistance = _in[1].m_size; 117 | out_.Append(ret); 118 | } 119 | 120 | #endif 121 | #endif 122 | 123 | #ifdef PIXEL_SHADER 124 | float4 main(VS_OUTPUT _in): SV_Target 125 | { 126 | float4 ret = _in.m_color; 127 | 128 | #if defined(LINES) 129 | float d = abs(_in.m_edgeDistance) / _in.m_size; 130 | d = smoothstep(1.0, 1.0 - (kAntialiasing / _in.m_size), d); 131 | ret.a *= d; 132 | 133 | #elif defined(POINTS) 134 | float d = length(_in.m_uv - float2(0.5, 0.5)); 135 | d = smoothstep(0.5, 0.5 - (kAntialiasing / _in.m_size), d); 136 | ret.a *= d; 137 | 138 | #endif 139 | 140 | return ret; 141 | } 142 | #endif 143 | -------------------------------------------------------------------------------- /examples/DirectX11/imgui.hlsl: -------------------------------------------------------------------------------- 1 | struct PS_INPUT 2 | { 3 | float4 m_position : SV_POSITION; 4 | float4 m_color : COLOR0; 5 | float2 m_uv : TEXCOORD0; 6 | }; 7 | 8 | #ifdef VERTEX_SHADER 9 | cbuffer cbContextData : register(b0) 10 | { 11 | float4x4 uProjMatrix; 12 | }; 13 | struct VS_INPUT 14 | { 15 | float2 m_position : POSITION; 16 | float4 m_color : COLOR0; 17 | float2 m_uv : TEXCOORD0; 18 | }; 19 | 20 | PS_INPUT main(VS_INPUT _in) 21 | { 22 | PS_INPUT ret; 23 | ret.m_position = mul(uProjMatrix, float4(_in.m_position.xy, 0.0f, 1.0f)); 24 | ret.m_color = _in.m_color; 25 | ret.m_uv = _in.m_uv; 26 | return ret; 27 | } 28 | #endif 29 | 30 | #ifdef PIXEL_SHADER 31 | Texture2D texture0; 32 | sampler sampler0; 33 | 34 | float4 main(PS_INPUT _in) : SV_Target 35 | { 36 | float4 ret = _in.m_color; 37 | ret.a *= texture0.Sample(sampler0, _in.m_uv).r; 38 | return ret; 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /examples/DirectX11/model.hlsl: -------------------------------------------------------------------------------- 1 | struct VS_OUTPUT 2 | { 3 | linear float4 m_position : SV_POSITION; 4 | linear float3 m_normal : NORMAL; 5 | }; 6 | 7 | #ifdef VERTEX_SHADER 8 | cbuffer cbContextData : register(b0) 9 | { 10 | float4x4 uWorldMatrix; 11 | float4x4 uViewProjMatrix; 12 | }; 13 | 14 | struct VS_INPUT 15 | { 16 | float3 m_position : POSITION; 17 | float3 m_normal : NORMAL; 18 | }; 19 | 20 | VS_OUTPUT main(VS_INPUT _in) 21 | { 22 | VS_OUTPUT ret; 23 | ret.m_normal = mul(uWorldMatrix, float4(_in.m_normal, 0.0)); 24 | ret.m_position = mul(uViewProjMatrix, mul(uWorldMatrix, float4(_in.m_position, 1.0))); 25 | return ret; 26 | } 27 | #endif 28 | 29 | #ifdef PIXEL_SHADER 30 | float4 main(VS_OUTPUT _in): SV_Target 31 | { 32 | float3 nrm = normalize(_in.m_normal); 33 | float3 ldir = normalize(float3(1.0, 1.0, 1.0)); 34 | float ndotl = max(dot(nrm, ldir), 0.0) * 0.5; 35 | return float4(ndotl, ndotl, ndotl, 1.0); 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /examples/DirectX11/premake5.lua: -------------------------------------------------------------------------------- 1 | local IM3D_DIR = "../../" 2 | local EXAMPLE_COMMON_DIR = "../common/" 3 | 4 | filter { "configurations:debug" } 5 | defines { "IM3D_DEBUG" } 6 | targetsuffix "_debug" 7 | symbols "On" 8 | optimize "Off" 9 | 10 | filter { "configurations:release" } 11 | symbols "On" 12 | optimize "Full" 13 | 14 | filter { "action:vs*" } 15 | defines { "_CRT_SECURE_NO_WARNINGS", "_SCL_SECURE_NO_WARNINGS" } 16 | characterset "MBCS" -- force Win32 API to use *A variants (i.e. can pass char* for strings) 17 | 18 | workspace "im3d_directx11" 19 | location(_ACTION) 20 | configurations { "Debug", "Release" } 21 | platforms { "Win32", "Win64" } 22 | cppdialect "C++11" 23 | staticruntime "On" 24 | 25 | filter { "platforms:Win32 or platforms:Win64" } 26 | system "windows" 27 | 28 | -- \todo select graphics lib? 29 | defines { "IM3D_DX11" } 30 | links { "d3d11", "d3dcompiler" } 31 | 32 | filter { "platforms:Win32" } 33 | architecture "x86" 34 | filter { "platforms:Win64" } 35 | architecture "x86_64" 36 | 37 | filter {} 38 | 39 | vpaths({ 40 | ["im3d"] = { IM3D_DIR .. "*.h", IM3D_DIR .. "*.cpp" }, 41 | ["imgui"] = EXAMPLE_COMMON_DIR .. "imgui/**", 42 | ["common"] = { EXAMPLE_COMMON_DIR .. "*.h", EXAMPLE_COMMON_DIR .. "*.cpp" }, 43 | ["*"] = "*.cpp" 44 | }) 45 | 46 | files({ 47 | IM3D_DIR .. "*.h", 48 | IM3D_DIR .. "*.cpp", 49 | }) 50 | 51 | project "im3d_directx11" 52 | kind "ConsoleApp" 53 | language "C++" 54 | targetdir "" 55 | 56 | 57 | includedirs({ 58 | IM3D_DIR, 59 | EXAMPLE_COMMON_DIR, 60 | }) 61 | files({ 62 | EXAMPLE_COMMON_DIR .. "**.h", 63 | EXAMPLE_COMMON_DIR .. "**.hpp", 64 | EXAMPLE_COMMON_DIR .. "**.c", 65 | EXAMPLE_COMMON_DIR .. "**.cpp", 66 | "*.cpp" 67 | }) 68 | removefiles({ 69 | EXAMPLE_COMMON_DIR .. "GL/*" 70 | }) 71 | -------------------------------------------------------------------------------- /examples/DirectX11/vs2017/im3d_directx11.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "im3d_directx11", "im3d_directx11.vcxproj", "{A690B81F-925E-AC25-7BF2-1C4C675F888A}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|Win64 = Debug|Win64 10 | Release|Win32 = Release|Win32 11 | Release|Win64 = Release|Win64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Debug|Win32.Build.0 = Debug|Win32 16 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Debug|Win64.ActiveCfg = Debug Win64|x64 17 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Debug|Win64.Build.0 = Debug Win64|x64 18 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Release|Win32.ActiveCfg = Release|Win32 19 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Release|Win32.Build.0 = Release|Win32 20 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Release|Win64.ActiveCfg = Release Win64|x64 21 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Release|Win64.Build.0 = Release Win64|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /examples/DirectX11/vs2017/im3d_directx11.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Debug Win64 14 | Win32 15 | 16 | 17 | Debug Win64 18 | x64 19 | 20 | 21 | Release 22 | Win32 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | Release Win64 30 | Win32 31 | 32 | 33 | Release Win64 34 | x64 35 | 36 | 37 | 38 | {A690B81F-925E-AC25-7BF2-1C4C675F888A} 39 | true 40 | Win32Proj 41 | im3d_directx11 42 | 43 | 44 | 45 | Application 46 | true 47 | MultiByte 48 | v141 49 | 50 | 51 | Application 52 | true 53 | MultiByte 54 | v141 55 | 56 | 57 | Application 58 | false 59 | MultiByte 60 | v141 61 | 62 | 63 | Application 64 | false 65 | MultiByte 66 | v141 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | true 86 | ..\ 87 | obj\Win32\Debug\ 88 | im3d_directx11_debug 89 | .exe 90 | 91 | 92 | true 93 | ..\ 94 | obj\Win64\Debug\ 95 | im3d_directx11_debug 96 | .exe 97 | 98 | 99 | false 100 | ..\ 101 | obj\Win32\Release\ 102 | im3d_directx11 103 | .exe 104 | 105 | 106 | false 107 | ..\ 108 | obj\Win64\Release\ 109 | im3d_directx11 110 | .exe 111 | 112 | 113 | 114 | NotUsing 115 | Level3 116 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_DX11;%(PreprocessorDefinitions) 117 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 118 | EditAndContinue 119 | Disabled 120 | MultiThreadedDebug 121 | 122 | 123 | Console 124 | true 125 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 126 | 127 | 128 | 129 | 130 | NotUsing 131 | Level3 132 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_DX11;%(PreprocessorDefinitions) 133 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 134 | EditAndContinue 135 | Disabled 136 | MultiThreadedDebug 137 | 138 | 139 | Console 140 | true 141 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 142 | 143 | 144 | 145 | 146 | NotUsing 147 | Level3 148 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_DX11;%(PreprocessorDefinitions) 149 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 150 | ProgramDatabase 151 | Full 152 | true 153 | true 154 | false 155 | true 156 | MultiThreaded 157 | 158 | 159 | Console 160 | true 161 | true 162 | true 163 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 164 | 165 | 166 | 167 | 168 | NotUsing 169 | Level3 170 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_DX11;%(PreprocessorDefinitions) 171 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 172 | ProgramDatabase 173 | Full 174 | true 175 | true 176 | false 177 | true 178 | MultiThreaded 179 | 180 | 181 | Console 182 | true 183 | true 184 | true 185 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /examples/DirectX11/vs2017/im3d_directx11.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 6 | 7 | 8 | {F279987C-DEB0-990D-879D-7F1073B3150F} 9 | 10 | 11 | {0098A80F-6CAC-D0C0-352E-7420A101CDF1} 12 | 13 | 14 | 15 | 16 | im3d 17 | 18 | 19 | im3d 20 | 21 | 22 | im3d 23 | 24 | 25 | common 26 | 27 | 28 | imgui 29 | 30 | 31 | imgui 32 | 33 | 34 | imgui 35 | 36 | 37 | imgui 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | common 47 | 48 | 49 | 50 | 51 | im3d 52 | 53 | 54 | common 55 | 56 | 57 | imgui 58 | 59 | 60 | imgui 61 | 62 | 63 | imgui 64 | 65 | 66 | imgui 67 | 68 | 69 | common 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /examples/DirectX11/vs2019/im3d_directx11.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 16 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "im3d_directx11", "im3d_directx11.vcxproj", "{A690B81F-925E-AC25-7BF2-1C4C675F888A}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|Win64 = Debug|Win64 10 | Release|Win32 = Release|Win32 11 | Release|Win64 = Release|Win64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Debug|Win32.Build.0 = Debug|Win32 16 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Debug|Win64.ActiveCfg = Debug Win64|x64 17 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Debug|Win64.Build.0 = Debug Win64|x64 18 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Release|Win32.ActiveCfg = Release|Win32 19 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Release|Win32.Build.0 = Release|Win32 20 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Release|Win64.ActiveCfg = Release Win64|x64 21 | {A690B81F-925E-AC25-7BF2-1C4C675F888A}.Release|Win64.Build.0 = Release Win64|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /examples/DirectX11/vs2019/im3d_directx11.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Debug Win64 14 | Win32 15 | 16 | 17 | Debug Win64 18 | x64 19 | 20 | 21 | Release 22 | Win32 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | Release Win64 30 | Win32 31 | 32 | 33 | Release Win64 34 | x64 35 | 36 | 37 | 38 | {A690B81F-925E-AC25-7BF2-1C4C675F888A} 39 | true 40 | Win32Proj 41 | im3d_directx11 42 | 43 | 44 | 45 | Application 46 | true 47 | MultiByte 48 | v142 49 | 50 | 51 | Application 52 | true 53 | MultiByte 54 | v142 55 | 56 | 57 | Application 58 | false 59 | MultiByte 60 | v142 61 | 62 | 63 | Application 64 | false 65 | MultiByte 66 | v142 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | true 86 | ..\ 87 | obj\Win32\Debug\ 88 | im3d_directx11_debug 89 | .exe 90 | 91 | 92 | true 93 | ..\ 94 | obj\Win64\Debug\ 95 | im3d_directx11_debug 96 | .exe 97 | 98 | 99 | false 100 | ..\ 101 | obj\Win32\Release\ 102 | im3d_directx11 103 | .exe 104 | 105 | 106 | false 107 | ..\ 108 | obj\Win64\Release\ 109 | im3d_directx11 110 | .exe 111 | 112 | 113 | 114 | NotUsing 115 | Level3 116 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_DX11;%(PreprocessorDefinitions) 117 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 118 | EditAndContinue 119 | Disabled 120 | MultiThreadedDebug 121 | 122 | 123 | Console 124 | true 125 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 126 | 127 | 128 | 129 | 130 | NotUsing 131 | Level3 132 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_DX11;%(PreprocessorDefinitions) 133 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 134 | EditAndContinue 135 | Disabled 136 | MultiThreadedDebug 137 | 138 | 139 | Console 140 | true 141 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 142 | 143 | 144 | 145 | 146 | NotUsing 147 | Level3 148 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_DX11;%(PreprocessorDefinitions) 149 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 150 | ProgramDatabase 151 | Full 152 | true 153 | true 154 | false 155 | true 156 | MultiThreaded 157 | 158 | 159 | Console 160 | true 161 | true 162 | true 163 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 164 | 165 | 166 | 167 | 168 | NotUsing 169 | Level3 170 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_DX11;%(PreprocessorDefinitions) 171 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 172 | ProgramDatabase 173 | Full 174 | true 175 | true 176 | false 177 | true 178 | MultiThreaded 179 | 180 | 181 | Console 182 | true 183 | true 184 | true 185 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /examples/DirectX11/vs2019/im3d_directx11.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 6 | 7 | 8 | {F279987C-DEB0-990D-879D-7F1073B3150F} 9 | 10 | 11 | {0098A80F-6CAC-D0C0-352E-7420A101CDF1} 12 | 13 | 14 | 15 | 16 | im3d 17 | 18 | 19 | im3d 20 | 21 | 22 | im3d 23 | 24 | 25 | common 26 | 27 | 28 | imgui 29 | 30 | 31 | imgui 32 | 33 | 34 | imgui 35 | 36 | 37 | imgui 38 | 39 | 40 | imgui 41 | 42 | 43 | imgui 44 | 45 | 46 | common 47 | 48 | 49 | 50 | 51 | im3d 52 | 53 | 54 | common 55 | 56 | 57 | imgui 58 | 59 | 60 | imgui 61 | 62 | 63 | imgui 64 | 65 | 66 | imgui 67 | 68 | 69 | common 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /examples/MultiContext/gmake/Makefile: -------------------------------------------------------------------------------- 1 | # GNU Make workspace makefile autogenerated by Premake 2 | 3 | ifndef config 4 | config=debug_win32 5 | endif 6 | 7 | ifndef verbose 8 | SILENT = @ 9 | endif 10 | 11 | ifeq ($(config),debug_win32) 12 | im3d_multicontext_config = debug_win32 13 | endif 14 | ifeq ($(config),debug_win64) 15 | im3d_multicontext_config = debug_win64 16 | endif 17 | ifeq ($(config),release_win32) 18 | im3d_multicontext_config = release_win32 19 | endif 20 | ifeq ($(config),release_win64) 21 | im3d_multicontext_config = release_win64 22 | endif 23 | 24 | PROJECTS := im3d_multicontext 25 | 26 | .PHONY: all clean help $(PROJECTS) 27 | 28 | all: $(PROJECTS) 29 | 30 | im3d_multicontext: 31 | ifneq (,$(im3d_multicontext_config)) 32 | @echo "==== Building im3d_multicontext ($(im3d_multicontext_config)) ====" 33 | @${MAKE} --no-print-directory -C . -f im3d_multicontext.make config=$(im3d_multicontext_config) 34 | endif 35 | 36 | clean: 37 | @${MAKE} --no-print-directory -C . -f im3d_multicontext.make clean 38 | 39 | help: 40 | @echo "Usage: make [config=name] [target]" 41 | @echo "" 42 | @echo "CONFIGURATIONS:" 43 | @echo " debug_win32" 44 | @echo " debug_win64" 45 | @echo " release_win32" 46 | @echo " release_win64" 47 | @echo "" 48 | @echo "TARGETS:" 49 | @echo " all (default)" 50 | @echo " clean" 51 | @echo " im3d_multicontext" 52 | @echo "" 53 | @echo "For more information, see https://github.com/premake/premake-core/wiki" -------------------------------------------------------------------------------- /examples/MultiContext/gmake/im3d_multicontext.make: -------------------------------------------------------------------------------- 1 | # GNU Make project makefile autogenerated by Premake 2 | 3 | ifndef config 4 | config=debug_win32 5 | endif 6 | 7 | ifndef verbose 8 | SILENT = @ 9 | endif 10 | 11 | .PHONY: clean prebuild prelink 12 | 13 | ifeq ($(config),debug_win32) 14 | RESCOMP = windres 15 | TARGETDIR = .. 16 | TARGET = $(TARGETDIR)/im3d_multicontext_debug.exe 17 | OBJDIR = obj/Win32/Debug 18 | DEFINES += -DIM3D_DEBUG -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=3 -DIM3D_OPENGL_VSHADER=330 -DIM3D_THREAD_LOCAL_CONTEXT_PTR=1 19 | INCLUDES += -I../../.. -I../../common 20 | FORCE_INCLUDE += 21 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 22 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O0 -g 23 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O0 -g -std=c++11 24 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 25 | LIBS += -lopengl32 -lgdi32 26 | LDDEPS += 27 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 28 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 29 | define PREBUILDCMDS 30 | endef 31 | define PRELINKCMDS 32 | endef 33 | define POSTBUILDCMDS 34 | endef 35 | all: prebuild prelink $(TARGET) 36 | @: 37 | 38 | endif 39 | 40 | ifeq ($(config),debug_win64) 41 | RESCOMP = windres 42 | TARGETDIR = .. 43 | TARGET = $(TARGETDIR)/im3d_multicontext_debug.exe 44 | OBJDIR = obj/Win64/Debug 45 | DEFINES += -DIM3D_DEBUG -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=3 -DIM3D_OPENGL_VSHADER=330 -DIM3D_THREAD_LOCAL_CONTEXT_PTR=1 46 | INCLUDES += -I../../.. -I../../common 47 | FORCE_INCLUDE += 48 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 49 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O0 -g 50 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O0 -g -std=c++11 51 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 52 | LIBS += -lopengl32 -lgdi32 53 | LDDEPS += 54 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 55 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 56 | define PREBUILDCMDS 57 | endef 58 | define PRELINKCMDS 59 | endef 60 | define POSTBUILDCMDS 61 | endef 62 | all: prebuild prelink $(TARGET) 63 | @: 64 | 65 | endif 66 | 67 | ifeq ($(config),release_win32) 68 | RESCOMP = windres 69 | TARGETDIR = .. 70 | TARGET = $(TARGETDIR)/im3d_multicontext.exe 71 | OBJDIR = obj/Win32/Release 72 | DEFINES += -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=3 -DIM3D_OPENGL_VSHADER=330 -DIM3D_THREAD_LOCAL_CONTEXT_PTR=1 73 | INCLUDES += -I../../.. -I../../common 74 | FORCE_INCLUDE += 75 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 76 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -g 77 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -g -std=c++11 78 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 79 | LIBS += -lopengl32 -lgdi32 80 | LDDEPS += 81 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 82 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 83 | define PREBUILDCMDS 84 | endef 85 | define PRELINKCMDS 86 | endef 87 | define POSTBUILDCMDS 88 | endef 89 | all: prebuild prelink $(TARGET) 90 | @: 91 | 92 | endif 93 | 94 | ifeq ($(config),release_win64) 95 | RESCOMP = windres 96 | TARGETDIR = .. 97 | TARGET = $(TARGETDIR)/im3d_multicontext.exe 98 | OBJDIR = obj/Win64/Release 99 | DEFINES += -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=3 -DIM3D_OPENGL_VSHADER=330 -DIM3D_THREAD_LOCAL_CONTEXT_PTR=1 100 | INCLUDES += -I../../.. -I../../common 101 | FORCE_INCLUDE += 102 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 103 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -g 104 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -g -std=c++11 105 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 106 | LIBS += -lopengl32 -lgdi32 107 | LDDEPS += 108 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 109 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 110 | define PREBUILDCMDS 111 | endef 112 | define PRELINKCMDS 113 | endef 114 | define POSTBUILDCMDS 115 | endef 116 | all: prebuild prelink $(TARGET) 117 | @: 118 | 119 | endif 120 | 121 | OBJECTS := \ 122 | $(OBJDIR)/glew.o \ 123 | $(OBJDIR)/im3d_example.o \ 124 | $(OBJDIR)/im3d.o \ 125 | $(OBJDIR)/im3d_multicontext.o \ 126 | $(OBJDIR)/im3d_opengl33.o \ 127 | $(OBJDIR)/imgui.o \ 128 | $(OBJDIR)/imgui_demo.o \ 129 | $(OBJDIR)/imgui_draw.o \ 130 | $(OBJDIR)/imgui_widgets.o \ 131 | 132 | RESOURCES := \ 133 | 134 | CUSTOMFILES := \ 135 | 136 | SHELLTYPE := posix 137 | ifeq (.exe,$(findstring .exe,$(ComSpec))) 138 | SHELLTYPE := msdos 139 | endif 140 | 141 | $(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) | $(TARGETDIR) 142 | @echo Linking im3d_multicontext 143 | $(SILENT) $(LINKCMD) 144 | $(POSTBUILDCMDS) 145 | 146 | $(CUSTOMFILES): | $(OBJDIR) 147 | 148 | $(TARGETDIR): 149 | @echo Creating $(TARGETDIR) 150 | ifeq (posix,$(SHELLTYPE)) 151 | $(SILENT) mkdir -p $(TARGETDIR) 152 | else 153 | $(SILENT) mkdir $(subst /,\\,$(TARGETDIR)) 154 | endif 155 | 156 | $(OBJDIR): 157 | @echo Creating $(OBJDIR) 158 | ifeq (posix,$(SHELLTYPE)) 159 | $(SILENT) mkdir -p $(OBJDIR) 160 | else 161 | $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) 162 | endif 163 | 164 | clean: 165 | @echo Cleaning im3d_multicontext 166 | ifeq (posix,$(SHELLTYPE)) 167 | $(SILENT) rm -f $(TARGET) 168 | $(SILENT) rm -rf $(OBJDIR) 169 | else 170 | $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET)) 171 | $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR)) 172 | endif 173 | 174 | prebuild: 175 | $(PREBUILDCMDS) 176 | 177 | prelink: 178 | $(PRELINKCMDS) 179 | 180 | ifneq (,$(PCH)) 181 | $(OBJECTS): $(GCH) $(PCH) | $(OBJDIR) 182 | $(GCH): $(PCH) | $(OBJDIR) 183 | @echo $(notdir $<) 184 | $(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" 185 | else 186 | $(OBJECTS): | $(OBJDIR) 187 | endif 188 | 189 | $(OBJDIR)/glew.o: ../../common/GL/glew.c 190 | @echo $(notdir $<) 191 | $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 192 | $(OBJDIR)/im3d_example.o: ../../common/im3d_example.cpp 193 | @echo $(notdir $<) 194 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 195 | $(OBJDIR)/im3d.o: ../../../im3d.cpp 196 | @echo $(notdir $<) 197 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 198 | $(OBJDIR)/im3d_multicontext.o: ../im3d_multicontext.cpp 199 | @echo $(notdir $<) 200 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 201 | $(OBJDIR)/im3d_opengl33.o: ../../OpenGL33/im3d_opengl33.cpp 202 | @echo $(notdir $<) 203 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 204 | $(OBJDIR)/imgui.o: ../../common/imgui/imgui.cpp 205 | @echo $(notdir $<) 206 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 207 | $(OBJDIR)/imgui_demo.o: ../../common/imgui/imgui_demo.cpp 208 | @echo $(notdir $<) 209 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 210 | $(OBJDIR)/imgui_draw.o: ../../common/imgui/imgui_draw.cpp 211 | @echo $(notdir $<) 212 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 213 | $(OBJDIR)/imgui_widgets.o: ../../common/imgui/imgui_widgets.cpp 214 | @echo $(notdir $<) 215 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 216 | 217 | -include $(OBJECTS:%.o=%.d) 218 | ifneq (,$(PCH)) 219 | -include $(OBJDIR)/$(notdir $(PCH)).d 220 | endif -------------------------------------------------------------------------------- /examples/MultiContext/im3d.glsl: -------------------------------------------------------------------------------- 1 | #if !defined(POINTS) && !defined(LINES) && !defined(TRIANGLES) 2 | #error No primitive type defined 3 | #endif 4 | #if !defined(VERTEX_SHADER) && !defined(GEOMETRY_SHADER) && !defined(FRAGMENT_SHADER) 5 | #error No shader stage defined 6 | #endif 7 | 8 | #define VertexData \ 9 | _VertexData { \ 10 | noperspective float m_edgeDistance; \ 11 | noperspective float m_size; \ 12 | smooth vec4 m_color; \ 13 | } 14 | 15 | #define kAntialiasing 2.0 16 | 17 | #ifdef VERTEX_SHADER 18 | uniform mat4 uViewProjMatrix; 19 | 20 | layout(location=0) in vec4 aPositionSize; 21 | layout(location=1) in vec4 aColor; 22 | 23 | out VertexData vData; 24 | 25 | void main() 26 | { 27 | vData.m_color = aColor.abgr; // swizzle to correct endianness 28 | #if !defined(TRIANGLES) 29 | vData.m_color.a *= smoothstep(0.0, 1.0, aPositionSize.w / kAntialiasing); 30 | #endif 31 | vData.m_size = max(aPositionSize.w, kAntialiasing); 32 | gl_Position = uViewProjMatrix * vec4(aPositionSize.xyz, 1.0); 33 | #if defined(POINTS) 34 | gl_PointSize = vData.m_size; 35 | #endif 36 | } 37 | #endif 38 | 39 | #ifdef GEOMETRY_SHADER 40 | // expand line -> triangle strip 41 | layout(lines) in; 42 | layout(triangle_strip, max_vertices = 4) out; 43 | 44 | uniform vec2 uViewport; 45 | 46 | in VertexData vData[]; 47 | out VertexData vDataOut; 48 | 49 | void main() 50 | { 51 | vec2 pos0 = gl_in[0].gl_Position.xy / gl_in[0].gl_Position.w; 52 | vec2 pos1 = gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w; 53 | 54 | vec2 dir = pos0 - pos1; 55 | dir = normalize(vec2(dir.x, dir.y * uViewport.y / uViewport.x)); // correct for aspect ratio 56 | vec2 tng0 = vec2(-dir.y, dir.x); 57 | vec2 tng1 = tng0 * vData[1].m_size / uViewport; 58 | tng0 = tng0 * vData[0].m_size / uViewport; 59 | 60 | // line start 61 | gl_Position = vec4((pos0 - tng0) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw); 62 | vDataOut.m_edgeDistance = -vData[0].m_size; 63 | vDataOut.m_size = vData[0].m_size; 64 | vDataOut.m_color = vData[0].m_color; 65 | EmitVertex(); 66 | 67 | gl_Position = vec4((pos0 + tng0) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw); 68 | vDataOut.m_color = vData[0].m_color; 69 | vDataOut.m_edgeDistance = vData[0].m_size; 70 | vDataOut.m_size = vData[0].m_size; 71 | EmitVertex(); 72 | 73 | // line end 74 | gl_Position = vec4((pos1 - tng1) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw); 75 | vDataOut.m_edgeDistance = -vData[1].m_size; 76 | vDataOut.m_size = vData[1].m_size; 77 | vDataOut.m_color = vData[1].m_color; 78 | EmitVertex(); 79 | 80 | gl_Position = vec4((pos1 + tng1) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw); 81 | vDataOut.m_color = vData[1].m_color; 82 | vDataOut.m_size = vData[1].m_size; 83 | vDataOut.m_edgeDistance = vData[1].m_size; 84 | EmitVertex(); 85 | } 86 | #endif 87 | 88 | #ifdef FRAGMENT_SHADER 89 | in VertexData vData; 90 | 91 | layout(location=0) out vec4 fResult; 92 | 93 | void main() 94 | { 95 | fResult = vData.m_color; 96 | 97 | #if defined(LINES) 98 | float d = abs(vData.m_edgeDistance) / vData.m_size; 99 | d = smoothstep(1.0, 1.0 - (kAntialiasing / vData.m_size), d); 100 | fResult.a *= d; 101 | 102 | #elif defined(POINTS) 103 | float d = length(gl_PointCoord.xy - vec2(0.5)); 104 | d = smoothstep(0.5, 0.5 - (kAntialiasing / vData.m_size), d); 105 | fResult.a *= d; 106 | 107 | #endif 108 | } 109 | #endif 110 | -------------------------------------------------------------------------------- /examples/MultiContext/im3d_multicontext.cpp: -------------------------------------------------------------------------------- 1 | /* Multi context example 2 | This example shows how to use multiple Im3d contexts to draw from multiple threads. 3 | 4 | Im3d doesn't provide any thread safety mechanism per se; applications are expected to 5 | draw to per-thread contexts and then use Im3d::MergeContexts() to combine vertex data 6 | and draw on the main thread. 7 | 8 | There are some prerequisites to making this work: 9 | 10 | 1) #define IM3D_THREAD_LOCAL_CONTEXT_PTR 1 - either modify im3d_config.h or define via the build 11 | system. This is required to declare Im3d's internal context ptr as thread_local which allows the 12 | application to set a different context per thread. 13 | 14 | 2) Declare some number of Im3d::Context instances (1 per thread) - the internal context ptr is thread 15 | local but points to the main context by default. Im3d::SetContext(&threadCtx) must therefore be called 16 | on each thread. 17 | 18 | 3) At the beginning of the frame, fill the Im3d::AppData struct for *all* contexts which will be used 19 | during the frame. The simplest approach is to fill this once on the main thread and then copy the 20 | result into each per-thread context. See the integration examples for how to fill the AppData struct. 21 | 22 | 4) Towards the end of the frame, merge each per-thread context into the main thread via Im3d::MergeContexts(), 23 | then call Im3d::EndFrame() and draw the combined draw lists. This requires synchronization to ensure that 24 | threads cannot modify either context during the merge. 25 | */ 26 | #include "im3d_example.h" 27 | 28 | #include 29 | 30 | static const int kThreadCountMax = 6; 31 | static int g_ThreadCount = kThreadCountMax; 32 | static Im3d::Context g_ThreadContexts[kThreadCountMax]; 33 | static bool g_EnableSorting = false; 34 | static Im3d::Mat4 g_ThreadGizmoTest[kThreadCountMax]; 35 | static Im3d::Color g_ThreadColors[kThreadCountMax] = 36 | { 37 | Im3d::Color_Red, 38 | Im3d::Color_Green, 39 | Im3d::Color_Blue, 40 | Im3d::Color_Magenta, 41 | Im3d::Color_Yellow, 42 | Im3d::Color_Cyan 43 | }; 44 | 45 | static void ThreadDraw(int _threadIndex); 46 | static void MainThreadDraw(); 47 | 48 | int main(int, char**) 49 | { 50 | Im3d::Example example; 51 | if (!example.init(-1, -1, "Im3d Example")) 52 | { 53 | return 1; 54 | } 55 | 56 | for (int i = 0; i < kThreadCountMax; ++i) 57 | { 58 | float threadX = (float)i / (float)kThreadCountMax * 10.0f - 5.0f; 59 | g_ThreadGizmoTest[i] = Im3d::Mat4(Im3d::Vec3(threadX, 0.0f, 0.0f), Im3d::Mat3(1.0f), Im3d::Vec3(1.0f)); 60 | } 61 | 62 | while (example.update()) // calls Im3d_NewFrame() (see im3d_opengl33.cpp) 63 | { 64 | // At this point we have updated the default context and filled its AppData struct. 65 | 66 | // Each separate context could potentially use different AppData (e.g. different cameras/viewports). Here 67 | // we just copy the default for simplicity. 68 | for (auto& ctx : g_ThreadContexts) 69 | { 70 | ctx.getAppData() = Im3d::GetAppData(); 71 | 72 | ctx.reset(); // equivalent to calling Im3d::NewFrame() on the thread 73 | } 74 | 75 | MainThreadDraw(); 76 | 77 | // The frame can now proceed, threads can safely make Im3d:: calls (after setting the context ptr, see ThreadDraw()). 78 | std::thread threads[kThreadCountMax]; 79 | for (int i = 0; i < g_ThreadCount; ++i) 80 | { 81 | threads[i] = std::thread(&ThreadDraw, i); 82 | } 83 | 84 | // Towards the end of the frame we need to synchronize so that we can safely merge vertex data from the per-thread contexts. 85 | for (int i = 0; i < g_ThreadCount; ++i) 86 | { 87 | threads[i].join(); 88 | } 89 | 90 | // Prior to calling Im3d::EndFrame() we need to merge the per-thread contexts into the main thread context. 91 | for (int i = 0; i < g_ThreadCount; ++i) 92 | { 93 | Im3d::MergeContexts(Im3d::GetContext(), g_ThreadContexts[i]); 94 | } 95 | 96 | example.draw(); // calls Im3d_EndFrame() (see im3d_opengl33.cpp). 97 | } 98 | example.shutdown(); 99 | 100 | return 0; 101 | } 102 | 103 | void ThreadDraw(int _threadIndex) 104 | { 105 | Im3d::SetContext(g_ThreadContexts[_threadIndex]); 106 | //Im3d::NewFrame(); // in this example we call ctx.reset() outside the thread, which is equivalent 107 | 108 | // Gizmos work, however the application is responsible for isolating inputs between multiple contexts. 109 | // In this example we simply copy AppData from the main thread, therefore it's possible to interact with 110 | // multiple gizmos simultaneously. 111 | Im3d::Gizmo("Gizmo", (float*)&g_ThreadGizmoTest[_threadIndex]); 112 | 113 | Im3d::PushMatrix(g_ThreadGizmoTest[_threadIndex]); 114 | 115 | #if 0 116 | Im3d::PushDrawState(); 117 | Im3d::PushEnableSorting(g_EnableSorting); 118 | Im3d::SetColor(g_ThreadColors[_threadIndex]); 119 | Im3d::BeginTriangles(); 120 | Im3d::Vertex(-1.0f, 0.0f, 0.0f); 121 | Im3d::Vertex( 0.0f, 2.0f, 0.0f); 122 | Im3d::Vertex( 1.0f, 0.0f, 0.0f); 123 | Im3d::End(); 124 | Im3d::PopEnableSorting(); 125 | Im3d::PopDrawState(); 126 | #endif 127 | 128 | Im3d::Text(Im3d::Vec3(0.0f, 1.0f, 0.0f), 2.0f, Im3d::Color_White, 0, "Thread %d", _threadIndex); 129 | 130 | Im3d::RandSeed(_threadIndex); // \todo this is potentially not thread safe 131 | 132 | Im3d::PushDrawState(); 133 | Im3d::PushEnableSorting(g_EnableSorting); 134 | Im3d::SetColor(g_ThreadColors[_threadIndex]); 135 | 136 | Im3d::BeginPoints(); 137 | for (int i = 0; i < 256; ++i) 138 | { 139 | Im3d::Vertex(Im3d::RandVec3(-10.0f, 10.0f), Im3d::RandFloat(2.0f, 16.0f)); 140 | } 141 | Im3d::End(); 142 | 143 | Im3d::SetAlpha(0.5f); 144 | Im3d::BeginTriangles(); 145 | for (int i = 0; i < 32; ++i) 146 | { 147 | Im3d::Mat4 wm(1.0f); 148 | Im3d::PushMatrix(); 149 | Im3d::Rotate(Im3d::Normalize(Im3d::RandVec3(-1.0f, 1.0f)), Im3d::RandFloat(0.0f, 6.0f)); 150 | Im3d::Translate(Im3d::RandVec3(-10.0f, 10.0f)); 151 | Im3d::Vertex(-1.0f, 0.0f, -1.0f); 152 | Im3d::Vertex( 0.0f, 2.0f, -1.0f); 153 | Im3d::Vertex( 1.0f, 0.0f, -1.0f); 154 | Im3d::PopMatrix(); 155 | } 156 | Im3d::End(); 157 | 158 | Im3d::PopEnableSorting(); 159 | Im3d::PopDrawState(); 160 | Im3d::PopMatrix(); 161 | } 162 | 163 | void MainThreadDraw() 164 | { 165 | Im3d::Context& ctx = Im3d::GetContext(); 166 | Im3d::AppData& ad = Im3d::GetAppData(); 167 | 168 | ImGui::Begin("Im3d Demo", nullptr, ImGuiWindowFlags_AlwaysAutoResize); 169 | 170 | ImGui::SetNextTreeNodeOpen(true, ImGuiSetCond_Once); 171 | if (ImGui::TreeNode("About")) 172 | { 173 | ImGui::Text("Welcome to the Im3d demo!"); 174 | ImGui::Spacing(); 175 | ImGui::Text("WASD = forward/left/backward/right"); 176 | ImGui::Text("QE = down/up"); 177 | ImGui::Text("RMouse = camera orientation"); 178 | ImGui::Text("LShift = move faster"); 179 | ImGui::Spacing(); 180 | 181 | ImGui::TreePop(); 182 | } 183 | ImGui::Spacing(); 184 | 185 | ImGui::SetNextTreeNodeOpen(true, ImGuiSetCond_Once); 186 | if (ImGui::TreeNode("Threads")) 187 | { 188 | ImGui::SliderInt("Thread Count", &g_ThreadCount, 0, kThreadCountMax); 189 | ImGui::Checkbox("Enable Sorting", &g_EnableSorting); 190 | ImGui::TreePop(); 191 | } 192 | 193 | ImGui::SetNextTreeNodeOpen(true, ImGuiSetCond_Once); 194 | if (ImGui::TreeNode("Grid")) 195 | { 196 | static int gridSize = 20; 197 | ImGui::SliderInt("Grid Size", &gridSize, 1, 50); 198 | const float gridHalf = (float)gridSize * 0.5f; 199 | Im3d::SetAlpha(1.0f); 200 | Im3d::SetSize(1.0f); 201 | Im3d::BeginLines(); 202 | for (int x = 0; x <= gridSize; ++x) 203 | { 204 | Im3d::Vertex(-gridHalf, 0.0f, (float)x - gridHalf, Im3d::Color(0.0f, 0.0f, 0.0f)); 205 | Im3d::Vertex( gridHalf, 0.0f, (float)x - gridHalf, Im3d::Color(1.0f, 0.0f, 0.0f)); 206 | } 207 | for (int z = 0; z <= gridSize; ++z) 208 | { 209 | Im3d::Vertex((float)z - gridHalf, 0.0f, -gridHalf, Im3d::Color(0.0f, 0.0f, 0.0f)); 210 | Im3d::Vertex((float)z - gridHalf, 0.0f, gridHalf, Im3d::Color(0.0f, 0.0f, 1.0f)); 211 | } 212 | Im3d::End(); 213 | 214 | ImGui::TreePop(); 215 | } 216 | 217 | ImGui::End(); 218 | } -------------------------------------------------------------------------------- /examples/MultiContext/imgui.glsl: -------------------------------------------------------------------------------- 1 | #ifdef VERTEX_SHADER 2 | layout(location=0) in vec2 aPosition; 3 | layout(location=1) in vec2 aTexcoord; 4 | layout(location=2) in vec4 aColor; 5 | 6 | uniform mat4 uProjMatrix; 7 | 8 | noperspective out vec2 vUv; 9 | noperspective out vec4 vColor; 10 | 11 | void main() 12 | { 13 | vUv = aTexcoord; 14 | vColor = aColor; 15 | gl_Position = uProjMatrix * vec4(aPosition.xy, 0.0, 1.0); 16 | } 17 | #endif 18 | 19 | #ifdef FRAGMENT_SHADER 20 | noperspective in vec2 vUv; 21 | noperspective in vec4 vColor; 22 | 23 | uniform sampler2D txTexture; 24 | 25 | layout(location=0) out vec4 fResult; 26 | 27 | void main() 28 | { 29 | fResult = vColor; 30 | fResult.a *= texture(txTexture, vUv).r; 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /examples/MultiContext/model.glsl: -------------------------------------------------------------------------------- 1 | #ifdef VERTEX_SHADER 2 | uniform mat4 uWorldMatrix; 3 | uniform mat4 uViewProjMatrix; 4 | 5 | layout(location=0) in vec3 aPosition; 6 | layout(location=1) in vec3 aNormal; 7 | 8 | smooth out vec3 vNormalW; 9 | 10 | void main() 11 | { 12 | vNormalW = mat3(uWorldMatrix) * aNormal; 13 | gl_Position = uViewProjMatrix * (uWorldMatrix * vec4(aPosition, 1.0)); 14 | } 15 | #endif 16 | 17 | #ifdef FRAGMENT_SHADER 18 | smooth in vec3 vNormalW; 19 | 20 | layout(location=0) out vec3 fResult; 21 | 22 | void main() 23 | { 24 | vec3 nrm = normalize(vNormalW); 25 | vec3 ldir = normalize(vec3(1.0)); 26 | float ndotl = max(dot(nrm, ldir), 0.0) * 0.5; 27 | fResult = vec3(ndotl); 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /examples/MultiContext/premake5.lua: -------------------------------------------------------------------------------- 1 | local IM3D_DIR = "../../" 2 | local EXAMPLE_DIR = "../" 3 | local EXAMPLE_COMMON_DIR = EXAMPLE_DIR .. "common/" 4 | 5 | filter { "configurations:debug" } 6 | defines { "IM3D_DEBUG" } 7 | targetsuffix "_debug" 8 | symbols "On" 9 | optimize "Off" 10 | 11 | filter { "configurations:release" } 12 | symbols "On" 13 | optimize "Full" 14 | 15 | filter { "action:vs*" } 16 | defines { "_CRT_SECURE_NO_WARNINGS", "_SCL_SECURE_NO_WARNINGS" } 17 | characterset "MBCS" -- force Win32 API to use *A variants (i.e. can pass char* for strings) 18 | 19 | workspace "im3d_multicontext" 20 | location(_ACTION) 21 | configurations { "Debug", "Release" } 22 | platforms { "Win32", "Win64" } 23 | cppdialect "C++11" 24 | staticruntime "On" 25 | 26 | filter { "platforms:Win32 or platforms:Win64" } 27 | system "windows" 28 | 29 | -- \todo select graphics lib? 30 | defines { "IM3D_OPENGL", "GLEW_STATIC" } 31 | links { "opengl32", "gdi32" } 32 | 33 | filter { "platforms:Win32" } 34 | architecture "x86" 35 | filter { "platforms:Win64" } 36 | architecture "x86_64" 37 | 38 | filter {} 39 | 40 | vpaths({ 41 | ["im3d"] = { IM3D_DIR .. "*.h", IM3D_DIR .. "*.cpp" }, 42 | ["imgui"] = EXAMPLE_COMMON_DIR .. "imgui/**", 43 | ["common"] = { EXAMPLE_COMMON_DIR .. "*.h", EXAMPLE_COMMON_DIR .. "*.cpp" }, 44 | ["*"] = { "*.cpp", EXAMPLE_DIR .. "OpenGL33/*.cpp" }, 45 | }) 46 | 47 | files({ 48 | IM3D_DIR .. "*.h", 49 | IM3D_DIR .. "*.cpp", 50 | }) 51 | 52 | project "im3d_multicontext" 53 | kind "ConsoleApp" 54 | language "C++" 55 | targetdir "" 56 | 57 | defines { "IM3D_OPENGL_VMAJ=3", "IM3D_OPENGL_VMIN=3", "IM3D_OPENGL_VSHADER=330" } 58 | defines { "IM3D_THREAD_LOCAL_CONTEXT_PTR=1" } -- can also do this via im3d_config.h 59 | 60 | includedirs({ 61 | IM3D_DIR, 62 | EXAMPLE_COMMON_DIR, 63 | }) 64 | files({ 65 | EXAMPLE_COMMON_DIR .. "**.h", 66 | EXAMPLE_COMMON_DIR .. "**.hpp", 67 | EXAMPLE_COMMON_DIR .. "**.c", 68 | EXAMPLE_COMMON_DIR .. "**.cpp", 69 | "*.cpp" 70 | }) 71 | 72 | -- this example provides its own main 73 | removefiles({ 74 | EXAMPLE_COMMON_DIR .. "main.cpp" 75 | }) 76 | files({ 77 | EXAMPLE_DIR .. "OpenGL33/im3d_opengl33.cpp" 78 | }) 79 | -------------------------------------------------------------------------------- /examples/MultiContext/vs2017/im3d_multicontext.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "im3d_multicontext", "im3d_multicontext.vcxproj", "{216F6004-8D85-5E9A-D6FC-E9BB42522F22}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|Win64 = Debug|Win64 10 | Release|Win32 = Release|Win32 11 | Release|Win64 = Release|Win64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Debug|Win32.Build.0 = Debug|Win32 16 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Debug|Win64.ActiveCfg = Debug Win64|x64 17 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Debug|Win64.Build.0 = Debug Win64|x64 18 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Release|Win32.ActiveCfg = Release|Win32 19 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Release|Win32.Build.0 = Release|Win32 20 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Release|Win64.ActiveCfg = Release Win64|x64 21 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Release|Win64.Build.0 = Release Win64|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /examples/MultiContext/vs2017/im3d_multicontext.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 6 | 7 | 8 | {5079AB3B-BCE3-5FB2-0522-115871CB3D07} 9 | 10 | 11 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 12 | 13 | 14 | {F279987C-DEB0-990D-879D-7F1073B3150F} 15 | 16 | 17 | {0098A80F-6CAC-D0C0-352E-7420A101CDF1} 18 | 19 | 20 | 21 | 22 | im3d 23 | 24 | 25 | im3d 26 | 27 | 28 | im3d 29 | 30 | 31 | common\GL 32 | 33 | 34 | common\GL 35 | 36 | 37 | common\GL 38 | 39 | 40 | common\GL 41 | 42 | 43 | common 44 | 45 | 46 | imgui 47 | 48 | 49 | imgui 50 | 51 | 52 | imgui 53 | 54 | 55 | imgui 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | common 65 | 66 | 67 | 68 | 69 | im3d 70 | 71 | 72 | 73 | common\GL 74 | 75 | 76 | common 77 | 78 | 79 | imgui 80 | 81 | 82 | imgui 83 | 84 | 85 | imgui 86 | 87 | 88 | imgui 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /examples/MultiContext/vs2019/im3d_multicontext.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 16 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "im3d_multicontext", "im3d_multicontext.vcxproj", "{216F6004-8D85-5E9A-D6FC-E9BB42522F22}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|Win64 = Debug|Win64 10 | Release|Win32 = Release|Win32 11 | Release|Win64 = Release|Win64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Debug|Win32.Build.0 = Debug|Win32 16 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Debug|Win64.ActiveCfg = Debug Win64|x64 17 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Debug|Win64.Build.0 = Debug Win64|x64 18 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Release|Win32.ActiveCfg = Release|Win32 19 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Release|Win32.Build.0 = Release|Win32 20 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Release|Win64.ActiveCfg = Release Win64|x64 21 | {216F6004-8D85-5E9A-D6FC-E9BB42522F22}.Release|Win64.Build.0 = Release Win64|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /examples/MultiContext/vs2019/im3d_multicontext.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 6 | 7 | 8 | {5079AB3B-BCE3-5FB2-0522-115871CB3D07} 9 | 10 | 11 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 12 | 13 | 14 | {F279987C-DEB0-990D-879D-7F1073B3150F} 15 | 16 | 17 | {0098A80F-6CAC-D0C0-352E-7420A101CDF1} 18 | 19 | 20 | 21 | 22 | im3d 23 | 24 | 25 | im3d 26 | 27 | 28 | im3d 29 | 30 | 31 | common\GL 32 | 33 | 34 | common\GL 35 | 36 | 37 | common\GL 38 | 39 | 40 | common\GL 41 | 42 | 43 | common 44 | 45 | 46 | imgui 47 | 48 | 49 | imgui 50 | 51 | 52 | imgui 53 | 54 | 55 | imgui 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | common 65 | 66 | 67 | 68 | 69 | im3d 70 | 71 | 72 | 73 | common\GL 74 | 75 | 76 | common 77 | 78 | 79 | imgui 80 | 81 | 82 | imgui 83 | 84 | 85 | imgui 86 | 87 | 88 | imgui 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /examples/OpenGL31/gmake/Makefile: -------------------------------------------------------------------------------- 1 | # GNU Make workspace makefile autogenerated by Premake 2 | 3 | ifndef config 4 | config=debug_win32 5 | endif 6 | 7 | ifndef verbose 8 | SILENT = @ 9 | endif 10 | 11 | ifeq ($(config),debug_win32) 12 | im3d_opengl31_config = debug_win32 13 | endif 14 | ifeq ($(config),debug_win64) 15 | im3d_opengl31_config = debug_win64 16 | endif 17 | ifeq ($(config),release_win32) 18 | im3d_opengl31_config = release_win32 19 | endif 20 | ifeq ($(config),release_win64) 21 | im3d_opengl31_config = release_win64 22 | endif 23 | 24 | PROJECTS := im3d_opengl31 25 | 26 | .PHONY: all clean help $(PROJECTS) 27 | 28 | all: $(PROJECTS) 29 | 30 | im3d_opengl31: 31 | ifneq (,$(im3d_opengl31_config)) 32 | @echo "==== Building im3d_opengl31 ($(im3d_opengl31_config)) ====" 33 | @${MAKE} --no-print-directory -C . -f im3d_opengl31.make config=$(im3d_opengl31_config) 34 | endif 35 | 36 | clean: 37 | @${MAKE} --no-print-directory -C . -f im3d_opengl31.make clean 38 | 39 | help: 40 | @echo "Usage: make [config=name] [target]" 41 | @echo "" 42 | @echo "CONFIGURATIONS:" 43 | @echo " debug_win32" 44 | @echo " debug_win64" 45 | @echo " release_win32" 46 | @echo " release_win64" 47 | @echo "" 48 | @echo "TARGETS:" 49 | @echo " all (default)" 50 | @echo " clean" 51 | @echo " im3d_opengl31" 52 | @echo "" 53 | @echo "For more information, see https://github.com/premake/premake-core/wiki" -------------------------------------------------------------------------------- /examples/OpenGL31/gmake/im3d_opengl3.make: -------------------------------------------------------------------------------- 1 | # GNU Make project makefile autogenerated by Premake 2 | 3 | ifndef config 4 | config=debug_win32 5 | endif 6 | 7 | ifndef verbose 8 | SILENT = @ 9 | endif 10 | 11 | .PHONY: clean prebuild prelink 12 | 13 | ifeq ($(config),debug_win32) 14 | RESCOMP = windres 15 | TARGETDIR = .. 16 | TARGET = $(TARGETDIR)/im3d_opengl3_debug.exe 17 | OBJDIR = obj/Win32/Debug 18 | DEFINES += -DIM3D_DEBUG -DIM3D_OPENGL -DGLEW_STATIC 19 | INCLUDES += -I../../.. -I../../common 20 | FORCE_INCLUDE += 21 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 22 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O0 -g 23 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=c++11 24 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 25 | LIBS += -lopengl32 -lgdi32 26 | LDDEPS += 27 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 28 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 29 | define PREBUILDCMDS 30 | endef 31 | define PRELINKCMDS 32 | endef 33 | define POSTBUILDCMDS 34 | endef 35 | all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET) 36 | @: 37 | 38 | endif 39 | 40 | ifeq ($(config),debug_win64) 41 | RESCOMP = windres 42 | TARGETDIR = .. 43 | TARGET = $(TARGETDIR)/im3d_opengl3_debug.exe 44 | OBJDIR = obj/Win64/Debug 45 | DEFINES += -DIM3D_DEBUG -DIM3D_OPENGL -DGLEW_STATIC 46 | INCLUDES += -I../../.. -I../../common 47 | FORCE_INCLUDE += 48 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 49 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O0 -g 50 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=c++11 51 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 52 | LIBS += -lopengl32 -lgdi32 53 | LDDEPS += 54 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 55 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 56 | define PREBUILDCMDS 57 | endef 58 | define PRELINKCMDS 59 | endef 60 | define POSTBUILDCMDS 61 | endef 62 | all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET) 63 | @: 64 | 65 | endif 66 | 67 | ifeq ($(config),release_win32) 68 | RESCOMP = windres 69 | TARGETDIR = .. 70 | TARGET = $(TARGETDIR)/im3d_opengl3.exe 71 | OBJDIR = obj/Win32/Release 72 | DEFINES += -DIM3D_OPENGL -DGLEW_STATIC 73 | INCLUDES += -I../../.. -I../../common 74 | FORCE_INCLUDE += 75 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 76 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -g 77 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=c++11 78 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 79 | LIBS += -lopengl32 -lgdi32 80 | LDDEPS += 81 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 82 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 83 | define PREBUILDCMDS 84 | endef 85 | define PRELINKCMDS 86 | endef 87 | define POSTBUILDCMDS 88 | endef 89 | all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET) 90 | @: 91 | 92 | endif 93 | 94 | ifeq ($(config),release_win64) 95 | RESCOMP = windres 96 | TARGETDIR = .. 97 | TARGET = $(TARGETDIR)/im3d_opengl3.exe 98 | OBJDIR = obj/Win64/Release 99 | DEFINES += -DIM3D_OPENGL -DGLEW_STATIC 100 | INCLUDES += -I../../.. -I../../common 101 | FORCE_INCLUDE += 102 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 103 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -g 104 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=c++11 105 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 106 | LIBS += -lopengl32 -lgdi32 107 | LDDEPS += 108 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 109 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 110 | define PREBUILDCMDS 111 | endef 112 | define PRELINKCMDS 113 | endef 114 | define POSTBUILDCMDS 115 | endef 116 | all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET) 117 | @: 118 | 119 | endif 120 | 121 | OBJECTS := \ 122 | $(OBJDIR)/glew.o \ 123 | $(OBJDIR)/im3d_example.o \ 124 | $(OBJDIR)/main.o \ 125 | $(OBJDIR)/im3d.o \ 126 | $(OBJDIR)/im3d_opengl3.o \ 127 | $(OBJDIR)/imgui.o \ 128 | $(OBJDIR)/imgui_demo.o \ 129 | $(OBJDIR)/imgui_draw.o \ 130 | 131 | RESOURCES := \ 132 | 133 | CUSTOMFILES := \ 134 | 135 | SHELLTYPE := msdos 136 | ifeq (,$(ComSpec)$(COMSPEC)) 137 | SHELLTYPE := posix 138 | endif 139 | ifeq (/bin,$(findstring /bin,$(SHELL))) 140 | SHELLTYPE := posix 141 | endif 142 | 143 | $(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) 144 | @echo Linking im3d_opengl3 145 | $(SILENT) $(LINKCMD) 146 | $(POSTBUILDCMDS) 147 | 148 | $(TARGETDIR): 149 | @echo Creating $(TARGETDIR) 150 | ifeq (posix,$(SHELLTYPE)) 151 | $(SILENT) mkdir -p $(TARGETDIR) 152 | else 153 | $(SILENT) mkdir $(subst /,\\,$(TARGETDIR)) 154 | endif 155 | 156 | $(OBJDIR): 157 | @echo Creating $(OBJDIR) 158 | ifeq (posix,$(SHELLTYPE)) 159 | $(SILENT) mkdir -p $(OBJDIR) 160 | else 161 | $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) 162 | endif 163 | 164 | clean: 165 | @echo Cleaning im3d_opengl3 166 | ifeq (posix,$(SHELLTYPE)) 167 | $(SILENT) rm -f $(TARGET) 168 | $(SILENT) rm -rf $(OBJDIR) 169 | else 170 | $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET)) 171 | $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR)) 172 | endif 173 | 174 | prebuild: 175 | $(PREBUILDCMDS) 176 | 177 | prelink: 178 | $(PRELINKCMDS) 179 | 180 | ifneq (,$(PCH)) 181 | $(OBJECTS): $(GCH) $(PCH) 182 | $(GCH): $(PCH) 183 | @echo $(notdir $<) 184 | $(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" 185 | endif 186 | 187 | $(OBJDIR)/glew.o: ../../common/GL/glew.c 188 | @echo $(notdir $<) 189 | $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 190 | $(OBJDIR)/im3d_example.o: ../../common/im3d_example.cpp 191 | @echo $(notdir $<) 192 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 193 | $(OBJDIR)/main.o: ../../common/main.cpp 194 | @echo $(notdir $<) 195 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 196 | $(OBJDIR)/im3d.o: ../../../im3d.cpp 197 | @echo $(notdir $<) 198 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 199 | $(OBJDIR)/im3d_opengl3.o: ../im3d_opengl3.cpp 200 | @echo $(notdir $<) 201 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 202 | $(OBJDIR)/imgui.o: ../../common/imgui/imgui.cpp 203 | @echo $(notdir $<) 204 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 205 | $(OBJDIR)/imgui_demo.o: ../../common/imgui/imgui_demo.cpp 206 | @echo $(notdir $<) 207 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 208 | $(OBJDIR)/imgui_draw.o: ../../common/imgui/imgui_draw.cpp 209 | @echo $(notdir $<) 210 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 211 | 212 | -include $(OBJECTS:%.o=%.d) 213 | ifneq (,$(PCH)) 214 | -include $(OBJDIR)/$(notdir $(PCH)).d 215 | endif -------------------------------------------------------------------------------- /examples/OpenGL31/gmake/im3d_opengl31.make: -------------------------------------------------------------------------------- 1 | # GNU Make project makefile autogenerated by Premake 2 | 3 | ifndef config 4 | config=debug_win32 5 | endif 6 | 7 | ifndef verbose 8 | SILENT = @ 9 | endif 10 | 11 | .PHONY: clean prebuild prelink 12 | 13 | ifeq ($(config),debug_win32) 14 | RESCOMP = windres 15 | TARGETDIR = .. 16 | TARGET = $(TARGETDIR)/im3d_opengl31_debug.exe 17 | OBJDIR = obj/Win32/Debug 18 | DEFINES += -DIM3D_DEBUG -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=1 -DIM3D_OPENGL_VSHADER=140 -DIM3D_VERTEX_ALIGNMENT=16 19 | INCLUDES += -I../../.. -I../../common 20 | FORCE_INCLUDE += 21 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 22 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O0 -g 23 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O0 -g -std=c++11 24 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 25 | LIBS += -lopengl32 -lgdi32 26 | LDDEPS += 27 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 28 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 29 | define PREBUILDCMDS 30 | endef 31 | define PRELINKCMDS 32 | endef 33 | define POSTBUILDCMDS 34 | endef 35 | all: prebuild prelink $(TARGET) 36 | @: 37 | 38 | endif 39 | 40 | ifeq ($(config),debug_win64) 41 | RESCOMP = windres 42 | TARGETDIR = .. 43 | TARGET = $(TARGETDIR)/im3d_opengl31_debug.exe 44 | OBJDIR = obj/Win64/Debug 45 | DEFINES += -DIM3D_DEBUG -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=1 -DIM3D_OPENGL_VSHADER=140 -DIM3D_VERTEX_ALIGNMENT=16 46 | INCLUDES += -I../../.. -I../../common 47 | FORCE_INCLUDE += 48 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 49 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O0 -g 50 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O0 -g -std=c++11 51 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 52 | LIBS += -lopengl32 -lgdi32 53 | LDDEPS += 54 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 55 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 56 | define PREBUILDCMDS 57 | endef 58 | define PRELINKCMDS 59 | endef 60 | define POSTBUILDCMDS 61 | endef 62 | all: prebuild prelink $(TARGET) 63 | @: 64 | 65 | endif 66 | 67 | ifeq ($(config),release_win32) 68 | RESCOMP = windres 69 | TARGETDIR = .. 70 | TARGET = $(TARGETDIR)/im3d_opengl31.exe 71 | OBJDIR = obj/Win32/Release 72 | DEFINES += -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=1 -DIM3D_OPENGL_VSHADER=140 -DIM3D_VERTEX_ALIGNMENT=16 73 | INCLUDES += -I../../.. -I../../common 74 | FORCE_INCLUDE += 75 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 76 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -g 77 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -g -std=c++11 78 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 79 | LIBS += -lopengl32 -lgdi32 80 | LDDEPS += 81 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 82 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 83 | define PREBUILDCMDS 84 | endef 85 | define PRELINKCMDS 86 | endef 87 | define POSTBUILDCMDS 88 | endef 89 | all: prebuild prelink $(TARGET) 90 | @: 91 | 92 | endif 93 | 94 | ifeq ($(config),release_win64) 95 | RESCOMP = windres 96 | TARGETDIR = .. 97 | TARGET = $(TARGETDIR)/im3d_opengl31.exe 98 | OBJDIR = obj/Win64/Release 99 | DEFINES += -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=1 -DIM3D_OPENGL_VSHADER=140 -DIM3D_VERTEX_ALIGNMENT=16 100 | INCLUDES += -I../../.. -I../../common 101 | FORCE_INCLUDE += 102 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 103 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -g 104 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -g -std=c++11 105 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 106 | LIBS += -lopengl32 -lgdi32 107 | LDDEPS += 108 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 109 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 110 | define PREBUILDCMDS 111 | endef 112 | define PRELINKCMDS 113 | endef 114 | define POSTBUILDCMDS 115 | endef 116 | all: prebuild prelink $(TARGET) 117 | @: 118 | 119 | endif 120 | 121 | OBJECTS := \ 122 | $(OBJDIR)/glew.o \ 123 | $(OBJDIR)/im3d_example.o \ 124 | $(OBJDIR)/main.o \ 125 | $(OBJDIR)/im3d.o \ 126 | $(OBJDIR)/im3d_opengl31.o \ 127 | $(OBJDIR)/imgui.o \ 128 | $(OBJDIR)/imgui_demo.o \ 129 | $(OBJDIR)/imgui_draw.o \ 130 | $(OBJDIR)/imgui_widgets.o \ 131 | 132 | RESOURCES := \ 133 | 134 | CUSTOMFILES := \ 135 | 136 | SHELLTYPE := posix 137 | ifeq (.exe,$(findstring .exe,$(ComSpec))) 138 | SHELLTYPE := msdos 139 | endif 140 | 141 | $(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) | $(TARGETDIR) 142 | @echo Linking im3d_opengl31 143 | $(SILENT) $(LINKCMD) 144 | $(POSTBUILDCMDS) 145 | 146 | $(CUSTOMFILES): | $(OBJDIR) 147 | 148 | $(TARGETDIR): 149 | @echo Creating $(TARGETDIR) 150 | ifeq (posix,$(SHELLTYPE)) 151 | $(SILENT) mkdir -p $(TARGETDIR) 152 | else 153 | $(SILENT) mkdir $(subst /,\\,$(TARGETDIR)) 154 | endif 155 | 156 | $(OBJDIR): 157 | @echo Creating $(OBJDIR) 158 | ifeq (posix,$(SHELLTYPE)) 159 | $(SILENT) mkdir -p $(OBJDIR) 160 | else 161 | $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) 162 | endif 163 | 164 | clean: 165 | @echo Cleaning im3d_opengl31 166 | ifeq (posix,$(SHELLTYPE)) 167 | $(SILENT) rm -f $(TARGET) 168 | $(SILENT) rm -rf $(OBJDIR) 169 | else 170 | $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET)) 171 | $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR)) 172 | endif 173 | 174 | prebuild: 175 | $(PREBUILDCMDS) 176 | 177 | prelink: 178 | $(PRELINKCMDS) 179 | 180 | ifneq (,$(PCH)) 181 | $(OBJECTS): $(GCH) $(PCH) | $(OBJDIR) 182 | $(GCH): $(PCH) | $(OBJDIR) 183 | @echo $(notdir $<) 184 | $(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" 185 | else 186 | $(OBJECTS): | $(OBJDIR) 187 | endif 188 | 189 | $(OBJDIR)/glew.o: ../../common/GL/glew.c 190 | @echo $(notdir $<) 191 | $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 192 | $(OBJDIR)/im3d_example.o: ../../common/im3d_example.cpp 193 | @echo $(notdir $<) 194 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 195 | $(OBJDIR)/main.o: ../../common/main.cpp 196 | @echo $(notdir $<) 197 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 198 | $(OBJDIR)/im3d.o: ../../../im3d.cpp 199 | @echo $(notdir $<) 200 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 201 | $(OBJDIR)/im3d_opengl31.o: ../im3d_opengl31.cpp 202 | @echo $(notdir $<) 203 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 204 | $(OBJDIR)/imgui.o: ../../common/imgui/imgui.cpp 205 | @echo $(notdir $<) 206 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 207 | $(OBJDIR)/imgui_demo.o: ../../common/imgui/imgui_demo.cpp 208 | @echo $(notdir $<) 209 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 210 | $(OBJDIR)/imgui_draw.o: ../../common/imgui/imgui_draw.cpp 211 | @echo $(notdir $<) 212 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 213 | $(OBJDIR)/imgui_widgets.o: ../../common/imgui/imgui_widgets.cpp 214 | @echo $(notdir $<) 215 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 216 | 217 | -include $(OBJECTS:%.o=%.d) 218 | ifneq (,$(PCH)) 219 | -include $(OBJDIR)/$(notdir $(PCH)).d 220 | endif -------------------------------------------------------------------------------- /examples/OpenGL31/im3d.glsl: -------------------------------------------------------------------------------- 1 | #if !defined(POINTS) && !defined(LINES) && !defined(TRIANGLES) 2 | #error No primitive type defined 3 | #endif 4 | #if !defined(VERTEX_SHADER) && !defined(FRAGMENT_SHADER) 5 | #error No shader stage defined 6 | #endif 7 | 8 | #define kAntialiasing 2.0 9 | 10 | #ifdef VERTEX_SHADER 11 | /* This vertex shader fetches Im3d vertex data manually from a uniform buffer (uVertexData). It assumes that the bound vertex buffer contains 4 vertices as follows: 12 | 13 | -1,1 1,1 14 | 2 ------- 3 15 | | \ | 16 | | \ | 17 | | \ | 18 | | \ | 19 | 0 ------- 1 20 | -1,-1 1,-1 21 | 22 | Both the vertex ID and the vertex position are used for point/line expansion. This vertex buffer is valid for both triangle strip rendering (points/lines), and 23 | triangle render using vertices 0,1,2. 24 | 25 | See im3d_opengl31.cpp for more details. 26 | */ 27 | 28 | struct VertexData 29 | { 30 | vec4 m_positionSize; 31 | uint m_color; 32 | }; 33 | uniform VertexDataBlock 34 | { 35 | VertexData uVertexData[(64 * 1024) / 32]; // assume a 64kb block size, 32 is the aligned size of VertexData 36 | }; 37 | 38 | uniform mat4 uViewProjMatrix; 39 | uniform vec2 uViewport; 40 | 41 | in vec4 aPosition; 42 | 43 | #if defined(POINTS) 44 | noperspective out vec2 vUv; 45 | #elif defined(LINES) 46 | noperspective out float vEdgeDistance; 47 | #endif 48 | noperspective out float vSize; 49 | smooth out vec4 vColor; 50 | 51 | vec4 UintToRgba(uint _u) 52 | { 53 | vec4 ret = vec4(0.0); 54 | ret.r = float((_u & 0xff000000u) >> 24u) / 255.0; 55 | ret.g = float((_u & 0x00ff0000u) >> 16u) / 255.0; 56 | ret.b = float((_u & 0x0000ff00u) >> 8u) / 255.0; 57 | ret.a = float((_u & 0x000000ffu) >> 0u) / 255.0; 58 | return ret; 59 | } 60 | 61 | void main() 62 | { 63 | #if defined(POINTS) 64 | int vid = gl_InstanceID; 65 | 66 | vSize = max(uVertexData[vid].m_positionSize.w, kAntialiasing); 67 | vColor = UintToRgba(uVertexData[vid].m_color); 68 | vColor.a *= smoothstep(0.0, 1.0, vSize / kAntialiasing); 69 | 70 | gl_Position = uViewProjMatrix * vec4(uVertexData[vid].m_positionSize.xyz, 1.0); 71 | vec2 scale = 1.0 / uViewport * vSize; 72 | gl_Position.xy += aPosition.xy * scale * gl_Position.w; 73 | vUv = aPosition.xy * 0.5 + 0.5; 74 | 75 | #elif defined(LINES) 76 | int vid0 = gl_InstanceID * 2; // line start 77 | int vid1 = vid0 + 1; // line end 78 | int vid = (gl_VertexID % 2 == 0) ? vid0 : vid1; // data for this vertex 79 | 80 | vColor = UintToRgba(uVertexData[vid].m_color); 81 | vSize = uVertexData[vid].m_positionSize.w; 82 | vColor.a *= smoothstep(0.0, 1.0, vSize / kAntialiasing); 83 | vSize = max(vSize, kAntialiasing); 84 | vEdgeDistance = vSize * aPosition.y; 85 | 86 | vec4 pos0 = uViewProjMatrix * vec4(uVertexData[vid0].m_positionSize.xyz, 1.0); 87 | vec4 pos1 = uViewProjMatrix * vec4(uVertexData[vid1].m_positionSize.xyz, 1.0); 88 | vec2 dir = (pos0.xy / pos0.w) - (pos1.xy / pos1.w); 89 | dir = normalize(vec2(dir.x, dir.y * uViewport.y / uViewport.x)); // correct for aspect ratio 90 | vec2 tng = vec2(-dir.y, dir.x) * vSize / uViewport; 91 | 92 | gl_Position = (gl_VertexID % 2 == 0) ? pos0 : pos1; 93 | gl_Position.xy += tng * aPosition.y * gl_Position.w; 94 | 95 | #elif defined(TRIANGLES) 96 | int vid = gl_InstanceID * 3 + gl_VertexID; 97 | vColor = UintToRgba(uVertexData[vid].m_color); 98 | gl_Position = uViewProjMatrix * vec4(uVertexData[vid].m_positionSize.xyz, 1.0); 99 | 100 | #endif 101 | } 102 | #endif 103 | 104 | #ifdef FRAGMENT_SHADER 105 | #if defined(POINTS) 106 | noperspective in vec2 vUv; 107 | #elif defined(LINES) 108 | noperspective in float vEdgeDistance; 109 | #endif 110 | noperspective in float vSize; 111 | smooth in vec4 vColor; 112 | 113 | out vec4 fResult; 114 | 115 | void main() 116 | { 117 | fResult = vColor; 118 | #if defined(LINES) 119 | float d = abs(vEdgeDistance) / vSize; 120 | d = smoothstep(1.0, 1.0 - (kAntialiasing / vSize), d); 121 | fResult.a *= d; 122 | #elif defined(POINTS) 123 | float d = length(vUv - vec2(0.5)); 124 | d = smoothstep(0.5, 0.5 - (kAntialiasing / vSize), d); 125 | fResult.a *= d; 126 | #endif 127 | } 128 | #endif 129 | -------------------------------------------------------------------------------- /examples/OpenGL31/imgui.glsl: -------------------------------------------------------------------------------- 1 | #ifdef VERTEX_SHADER 2 | in vec2 aPosition; 3 | in vec2 aTexcoord; 4 | in vec4 aColor; 5 | 6 | uniform mat4 uProjMatrix; 7 | 8 | noperspective out vec2 vUv; 9 | noperspective out vec4 vColor; 10 | 11 | void main() 12 | { 13 | vUv = aTexcoord; 14 | vColor = aColor; 15 | gl_Position = uProjMatrix * vec4(aPosition.xy, 0.0, 1.0); 16 | } 17 | #endif 18 | 19 | #ifdef FRAGMENT_SHADER 20 | noperspective in vec2 vUv; 21 | noperspective in vec4 vColor; 22 | 23 | uniform sampler2D txTexture; 24 | 25 | out vec4 fResult; 26 | 27 | void main() 28 | { 29 | fResult = vColor; 30 | fResult.a *= texture(txTexture, vUv).r; 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /examples/OpenGL31/model.glsl: -------------------------------------------------------------------------------- 1 | #ifdef VERTEX_SHADER 2 | uniform mat4 uWorldMatrix; 3 | uniform mat4 uViewProjMatrix; 4 | 5 | in vec3 aPosition; 6 | in vec3 aNormal; 7 | 8 | smooth out vec3 vNormalW; 9 | 10 | void main() 11 | { 12 | vNormalW = mat3(uWorldMatrix) * aNormal; 13 | gl_Position = uViewProjMatrix * (uWorldMatrix * vec4(aPosition, 1.0)); 14 | } 15 | #endif 16 | 17 | #ifdef FRAGMENT_SHADER 18 | smooth in vec3 vNormalW; 19 | 20 | out vec3 fResult; 21 | 22 | void main() 23 | { 24 | vec3 nrm = normalize(vNormalW); 25 | vec3 ldir = normalize(vec3(1.0)); 26 | float ndotl = max(dot(nrm, ldir), 0.0) * 0.5; 27 | fResult = vec3(ndotl); 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /examples/OpenGL31/premake5.lua: -------------------------------------------------------------------------------- 1 | local IM3D_DIR = "../../" 2 | local EXAMPLE_COMMON_DIR = "../common/" 3 | 4 | filter { "configurations:debug" } 5 | defines { "IM3D_DEBUG" } 6 | targetsuffix "_debug" 7 | symbols "On" 8 | optimize "Off" 9 | 10 | filter { "configurations:release" } 11 | symbols "On" 12 | optimize "Full" 13 | 14 | filter { "action:vs*" } 15 | defines { "_CRT_SECURE_NO_WARNINGS", "_SCL_SECURE_NO_WARNINGS" } 16 | characterset "MBCS" -- force Win32 API to use *A variants (i.e. can pass char* for strings) 17 | 18 | workspace "im3d_opengl31" 19 | location(_ACTION) 20 | configurations { "Debug", "Release" } 21 | platforms { "Win32", "Win64" } 22 | cppdialect "C++11" 23 | staticruntime "On" 24 | 25 | filter { "platforms:Win32 or platforms:Win64" } 26 | system "windows" 27 | 28 | -- \todo select graphics lib? 29 | defines { "IM3D_OPENGL", "GLEW_STATIC" } 30 | links { "opengl32", "gdi32" } 31 | 32 | filter { "platforms:Win32" } 33 | architecture "x86" 34 | filter { "platforms:Win64" } 35 | architecture "x86_64" 36 | 37 | filter {} 38 | 39 | vpaths({ 40 | ["im3d"] = { IM3D_DIR .. "*.h", IM3D_DIR .. "*.cpp" }, 41 | ["imgui"] = EXAMPLE_COMMON_DIR .. "imgui/**", 42 | ["common"] = { EXAMPLE_COMMON_DIR .. "*.h", EXAMPLE_COMMON_DIR .. "*.cpp" }, 43 | ["*"] = "*.cpp" 44 | }) 45 | 46 | files({ 47 | IM3D_DIR .. "*.h", 48 | IM3D_DIR .. "*.cpp", 49 | }) 50 | 51 | project "im3d_opengl31" 52 | kind "ConsoleApp" 53 | language "C++" 54 | targetdir "" 55 | 56 | defines { "IM3D_OPENGL_VMAJ=3", "IM3D_OPENGL_VMIN=1", "IM3D_OPENGL_VSHADER=140" } 57 | defines { "IM3D_VERTEX_ALIGNMENT=16" } -- can also do this via im3d_config.h 58 | 59 | includedirs({ 60 | IM3D_DIR, 61 | EXAMPLE_COMMON_DIR, 62 | }) 63 | files({ 64 | EXAMPLE_COMMON_DIR .. "**.h", 65 | EXAMPLE_COMMON_DIR .. "**.hpp", 66 | EXAMPLE_COMMON_DIR .. "**.c", 67 | EXAMPLE_COMMON_DIR .. "**.cpp", 68 | "*.cpp" 69 | }) 70 | -------------------------------------------------------------------------------- /examples/OpenGL31/vs2017/im3d_opengl31.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "im3d_opengl31", "im3d_opengl31.vcxproj", "{BA77FB43-2638-777A-EF72-C0F75BF2BB56}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|Win64 = Debug|Win64 10 | Release|Win32 = Release|Win32 11 | Release|Win64 = Release|Win64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Debug|Win32.Build.0 = Debug|Win32 16 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Debug|Win64.ActiveCfg = Debug Win64|x64 17 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Debug|Win64.Build.0 = Debug Win64|x64 18 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Release|Win32.ActiveCfg = Release|Win32 19 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Release|Win32.Build.0 = Release|Win32 20 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Release|Win64.ActiveCfg = Release Win64|x64 21 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Release|Win64.Build.0 = Release Win64|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /examples/OpenGL31/vs2017/im3d_opengl31.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Debug Win64 14 | Win32 15 | 16 | 17 | Debug Win64 18 | x64 19 | 20 | 21 | Release 22 | Win32 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | Release Win64 30 | Win32 31 | 32 | 33 | Release Win64 34 | x64 35 | 36 | 37 | 38 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56} 39 | true 40 | Win32Proj 41 | im3d_opengl31 42 | 43 | 44 | 45 | Application 46 | true 47 | MultiByte 48 | v141 49 | 50 | 51 | Application 52 | true 53 | MultiByte 54 | v141 55 | 56 | 57 | Application 58 | false 59 | MultiByte 60 | v141 61 | 62 | 63 | Application 64 | false 65 | MultiByte 66 | v141 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | true 86 | ..\ 87 | obj\Win32\Debug\ 88 | im3d_opengl31_debug 89 | .exe 90 | 91 | 92 | true 93 | ..\ 94 | obj\Win64\Debug\ 95 | im3d_opengl31_debug 96 | .exe 97 | 98 | 99 | false 100 | ..\ 101 | obj\Win32\Release\ 102 | im3d_opengl31 103 | .exe 104 | 105 | 106 | false 107 | ..\ 108 | obj\Win64\Release\ 109 | im3d_opengl31 110 | .exe 111 | 112 | 113 | 114 | NotUsing 115 | Level3 116 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=1;IM3D_OPENGL_VSHADER=140;IM3D_VERTEX_ALIGNMENT=16;%(PreprocessorDefinitions) 117 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 118 | EditAndContinue 119 | Disabled 120 | MultiThreadedDebug 121 | 122 | 123 | Console 124 | true 125 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 126 | 127 | 128 | 129 | 130 | NotUsing 131 | Level3 132 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=1;IM3D_OPENGL_VSHADER=140;IM3D_VERTEX_ALIGNMENT=16;%(PreprocessorDefinitions) 133 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 134 | EditAndContinue 135 | Disabled 136 | MultiThreadedDebug 137 | 138 | 139 | Console 140 | true 141 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 142 | 143 | 144 | 145 | 146 | NotUsing 147 | Level3 148 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=1;IM3D_OPENGL_VSHADER=140;IM3D_VERTEX_ALIGNMENT=16;%(PreprocessorDefinitions) 149 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 150 | ProgramDatabase 151 | Full 152 | true 153 | true 154 | false 155 | true 156 | MultiThreaded 157 | 158 | 159 | Console 160 | true 161 | true 162 | true 163 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 164 | 165 | 166 | 167 | 168 | NotUsing 169 | Level3 170 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=1;IM3D_OPENGL_VSHADER=140;IM3D_VERTEX_ALIGNMENT=16;%(PreprocessorDefinitions) 171 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 172 | ProgramDatabase 173 | Full 174 | true 175 | true 176 | false 177 | true 178 | MultiThreaded 179 | 180 | 181 | Console 182 | true 183 | true 184 | true 185 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /examples/OpenGL31/vs2017/im3d_opengl31.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 6 | 7 | 8 | {5079AB3B-BCE3-5FB2-0522-115871CB3D07} 9 | 10 | 11 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 12 | 13 | 14 | {F279987C-DEB0-990D-879D-7F1073B3150F} 15 | 16 | 17 | {0098A80F-6CAC-D0C0-352E-7420A101CDF1} 18 | 19 | 20 | 21 | 22 | im3d 23 | 24 | 25 | im3d 26 | 27 | 28 | im3d 29 | 30 | 31 | common\GL 32 | 33 | 34 | common\GL 35 | 36 | 37 | common\GL 38 | 39 | 40 | common\GL 41 | 42 | 43 | common 44 | 45 | 46 | imgui 47 | 48 | 49 | imgui 50 | 51 | 52 | imgui 53 | 54 | 55 | imgui 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | common 65 | 66 | 67 | 68 | 69 | im3d 70 | 71 | 72 | common\GL 73 | 74 | 75 | common 76 | 77 | 78 | imgui 79 | 80 | 81 | imgui 82 | 83 | 84 | imgui 85 | 86 | 87 | imgui 88 | 89 | 90 | common 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /examples/OpenGL31/vs2019/im3d_opengl31.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 16 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "im3d_opengl31", "im3d_opengl31.vcxproj", "{BA77FB43-2638-777A-EF72-C0F75BF2BB56}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|Win64 = Debug|Win64 10 | Release|Win32 = Release|Win32 11 | Release|Win64 = Release|Win64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Debug|Win32.Build.0 = Debug|Win32 16 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Debug|Win64.ActiveCfg = Debug Win64|x64 17 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Debug|Win64.Build.0 = Debug Win64|x64 18 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Release|Win32.ActiveCfg = Release|Win32 19 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Release|Win32.Build.0 = Release|Win32 20 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Release|Win64.ActiveCfg = Release Win64|x64 21 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56}.Release|Win64.Build.0 = Release Win64|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /examples/OpenGL31/vs2019/im3d_opengl31.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Debug Win64 14 | Win32 15 | 16 | 17 | Debug Win64 18 | x64 19 | 20 | 21 | Release 22 | Win32 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | Release Win64 30 | Win32 31 | 32 | 33 | Release Win64 34 | x64 35 | 36 | 37 | 38 | {BA77FB43-2638-777A-EF72-C0F75BF2BB56} 39 | true 40 | Win32Proj 41 | im3d_opengl31 42 | 43 | 44 | 45 | Application 46 | true 47 | MultiByte 48 | v142 49 | 50 | 51 | Application 52 | true 53 | MultiByte 54 | v142 55 | 56 | 57 | Application 58 | false 59 | MultiByte 60 | v142 61 | 62 | 63 | Application 64 | false 65 | MultiByte 66 | v142 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | true 86 | ..\ 87 | obj\Win32\Debug\ 88 | im3d_opengl31_debug 89 | .exe 90 | 91 | 92 | true 93 | ..\ 94 | obj\Win64\Debug\ 95 | im3d_opengl31_debug 96 | .exe 97 | 98 | 99 | false 100 | ..\ 101 | obj\Win32\Release\ 102 | im3d_opengl31 103 | .exe 104 | 105 | 106 | false 107 | ..\ 108 | obj\Win64\Release\ 109 | im3d_opengl31 110 | .exe 111 | 112 | 113 | 114 | NotUsing 115 | Level3 116 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=1;IM3D_OPENGL_VSHADER=140;IM3D_VERTEX_ALIGNMENT=16;%(PreprocessorDefinitions) 117 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 118 | EditAndContinue 119 | Disabled 120 | MultiThreadedDebug 121 | 122 | 123 | Console 124 | true 125 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 126 | 127 | 128 | 129 | 130 | NotUsing 131 | Level3 132 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=1;IM3D_OPENGL_VSHADER=140;IM3D_VERTEX_ALIGNMENT=16;%(PreprocessorDefinitions) 133 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 134 | EditAndContinue 135 | Disabled 136 | MultiThreadedDebug 137 | 138 | 139 | Console 140 | true 141 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 142 | 143 | 144 | 145 | 146 | NotUsing 147 | Level3 148 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=1;IM3D_OPENGL_VSHADER=140;IM3D_VERTEX_ALIGNMENT=16;%(PreprocessorDefinitions) 149 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 150 | ProgramDatabase 151 | Full 152 | true 153 | true 154 | false 155 | true 156 | MultiThreaded 157 | 158 | 159 | Console 160 | true 161 | true 162 | true 163 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 164 | 165 | 166 | 167 | 168 | NotUsing 169 | Level3 170 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=1;IM3D_OPENGL_VSHADER=140;IM3D_VERTEX_ALIGNMENT=16;%(PreprocessorDefinitions) 171 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 172 | ProgramDatabase 173 | Full 174 | true 175 | true 176 | false 177 | true 178 | MultiThreaded 179 | 180 | 181 | Console 182 | true 183 | true 184 | true 185 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /examples/OpenGL31/vs2019/im3d_opengl31.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 6 | 7 | 8 | {5079AB3B-BCE3-5FB2-0522-115871CB3D07} 9 | 10 | 11 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 12 | 13 | 14 | {F279987C-DEB0-990D-879D-7F1073B3150F} 15 | 16 | 17 | {0098A80F-6CAC-D0C0-352E-7420A101CDF1} 18 | 19 | 20 | 21 | 22 | im3d 23 | 24 | 25 | im3d 26 | 27 | 28 | im3d 29 | 30 | 31 | common\GL 32 | 33 | 34 | common\GL 35 | 36 | 37 | common\GL 38 | 39 | 40 | common\GL 41 | 42 | 43 | common 44 | 45 | 46 | imgui 47 | 48 | 49 | imgui 50 | 51 | 52 | imgui 53 | 54 | 55 | imgui 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | common 65 | 66 | 67 | 68 | 69 | im3d 70 | 71 | 72 | common\GL 73 | 74 | 75 | common 76 | 77 | 78 | imgui 79 | 80 | 81 | imgui 82 | 83 | 84 | imgui 85 | 86 | 87 | imgui 88 | 89 | 90 | common 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /examples/OpenGL33/gmake/Makefile: -------------------------------------------------------------------------------- 1 | # GNU Make workspace makefile autogenerated by Premake 2 | 3 | ifndef config 4 | config=debug_win32 5 | endif 6 | 7 | ifndef verbose 8 | SILENT = @ 9 | endif 10 | 11 | ifeq ($(config),debug_win32) 12 | im3d_opengl33_config = debug_win32 13 | endif 14 | ifeq ($(config),debug_win64) 15 | im3d_opengl33_config = debug_win64 16 | endif 17 | ifeq ($(config),release_win32) 18 | im3d_opengl33_config = release_win32 19 | endif 20 | ifeq ($(config),release_win64) 21 | im3d_opengl33_config = release_win64 22 | endif 23 | 24 | PROJECTS := im3d_opengl33 25 | 26 | .PHONY: all clean help $(PROJECTS) 27 | 28 | all: $(PROJECTS) 29 | 30 | im3d_opengl33: 31 | ifneq (,$(im3d_opengl33_config)) 32 | @echo "==== Building im3d_opengl33 ($(im3d_opengl33_config)) ====" 33 | @${MAKE} --no-print-directory -C . -f im3d_opengl33.make config=$(im3d_opengl33_config) 34 | endif 35 | 36 | clean: 37 | @${MAKE} --no-print-directory -C . -f im3d_opengl33.make clean 38 | 39 | help: 40 | @echo "Usage: make [config=name] [target]" 41 | @echo "" 42 | @echo "CONFIGURATIONS:" 43 | @echo " debug_win32" 44 | @echo " debug_win64" 45 | @echo " release_win32" 46 | @echo " release_win64" 47 | @echo "" 48 | @echo "TARGETS:" 49 | @echo " all (default)" 50 | @echo " clean" 51 | @echo " im3d_opengl33" 52 | @echo "" 53 | @echo "For more information, see https://github.com/premake/premake-core/wiki" -------------------------------------------------------------------------------- /examples/OpenGL33/gmake/im3d_opengl3.make: -------------------------------------------------------------------------------- 1 | # GNU Make project makefile autogenerated by Premake 2 | 3 | ifndef config 4 | config=debug_win32 5 | endif 6 | 7 | ifndef verbose 8 | SILENT = @ 9 | endif 10 | 11 | .PHONY: clean prebuild prelink 12 | 13 | ifeq ($(config),debug_win32) 14 | RESCOMP = windres 15 | TARGETDIR = .. 16 | TARGET = $(TARGETDIR)/im3d_opengl3_debug.exe 17 | OBJDIR = obj/Win32/Debug 18 | DEFINES += -DIM3D_DEBUG -DIM3D_OPENGL -DGLEW_STATIC 19 | INCLUDES += -I../../.. -I../../common 20 | FORCE_INCLUDE += 21 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 22 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O0 -g 23 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=c++11 24 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 25 | LIBS += -lopengl32 -lgdi32 26 | LDDEPS += 27 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 28 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 29 | define PREBUILDCMDS 30 | endef 31 | define PRELINKCMDS 32 | endef 33 | define POSTBUILDCMDS 34 | endef 35 | all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET) 36 | @: 37 | 38 | endif 39 | 40 | ifeq ($(config),debug_win64) 41 | RESCOMP = windres 42 | TARGETDIR = .. 43 | TARGET = $(TARGETDIR)/im3d_opengl3_debug.exe 44 | OBJDIR = obj/Win64/Debug 45 | DEFINES += -DIM3D_DEBUG -DIM3D_OPENGL -DGLEW_STATIC 46 | INCLUDES += -I../../.. -I../../common 47 | FORCE_INCLUDE += 48 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 49 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O0 -g 50 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=c++11 51 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 52 | LIBS += -lopengl32 -lgdi32 53 | LDDEPS += 54 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 55 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 56 | define PREBUILDCMDS 57 | endef 58 | define PRELINKCMDS 59 | endef 60 | define POSTBUILDCMDS 61 | endef 62 | all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET) 63 | @: 64 | 65 | endif 66 | 67 | ifeq ($(config),release_win32) 68 | RESCOMP = windres 69 | TARGETDIR = .. 70 | TARGET = $(TARGETDIR)/im3d_opengl3.exe 71 | OBJDIR = obj/Win32/Release 72 | DEFINES += -DIM3D_OPENGL -DGLEW_STATIC 73 | INCLUDES += -I../../.. -I../../common 74 | FORCE_INCLUDE += 75 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 76 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -g 77 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=c++11 78 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 79 | LIBS += -lopengl32 -lgdi32 80 | LDDEPS += 81 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 82 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 83 | define PREBUILDCMDS 84 | endef 85 | define PRELINKCMDS 86 | endef 87 | define POSTBUILDCMDS 88 | endef 89 | all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET) 90 | @: 91 | 92 | endif 93 | 94 | ifeq ($(config),release_win64) 95 | RESCOMP = windres 96 | TARGETDIR = .. 97 | TARGET = $(TARGETDIR)/im3d_opengl3.exe 98 | OBJDIR = obj/Win64/Release 99 | DEFINES += -DIM3D_OPENGL -DGLEW_STATIC 100 | INCLUDES += -I../../.. -I../../common 101 | FORCE_INCLUDE += 102 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 103 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -g 104 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=c++11 105 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 106 | LIBS += -lopengl32 -lgdi32 107 | LDDEPS += 108 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 109 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 110 | define PREBUILDCMDS 111 | endef 112 | define PRELINKCMDS 113 | endef 114 | define POSTBUILDCMDS 115 | endef 116 | all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET) 117 | @: 118 | 119 | endif 120 | 121 | OBJECTS := \ 122 | $(OBJDIR)/glew.o \ 123 | $(OBJDIR)/im3d_example.o \ 124 | $(OBJDIR)/main.o \ 125 | $(OBJDIR)/im3d.o \ 126 | $(OBJDIR)/im3d_opengl3.o \ 127 | $(OBJDIR)/imgui.o \ 128 | $(OBJDIR)/imgui_demo.o \ 129 | $(OBJDIR)/imgui_draw.o \ 130 | 131 | RESOURCES := \ 132 | 133 | CUSTOMFILES := \ 134 | 135 | SHELLTYPE := msdos 136 | ifeq (,$(ComSpec)$(COMSPEC)) 137 | SHELLTYPE := posix 138 | endif 139 | ifeq (/bin,$(findstring /bin,$(SHELL))) 140 | SHELLTYPE := posix 141 | endif 142 | 143 | $(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) 144 | @echo Linking im3d_opengl3 145 | $(SILENT) $(LINKCMD) 146 | $(POSTBUILDCMDS) 147 | 148 | $(TARGETDIR): 149 | @echo Creating $(TARGETDIR) 150 | ifeq (posix,$(SHELLTYPE)) 151 | $(SILENT) mkdir -p $(TARGETDIR) 152 | else 153 | $(SILENT) mkdir $(subst /,\\,$(TARGETDIR)) 154 | endif 155 | 156 | $(OBJDIR): 157 | @echo Creating $(OBJDIR) 158 | ifeq (posix,$(SHELLTYPE)) 159 | $(SILENT) mkdir -p $(OBJDIR) 160 | else 161 | $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) 162 | endif 163 | 164 | clean: 165 | @echo Cleaning im3d_opengl3 166 | ifeq (posix,$(SHELLTYPE)) 167 | $(SILENT) rm -f $(TARGET) 168 | $(SILENT) rm -rf $(OBJDIR) 169 | else 170 | $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET)) 171 | $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR)) 172 | endif 173 | 174 | prebuild: 175 | $(PREBUILDCMDS) 176 | 177 | prelink: 178 | $(PRELINKCMDS) 179 | 180 | ifneq (,$(PCH)) 181 | $(OBJECTS): $(GCH) $(PCH) 182 | $(GCH): $(PCH) 183 | @echo $(notdir $<) 184 | $(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" 185 | endif 186 | 187 | $(OBJDIR)/glew.o: ../../common/GL/glew.c 188 | @echo $(notdir $<) 189 | $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 190 | $(OBJDIR)/im3d_example.o: ../../common/im3d_example.cpp 191 | @echo $(notdir $<) 192 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 193 | $(OBJDIR)/main.o: ../../common/main.cpp 194 | @echo $(notdir $<) 195 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 196 | $(OBJDIR)/im3d.o: ../../../im3d.cpp 197 | @echo $(notdir $<) 198 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 199 | $(OBJDIR)/im3d_opengl3.o: ../im3d_opengl3.cpp 200 | @echo $(notdir $<) 201 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 202 | $(OBJDIR)/imgui.o: ../../common/imgui/imgui.cpp 203 | @echo $(notdir $<) 204 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 205 | $(OBJDIR)/imgui_demo.o: ../../common/imgui/imgui_demo.cpp 206 | @echo $(notdir $<) 207 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 208 | $(OBJDIR)/imgui_draw.o: ../../common/imgui/imgui_draw.cpp 209 | @echo $(notdir $<) 210 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 211 | 212 | -include $(OBJECTS:%.o=%.d) 213 | ifneq (,$(PCH)) 214 | -include $(OBJDIR)/$(notdir $(PCH)).d 215 | endif -------------------------------------------------------------------------------- /examples/OpenGL33/gmake/im3d_opengl33.make: -------------------------------------------------------------------------------- 1 | # GNU Make project makefile autogenerated by Premake 2 | 3 | ifndef config 4 | config=debug_win32 5 | endif 6 | 7 | ifndef verbose 8 | SILENT = @ 9 | endif 10 | 11 | .PHONY: clean prebuild prelink 12 | 13 | ifeq ($(config),debug_win32) 14 | RESCOMP = windres 15 | TARGETDIR = .. 16 | TARGET = $(TARGETDIR)/im3d_opengl33_debug.exe 17 | OBJDIR = obj/Win32/Debug 18 | DEFINES += -DIM3D_DEBUG -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=3 -DIM3D_OPENGL_VSHADER=330 19 | INCLUDES += -I../../.. -I../../common 20 | FORCE_INCLUDE += 21 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 22 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O0 -g 23 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O0 -g -std=c++11 24 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 25 | LIBS += -lopengl32 -lgdi32 26 | LDDEPS += 27 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 28 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 29 | define PREBUILDCMDS 30 | endef 31 | define PRELINKCMDS 32 | endef 33 | define POSTBUILDCMDS 34 | endef 35 | all: prebuild prelink $(TARGET) 36 | @: 37 | 38 | endif 39 | 40 | ifeq ($(config),debug_win64) 41 | RESCOMP = windres 42 | TARGETDIR = .. 43 | TARGET = $(TARGETDIR)/im3d_opengl33_debug.exe 44 | OBJDIR = obj/Win64/Debug 45 | DEFINES += -DIM3D_DEBUG -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=3 -DIM3D_OPENGL_VSHADER=330 46 | INCLUDES += -I../../.. -I../../common 47 | FORCE_INCLUDE += 48 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 49 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O0 -g 50 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O0 -g -std=c++11 51 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 52 | LIBS += -lopengl32 -lgdi32 53 | LDDEPS += 54 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 55 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 56 | define PREBUILDCMDS 57 | endef 58 | define PRELINKCMDS 59 | endef 60 | define POSTBUILDCMDS 61 | endef 62 | all: prebuild prelink $(TARGET) 63 | @: 64 | 65 | endif 66 | 67 | ifeq ($(config),release_win32) 68 | RESCOMP = windres 69 | TARGETDIR = .. 70 | TARGET = $(TARGETDIR)/im3d_opengl33.exe 71 | OBJDIR = obj/Win32/Release 72 | DEFINES += -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=3 -DIM3D_OPENGL_VSHADER=330 73 | INCLUDES += -I../../.. -I../../common 74 | FORCE_INCLUDE += 75 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 76 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -g 77 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -g -std=c++11 78 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 79 | LIBS += -lopengl32 -lgdi32 80 | LDDEPS += 81 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 82 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 83 | define PREBUILDCMDS 84 | endef 85 | define PRELINKCMDS 86 | endef 87 | define POSTBUILDCMDS 88 | endef 89 | all: prebuild prelink $(TARGET) 90 | @: 91 | 92 | endif 93 | 94 | ifeq ($(config),release_win64) 95 | RESCOMP = windres 96 | TARGETDIR = .. 97 | TARGET = $(TARGETDIR)/im3d_opengl33.exe 98 | OBJDIR = obj/Win64/Release 99 | DEFINES += -DIM3D_OPENGL -DGLEW_STATIC -DIM3D_OPENGL_VMAJ=3 -DIM3D_OPENGL_VMIN=3 -DIM3D_OPENGL_VSHADER=330 100 | INCLUDES += -I../../.. -I../../common 101 | FORCE_INCLUDE += 102 | ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) 103 | ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -g 104 | ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -g -std=c++11 105 | ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) 106 | LIBS += -lopengl32 -lgdi32 107 | LDDEPS += 108 | ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 109 | LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) 110 | define PREBUILDCMDS 111 | endef 112 | define PRELINKCMDS 113 | endef 114 | define POSTBUILDCMDS 115 | endef 116 | all: prebuild prelink $(TARGET) 117 | @: 118 | 119 | endif 120 | 121 | OBJECTS := \ 122 | $(OBJDIR)/glew.o \ 123 | $(OBJDIR)/im3d_example.o \ 124 | $(OBJDIR)/main.o \ 125 | $(OBJDIR)/im3d.o \ 126 | $(OBJDIR)/im3d_opengl33.o \ 127 | $(OBJDIR)/imgui.o \ 128 | $(OBJDIR)/imgui_demo.o \ 129 | $(OBJDIR)/imgui_draw.o \ 130 | $(OBJDIR)/imgui_widgets.o \ 131 | 132 | RESOURCES := \ 133 | 134 | CUSTOMFILES := \ 135 | 136 | SHELLTYPE := posix 137 | ifeq (.exe,$(findstring .exe,$(ComSpec))) 138 | SHELLTYPE := msdos 139 | endif 140 | 141 | $(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) | $(TARGETDIR) 142 | @echo Linking im3d_opengl33 143 | $(SILENT) $(LINKCMD) 144 | $(POSTBUILDCMDS) 145 | 146 | $(CUSTOMFILES): | $(OBJDIR) 147 | 148 | $(TARGETDIR): 149 | @echo Creating $(TARGETDIR) 150 | ifeq (posix,$(SHELLTYPE)) 151 | $(SILENT) mkdir -p $(TARGETDIR) 152 | else 153 | $(SILENT) mkdir $(subst /,\\,$(TARGETDIR)) 154 | endif 155 | 156 | $(OBJDIR): 157 | @echo Creating $(OBJDIR) 158 | ifeq (posix,$(SHELLTYPE)) 159 | $(SILENT) mkdir -p $(OBJDIR) 160 | else 161 | $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) 162 | endif 163 | 164 | clean: 165 | @echo Cleaning im3d_opengl33 166 | ifeq (posix,$(SHELLTYPE)) 167 | $(SILENT) rm -f $(TARGET) 168 | $(SILENT) rm -rf $(OBJDIR) 169 | else 170 | $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET)) 171 | $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR)) 172 | endif 173 | 174 | prebuild: 175 | $(PREBUILDCMDS) 176 | 177 | prelink: 178 | $(PRELINKCMDS) 179 | 180 | ifneq (,$(PCH)) 181 | $(OBJECTS): $(GCH) $(PCH) | $(OBJDIR) 182 | $(GCH): $(PCH) | $(OBJDIR) 183 | @echo $(notdir $<) 184 | $(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" 185 | else 186 | $(OBJECTS): | $(OBJDIR) 187 | endif 188 | 189 | $(OBJDIR)/glew.o: ../../common/GL/glew.c 190 | @echo $(notdir $<) 191 | $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 192 | $(OBJDIR)/im3d_example.o: ../../common/im3d_example.cpp 193 | @echo $(notdir $<) 194 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 195 | $(OBJDIR)/main.o: ../../common/main.cpp 196 | @echo $(notdir $<) 197 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 198 | $(OBJDIR)/im3d.o: ../../../im3d.cpp 199 | @echo $(notdir $<) 200 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 201 | $(OBJDIR)/im3d_opengl33.o: ../im3d_opengl33.cpp 202 | @echo $(notdir $<) 203 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 204 | $(OBJDIR)/imgui.o: ../../common/imgui/imgui.cpp 205 | @echo $(notdir $<) 206 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 207 | $(OBJDIR)/imgui_demo.o: ../../common/imgui/imgui_demo.cpp 208 | @echo $(notdir $<) 209 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 210 | $(OBJDIR)/imgui_draw.o: ../../common/imgui/imgui_draw.cpp 211 | @echo $(notdir $<) 212 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 213 | $(OBJDIR)/imgui_widgets.o: ../../common/imgui/imgui_widgets.cpp 214 | @echo $(notdir $<) 215 | $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" 216 | 217 | -include $(OBJECTS:%.o=%.d) 218 | ifneq (,$(PCH)) 219 | -include $(OBJDIR)/$(notdir $(PCH)).d 220 | endif -------------------------------------------------------------------------------- /examples/OpenGL33/im3d.glsl: -------------------------------------------------------------------------------- 1 | #if !defined(POINTS) && !defined(LINES) && !defined(TRIANGLES) 2 | #error No primitive type defined 3 | #endif 4 | #if !defined(VERTEX_SHADER) && !defined(GEOMETRY_SHADER) && !defined(FRAGMENT_SHADER) 5 | #error No shader stage defined 6 | #endif 7 | 8 | #define VertexData \ 9 | _VertexData { \ 10 | noperspective float m_edgeDistance; \ 11 | noperspective float m_size; \ 12 | smooth vec4 m_color; \ 13 | } 14 | 15 | #define kAntialiasing 2.0 16 | 17 | #ifdef VERTEX_SHADER 18 | uniform mat4 uViewProjMatrix; 19 | 20 | layout(location=0) in vec4 aPositionSize; 21 | layout(location=1) in vec4 aColor; 22 | 23 | out VertexData vData; 24 | 25 | void main() 26 | { 27 | vData.m_color = aColor.abgr; // swizzle to correct endianness 28 | #if !defined(TRIANGLES) 29 | vData.m_color.a *= smoothstep(0.0, 1.0, aPositionSize.w / kAntialiasing); 30 | #endif 31 | vData.m_size = max(aPositionSize.w, kAntialiasing); 32 | gl_Position = uViewProjMatrix * vec4(aPositionSize.xyz, 1.0); 33 | #if defined(POINTS) 34 | gl_PointSize = vData.m_size; 35 | #endif 36 | } 37 | #endif 38 | 39 | #ifdef GEOMETRY_SHADER 40 | // expand line -> triangle strip 41 | layout(lines) in; 42 | layout(triangle_strip, max_vertices = 4) out; 43 | 44 | uniform vec2 uViewport; 45 | 46 | in VertexData vData[]; 47 | out VertexData vDataOut; 48 | 49 | void main() 50 | { 51 | vec2 pos0 = gl_in[0].gl_Position.xy / gl_in[0].gl_Position.w; 52 | vec2 pos1 = gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w; 53 | 54 | vec2 dir = pos0 - pos1; 55 | dir = normalize(vec2(dir.x, dir.y * uViewport.y / uViewport.x)); // correct for aspect ratio 56 | vec2 tng0 = vec2(-dir.y, dir.x); 57 | vec2 tng1 = tng0 * vData[1].m_size / uViewport; 58 | tng0 = tng0 * vData[0].m_size / uViewport; 59 | 60 | // line start 61 | gl_Position = vec4((pos0 - tng0) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw); 62 | vDataOut.m_edgeDistance = -vData[0].m_size; 63 | vDataOut.m_size = vData[0].m_size; 64 | vDataOut.m_color = vData[0].m_color; 65 | EmitVertex(); 66 | 67 | gl_Position = vec4((pos0 + tng0) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw); 68 | vDataOut.m_color = vData[0].m_color; 69 | vDataOut.m_edgeDistance = vData[0].m_size; 70 | vDataOut.m_size = vData[0].m_size; 71 | EmitVertex(); 72 | 73 | // line end 74 | gl_Position = vec4((pos1 - tng1) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw); 75 | vDataOut.m_edgeDistance = -vData[1].m_size; 76 | vDataOut.m_size = vData[1].m_size; 77 | vDataOut.m_color = vData[1].m_color; 78 | EmitVertex(); 79 | 80 | gl_Position = vec4((pos1 + tng1) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw); 81 | vDataOut.m_color = vData[1].m_color; 82 | vDataOut.m_size = vData[1].m_size; 83 | vDataOut.m_edgeDistance = vData[1].m_size; 84 | EmitVertex(); 85 | } 86 | #endif 87 | 88 | #ifdef FRAGMENT_SHADER 89 | in VertexData vData; 90 | 91 | layout(location=0) out vec4 fResult; 92 | 93 | void main() 94 | { 95 | fResult = vData.m_color; 96 | 97 | #if defined(LINES) 98 | float d = abs(vData.m_edgeDistance) / vData.m_size; 99 | d = smoothstep(1.0, 1.0 - (kAntialiasing / vData.m_size), d); 100 | fResult.a *= d; 101 | 102 | #elif defined(POINTS) 103 | float d = length(gl_PointCoord.xy - vec2(0.5)); 104 | d = smoothstep(0.5, 0.5 - (kAntialiasing / vData.m_size), d); 105 | fResult.a *= d; 106 | 107 | #endif 108 | } 109 | #endif 110 | -------------------------------------------------------------------------------- /examples/OpenGL33/im3d_opengl33.cpp: -------------------------------------------------------------------------------- 1 | /* OpenGL 3.3 example 2 | This is a standard 'modern' example which implements line expansion via a geometry shader. 3 | See examples/OpenGL31 for a reference which doesn't require geometry shaders. 4 | */ 5 | #include "im3d_example.h" 6 | 7 | static GLuint g_Im3dVertexArray; 8 | static GLuint g_Im3dVertexBuffer; 9 | static GLuint g_Im3dShaderPoints; 10 | static GLuint g_Im3dShaderLines; 11 | static GLuint g_Im3dShaderTriangles; 12 | 13 | using namespace Im3d; 14 | 15 | // Resource init/shutdown will be app specific. In general you'll need one shader for each of the 3 16 | // draw primitive types (points, lines, triangles), plus some number of vertex buffers. 17 | bool Im3d_Init() 18 | { 19 | { GLuint vs = LoadCompileShader(GL_VERTEX_SHADER, "im3d.glsl", "VERTEX_SHADER\0POINTS\0"); 20 | GLuint fs = LoadCompileShader(GL_FRAGMENT_SHADER, "im3d.glsl", "FRAGMENT_SHADER\0POINTS\0"); 21 | if (vs && fs) { 22 | glAssert(g_Im3dShaderPoints = glCreateProgram()); 23 | glAssert(glAttachShader(g_Im3dShaderPoints, vs)); 24 | glAssert(glAttachShader(g_Im3dShaderPoints, fs)); 25 | bool ret = LinkShaderProgram(g_Im3dShaderPoints); 26 | glAssert(glDeleteShader(vs)); 27 | glAssert(glDeleteShader(fs)); 28 | if (!ret) 29 | { 30 | return false; 31 | } 32 | } 33 | else 34 | { 35 | return false; 36 | } 37 | } 38 | 39 | { GLuint vs = LoadCompileShader(GL_VERTEX_SHADER, "im3d.glsl", "VERTEX_SHADER\0LINES\0"); 40 | GLuint gs = LoadCompileShader(GL_GEOMETRY_SHADER, "im3d.glsl", "GEOMETRY_SHADER\0LINES\0"); 41 | GLuint fs = LoadCompileShader(GL_FRAGMENT_SHADER, "im3d.glsl", "FRAGMENT_SHADER\0LINES\0"); 42 | if (vs && gs && fs) 43 | { 44 | glAssert(g_Im3dShaderLines = glCreateProgram()); 45 | glAssert(glAttachShader(g_Im3dShaderLines, vs)); 46 | glAssert(glAttachShader(g_Im3dShaderLines, gs)); 47 | glAssert(glAttachShader(g_Im3dShaderLines, fs)); 48 | bool ret = LinkShaderProgram(g_Im3dShaderLines); 49 | glAssert(glDeleteShader(vs)); 50 | glAssert(glDeleteShader(gs)); 51 | glAssert(glDeleteShader(fs)); 52 | if (!ret) 53 | { 54 | return false; 55 | } 56 | } 57 | else 58 | { 59 | return false; 60 | } 61 | } 62 | 63 | { GLuint vs = LoadCompileShader(GL_VERTEX_SHADER, "im3d.glsl", "VERTEX_SHADER\0TRIANGLES\0"); 64 | GLuint fs = LoadCompileShader(GL_FRAGMENT_SHADER, "im3d.glsl", "FRAGMENT_SHADER\0TRIANGLES\0"); 65 | if (vs && fs) 66 | { 67 | glAssert(g_Im3dShaderTriangles = glCreateProgram()); 68 | glAssert(glAttachShader(g_Im3dShaderTriangles, vs)); 69 | glAssert(glAttachShader(g_Im3dShaderTriangles, fs)); 70 | bool ret = LinkShaderProgram(g_Im3dShaderTriangles); 71 | glAssert(glDeleteShader(vs)); 72 | glAssert(glDeleteShader(fs)); 73 | if (!ret) 74 | { 75 | return false; 76 | } 77 | } 78 | else 79 | { 80 | return false; 81 | } 82 | } 83 | 84 | glAssert(glGenBuffers(1, &g_Im3dVertexBuffer));; 85 | glAssert(glGenVertexArrays(1, &g_Im3dVertexArray)); 86 | glAssert(glBindVertexArray(g_Im3dVertexArray)); 87 | glAssert(glBindBuffer(GL_ARRAY_BUFFER, g_Im3dVertexBuffer)); 88 | glAssert(glEnableVertexAttribArray(0)); 89 | glAssert(glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Im3d::VertexData), (GLvoid*)offsetof(Im3d::VertexData, m_positionSize))); 90 | glAssert(glEnableVertexAttribArray(1)); 91 | glAssert(glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Im3d::VertexData), (GLvoid*)offsetof(Im3d::VertexData, m_color))); 92 | glAssert(glBindVertexArray(0)); 93 | 94 | return true; 95 | } 96 | 97 | void Im3d_Shutdown() 98 | { 99 | glAssert(glDeleteVertexArrays(1, &g_Im3dVertexArray)); 100 | glAssert(glDeleteBuffers(1, &g_Im3dVertexBuffer)); 101 | glAssert(glDeleteProgram(g_Im3dShaderPoints)); 102 | glAssert(glDeleteProgram(g_Im3dShaderLines)); 103 | glAssert(glDeleteProgram(g_Im3dShaderTriangles)); 104 | } 105 | 106 | // At the top of each frame, the application must fill the Im3d::AppData struct and then call Im3d::NewFrame(). 107 | // The example below shows how to do this, in particular how to generate the 'cursor ray' from a mouse position 108 | // which is necessary for interacting with gizmos. 109 | void Im3d_NewFrame() 110 | { 111 | AppData& ad = GetAppData(); 112 | 113 | ad.m_deltaTime = g_Example->m_deltaTime; 114 | ad.m_viewportSize = Vec2((float)g_Example->m_width, (float)g_Example->m_height); 115 | ad.m_viewOrigin = g_Example->m_camPos; // for VR use the head position 116 | ad.m_viewDirection = g_Example->m_camDir; 117 | ad.m_worldUp = Vec3(0.0f, 1.0f, 0.0f); // used internally for generating orthonormal bases 118 | ad.m_projOrtho = g_Example->m_camOrtho; 119 | 120 | // m_projScaleY controls how gizmos are scaled in world space to maintain a constant screen height 121 | ad.m_projScaleY = g_Example->m_camOrtho 122 | ? 2.0f / g_Example->m_camProj(1, 1) // use far plane height for an ortho projection 123 | : tanf(g_Example->m_camFovRad * 0.5f) * 2.0f // or vertical fov for a perspective projection 124 | ; 125 | 126 | // World space cursor ray from mouse position; for VR this might be the position/orientation of the HMD or a tracked controller. 127 | Vec2 cursorPos = g_Example->getWindowRelativeCursor(); 128 | cursorPos = (cursorPos / ad.m_viewportSize) * 2.0f - 1.0f; 129 | cursorPos.y = -cursorPos.y; // window origin is top-left, ndc is bottom-left 130 | Vec3 rayOrigin, rayDirection; 131 | if (g_Example->m_camOrtho) 132 | { 133 | rayOrigin.x = cursorPos.x / g_Example->m_camProj(0, 0); 134 | rayOrigin.y = cursorPos.y / g_Example->m_camProj(1, 1); 135 | rayOrigin.z = 0.0f; 136 | rayOrigin = g_Example->m_camWorld * Vec4(rayOrigin, 1.0f); 137 | rayDirection = g_Example->m_camWorld * Vec4(0.0f, 0.0f, -1.0f, 0.0f); 138 | 139 | } 140 | else 141 | { 142 | rayOrigin = ad.m_viewOrigin; 143 | rayDirection.x = cursorPos.x / g_Example->m_camProj(0, 0); 144 | rayDirection.y = cursorPos.y / g_Example->m_camProj(1, 1); 145 | rayDirection.z = -1.0f; 146 | rayDirection = g_Example->m_camWorld * Vec4(Normalize(rayDirection), 0.0f); 147 | } 148 | ad.m_cursorRayOrigin = rayOrigin; 149 | ad.m_cursorRayDirection = rayDirection; 150 | 151 | // Set cull frustum planes. This is only required if IM3D_CULL_GIZMOS or IM3D_CULL_PRIMTIIVES is enable via 152 | // im3d_config.h, or if any of the IsVisible() functions are called. 153 | ad.setCullFrustum(g_Example->m_camViewProj, true); 154 | 155 | // Fill the key state array; using GetAsyncKeyState here but this could equally well be done via the window proc. 156 | // All key states have an equivalent (and more descriptive) 'Action_' enum. 157 | ad.m_keyDown[Im3d::Mouse_Left/*Im3d::Action_Select*/] = (GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0; 158 | 159 | // The following key states control which gizmo to use for the generic Gizmo() function. Here using the left ctrl 160 | // key as an additional predicate. 161 | bool ctrlDown = (GetAsyncKeyState(VK_LCONTROL) & 0x8000) != 0; 162 | ad.m_keyDown[Im3d::Key_L/*Action_GizmoLocal*/] = ctrlDown && (GetAsyncKeyState(0x4c) & 0x8000) != 0; 163 | ad.m_keyDown[Im3d::Key_T/*Action_GizmoTranslation*/] = ctrlDown && (GetAsyncKeyState(0x54) & 0x8000) != 0; 164 | ad.m_keyDown[Im3d::Key_R/*Action_GizmoRotation*/] = ctrlDown && (GetAsyncKeyState(0x52) & 0x8000) != 0; 165 | ad.m_keyDown[Im3d::Key_S/*Action_GizmoScale*/] = ctrlDown && (GetAsyncKeyState(0x53) & 0x8000) != 0; 166 | 167 | // Enable gizmo snapping by setting the translation/rotation/scale increments to be > 0 168 | ad.m_snapTranslation = ctrlDown ? 0.5f : 0.0f; 169 | ad.m_snapRotation = ctrlDown ? Im3d::Radians(30.0f) : 0.0f; 170 | ad.m_snapScale = ctrlDown ? 0.5f : 0.0f; 171 | 172 | Im3d::NewFrame(); 173 | } 174 | 175 | // After all Im3d calls have been made for a frame, the user must call Im3d::EndFrame() to finalize draw data, then 176 | // access the draw lists for rendering. Draw lists are only valid between calls to EndFrame() and NewFrame(). 177 | // The example below shows the simplest approach to rendering draw lists; variations on this are possible. See the 178 | // shader source file for more details. 179 | void Im3d_EndFrame() 180 | { 181 | Im3d::EndFrame(); 182 | 183 | // Primitive rendering. 184 | 185 | // Typical pipeline state: enable alpha blending, disable depth test and backface culling. 186 | glAssert(glEnable(GL_BLEND)); 187 | glAssert(glBlendEquation(GL_FUNC_ADD)); 188 | glAssert(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); 189 | glAssert(glEnable(GL_PROGRAM_POINT_SIZE)); 190 | glAssert(glDisable(GL_DEPTH_TEST)); 191 | glAssert(glDisable(GL_CULL_FACE)); 192 | 193 | glAssert(glViewport(0, 0, (GLsizei)g_Example->m_width, (GLsizei)g_Example->m_height)); 194 | 195 | for (U32 i = 0, n = Im3d::GetDrawListCount(); i < n; ++i) 196 | { 197 | const Im3d::DrawList& drawList = Im3d::GetDrawLists()[i]; 198 | 199 | if (drawList.m_layerId == Im3d::MakeId("NamedLayer")) 200 | { 201 | // The application may group primitives into layers, which can be used to change the draw state (e.g. enable depth testing, use a different shader) 202 | } 203 | 204 | GLenum prim; 205 | GLuint sh; 206 | switch (drawList.m_primType) 207 | { 208 | case Im3d::DrawPrimitive_Points: 209 | prim = GL_POINTS; 210 | sh = g_Im3dShaderPoints; 211 | glAssert(glDisable(GL_CULL_FACE)); // points are view-aligned 212 | break; 213 | case Im3d::DrawPrimitive_Lines: 214 | prim = GL_LINES; 215 | sh = g_Im3dShaderLines; 216 | glAssert(glDisable(GL_CULL_FACE)); // lines are view-aligned 217 | break; 218 | case Im3d::DrawPrimitive_Triangles: 219 | prim = GL_TRIANGLES; 220 | sh = g_Im3dShaderTriangles; 221 | //glAssert(glEnable(GL_CULL_FACE)); // culling valid for triangles, but optional 222 | break; 223 | default: 224 | IM3D_ASSERT(false); 225 | return; 226 | }; 227 | 228 | glAssert(glBindVertexArray(g_Im3dVertexArray)); 229 | glAssert(glBindBuffer(GL_ARRAY_BUFFER, g_Im3dVertexBuffer)); 230 | glAssert(glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)drawList.m_vertexCount * sizeof(Im3d::VertexData), (GLvoid*)drawList.m_vertexData, GL_STREAM_DRAW)); 231 | 232 | AppData& ad = GetAppData(); 233 | glAssert(glUseProgram(sh)); 234 | glAssert(glUniform2f(glGetUniformLocation(sh, "uViewport"), ad.m_viewportSize.x, ad.m_viewportSize.y)); 235 | glAssert(glUniformMatrix4fv(glGetUniformLocation(sh, "uViewProjMatrix"), 1, false, (const GLfloat*)g_Example->m_camViewProj)); 236 | glAssert(glDrawArrays(prim, 0, (GLsizei)drawList.m_vertexCount)); 237 | } 238 | 239 | // Text rendering. 240 | // This is common to all examples since we're using ImGui to draw the text lists, see im3d_example.cpp. 241 | g_Example->drawTextDrawListsImGui(Im3d::GetTextDrawLists(), Im3d::GetTextDrawListCount()); 242 | } 243 | -------------------------------------------------------------------------------- /examples/OpenGL33/imgui.glsl: -------------------------------------------------------------------------------- 1 | #ifdef VERTEX_SHADER 2 | layout(location=0) in vec2 aPosition; 3 | layout(location=1) in vec2 aTexcoord; 4 | layout(location=2) in vec4 aColor; 5 | 6 | uniform mat4 uProjMatrix; 7 | 8 | noperspective out vec2 vUv; 9 | noperspective out vec4 vColor; 10 | 11 | void main() 12 | { 13 | vUv = aTexcoord; 14 | vColor = aColor; 15 | gl_Position = uProjMatrix * vec4(aPosition.xy, 0.0, 1.0); 16 | } 17 | #endif 18 | 19 | #ifdef FRAGMENT_SHADER 20 | noperspective in vec2 vUv; 21 | noperspective in vec4 vColor; 22 | 23 | uniform sampler2D txTexture; 24 | 25 | layout(location=0) out vec4 fResult; 26 | 27 | void main() 28 | { 29 | fResult = vColor; 30 | fResult.a *= texture(txTexture, vUv).r; 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /examples/OpenGL33/model.glsl: -------------------------------------------------------------------------------- 1 | #ifdef VERTEX_SHADER 2 | uniform mat4 uWorldMatrix; 3 | uniform mat4 uViewProjMatrix; 4 | 5 | layout(location=0) in vec3 aPosition; 6 | layout(location=1) in vec3 aNormal; 7 | 8 | smooth out vec3 vNormalW; 9 | 10 | void main() 11 | { 12 | vNormalW = mat3(uWorldMatrix) * aNormal; 13 | gl_Position = uViewProjMatrix * (uWorldMatrix * vec4(aPosition, 1.0)); 14 | } 15 | #endif 16 | 17 | #ifdef FRAGMENT_SHADER 18 | smooth in vec3 vNormalW; 19 | 20 | layout(location=0) out vec3 fResult; 21 | 22 | void main() 23 | { 24 | vec3 nrm = normalize(vNormalW); 25 | vec3 ldir = normalize(vec3(1.0)); 26 | float ndotl = max(dot(nrm, ldir), 0.0) * 0.5; 27 | fResult = vec3(ndotl); 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /examples/OpenGL33/premake5.lua: -------------------------------------------------------------------------------- 1 | local IM3D_DIR = "../../" 2 | local EXAMPLE_COMMON_DIR = "../common/" 3 | 4 | filter { "configurations:debug" } 5 | defines { "IM3D_DEBUG" } 6 | targetsuffix "_debug" 7 | symbols "On" 8 | optimize "Off" 9 | 10 | filter { "configurations:release" } 11 | symbols "On" 12 | optimize "Full" 13 | 14 | filter { "action:vs*" } 15 | defines { "_CRT_SECURE_NO_WARNINGS", "_SCL_SECURE_NO_WARNINGS" } 16 | characterset "MBCS" -- force Win32 API to use *A variants (i.e. can pass char* for strings) 17 | 18 | workspace "im3d_opengl33" 19 | location(_ACTION) 20 | configurations { "Debug", "Release" } 21 | platforms { "Win32", "Win64" } 22 | cppdialect "C++11" 23 | staticruntime "On" 24 | 25 | filter { "platforms:Win32 or platforms:Win64" } 26 | system "windows" 27 | 28 | -- \todo select graphics lib? 29 | defines { "IM3D_OPENGL", "GLEW_STATIC" } 30 | links { "opengl32", "gdi32" } 31 | 32 | filter { "platforms:Win32" } 33 | architecture "x86" 34 | filter { "platforms:Win64" } 35 | architecture "x86_64" 36 | 37 | filter {} 38 | 39 | vpaths({ 40 | ["im3d"] = { IM3D_DIR .. "*.h", IM3D_DIR .. "*.cpp" }, 41 | ["imgui"] = EXAMPLE_COMMON_DIR .. "imgui/**", 42 | ["common"] = { EXAMPLE_COMMON_DIR .. "*.h", EXAMPLE_COMMON_DIR .. "*.cpp" }, 43 | ["*"] = "*.cpp" 44 | }) 45 | 46 | files({ 47 | IM3D_DIR .. "*.h", 48 | IM3D_DIR .. "*.cpp", 49 | }) 50 | 51 | project "im3d_opengl33" 52 | kind "ConsoleApp" 53 | language "C++" 54 | targetdir "" 55 | 56 | defines { "IM3D_OPENGL_VMAJ=3", "IM3D_OPENGL_VMIN=3", "IM3D_OPENGL_VSHADER=330" } 57 | 58 | includedirs({ 59 | IM3D_DIR, 60 | EXAMPLE_COMMON_DIR, 61 | }) 62 | files({ 63 | EXAMPLE_COMMON_DIR .. "**.h", 64 | EXAMPLE_COMMON_DIR .. "**.hpp", 65 | EXAMPLE_COMMON_DIR .. "**.c", 66 | EXAMPLE_COMMON_DIR .. "**.cpp", 67 | "*.cpp" 68 | }) 69 | -------------------------------------------------------------------------------- /examples/OpenGL33/vs2017/im3d_opengl33.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "im3d_opengl33", "im3d_opengl33.vcxproj", "{BC77FB43-2838-777A-F172-C0F75DF2BB56}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|Win64 = Debug|Win64 10 | Release|Win32 = Release|Win32 11 | Release|Win64 = Release|Win64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Debug|Win32.Build.0 = Debug|Win32 16 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Debug|Win64.ActiveCfg = Debug Win64|x64 17 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Debug|Win64.Build.0 = Debug Win64|x64 18 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Release|Win32.ActiveCfg = Release|Win32 19 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Release|Win32.Build.0 = Release|Win32 20 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Release|Win64.ActiveCfg = Release Win64|x64 21 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Release|Win64.Build.0 = Release Win64|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /examples/OpenGL33/vs2017/im3d_opengl33.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Debug Win64 14 | Win32 15 | 16 | 17 | Debug Win64 18 | x64 19 | 20 | 21 | Release 22 | Win32 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | Release Win64 30 | Win32 31 | 32 | 33 | Release Win64 34 | x64 35 | 36 | 37 | 38 | {BC77FB43-2838-777A-F172-C0F75DF2BB56} 39 | true 40 | Win32Proj 41 | im3d_opengl33 42 | 43 | 44 | 45 | Application 46 | true 47 | MultiByte 48 | v141 49 | 50 | 51 | Application 52 | true 53 | MultiByte 54 | v141 55 | 56 | 57 | Application 58 | false 59 | MultiByte 60 | v141 61 | 62 | 63 | Application 64 | false 65 | MultiByte 66 | v141 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | true 86 | ..\ 87 | obj\Win32\Debug\ 88 | im3d_opengl33_debug 89 | .exe 90 | 91 | 92 | true 93 | ..\ 94 | obj\Win64\Debug\ 95 | im3d_opengl33_debug 96 | .exe 97 | 98 | 99 | false 100 | ..\ 101 | obj\Win32\Release\ 102 | im3d_opengl33 103 | .exe 104 | 105 | 106 | false 107 | ..\ 108 | obj\Win64\Release\ 109 | im3d_opengl33 110 | .exe 111 | 112 | 113 | 114 | NotUsing 115 | Level3 116 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=3;IM3D_OPENGL_VSHADER=330;%(PreprocessorDefinitions) 117 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 118 | EditAndContinue 119 | Disabled 120 | MultiThreadedDebug 121 | 122 | 123 | Console 124 | true 125 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 126 | 127 | 128 | 129 | 130 | NotUsing 131 | Level3 132 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=3;IM3D_OPENGL_VSHADER=330;%(PreprocessorDefinitions) 133 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 134 | EditAndContinue 135 | Disabled 136 | MultiThreadedDebug 137 | 138 | 139 | Console 140 | true 141 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 142 | 143 | 144 | 145 | 146 | NotUsing 147 | Level3 148 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=3;IM3D_OPENGL_VSHADER=330;%(PreprocessorDefinitions) 149 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 150 | ProgramDatabase 151 | Full 152 | true 153 | true 154 | false 155 | true 156 | MultiThreaded 157 | 158 | 159 | Console 160 | true 161 | true 162 | true 163 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 164 | 165 | 166 | 167 | 168 | NotUsing 169 | Level3 170 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=3;IM3D_OPENGL_VSHADER=330;%(PreprocessorDefinitions) 171 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 172 | ProgramDatabase 173 | Full 174 | true 175 | true 176 | false 177 | true 178 | MultiThreaded 179 | 180 | 181 | Console 182 | true 183 | true 184 | true 185 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /examples/OpenGL33/vs2017/im3d_opengl33.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 6 | 7 | 8 | {5079AB3B-BCE3-5FB2-0522-115871CB3D07} 9 | 10 | 11 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 12 | 13 | 14 | {F279987C-DEB0-990D-879D-7F1073B3150F} 15 | 16 | 17 | {0098A80F-6CAC-D0C0-352E-7420A101CDF1} 18 | 19 | 20 | 21 | 22 | im3d 23 | 24 | 25 | im3d 26 | 27 | 28 | im3d 29 | 30 | 31 | common\GL 32 | 33 | 34 | common\GL 35 | 36 | 37 | common\GL 38 | 39 | 40 | common\GL 41 | 42 | 43 | common 44 | 45 | 46 | imgui 47 | 48 | 49 | imgui 50 | 51 | 52 | imgui 53 | 54 | 55 | imgui 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | common 65 | 66 | 67 | 68 | 69 | im3d 70 | 71 | 72 | common\GL 73 | 74 | 75 | common 76 | 77 | 78 | imgui 79 | 80 | 81 | imgui 82 | 83 | 84 | imgui 85 | 86 | 87 | imgui 88 | 89 | 90 | common 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /examples/OpenGL33/vs2019/im3d_opengl33.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 16 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "im3d_opengl33", "im3d_opengl33.vcxproj", "{BC77FB43-2838-777A-F172-C0F75DF2BB56}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|Win64 = Debug|Win64 10 | Release|Win32 = Release|Win32 11 | Release|Win64 = Release|Win64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Debug|Win32.Build.0 = Debug|Win32 16 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Debug|Win64.ActiveCfg = Debug Win64|x64 17 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Debug|Win64.Build.0 = Debug Win64|x64 18 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Release|Win32.ActiveCfg = Release|Win32 19 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Release|Win32.Build.0 = Release|Win32 20 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Release|Win64.ActiveCfg = Release Win64|x64 21 | {BC77FB43-2838-777A-F172-C0F75DF2BB56}.Release|Win64.Build.0 = Release Win64|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /examples/OpenGL33/vs2019/im3d_opengl33.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Debug Win64 14 | Win32 15 | 16 | 17 | Debug Win64 18 | x64 19 | 20 | 21 | Release 22 | Win32 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | Release Win64 30 | Win32 31 | 32 | 33 | Release Win64 34 | x64 35 | 36 | 37 | 38 | {BC77FB43-2838-777A-F172-C0F75DF2BB56} 39 | true 40 | Win32Proj 41 | im3d_opengl33 42 | 43 | 44 | 45 | Application 46 | true 47 | MultiByte 48 | v142 49 | 50 | 51 | Application 52 | true 53 | MultiByte 54 | v142 55 | 56 | 57 | Application 58 | false 59 | MultiByte 60 | v142 61 | 62 | 63 | Application 64 | false 65 | MultiByte 66 | v142 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | true 86 | ..\ 87 | obj\Win32\Debug\ 88 | im3d_opengl33_debug 89 | .exe 90 | 91 | 92 | true 93 | ..\ 94 | obj\Win64\Debug\ 95 | im3d_opengl33_debug 96 | .exe 97 | 98 | 99 | false 100 | ..\ 101 | obj\Win32\Release\ 102 | im3d_opengl33 103 | .exe 104 | 105 | 106 | false 107 | ..\ 108 | obj\Win64\Release\ 109 | im3d_opengl33 110 | .exe 111 | 112 | 113 | 114 | NotUsing 115 | Level3 116 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=3;IM3D_OPENGL_VSHADER=330;%(PreprocessorDefinitions) 117 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 118 | EditAndContinue 119 | Disabled 120 | MultiThreadedDebug 121 | 122 | 123 | Console 124 | true 125 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 126 | 127 | 128 | 129 | 130 | NotUsing 131 | Level3 132 | IM3D_DEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=3;IM3D_OPENGL_VSHADER=330;%(PreprocessorDefinitions) 133 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 134 | EditAndContinue 135 | Disabled 136 | MultiThreadedDebug 137 | 138 | 139 | Console 140 | true 141 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 142 | 143 | 144 | 145 | 146 | NotUsing 147 | Level3 148 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=3;IM3D_OPENGL_VSHADER=330;%(PreprocessorDefinitions) 149 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 150 | ProgramDatabase 151 | Full 152 | true 153 | true 154 | false 155 | true 156 | MultiThreaded 157 | 158 | 159 | Console 160 | true 161 | true 162 | true 163 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 164 | 165 | 166 | 167 | 168 | NotUsing 169 | Level3 170 | _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;IM3D_OPENGL;GLEW_STATIC;IM3D_OPENGL_VMAJ=3;IM3D_OPENGL_VMIN=3;IM3D_OPENGL_VSHADER=330;%(PreprocessorDefinitions) 171 | ..\..\..;..\..\common;%(AdditionalIncludeDirectories) 172 | ProgramDatabase 173 | Full 174 | true 175 | true 176 | false 177 | true 178 | MultiThreaded 179 | 180 | 181 | Console 182 | true 183 | true 184 | true 185 | opengl32.lib;gdi32.lib;%(AdditionalDependencies) 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /examples/OpenGL33/vs2019/im3d_opengl33.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 6 | 7 | 8 | {5079AB3B-BCE3-5FB2-0522-115871CB3D07} 9 | 10 | 11 | {AEFEE3F6-9AA0-0ECD-835B-22216F9C951D} 12 | 13 | 14 | {F279987C-DEB0-990D-879D-7F1073B3150F} 15 | 16 | 17 | {0098A80F-6CAC-D0C0-352E-7420A101CDF1} 18 | 19 | 20 | 21 | 22 | im3d 23 | 24 | 25 | im3d 26 | 27 | 28 | im3d 29 | 30 | 31 | common\GL 32 | 33 | 34 | common\GL 35 | 36 | 37 | common\GL 38 | 39 | 40 | common\GL 41 | 42 | 43 | common 44 | 45 | 46 | imgui 47 | 48 | 49 | imgui 50 | 51 | 52 | imgui 53 | 54 | 55 | imgui 56 | 57 | 58 | imgui 59 | 60 | 61 | imgui 62 | 63 | 64 | common 65 | 66 | 67 | 68 | 69 | im3d 70 | 71 | 72 | common\GL 73 | 74 | 75 | common 76 | 77 | 78 | imgui 79 | 80 | 81 | imgui 82 | 83 | 84 | imgui 85 | 86 | 87 | imgui 88 | 89 | 90 | common 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /examples/common/im3d_example.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "im3d.h" 4 | 5 | // Compiler 6 | #if defined(__GNUC__) 7 | #define IM3D_COMPILER_GNU 8 | #elif defined(_MSC_VER) 9 | #define IM3D_COMPILER_MSVC 10 | #else 11 | #error im3d: Compiler not defined 12 | #endif 13 | 14 | // Platform 15 | #if defined(_WIN32) || defined(_WIN64) 16 | // Windows 17 | #define IM3D_PLATFORM_WIN 18 | 19 | #define NOMINMAX 1 20 | #define WIN32_LEAN_AND_MEAN 1 21 | #define VC_EXTRALEAN 1 22 | #include 23 | 24 | #define winAssert(e) IM3D_VERIFY_MSG(e, Im3d::GetPlatformErrorString(GetLastError())) 25 | 26 | namespace Im3d { 27 | const char* GetPlatformErrorString(DWORD _err); 28 | } 29 | 30 | #else 31 | #error im3d: Platform not defined 32 | #endif 33 | 34 | // Graphics API 35 | #if defined(IM3D_OPENGL) 36 | // OpenGL 37 | //#define IM3D_OPENGL_VMAJ 3 38 | //#define IM3D_OPENGL_VMIN 3 39 | //#define IM3D_OPENGL_VSHADER "#version 150" 40 | 41 | #include "GL/glew.h" 42 | #define glAssert(call) \ 43 | do { \ 44 | (call); \ 45 | GLenum err = glGetError(); \ 46 | if (err != GL_NO_ERROR) { \ 47 | Im3d::Assert(#call, __FILE__, __LINE__, Im3d::GetGlEnumString(err)); \ 48 | IM3D_BREAK(); \ 49 | } \ 50 | } while (0) 51 | 52 | namespace Im3d { 53 | // Return 0 on failure (prints log info to stderr). _defines is a list of null-separated strings e.g. "DEFINE1 1\0DEFINE2 1\0" 54 | GLuint LoadCompileShader(GLenum _stage, const char* _path, const char* _defines = 0); 55 | // Return false on failure (prints log info to stderr). 56 | bool LinkShaderProgram(GLuint _handle); 57 | 58 | const char* GetGlEnumString(GLenum _enum); 59 | const char* GlGetString(GLenum _name); 60 | } 61 | 62 | #elif defined(IM3D_DX11) 63 | // DirectX 11 64 | #include 65 | 66 | #define IM3D_DX11_VSHADER "4_0" 67 | 68 | #define dxAssert(call) \ 69 | do { \ 70 | HRESULT err = (call); \ 71 | if (err != S_OK) { \ 72 | Im3d::Assert(#call, __FILE__, __LINE__, Im3d::GetPlatformErrorString((DWORD)err)); \ 73 | IM3D_BREAK(); \ 74 | } \ 75 | } while (0) 76 | 77 | namespace Im3d { 78 | // Return 0 on failure (prints log info to stderr). _defines is a list of null-separated strings e.g. "DEFINE1 1\0DEFINE2 1\0" 79 | ID3DBlob* LoadCompileShader(const char* _target, const char* _path, const char* _defines = 0); 80 | 81 | // Resource helpers. 82 | ID3D11Buffer* CreateBuffer(UINT _size, D3D11_USAGE _usage, UINT _bind, const void* _data = nullptr); 83 | ID3D11Buffer* CreateConstantBuffer(UINT _size, D3D11_USAGE _usage, const void* _data = nullptr); 84 | ID3D11Buffer* CreateVertexBuffer(UINT _size, D3D11_USAGE _usage, const void* _data = nullptr); 85 | ID3D11Buffer* CreateIndexBuffer(UINT _size, D3D11_USAGE _usage, const void* _data = nullptr); 86 | void* MapBuffer(ID3D11Buffer* _buffer, D3D11_MAP _mapType); 87 | void UnmapBuffer(ID3D11Buffer* _buffer); 88 | ID3D11Texture2D* CreateTexture2D(UINT _width, UINT _height, DXGI_FORMAT _format, ID3D11ShaderResourceView** resView_ = nullptr, const void* _data = nullptr); 89 | ID3D11DepthStencilView* CreateDepthStencil(UINT _width, UINT _height, DXGI_FORMAT _format); 90 | } 91 | 92 | #else 93 | #error im3d: Graphics API not defined 94 | #endif 95 | 96 | #define IM3D_UNUSED(x) do { (void)sizeof(x); } while(0) 97 | #ifdef IM3D_COMPILER_MSVC 98 | #define IM3D_BREAK() __debugbreak() 99 | #else 100 | #include 101 | #define IM3D_BREAK() abort() 102 | #endif 103 | 104 | #define IM3D_ASSERT_MSG(e, msg, ...) \ 105 | do { \ 106 | if (!(e)) { \ 107 | Im3d::Assert(#e, __FILE__, __LINE__, msg, ## __VA_ARGS__); \ 108 | IM3D_BREAK(); \ 109 | } \ 110 | } while (0) 111 | 112 | #undef IM3D_ASSERT 113 | #define IM3D_ASSERT(e) IM3D_ASSERT_MSG(e, 0, 0) 114 | #define IM3D_VERIFY_MSG(e, msg, ...) IM3D_ASSERT_MSG(e, msg, ## __VA_ARGS__) 115 | #define IM3D_VERIFY(e) IM3D_VERIFY_MSG(e, 0, 0) 116 | 117 | #ifndef __COUNTER__ 118 | #define __COUNTER__ __LINE__ 119 | #endif 120 | #define IM3D_TOKEN_CONCATENATE_(_t0, _t1) _t0 ## _t1 121 | #define IM3D_TOKEN_CONCATENATE(_t0, _t1) IM3D_TOKEN_CONCATENATE_(_t0, _t1) 122 | #define IM3D_UNIQUE_NAME(_base) IM3D_TOKEN_CONCATENATE(_base, __COUNTER__) 123 | #define IM3D_STRINGIFY_(_t) #_t 124 | #define IM3D_STRINGIFY(_t) IM3D_STRINGIFY_(_t) 125 | 126 | #include "im3d_math.h" 127 | 128 | #include "imgui/imgui.h" 129 | 130 | namespace Im3d { 131 | 132 | void Assert(const char* _e, const char* _file, int _line, const char* _msg, ...); 133 | 134 | void RandSeed(int _seed); 135 | int RandInt(int _min, int _max); 136 | float RandFloat(float _min, float _max); 137 | Vec3 RandVec3(float _min, float _max); 138 | Mat3 RandRotation(); 139 | Color RandColor(float _min, float _max); 140 | 141 | void DrawNdcQuad(); 142 | void DrawTeapot(const Mat4& _world, const Mat4& _viewProj); 143 | 144 | struct Example 145 | { 146 | bool init(int _width, int _height, const char* _title); 147 | void shutdown(); 148 | bool update(); 149 | void draw(); 150 | 151 | // window 152 | int m_width, m_height; 153 | const char* m_title; 154 | Vec2 m_prevCursorPos; 155 | 156 | bool hasFocus() const; 157 | Vec2 getWindowRelativeCursor() const; 158 | 159 | // 3d camera 160 | bool m_camOrtho; 161 | Vec3 m_camPos; 162 | Vec3 m_camDir; 163 | float m_camFovDeg; 164 | float m_camFovRad; 165 | Mat4 m_camWorld; 166 | Mat4 m_camView; 167 | Mat4 m_camProj; 168 | Mat4 m_camViewProj; 169 | 170 | float m_deltaTime; 171 | 172 | // platform/graphics specifics 173 | #if defined(IM3D_PLATFORM_WIN) 174 | HWND m_hwnd; 175 | LARGE_INTEGER m_currTime, m_prevTime; 176 | 177 | #if defined(IM3D_OPENGL) 178 | HDC m_hdc; 179 | HGLRC m_hglrc; 180 | 181 | #elif defined(IM3D_DX11) 182 | ID3D11Device* m_d3dDevice; 183 | ID3D11DeviceContext* m_d3dDeviceCtx; 184 | IDXGISwapChain* m_dxgiSwapChain; 185 | ID3D11RenderTargetView* m_d3dRenderTarget; 186 | ID3D11DepthStencilView* m_d3dDepthStencil; 187 | #endif 188 | #endif 189 | 190 | // text rendering 191 | void drawTextDrawListsImGui(const Im3d::TextDrawList _textDrawLists[], U32 _count); 192 | 193 | }; // struct Example 194 | 195 | extern Example* g_Example; 196 | 197 | } // namespace Im3d 198 | 199 | 200 | // per-example implementations (in the example .cpp) 201 | extern bool Im3d_Init(); 202 | extern void Im3d_Shutdown(); 203 | extern void Im3d_NewFrame(); 204 | extern void Im3d_EndFrame(); 205 | -------------------------------------------------------------------------------- /examples/common/imgui/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2018 Omar Cornut 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/common/imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating imgui, or maintain a patch/branch with your modifications to imconfig.h) 7 | // B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h" 8 | // If you do so you need to make sure that configuration settings are defined consistently _everywhere_ dear imgui is used, which include 9 | // the imgui*.cpp files but also _any_ of your code that uses imgui. This is because some compile-time options have an affect on data structures. 10 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 11 | // Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. 12 | //----------------------------------------------------------------------------- 13 | 14 | #pragma once 15 | 16 | //---- Define assertion handler. Defaults to calling assert(). 17 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 18 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 19 | 20 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows. 21 | //#define IMGUI_API __declspec( dllexport ) 22 | //#define IMGUI_API __declspec( dllimport ) 23 | 24 | //---- Don't define obsolete functions/enums names. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. 25 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 26 | 27 | //---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty) 28 | //---- It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp. 29 | //#define IMGUI_DISABLE_DEMO_WINDOWS 30 | 31 | //---- Don't implement some functions to reduce linkage requirements. 32 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. 33 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. 34 | //#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself if you don't want to link with vsnprintf. 35 | //#define IMGUI_DISABLE_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 wrapper so you can implement them yourself. Declare your prototypes in imconfig.h. 36 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 37 | 38 | //---- Include imgui_user.h at the end of imgui.h as a convenience 39 | //#define IMGUI_INCLUDE_IMGUI_USER_H 40 | 41 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) 42 | //#define IMGUI_USE_BGRA_PACKED_COLOR 43 | 44 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 45 | // By default the embedded implementations are declared static and not available outside of imgui cpp files. 46 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 47 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 48 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 49 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 50 | 51 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 52 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 53 | 54 | #include "im3d.h" 55 | 56 | #define IM_VEC2_CLASS_EXTRA \ 57 | ImVec2(const Im3d::Vec2& f) { x = f.x; y = f.y; } \ 58 | operator Im3d::Vec2() const { return Im3d::Vec2(x,y); } 59 | 60 | #define IM_VEC4_CLASS_EXTRA \ 61 | ImVec4(const Im3d::Vec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ 62 | operator Im3d::Vec4() const { return Im3d::Vec4(x,y,z,w); } 63 | 64 | 65 | //---- Use 32-bit vertex indices (default is 16-bit) to allow meshes with more than 64K vertices. Render function needs to support it. 66 | //#define ImDrawIdx unsigned int 67 | 68 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 69 | /* 70 | namespace ImGui 71 | { 72 | void MyFunction(const char* name, const MyMatrix44& v); 73 | } 74 | */ 75 | -------------------------------------------------------------------------------- /im3d_config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // User-defined assertion handler (default is cassert assert()). 4 | //#define IM3D_ASSERT(e) assert(e) 5 | 6 | // User-defined malloc/free. Define both or neither (default is cstdlib malloc()/free()). 7 | //#define IM3D_MALLOC(size) malloc(size) 8 | //#define IM3D_FREE(ptr) free(ptr) 9 | 10 | // User-defined API declaration (e.g. __declspec(dllexport)). 11 | //#define IM3D_API 12 | 13 | // Use a thread-local context pointer. 14 | //#define IM3D_THREAD_LOCAL_CONTEXT_PTR 1 15 | 16 | // Use row-major internal matrix layout. 17 | //#define IM3D_MATRIX_ROW_MAJOR 1 18 | 19 | // Force vertex data alignment (default is 4 bytes). 20 | //#define IM3D_VERTEX_ALIGNMENT 4 21 | 22 | // Enable internal culling for primitives (everything drawn between Begin*()/End()). The application must set a culling frustum via AppData. 23 | //#define IM3D_CULL_PRIMITIVES 1 24 | 25 | // Enable internal culling for gizmos. The application must set a culling frustum via AppData. 26 | //#define IM3D_CULL_GIZMOS 1 27 | 28 | // Set a layer ID for all gizmos to use internally. 29 | //#define IM3D_GIZMO_LAYER_ID 0xD4A1B5 30 | 31 | // Conversion to/from application math types. 32 | //#define IM3D_VEC2_APP 33 | // Vec2(const glm::vec2& _v) { x = _v.x; y = _v.y; } 34 | // operator glm::vec2() const { return glm::vec2(x, y); } 35 | //#define IM3D_VEC3_APP 36 | // Vec3(const glm::vec3& _v) { x = _v.x; y = _v.y; z = _v.z; } 37 | // operator glm::vec3() const { return glm::vec3(x, y, z); } 38 | //#define IM3D_VEC4_APP 39 | // Vec4(const glm::vec4& _v) { x = _v.x; y = _v.y; z = _v.z; w = _v.w; } 40 | // operator glm::vec4() const { return glm::vec4(x, y, z, w); } 41 | //#define IM3D_MAT3_APP 42 | // Mat3(const glm::mat3& _m) { for (int i = 0; i < 9; ++i) m[i] = *(&(_m[0][0]) + i); } 43 | // operator glm::mat3() const { glm::mat3 ret; for (int i = 0; i < 9; ++i) *(&(ret[0][0]) + i) = m[i]; return ret; } 44 | //#define IM3D_MAT4_APP 45 | // Mat4(const glm::mat4& _m) { for (int i = 0; i < 16; ++i) m[i] = *(&(_m[0][0]) + i); } 46 | // operator glm::mat4() const { glm::mat4 ret; for (int i = 0; i < 16; ++i) *(&(ret[0][0]) + i) = m[i]; return ret; } 47 | --------------------------------------------------------------------------------