mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-11 02:53:23 +08:00
Breakout changes for revision 'Rendering Sprites'
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/*******************************************************************
|
||||
** 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.
|
||||
******************************************************************/
|
||||
#include "game.h"
|
||||
#include "resource_manager.h"
|
||||
#include "sprite_renderer.h"
|
||||
|
||||
|
||||
// Game-related State data
|
||||
SpriteRenderer *Renderer;
|
||||
|
||||
|
||||
Game::Game(unsigned int width, unsigned int height)
|
||||
: State(GAME_MENU), Keys(), KeysProcessed(), Width(width), Height(height)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Game::~Game()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Game::Init()
|
||||
{
|
||||
// load shaders
|
||||
ResourceManager::LoadShader("shaders/sprite.vs", "shaders/sprite.frag", nullptr, "sprite");
|
||||
// configure shaders
|
||||
glm::mat4 projection = glm::ortho(0.0f, static_cast<float>(this->Width),
|
||||
static_cast<float>(this->Height), 0.0f, -1.0f, 1.0f);
|
||||
ResourceManager::GetShader("sprite").Use().SetInteger("image", 0);
|
||||
ResourceManager::GetShader("sprite").SetMatrix4("projection", projection);
|
||||
// set render-specific controls
|
||||
Renderer = new SpriteRenderer(ResourceManager::GetShader("sprite"));
|
||||
// load textures
|
||||
ResourceManager::LoadTexture("textures/awesomeface.png", true, "face");
|
||||
}
|
||||
|
||||
void Game::Update(float dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Game::ProcessInput(float dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Game::Render()
|
||||
{
|
||||
Renderer->DrawSprite(ResourceManager::GetTexture("face"), glm::vec2(200.0f, 200.0f), glm::vec2(300.0f, 400.0f), 45.0f, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
}
|
||||
Reference in New Issue
Block a user