src/gl/basicshaderprogram.h

Thu, 15 Jun 2023 16:18:03 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Thu, 15 Jun 2023 16:18:03 +0300
changeset 383
530d23cd4e97
parent 378
01537fbe096e
permissions
-rw-r--r--

Refactor, make selecting elements from the model select the corresponding line from the editor as well

70
f21b800b02a4 Added axes rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #pragma once
264
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 259
diff changeset
2 #include "src/gl/common.h"
70
f21b800b02a4 Added axes rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3
215
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
4 struct GLAttributeSpec
70
f21b800b02a4 Added axes rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 {
215
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
6 GLenum type;
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
7 int offset;
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
8 int tuplesize;
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
9 int stride;
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
10 };
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
11
377
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
12 namespace gl
215
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
13 {
377
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
14 struct basic_shader;
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
15 void initialize_basic_shader(
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
16 gl::basic_shader* shader,
215
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
17 const char* vertexShaderSource,
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
18 const char* fragmentShaderSource,
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
19 QOpenGLBuffer::UsagePattern usagePattern,
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 118
diff changeset
20 const std::vector<GLAttributeSpec>& attributeSpecs);
377
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
21 void set_shader_matrix_uniform(
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
22 gl::basic_shader* shader,
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
23 const char* name,
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
24 const glm::mat4& value);
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
25 void set_shader_vector_uniform(
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
26 gl::basic_shader* shader,
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
27 const char* name,
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
28 const glm::vec4& value);
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
29 void buffer_shader_data(
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
30 gl::basic_shader* shader,
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
31 const void* data,
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
32 std::size_t count,
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
33 std::size_t size);
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
34 void draw_shader(
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
35 gl::basic_shader* shader,
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
36 GLenum drawMode);
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
37 }
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
38
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
39 //! @brief A collection of a single VAO with a single VBO,
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
40 //! a vertex shader and a fragment shader.
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
41 struct gl::basic_shader
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
42 {
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
43 QOpenGLBuffer buffer{QOpenGLBuffer::VertexBuffer};
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
44 QOpenGLShader vertexShader{QOpenGLShader::Vertex};
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
45 QOpenGLShader fragmentShader{QOpenGLShader::Fragment};
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
46 std::unique_ptr<gl::ShaderProgram> program = nullptr;
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
47 QOpenGLVertexArrayObject vertexArrayObject;
e1c5e4310f8b BasicShader is no longer a class
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
48 int vertexCount = 0;
70
f21b800b02a4 Added axes rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
49 };

mercurial