Texture.h
author František Kučera <franta-hg@frantovo.cz>
Tue, 02 Jan 2024 17:50:43 +0100
branchv_0
changeset 32 74111f4e67cd
parent 29 69903e30b00d
permissions -rw-r--r--
Added tag v0.1 for changeset 22827574296e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * ShaderShark
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2023 František Kučera (Frantovo.cz, GlobalCode.info)
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
262828ae9682 OOP for Texture
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
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
#pragma once
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <string>
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
#include "Buffer.h"
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
class Texture {
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
public:
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
	/**
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
	 * @param width horizontal pixel count
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
	 * @param height vertical pixel count
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
	 * @param img RGBA pixels, 8 bits per channel, size == width * height * 4
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
	 * @param fileName not used by this class, just stored for others
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
	 */
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
	Texture(int width, int height, const Buffer& img,
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
			const std::string& fileName);
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
	virtual ~Texture();
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
	GLuint getId() const;
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
	const std::string getFileName() const;
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
	int getWidth() const;
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
	int getHeight() const;
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
	GLfloat getRatio() const;
28
4cbd9c0beb4c pass texture xattr 'shader-shark.texture.scale' to the shaders as 'uTextureScale' + update variable locations on each shader reload
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
    41
	GLfloat getScale() const;
4cbd9c0beb4c pass texture xattr 'shader-shark.texture.scale' to the shaders as 'uTextureScale' + update variable locations on each shader reload
František Kučera <franta-hg@frantovo.cz>
parents: 19
diff changeset
    42
	void setScale(GLfloat scale);
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
	void update(int width, int height, const Buffer& img);
29
69903e30b00d add Texture::bind() method
František Kučera <franta-hg@frantovo.cz>
parents: 28
diff changeset
    44
	void bind();
19
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
private:
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
	class Impl;
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
	Impl* impl;
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
	Texture(const Texture&) = delete;
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
	Texture& operator=(const Texture&) = delete;
262828ae9682 OOP for Texture
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
};