Shader.h
author František Kučera <franta-hg@frantovo.cz>
Fri, 01 Dec 2023 20:25:49 +0100
branchv_0
changeset 5 ee4ba9f5a053
parent 3 Shark.h@48dc4ae894b0
child 10 8382173bfc35
permissions -rw-r--r--
OOP for Shader and ShaderProgram
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * ShaderShark
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2023 František Kučera (Frantovo.cz, GlobalCode.info)
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
#pragma once
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <string>
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
5
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    22
#include <epoxy/gl.h>
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    23
#include <epoxy/glx.h>
0
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
5
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    25
#include "Buffer.h"
0
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
5
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    27
class Shader {
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    28
public:
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    29
	class Impl;
0
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
5
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    31
	enum class Type : GLenum {
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    32
		FRAGMENT = GL_FRAGMENT_SHADER,
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    33
		VERTEX = GL_VERTEX_SHADER,
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    34
	};
0
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
5
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    36
	Shader(Type type, const Buffer& source, const std::string& fileName);
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    37
	virtual ~Shader();
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    38
	GLuint getId() const;
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    39
	const std::string getFileName() const;
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    40
	void update(const Buffer& source);
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    41
private:
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    42
	Impl* impl;
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    43
	Shader(const Shader&) = delete;
ee4ba9f5a053 OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    44
	Shader& operator=(const Shader&) = delete;
0
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
};