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:
37
src/7.in_practice/3.2d_game/0.full_source/sprite_renderer.h
Normal file
37
src/7.in_practice/3.2d_game/0.full_source/sprite_renderer.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*******************************************************************
|
||||
** 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 SPRITE_RENDERER_H
|
||||
#define SPRITE_RENDERER_H
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#include "texture.h"
|
||||
#include "shader.h"
|
||||
|
||||
|
||||
class SpriteRenderer
|
||||
{
|
||||
public:
|
||||
// Constructor (inits shaders/shapes)
|
||||
SpriteRenderer(Shader &shader);
|
||||
// Destructor
|
||||
~SpriteRenderer();
|
||||
// Renders a defined quad textured with given sprite
|
||||
void DrawSprite(Texture2D &texture, glm::vec2 position, glm::vec2 size = glm::vec2(10.0f, 10.0f), float rotate = 0.0f, glm::vec3 color = glm::vec3(1.0f));
|
||||
private:
|
||||
// Render state
|
||||
Shader shader;
|
||||
unsigned int quadVAO;
|
||||
// Initializes and configures the quad's buffer and vertex attributes
|
||||
void initRenderData();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user