From 9b83919815f6a6ce5d73da1c28483970d0ca5589 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Feb 2021 14:22:28 -0600 Subject: added dev/MinGfx/ --- .../docs/html/default__shader_8h_source.html | 240 +++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 dev/MinGfx/docs/html/default__shader_8h_source.html (limited to 'dev/MinGfx/docs/html/default__shader_8h_source.html') diff --git a/dev/MinGfx/docs/html/default__shader_8h_source.html b/dev/MinGfx/docs/html/default__shader_8h_source.html new file mode 100644 index 0000000..374116c --- /dev/null +++ b/dev/MinGfx/docs/html/default__shader_8h_source.html @@ -0,0 +1,240 @@ + + + + + + + +MinGfx Toolkit: src/default_shader.h Source File + + + + + + + + + + + + +
+
+ + + + + + +
+
MinGfx Toolkit +  1.0 +
+
A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
default_shader.h
+
+
+Go to the documentation of this file.
1 /*
+
2  This file is part of the MinGfx Project.
+
3 
+
4  Copyright (c) 2017,2018 Regents of the University of Minnesota.
+
5  All Rights Reserved.
+
6 
+
7  Original Author(s) of this File:
+
8  Dan Keefe, 2018, University of Minnesota
+
9 
+
10  Author(s) of Significant Updates/Modifications to the File:
+
11  ...
+
12  */
+
13 
+
14 #ifndef SRC_DEFAULT_SHADER_H_
+
15 #define SRC_DEFAULT_SHADER_H_
+
16 
+
17 #include "color.h"
+
18 #include "point3.h"
+
19 #include "shader_program.h"
+
20 #include "texture2d.h"
+
21 #include "vector3.h"
+
22 #include "matrix4.h"
+
23 #include "mesh.h"
+
24 
+
25 
+
26 
+
27 namespace mingfx {
+
28 
+ +
63 public:
+
64 
+
66  static const unsigned int MAX_LIGHTS = 10;
+
67 
+
68 
+ +
71  public:
+ + + +
75  float shinniness;
+ +
77  // eventually, this might include a normal map, etc.
+
78 
+
79  // defaults
+ +
81  ambient_reflectance(0.25f, 0.25f, 0.25f),
+
82  diffuse_reflectance(0.6f, 0.6f, 0.6f),
+
83  specular_reflectance(0.4f, 0.4f, 0.4f),
+
84  shinniness(20.0f) {}
+
85  };
+
86 
+ +
89  public:
+ + + + +
94 
+
95  // defaults
+ +
97  position(10.0f, 10.0f, 10.0f),
+
98  ambient_intensity(0.25f, 0.25f, 0.25f),
+
99  diffuse_intensity(0.6f, 0.6f, 0.6f),
+
100  specular_intensity(0.6f, 0.6f, 0.6f) {}
+
101  };
+
102 
+
106  DefaultShader(bool add_default_light=true);
+
107 
+
108  virtual ~DefaultShader();
+
109 
+ +
113 
+ +
116 
+
117 
+
124  void Init();
+
125 
+
130  void Draw(const Matrix4 &model, const Matrix4 &view, const Matrix4 &projection,
+
131  Mesh *mesh, const MaterialProperties &material);
+
132 
+
133 
+
138  void UseProgram(const Matrix4 &model, const Matrix4 &view, const Matrix4 &projection,
+
139  const MaterialProperties &material);
+
140 
+
143  void StopProgram();
+
144 
+
145 
+
146  int num_lights();
+
147 
+ +
149 
+
150 
+
151 private:
+
152 
+
153  std::vector<LightProperties> lights_;
+
154 
+
155  // cached raw float arrays store data to send directly to the gpu
+
156  // GLSL requires fixed size arrays for these
+
157  float lightPositions_[3*MAX_LIGHTS];
+
158  float lightIas_[4*MAX_LIGHTS];
+
159  float lightIds_[4*MAX_LIGHTS];
+
160  float lightIss_[4*MAX_LIGHTS];
+
161  void update_light_arrays();
+
162 
+
163  ShaderProgram phongShader_;
+
164 };
+
165 
+
166 } // end namespace
+
167 
+
168 #endif
+
Represents a 4-component (R,G,B,A) color, stored internally in a float array to be compatable with Op...
Definition: color.h:41
+
Small data structure to hold per-light properties.
+ + + + + +
Small data structure to hold properties of the material to be lit.
+ + + + + + +
A simple GLSL shader for textured per-fragment Phong shading with multiple light sources.
+
void UseProgram(const Matrix4 &model, const Matrix4 &view, const Matrix4 &projection, const MaterialProperties &material)
Only needed if you do not want to draw a Mesh. This does all of the same setup for drawing that the D...
+ +
static const unsigned int MAX_LIGHTS
If changed, this needs to also be changed in the glsl shader code.
+
void StopProgram()
Only needed if you do not want to draw a Mesh. Call this after UseProgram() and after drawing your ge...
+
void SetLight(int i, LightProperties light)
Changes the properties for a light that was already added.
+
void Init()
This loads vertex and fragment shaders from files, compiles them, and links them. So,...
+
void Draw(const Matrix4 &model, const Matrix4 &view, const Matrix4 &projection, Mesh *mesh, const MaterialProperties &material)
This starts the shader and sets its uniform variables based upon the current set of lights,...
+
LightProperties light(int i)
+
DefaultShader(bool add_default_light=true)
The constructor defaults to adding a single white light to the scene at (10,10,10)....
+ +
void AddLight(LightProperties light)
Multiple lights are supported, this adds one to the end of the list. Up to MAX_LIGHTS can be added.
+
A 4x4 transformation matrix stored internally as an array of floats in column-major order so as to be...
Definition: matrix4.h:50
+
A triangle mesh data structure that can be rendered with a ShaderProgram like DefaultShader.
Definition: mesh.h:127
+
A 3D Point with floating point coordinates, used for storing vertices and all sorts of other 3D graph...
Definition: point3.h:52
+
A wrapper around GLSL shader programs.
+
A wrapper around a 2D texture that supports loading images from files or setting texture color data d...
Definition: texture2d.h:42
+ + + +
Namespace for the MinGfx Toolkit.
Definition: aabb.h:21
+ + + + +
+ + + + + -- cgit v1.2.3