Gamedev Framework (gf)
0.19.0
A C++17 framework for 2D games
include
gf
Shader.h
1
/*
2
* Gamedev Framework (gf)
3
* Copyright (C) 2016-2021 Julien Bernard
4
*
5
* This software is provided 'as-is', without any express or implied
6
* warranty. In no event will the authors be held liable for any damages
7
* arising from the use of this software.
8
*
9
* Permission is granted to anyone to use this software for any purpose,
10
* including commercial applications, and to alter it and redistribute it
11
* freely, subject to the following restrictions:
12
*
13
* 1. The origin of this software must not be misrepresented; you must not
14
* claim that you wrote the original software. If you use this software
15
* in a product, an acknowledgment in the product documentation would be
16
* appreciated but is not required.
17
* 2. Altered source versions must be plainly marked as such, and must not be
18
* misrepresented as being the original software.
19
* 3. This notice may not be removed or altered from any source distribution.
20
*
21
* Part of this file comes from SFML, with the same license:
22
* Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
23
*/
24
#ifndef GF_SHADER_H
25
#define GF_SHADER_H
26
27
#include <string>
28
#include <map>
29
30
#include "GraphicsApi.h"
31
#include "Matrix.h"
32
#include "Path.h"
33
#include "Texture.h"
34
#include "Vector.h"
35
36
namespace
gf
{
37
#ifndef DOXYGEN_SHOULD_SKIP_THIS
38
inline
namespace
v1 {
39
#endif
40
41
class
InputStream;
42
119
class
GF_GRAPHICS_API
Shader
{
120
public
:
124
enum
Type
{
125
Vertex
,
126
Fragment
,
127
};
128
134
Shader
();
135
151
Shader
(
const
Path
& filename,
Type
type);
152
169
Shader
(
const
Path
& vertexShaderFilename,
const
Path
& fragmentShaderFilename);
170
185
Shader
(
const
char
*shader,
Type
type);
186
203
Shader
(
const
char
*vertexShader,
const
char
*fragmentShader);
204
219
Shader
(
InputStream
& stream,
Type
type);
220
236
Shader
(
InputStream
& vertexShaderStream,
InputStream
& fragmentShaderStream);
237
241
~
Shader
();
242
246
Shader
(
const
Shader
&) =
delete
;
247
251
Shader
& operator=(
const
Shader
&) =
delete
;
252
270
void
setUniform(
const
std::string& name,
float
val);
271
278
void
setUniform(
const
std::string& name,
int
val);
279
286
void
setUniform(
const
std::string& name,
const
Vector2f
& vec);
287
294
void
setUniform(
const
std::string& name,
const
Vector3f
& vec);
295
302
void
setUniform(
const
std::string& name,
const
Vector4f
& vec);
303
310
void
setUniform(
const
std::string& name,
const
Vector2i
& vec);
311
318
void
setUniform(
const
std::string& name,
const
Vector3i
& vec);
319
326
void
setUniform(
const
std::string& name,
const
Vector4i
& vec);
327
334
void
setUniform(
const
std::string& name,
const
Matrix3f
& mat);
335
342
void
setUniform(
const
std::string& name,
const
Matrix4f
& mat);
343
370
void
setUniform(
const
std::string& name,
const
BareTexture
& tex);
371
382
static
void
bind(
const
Shader
*shader);
383
384
private
:
385
friend
class
RenderTarget
;
386
int
getUniformLocation(
const
std::string& name);
387
int
getAttributeLocation(
const
std::string& name);
388
389
struct
Guard;
390
391
private
:
392
unsigned
m_program;
393
394
std::map<int, const BareTexture *> m_textures;
395
};
396
397
#ifndef DOXYGEN_SHOULD_SKIP_THIS
398
}
399
#endif
400
}
401
402
#endif // GF_SHADER_H
gf::RenderTarget
Base class for all render targets (window, texture, ...)
Definition:
RenderTarget.h:102
gf::Shader
An OpenGL vertex and/or fragment shader.
Definition:
Shader.h:119
gf::Path
std::filesystem::path Path
A path in the filesystem.
Definition:
Path.h:40
gf::Matrix< float, 3, 3 >
gf
The namespace for gf classes.
Definition:
Action.h:35
gf::BareTexture
An image that lives in the graphic memory that can be used for drawing.
Definition:
Texture.h:79
gf::InputStream
Abstract class for custom file input streams.
Definition:
Stream.h:54
gf::Shader::Type
Type
Type of shaders.
Definition:
Shader.h:124
gf::Vector
General purpose math vector.
Definition:
Vector.h:61
gf::Shader::Fragment
Type for a fragment (or pixel) shader.
Definition:
Shader.h:126
gf::Shader::Vertex
Type for a vertex shader.
Definition:
Shader.h:125
Generated by
1.8.13