opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
graphics.h
Go to the documentation of this file.
1#pragma once
2
8
9#include <cstddef>
10#include <optional>
11
12namespace osc { class Camera; }
13namespace osc { class Cubemap; }
14namespace osc { class Material; }
15namespace osc { class Mesh; }
16namespace osc { class Rect; }
17namespace osc { class RenderTexture; }
18namespace osc { class Texture2D; }
19namespace osc { struct Transform; }
20
21// rendering functions
22//
23// these perform the necessary backend steps to get something useful done
25{
26 // Queues the given `Mesh` + `Transform` + `Material` + extras against
27 // the `Camera`.
28 //
29 // Once everything is queued against the `Camera`, the caller should call
30 // `Camera::render()` or `Camera::render_to()` to flush the queue.
31 void draw(const Mesh&, const Transform&, const Material&, Camera&);
32 void draw(const Mesh&, const Transform&, const Material&, Camera&, const MaterialPropertyBlock&);
33 void draw(const Mesh&, const Transform&, const Material&, Camera&, size_t submesh_index);
34 void draw(const Mesh&, const Transform&, const Material&, Camera&, const MaterialPropertyBlock&, size_t submesh_index);
35
36 // Queues the given `Mesh` + `Matrix4x4` + `Material` + extras against
37 // the `Camera`.
38 //
39 // Once everything is queued against the `Camera`, the caller should call
40 // `Camera::render()` or `Camera::render_to()` to flush the queue.
41 void draw(const Mesh&, const Matrix4x4&, const Material&, Camera&);
42 void draw(const Mesh&, const Matrix4x4&, const Material&, Camera&, const MaterialPropertyBlock&);
43 void draw(const Mesh&, const Matrix4x4&, const Material&, Camera&, size_t submesh_index);
44 void draw(const Mesh&, const Matrix4x4&, const Material&, Camera&, const MaterialPropertyBlock&, size_t submesh_index);
45
46 // Blits the `Texture` to the `RenderTexture`.
47 void blit(
48 const Texture2D&,
50 );
51
52 // Blits `render_texture` into a rectangular region of the main window.
53 //
54 // If provided, `destination_screen_rect` should be defined in screen space
55 // and device-independent pixels. Screen space starts in the bottom-left
56 // corner and ends in the top-right corner. If it is not provided, the
57 // destination region will be the entire contents of the main window.
60 std::optional<Rect> destination_screen_rect = std::nullopt,
61 BlitFlags = {}
62 );
63
64 // Renders `render_texture` as a quad using `material` into a rectangular region
65 // of the main window.
66 //
67 // `material` should have a `sampler2D` or `samplerCube` property called
68 // "uTexture". `texture` will be assigned to this property. `texture`'s
69 // `dimensionality()` dictates whether a `sampler2D` or `samplerCube` is
70 // required in the shader.
71 //
72 // If provided, `destination_screen_rect` should be defined in screen space
73 // and device-independent pixels. Screen space starts in the bottom-left
74 // corner and ends in the top-right corner. If it is not provided, the
75 // destination region will be the entire contents of the main window.
78 const Material& material,
79 std::optional<Rect> destination_screen_rect = std::nullopt,
80 BlitFlags = {}
81 );
82
83 // Blits the texture into a rectangular region in the main window.
84 //
85 // The rectangle should be defined in screen space, which:
86 //
87 // - Is measured in device-independent pixels
88 // - Starts in the bottom-left corner
89 // - Ends in the top-right corner
91 const Texture2D&,
92 const Rect&
93 );
94
95 // copy: copy a GPU texture to a (potentially, CPU-accessible) texture
96
98 const RenderTexture&,
100 );
101
103 const RenderTexture&,
104 Texture2D&,
106 );
107
109 const RenderTexture&,
110 Cubemap&,
111 size_t mipmap_level
112 );
113}
Definition camera.h:27
Definition cubemap.h:29
Definition flags.h:20
Definition material_property_block.h:20
Definition material.h:21
Definition mesh.h:33
Definition rect.h:17
Definition render_texture.h:18
Definition texture2d.h:22
Definition graphics.h:25
void copy_texture(const RenderTexture &, Texture2D &)
void blit_to_main_window(const RenderTexture &render_texture, std::optional< Rect > destination_screen_rect=std::nullopt, BlitFlags={})
void draw(const Mesh &, const Transform &, const Material &, Camera &)
void blit(const Texture2D &, RenderTexture &)
Definition custom_decoration_generator.h:5
constexpr U to(T &&value)
Definition conversion.h:56
CubemapFace
Definition cubemap_face.h:5
Definition transform.h:11