gdk-graphics 0a0aef92e917cfbac53dffbc32c295e4de914093
Loading...
Searching...
No Matches
context.h
1// © Joseph Cameron - MIT License
2
3#ifndef GDK_GRAPHICS_CONTEXT_H
4#define GDK_GRAPHICS_CONTEXT_H
5
6#include <gdk/graphics/entity.h>
7#include <gdk/graphics/limits.h>
8#include <gdk/graphics/types.h>
9
10#include <cstddef>
11#include <gdk/graphics/material.h>
12#include <gdk/graphics/model.h>
13#include <gdk/graphics/scene.h>
14#include <gdk/graphics/screen_camera.h>
15#include <gdk/graphics/shader_program.h>
16#include <gdk/graphics/texture.h>
17#include <gdk/graphics/texture_camera.h>
18
19#include <memory>
20
21namespace gdk::graphics {
23 class context {
24 public:
27 //
29 [[nodiscard]] virtual scene_ptr_type make_scene() = 0;
30
32 [[nodiscard]] virtual screen_camera_ptr_type make_camera() = 0;
33
35 [[nodiscard]] virtual texture_camera_ptr_type make_texture_camera() = 0;
36
38 [[nodiscard]] virtual texture_camera_ptr_type make_texture_camera(const intvector2_type &aSize) = 0;
39
41 [[nodiscard]] virtual entity_ptr_type make_entity(
42 const const_model_ptr_type pModel,
43 const const_material_ptr_type pMaterial
44 ) = 0;
45
47 [[nodiscard]] virtual model_ptr_type make_model(
49 const model_data &vertexData
50 ) = 0;
52 [[nodiscard]] virtual model_ptr_type make_model() = 0;
53
55 [[nodiscard]] virtual material_ptr_type make_material(
56 const const_shader_ptr_type pShader,
57 const material::render_mode aRenderMode,
58 const material::face_culling_mode aFaceCullingMode
59 ) = 0;
60
62 [[nodiscard]] material_ptr_type make_material(const const_shader_ptr_type pShader,
63 const material::render_mode aRenderMode) {
64 return make_material(pShader, aRenderMode, material::face_culling_mode::none);
65 }
66
68 [[nodiscard]] material_ptr_type make_material(const const_shader_ptr_type pShader) {
70 }
71
73 [[nodiscard]] virtual material_ptr_type make_material(
74 const const_material_ptr_type &aPrototype) = 0;
75
77 [[nodiscard]] virtual texture_ptr_type make_texture(
78 const texture_data::view &aTextureDataView,
79 const texture::wrap_mode aWrapModeU,
80 const texture::wrap_mode aWrapModeV,
81 const texture::filter_mode aFilterMode
82 ) = 0;
83
85 [[nodiscard]] texture_ptr_type make_texture(const texture_data::view &aTextureDataView,
86 const texture::wrap_mode aWrapModeU, const texture::wrap_mode aWrapModeV) {
87 return make_texture(aTextureDataView, aWrapModeU, aWrapModeV, texture::filter_mode::sharp);
88 }
89
91 [[nodiscard]] texture_ptr_type make_texture(const texture_data::view &aTextureDataView) {
94 }
95
97 [[nodiscard]] virtual texture_ptr_type make_texture() = 0;
99
102 //
105 [[nodiscard]] virtual model_ptr_type make_cube_model() const = 0;
106
107 [[nodiscard]] virtual model_ptr_type make_sphere_model() const = 0;
108
125 [[nodiscard]] virtual shader_ptr_type make_alpha_cutoff_shader() const = 0;
126
132 [[nodiscard]] virtual shader_ptr_type make_alpha_blend_shader() const = 0;
133
138 [[nodiscard]] virtual graphics::limits limits() const = 0;
140
142 virtual ~context() = default;
143 };
144}
145
146#endif
147
entry point for gdk-graphics
Definition context.h:23
virtual material_ptr_type make_material(const const_shader_ptr_type pShader, const material::render_mode aRenderMode, const material::face_culling_mode aFaceCullingMode)=0
make a material.
virtual ~context()=default
virtual destructor
virtual model_ptr_type make_model()=0
make an empty model
virtual screen_camera_ptr_type make_camera()=0
makes a camera that draws to the screen
virtual model_ptr_type make_model(const gdk::graphics::model::usage_hint, const model_data &vertexData)=0
make a model
virtual shader_ptr_type make_alpha_cutoff_shader() const =0
Basic unlit forward renderer program: Attributes:
virtual graphics::limits limits() const =0
the limits of the device, narrowed to the context's profile when it was given one
texture_ptr_type make_texture(const texture_data::view &aTextureDataView, const texture::wrap_mode aWrapModeU, const texture::wrap_mode aWrapModeV)
make a sharp texture
Definition context.h:85
virtual scene_ptr_type make_scene()=0
makes a scene
virtual shader_ptr_type make_alpha_blend_shader() const =0
a shader that keeps the texel's alpha, for the blender to use.
virtual material_ptr_type make_material(const const_material_ptr_type &aPrototype)=0
make a material that starts as a copy of another
material_ptr_type make_material(const const_shader_ptr_type pShader)
make an opaque material that culls no faces
Definition context.h:68
virtual texture_ptr_type make_texture(const texture_data::view &aTextureDataView, const texture::wrap_mode aWrapModeU, const texture::wrap_mode aWrapModeV, const texture::filter_mode aFilterMode)=0
make a texture
virtual texture_camera_ptr_type make_texture_camera(const intvector2_type &aSize)=0
makes a texture_camera drawing into textures aSize texels across
virtual texture_camera_ptr_type make_texture_camera()=0
makes a texture_camera drawing into textures 1024 texels square
virtual texture_ptr_type make_texture()=0
make an empty texture
texture_ptr_type make_texture(const texture_data::view &aTextureDataView)
make a sharp texture that repeats
Definition context.h:91
virtual model_ptr_type make_cube_model() const =0
a 1x1x1 cube model
virtual entity_ptr_type make_entity(const const_model_ptr_type pModel, const const_material_ptr_type pMaterial)=0
make an entity
material_ptr_type make_material(const const_shader_ptr_type pShader, const material::render_mode aRenderMode)
make a material that culls no faces
Definition context.h:62
render_mode
render mode decides transparency etc
Definition material.h:32
@ opaque
no transparency
Definition material.h:33
face_culling_mode
specify whether front- or back-facing polygons can be culled
Definition material.h:24
@ none
do not cull any polygons
Definition material.h:28
vertex data stored in system memory.
Definition model_data.h:25
usage_hint
Definition model.h:12
filter_mode
how a texel is chosen when a pixel does not land exactly on one
Definition texture.h:27
@ sharp
nearest: the one texel closest to the sample, so texels stay square
Definition texture.h:28
wrap_mode
behavior when sampling outside of the normalized texture range (u0-1, v0-1)
Definition texture.h:20
@ repeat
sampled values repeat. e.g: {2,2}, {3,3}, 100,100} would all sample {1,1}
Definition texture.h:22
used to (optionally) enforce limits on graphical types used across graphics apis
Definition limits.h:12
provides a pointer a contiguous list of channel data representing 2D texture metadata that contains i...
Definition texture_data.h:27