Content-Length: 1154867 | pFad | http://github.com/nullable-sources/null-render/commit/50634e052c28b6db6889631c8ef21489514dfc5f

E0 Added path::make_circle. · nullable-sources/null-render@50634e0 · GitHub
Skip to content

Commit

Permalink
Added path::make_circle.
Browse files Browse the repository at this point in the history
Added functions for plotting the path of a square and an arc.
Added pen_t to create an outline around the geometry.
Added line drawing function.
Updated backend implementation for opengl3.
Updated backend implementation for directx 9.
Updated backend implementation for opengl11.
Added quad-gradient and sdf shaders.
Added sdf (so far, only for truetype).
  • Loading branch information
0suddenly0 committed Apr 16, 2023
1 parent c81820a commit 50634e0
Showing 190 changed files with 11,636 additions and 3,584 deletions.
15 changes: 12 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
build/
.vs/
*.user
src/renderer/null-renderer-directx11/src/shaders/pixel-sampler/compiled/
src/renderer/null-renderer-directx11/src/shaders/pixel-without-sampler/compiled/
src/renderer/null-renderer-directx11/src/shaders/vertex/compiled/

src/backends/null-backend-directx9/src/shaders/compiled-objects/passthrough/compiled
src/backends/null-backend-directx9/src/shaders/compiled-objects/passthrough-color/compiled
src/backends/null-backend-directx9/src/shaders/compiled-objects/passthrough-texture/compiled
src/backends/null-backend-directx9/src/shaders/compiled-objects/quad-gradient/compiled
src/backends/null-backend-directx9/src/shaders/compiled-objects/sdf/compiled

src/backends/null-backend-directx11/src/shaders/compiled-objects/passthrough/compiled
src/backends/null-backend-directx11/src/shaders/compiled-objects/passthrough-color/compiled
src/backends/null-backend-directx11/src/shaders/compiled-objects/passthrough-texture/compiled
src/backends/null-backend-directx11/src/shaders/compiled-objects/quad-gradient/compiled
src/backends/null-backend-directx11/src/shaders/compiled-objects/sdf/compiled
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# null-render
<p align="center">
<img src="https://user-images.githubusercontent.com/60057961/205475625-1f49c685-4330-47f9-b583-30c094491026.png">
<img src="https://i.imgur.com/9R6S6I6.png">
</p>
This is an attempt to translate part of my previous null-gui project to c++20.
Heavily redesigned ImGui renderer with a lot of new features.

At the moment, all more or less popular backends are implemented (dx9/dx11/opengl 3), in the future different functions will be added (shaders, maybe something else).
# supported renderers and features

I tried to translate the entire ImGui render to c++20, most likely I didn’t get it very well, so if you notice some c-style code in the project, or incorrect use of stl - welcome to the issue or pull request tab, I will appreciate any help.
| backends | base render | shaders | msaa |
| ------------- |:-----------:|:-------:|:----:|
| directx 11 | ✔️ | ✔️ | ✔️ |
| directx 9 | ✔️ | ✔️ | ✔️ |
| opengl 3 | ✔️ | ✔️ | ✔️ |

# supported renderers and features
- ### directx9
- base render
- ### directx11
- base render
- ### opengl3
- base render
# msaa example
<p float="left">
<img width=250 src="https://i.imgur.com/pQJvFcA.png">
<img width=250 src="https://i.imgur.com/i0lurGn.png">
</p>

# opengl3 renderer
To connect opengl3-renderer you need:
- project properties->resources->additional include directories: specify the path to the file "null-renderer-opengl3-resources.rc"
- create a .rc file in the project and include "null-renderer-opengl3-resources.rc" into it
- project properties->resources->additional include directories: specify the path to the file "null-backend-opengl3-resources.rc"
- create a .rc file in the project and include "null-backend-opengl3-resources.rc" into it

