mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-11 02:53:23 +08:00
Add full source code of the finished (and revised code) Breakout example. Not set up for cross-platform compilation as it has irrKlang and FreeType dependency, but at least source code is available online (and can be referenced from Breakout chapters).
This commit is contained in:
39
src/7.in_practice/3.2d_game/0.full_source/texture.h
Normal file
39
src/7.in_practice/3.2d_game/0.full_source/texture.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*******************************************************************
|
||||
** This code is part of Breakout.
|
||||
**
|
||||
** Breakout is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the CC BY 4.0 license as published by
|
||||
** Creative Commons, either version 4 of the License, or (at your
|
||||
** option) any later version.
|
||||
******************************************************************/
|
||||
#ifndef TEXTURE_H
|
||||
#define TEXTURE_H
|
||||
|
||||
#include <glad/glad.h>
|
||||
|
||||
// Texture2D is able to store and configure a texture in OpenGL.
|
||||
// It also hosts utility functions for easy management.
|
||||
class Texture2D
|
||||
{
|
||||
public:
|
||||
// holds the ID of the texture object, used for all texture operations to reference to this particlar texture
|
||||
unsigned int ID;
|
||||
// texture image dimensions
|
||||
unsigned int Width, Height; // width and height of loaded image in pixels
|
||||
// texture Format
|
||||
unsigned int Internal_Format; // format of texture object
|
||||
unsigned int Image_Format; // format of loaded image
|
||||
// texture configuration
|
||||
unsigned int Wrap_S; // wrapping mode on S axis
|
||||
unsigned int Wrap_T; // wrapping mode on T axis
|
||||
unsigned int Filter_Min; // filtering mode if texture pixels < screen pixels
|
||||
unsigned int Filter_Max; // filtering mode if texture pixels > screen pixels
|
||||
// constructor (sets default texture modes)
|
||||
Texture2D();
|
||||
// generates texture from image data
|
||||
void Generate(unsigned int width, unsigned int height, unsigned char* data);
|
||||
// binds the texture as the current active GL_TEXTURE_2D texture object
|
||||
void Bind() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user