Build world model in engine

This commit is contained in:
2016-06-17 00:14:58 +10:00
parent b75009d03e
commit 5cebf9ad0d
19 changed files with 294 additions and 177 deletions
+6 -7
View File
@@ -1,13 +1,13 @@
#ifndef DENGINE_ASSET_MANAGER_H
#define DENGINE_ASSET_MANAGER_H
#include <Dengine\Common.h>
#include <Dengine\Texture.h>
#include <Dengine\Shader.h>
#include <Dengine/Common.h>
#include <Dengine/Shader.h>
#include <Dengine/Texture.h>
#include <iostream>
#include <map>
#include <string>
#include <iostream>
namespace Dengine
{
@@ -23,9 +23,8 @@ public:
/* Shaders */
static Shader *getShader(const std::string name);
static const i32 loadShaderFiles(const std::string vertexPath,
const std::string fragmentPath,
const std::string name);
static const i32 loadShaderFiles(const std::string vertexPath, const std::string fragmentPath,
const std::string name);
};
}
#endif
+25
View File
@@ -0,0 +1,25 @@
#ifndef DENGINE_ENTITY_H
#define DENGINE_ENTITY_H
#include <Dengine/Common.h>
#include <Dengine/Texture.h>
#include <glm/glm.hpp>
namespace Dengine
{
class Entity
{
public:
Entity();
Entity(const glm::vec2 pos, const Texture *tex);
Entity(const glm::vec2 pos, const glm::vec2 size, const Texture *tex);
Entity(const glm::vec2 pos, const std::string texName);
~Entity();
glm::vec2 pos;
glm::vec2 size;
const Texture *tex;
};
}
#endif
+1 -1
View File
@@ -5,8 +5,8 @@
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <string>
#include <iostream>
#include <string>
inline GLenum glCheckError_(const char *file, int line)
{
+4 -4
View File
@@ -2,8 +2,10 @@
#define DENGINE_RENDERER_H
#include <Dengine/Common.h>
#include <Dengine/Texture.h>
#include <Dengine/Entity.h>
#include <Dengine/Shader.h>
#include <Dengine/Texture.h>
#include <GLM/glm.hpp>
namespace Dengine
@@ -14,9 +16,7 @@ public:
Renderer(Shader *shader);
~Renderer();
void drawSprite(const Texture *texture, glm::vec2 position,
glm::vec2 size = glm::vec2(10, 10), GLfloat rotate = 0.0f,
glm::vec3 color = glm::vec3(1.0f));
void drawEntity(Entity *entity, GLfloat rotate = 0.0f, glm::vec3 color = glm::vec3(1.0f));
private:
Shader *shader;
+1 -2
View File
@@ -18,8 +18,7 @@ public:
Shader();
~Shader();
const i32 loadProgram(const GLuint vertexShader,
const GLuint fragmentShader);
const i32 loadProgram(const GLuint vertexShader, const GLuint fragmentShader);
void uniformSet1i(const GLchar *name, const GLuint data);
void uniformSetMat4fv(const GLchar *name, const glm::mat4 data);
+4 -5
View File
@@ -1,8 +1,8 @@
#ifndef DENGINE_TEXTURE_H
#define DENGINE_TEXTURE_H
#include <Dengine/OpenGL.h>
#include <Dengine/Common.h>
#include <Dengine/OpenGL.h>
namespace Dengine
{
@@ -13,7 +13,7 @@ public:
Texture();
// Generates texture from image data
void generate(const GLuint width, const GLuint height,
void generate(const GLuint width, const GLuint height, const GLint bytesPerPixel,
const u8 *const image);
// Binds the texture as the current active GL_TEXTURE_2D texture object
@@ -37,14 +37,13 @@ private:
GLuint imageFormat; // Format of loaded image
// Texture configuration
GLuint wrapS; // Wrapping mode on S axis
GLuint wrapT; // Wrapping mode on T axis
GLuint wrapS; // Wrapping mode on S axis
GLuint wrapT; // Wrapping mode on T axis
// Filtering mode if texture pixels < screen pixels
GLuint filterMinification;
// Filtering mode if texture pixels > screen pixels
GLuint filterMagnification;
};
}
#endif
@@ -1,27 +1,40 @@
#ifndef BREAKOUT_GAME_H
#define BREAKOUT_GAME_H
#ifndef WORLDTRAVELLER_GAME_H
#define WORLDTRAVELLER_GAME_H
#include <Dengine/OpenGL.h>
#include <Dengine/Common.h>
#include <Dengine/Renderer.h>
#include <Dengine/Shader.h>
#include <Dengine/AssetManager.h>
#include <Dengine/Entity.h>
namespace Breakout
namespace WorldTraveller
{
GLOBAL_VAR const i32 NUM_KEYS = 1024;
GLOBAL_VAR const i32 METERS_TO_PIXEL = 100;
enum GameState
enum Cardinal
{
GAME_ACTIVE,
GAME_MENU,
GAME_WIN
cardinal_north = 0,
cardinal_west = 1,
cardinal_south = 2,
cardinal_east = 3,
cardinal_num,
cardinal_null
};
enum State
{
state_active,
state_menu,
state_win
};
class Game
{
public:
GameState state;
State state;
GLboolean keys[NUM_KEYS];
i32 width, height;
@@ -30,12 +43,12 @@ public:
void init();
void processInput(const f32 dt);
void update(const f32 dt);
void render();
private:
Dengine::Shader *shader;
Dengine::Renderer *renderer;
Dengine::Entity hero;
};
}