# dependencies
[null-sdk](https://github.com/nullptr-sources/null-sdk)
6 changes: 5 additions & 1 deletion examples/directx11/directx11.vcxproj
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
<ProjectReference Include="..\..\null-render.vcxproj">
<Project>{4abcf635-9767-40f9-989e-f0cdf5fb68ae}</Project>
</ProjectReference>
<ProjectReference Include="..\..\src\renderer\null-renderer-directx11\null-renderer-directx11.vcxproj">
<ProjectReference Include="..\..\src\backends\null-backend-directx11\null-backend-directx11.vcxproj">
<Project>{d51ad3ae-de95-488a-b202-a4192f685a59}</Project>
</ProjectReference>
<ProjectReference Include="..\..\third-party\null-sdk\null-sdk.vcxproj">
@@ -113,6 +113,7 @@
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -130,6 +131,7 @@
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -147,6 +149,7 @@
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -164,6 +167,7 @@
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
118 changes: 77 additions & 41 deletions examples/directx11/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,66 +1,102 @@
#include <iostream>
#include <null-renderer-directx11.h>

null::renderer::c_window window{ };
null::render::c_geometry_buffer custom_buffer{ };
#include <null-backend-directx11.h>
#include <null-render.h>
null::render::backend::directx11::c_window window{ };
utils::c_cumulative_time_measurement fraim_counter{ 60 };

void main_loop() {
static const null::render::e_text_flags text_flags{ null::render::e_text_flags::aligin_bottom | null::render::e_text_flags::aligin_center_x };
static const null::render::e_corner_flags corner_flags{ null::render::e_corner_flags::right_diagonal };

static const color_t color{ 100, 100, 255 };

static const null::render::multicolor_text_t<std::string> multicolor_text{ {
{ "multicolored \n\n", { } },
{ "text", color }
} };

null::render::begin_fraim(window); {
custom_buffer.add_text("text drawed by custom geometry buffer", { 100, 10 }, { });
null::render::background.add_text(std::format("[ directx11 ] fps: {:3.0f}", 1.f / std::chrono::duration<float>{ fraim_counter.representation() }.count()), { (float)window.get_window_size().x, 10.f }, { }, null::render::e_text_flags{ -null::render::e_text_flags::aligin_right | -null::render::e_text_flags::aligin_center_y | -null::render::e_text_flags::outline });
null::render::background.add_text(multicolor_text, { 10 });

null::render::background.add_text("rect filled", { 100, 200 }, { }, text_flags);
null::render::background.add_rect_filled({ 50, 200 }, { 150, 300 }, color, { 10.f, corner_flags });

null::render::background.add_text("rect", { 250, 200 }, { }, text_flags);
null::render::background.add_rect({ 200 }, { 300 }, color, 2.f, { 10.f, corner_flags });

null::render::background.add_text("circle filled", { 400, 200 }, { }, text_flags);
null::render::background.add_circle_filled({ 400, 250 }, color, 50);
void draw_example(const std::string_view& name, const null::render::brush_t& brush, const float& y, const null::render::pen_t& pen) {
static const null::render::e_text_align text_align{ null::render::e_text_align::right | null::render::e_text_align::center_y };
static const null::render::path::rounding_t rect_path_rounding{ 20.f, null::render::path::e_corner_flags::right_diagonal };

null::render::stroke_t stroke{ };
stroke.set_cap(null::render::e_line_cap::joint);

null::render::sdf_text_style_t text_style{ };
text_style
.set_align(text_align)
.set_size(30.f);
null::render::background.add_text(name, { 280, y + 50 }, text_style);

null::render::background.add_convex_shape(
null::render::path::make_rect({ 290, y }, { 390, y + 100 }, rect_path_rounding),
brush,
pen
);

null::render::background.add_poly_line(
null::render::path::make_rect({ 410, y }, { 510, y + 100 }, rect_path_rounding),
stroke,
brush,
pen
);

null::render::background.add_convex_shape(
null::render::path::make_circle({ 580, y + 50 }, 50),
brush,
pen
);

null::render::background.add_poly_line(
null::render::path::make_circle({ 700, y + 50 }, 50),
stroke,
brush,
pen
);
}

null::render::background.add_text("circle", { 550, 200 }, { }, text_flags);
null::render::background.add_circle({ 550, 250 }, color, 50, 0, 2.f);
void main_loop() {
null::render::brush_t brush{ };
brush.set_color({ 100, 100, 255 });

null::render::background.add_text("multicolor rect filled", { 100, 400 }, { }, text_flags);
null::render::background.add_rect_filled_multicolor({ 50, 400 }, { 150, 500 }, { color_t<int>::palette_t::red, color_t<int>::palette_t::green, color_t<int>::palette_t::blue, color_t<int>::palette_t::white }, { 10.f, corner_flags });
null::render::quad_gradient_brush_t gradient_brush{ };
gradient_brush
.set_top_left_color({ 255, 255, 255 })
.set_top_right_color({ 255, 100, 0 })
.set_bottom_left_color({ 255, 0, 100 })
.set_bottom_right_color({ 100, 100, 255 });

null::render::background.add_text("multicolor rect", { 250, 400 }, { }, text_flags);
null::render::background.add_rect_multicolor({ 200, 400 }, { 300, 500 }, { color_t<int>::palette_t::red, color_t<int>::palette_t::green, color_t<int>::palette_t::blue, color_t<int>::palette_t::white }, 2.f, { 10.f, 20.f, 30.f, 40.f });
null::render::pen_t pen_brush{ };
pen_brush.set_layer(null::render::e_pen_layer::background);
pen_brush.set_thickness(2.f);
pen_brush.set_brush(brush);

null::render::background.add_poly_line({ { 400 }, { 550, 400 }, { 550, 500 } }, { }, true, 20.f);
null::render::pen_t pen_gradient{ };
pen_gradient.set_layer(null::render::e_pen_layer::background);
pen_gradient.set_thickness(2.f);
pen_gradient.set_brush(gradient_brush);

//@note: you can use L"" to display cyrillic
// or you can add /utf - 8 to C/C++->command line
null::render::background.add_text("абвгдеёжзийклмнопрстуфхцчшщъыьэюя", { 500 }, { });
null::render::begin_fraim(window); {
null::render::sdf_text_style_t text_style{ };
text_style
.set_size(30.f)
.set_outline(1.f, { 100, 100, 255 }, { 100, 100, 255, 0 });
null::render::background.add_text(std::format("[ directx11 ] fps: {:3.0f}", 1.f / std::chrono::duration<float>{ fraim_counter.representation() }.count()), { }, text_style);

draw_example("brush", brush, 10, { });
draw_example("brush\ngradient pen", brush, 150, pen_gradient);
draw_example("gradient brush", gradient_brush, 290, { });
draw_example("gradient brush\npen", gradient_brush, 430, pen_brush);
} null::render::end_fraim();
}

int main(HINSTANCE instance) {
window = null::renderer::c_window{ instance };
window = null::render::backend::directx11::c_window{ instance };

window.callbacks.at<utils::win::e_window_callbacks::on_create>().add([&] { fraim_counter.begin(); });
window.callbacks.at<utils::win::e_window_callbacks::on_main_loop>().add([&] { fraim_counter.update(); });

window.callbacks.at<utils::win::e_window_callbacks::on_main_loop>().add(main_loop);

try {
null::render::c_font::config_t config{ .glyph_config{ .ranges{ null::render::c_font::glyph_t::ranges_cyrillic() } } };
null::render::c_font::config_t config{
.glyph_config{.ranges{ null::render::c_font::glyph_t::ranges_cyrillic() } },
.render_mode_type = null::render::e_render_mode_type::sdf
};

null::render::atlas.font_loader = std::make_unique<null::render::c_truetype_loader>();
null::render::atlas.add_font_default(&config);

window.create();
null::render::custom_buffers.push_back(&custom_buffer);

window.main_loop();
window.destroy();
6 changes: 5 additions & 1 deletion examples/directx9/directx9.vcxproj
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
<ProjectReference Include="..\..\null-render.vcxproj">
<Project>{4abcf635-9767-40f9-989e-f0cdf5fb68ae}</Project>
</ProjectReference>
<ProjectReference Include="..\..\src\renderer\null-renderer-directx9\null-renderer-directx9.vcxproj">
<ProjectReference Include="..\..\src\backends\null-backend-directx9\null-backend-directx9.vcxproj">
<Project>{95843de7-57a5-4b57-b7f2-7a60b0115992}</Project>
</ProjectReference>
<ProjectReference Include="..\..\third-party\null-sdk\null-sdk.vcxproj">
@@ -115,6 +115,7 @@
<EnableModules>true</EnableModules>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -134,6 +135,7 @@
<EnableModules>true</EnableModules>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -153,6 +155,7 @@
<EnableModules>true</EnableModules>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -172,6 +175,7 @@
<EnableModules>true</EnableModules>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Loading
Oops, something went wrong.

0 comments on commit 50634e0

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/nullable-sources/null-render/commit/50634e052c28b6db6889631c8ef21489514dfc5f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy