mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-10 02:23:23 +08:00
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
/*******************************************************************
|
|
** 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 |