All Projects → john-chapman → Im3d

john-chapman / Im3d

Licence: mit
Immediate mode rendering and 3d gizmos.

Projects that are alternatives of or similar to Im3d

Renderer
A shader-based software renderer written from scratch in C89
Stars: ✭ 1,366 (+143.49%)
Mutual labels:  graphics, 3d, rendering
Hilo3d
Hilo3d, a WebGL Rendering Engine.
Stars: ✭ 123 (-78.07%)
Mutual labels:  graphics, 3d, rendering
Fauxgl
Software-only 3D renderer written in Go.
Stars: ✭ 658 (+17.29%)
Mutual labels:  graphics, 3d, rendering
Tinyraytracer
A brief computer graphics / rendering course
Stars: ✭ 3,971 (+607.84%)
Mutual labels:  graphics, 3d, rendering
Unity Dithered Transparency Shader
Unity material and shader for applying clipped, dithered transparency
Stars: ✭ 174 (-68.98%)
Mutual labels:  graphics, 3d, rendering
Tinyrenderer
A brief computer graphics / rendering course
Stars: ✭ 11,776 (+1999.11%)
Mutual labels:  graphics, 3d, rendering
Tinyraycaster
486 lines of C++: old-school FPS in a weekend
Stars: ✭ 1,383 (+146.52%)
Mutual labels:  graphics, 3d, rendering
Vxr
General purpose engine written in C++ with emphasis on materials rendering (PBR, clear coat, anisotropy, iridescence)
Stars: ✭ 181 (-67.74%)
Mutual labels:  graphics, 3d, rendering
Tinykaboom
A brief computer graphics / rendering course
Stars: ✭ 2,077 (+270.23%)
Mutual labels:  graphics, 3d, rendering
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (-72.91%)
Mutual labels:  graphics, 3d, rendering
Euc
A software rendering crate that lets you write shaders with Rust
Stars: ✭ 180 (-67.91%)
Mutual labels:  graphics, 3d, rendering
Renderhelp
⚡️ 可编程渲染管线实现,帮助初学者学习渲染
Stars: ✭ 494 (-11.94%)
Mutual labels:  graphics, 3d, rendering
Vue Babylonjs
A ready-to-go 3d environment for Vue.js using Babylon.js
Stars: ✭ 356 (-36.54%)
Mutual labels:  graphics, 3d
Silk.net
The high-speed OpenAL, OpenGL, Vulkan, and GLFW bindings library your mother warned you about.
Stars: ✭ 534 (-4.81%)
Mutual labels:  graphics, 3d
Touchdesigner shared
TouchDesigner toxes and small projects
Stars: ✭ 385 (-31.37%)
Mutual labels:  graphics, rendering
Magnum
Lightweight and modular C++11 graphics middleware for games and data visualization
Stars: ✭ 3,728 (+564.53%)
Mutual labels:  graphics, 3d
Beam
✨ Expressive WebGL
Stars: ✭ 383 (-31.73%)
Mutual labels:  graphics, 3d
Cpp 3d Game Tutorial Series
C++ 3D Game Tutorial Series is a YouTube tutorial series, whose purpose is to help all those who want to take their first steps in the game development from scratch.
Stars: ✭ 400 (-28.7%)
Mutual labels:  graphics, 3d
Vue Gl
Vue.js components rendering 3D WebGL graphics reactively with three.js
Stars: ✭ 434 (-22.64%)
Mutual labels:  graphics, 3d
Lume
Create CSS3D/WebGL applications declaratively with HTML. Give regular DOM elements shadow and lighting.
Stars: ✭ 445 (-20.68%)
Mutual labels:  graphics, 3d

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.

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.

Demo Screenshot 1 Demo Screenshot 2 Demo Screenshot 3

The API design follows OpenGL immediate mode in that it functions as a state machine:

Im3d::PushDrawState();
Im3d::SetSize(2.0f);
Im3d::BeginLineLoop();
	Im3d::Vertex(0.0f, 0.0f, 0.0f, Im3d::Color_Magenta);
	Im3d::Vertex(1.0f, 1.0f, 0.0f, Im3d::Color_Yellow);
	Im3d::Vertex(2.0f, 2.0f, 0.0f, Im3d::Color_Cyan);
Im3d::End();
Im3d::PopDrawState();

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).

The UI system follows the immediate mode paradigm in that no UI state is retained; you can create gizmos from anywhere in the code:

static mat4 transform;
if (Im3d::Gizmo("UnifiedGizmo", &transform)) {
	// transform was modified, do something with the matrix
}

Translation Gizmo Rotation Gizmo Scale Gizmo

See here for more complete examples.

Integration

Im3d has no dependencies other than the C standard lib. A C++11 compatible compiler is required.

Integration is fairly straightforward:

  • Copy the files from the root of this repo and add them to the application project.
  • Modify im3d_config.h if necessary (provide a custom malloc/free, set the vertex data alignment, matrix layout, etc.).

At runtime, the application should then proceed as follows:

  • At startup, load the graphics resources (shaders, etc.) required to actually draw the Im3d vertex buffers.
  • Each frame, fill the Im3d::AppData struct, providing user input and other context data, then call Im3d::NewFrame().
  • Towards the end of the frame, call Im3d::Draw() once for each view/projection to be rendered. Im3d calls an application-defined callback to actually execute rendering commands and draw the points/lines/triangles pushed during the frame.

More detailed and API-specific integration examples are available in examples/.

Frequently Asked Questions (FAQ)

Where is the documentation?

  • im3d.h contains the main API documentation.
  • examples/common/main.cpp contains usage examples for most features, especially how to use the Gizmo*() API.
  • examples/ contain reference implementations with lots of comments.

Are geometry shaders required?

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:

  • 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 for a reference implementation.
  • 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.
  • 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.

How can I update to the latest version?

  • Check which version you currently have; IM3D_VERSION is defined at the top of im3d.h.
  • Examine the change log in the latest version of im3d.cpp to see if there have been any API-breaking changes which require modifications on the application side.
  • Overwrite everything except im3d_config.h if you have made any changes to your copy.

Is Im3d thread safe?

Im3d provides no thread safety mechanism per se, however per-thread contexts are fully supported and can be used to achieve thread safety.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].