- Finished Buffer Object Implementation

- Implemented Vertex Array Object
 - Began Texture Implementation
This commit is contained in:
2025-08-03 13:49:33 -04:00
parent 9dc9ed4ed1
commit ff4d6efedc
5 changed files with 236 additions and 11 deletions

View File

@@ -0,0 +1,86 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_RENDERERS_OPENGL_LIB_TEXTURE_H
#define FENNEC_RENDERERS_OPENGL_LIB_TEXTURE_H
#include <fennec/renderers/opengl/lib/fwd.h>
#include <fennec/renderers/opengl/lib/enum.h>
namespace fennec
{
namespace gl
{
template<GLenum TypeV, GLint FormatV, GLboolean ImmutableV>
class texture {
public:
static constexpr GLenum type = TypeV;
static constexpr GLint format = FormatV;
static constexpr bool immutable = ImmutableV;
static constexpr bool sampled = TypeV == TEX_2D_MS or TypeV == TEX_2D_MS_V;
static constexpr bool is_rect = TypeV == TEX_RECT;
static constexpr bool is_buffered = TypeV == TEX_BUFFER;
static constexpr bool is_2d = sampled or is_rect or TypeV == TEX_2D or TypeV == TEX_2D_V;
static constexpr bool is_1d = TypeV == TEX_1D or TypeV == TEX_1D_V;
static constexpr bool is_array = TypeV == TEX_1D_V or TypeV == TEX_2D_V or TypeV == TEX_2D_MS_V or TypeV == TEX_CUBEMAP_V;
static constexpr bool has_mipmaps = not(sampled or is_rect or is_buffered);
texture(GLsizei width, GLint mips, void* data) requires is_1d and not is_array
: _handle(NULL)
, _width(width), _height(1), _depth(1)
, _samples(1)
, _mips(mips) {
glGenTextures(1, &_handle);
}
texture(GLsizei width, GLsizei height, GLint mips) requires is_2d and not (is_array or sampled) or (is_1d and is_array)
: _handle(NULL)
, _width(width), _height(height), _depth(1)
, _samples(1)
, _mips(mips) {
}
void start() {
glBindTexture(type, _handle);
}
void end() {
glBindTexture(type, NULL);
}
void bind(GLint i) {
glActiveTexture(GL_TEXTURE0 + i);
start();
}
private:
GLuint _handle;
GLsizei _width;
GLsizei _height;
GLsizei _depth;
GLsizei _samples;
GLint _mips;
};
}
}
#endif // FENNEC_RENDERERS_OPENGL_TEXTURE_H