small changes
This commit is contained in:
parent
486b81d153
commit
a6c9a55fb9
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,2 +1,6 @@
|
|||||||
build*
|
build*
|
||||||
*.user
|
*.user
|
||||||
|
Makefile*
|
||||||
|
object_script.*
|
||||||
|
debug
|
||||||
|
release
|
2
lights.h
2
lights.h
@ -1,8 +1,8 @@
|
|||||||
#ifndef LIGHT_H
|
#ifndef LIGHT_H
|
||||||
#define LIGHT_H
|
#define LIGHT_H
|
||||||
|
|
||||||
#include <glm/vec3.hpp>
|
|
||||||
#include <glew/glew.h>
|
#include <glew/glew.h>
|
||||||
|
#include <glm/vec3.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define MAX_LIGHTS 4
|
#define MAX_LIGHTS 4
|
||||||
|
2
mesh.h
2
mesh.h
@ -1,9 +1,9 @@
|
|||||||
#ifndef MESH_H
|
#ifndef MESH_H
|
||||||
#define MESH_H
|
#define MESH_H
|
||||||
|
|
||||||
|
#include <glew/glew.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glew/glew.h>
|
|
||||||
|
|
||||||
class Mesh
|
class Mesh
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ Modules :
|
|||||||
|
|
||||||
- bump mapping module
|
- bump mapping module
|
||||||
|
|
||||||
|
- billboard module
|
||||||
- particles module
|
- particles module
|
||||||
|
|
||||||
- text/gui module
|
- text/gui module
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#ifndef PHONGMODULE_H
|
#ifndef PHONGMODULE_H
|
||||||
#define PHONGMODULE_H
|
#define PHONGMODULE_H
|
||||||
|
|
||||||
|
#include <glew/glew.h>
|
||||||
#include "basicmodule.h"
|
#include "basicmodule.h"
|
||||||
#include "phongmaterial.h"
|
#include "phongmaterial.h"
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
#include <glew/glew.h>
|
|
||||||
|
|
||||||
class Lights;
|
class Lights;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ ResourceBase::DataBase<Mesh> ResourceBase::meshes;
|
|||||||
ResourceBase::DataBase<Material> ResourceBase::materials;
|
ResourceBase::DataBase<Material> ResourceBase::materials;
|
||||||
ResourceBase::DataBase<Shader> ResourceBase::shaders;
|
ResourceBase::DataBase<Shader> ResourceBase::shaders;
|
||||||
ResourceBase::DataBase<Entity> ResourceBase::entities;
|
ResourceBase::DataBase<Entity> ResourceBase::entities;
|
||||||
|
ResourceBase::DataBase<Lights> ResourceBase::lights;
|
||||||
|
|
||||||
void ResourceBase::setTexture(const std::string &textureName, Texture* myTexture)
|
void ResourceBase::setTexture(const std::string &textureName, Texture* myTexture)
|
||||||
{
|
{
|
||||||
@ -31,6 +32,11 @@ void ResourceBase::setEntity(const std::string &entityName, Entity* myEntity)
|
|||||||
entities.add(entityName, myEntity);
|
entities.add(entityName, myEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourceBase::setLights(const std::string &lightsName, Lights* myLights)
|
||||||
|
{
|
||||||
|
lights.add(lightsName, myLights);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Texture* ResourceBase::getTexture(const std::string &textureName)
|
Texture* ResourceBase::getTexture(const std::string &textureName)
|
||||||
{
|
{
|
||||||
@ -57,4 +63,8 @@ Entity* ResourceBase::getEntity(const std::string &entityName)
|
|||||||
return entities.get(entityName);
|
return entities.get(entityName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Lights* ResourceBase::getLights(const std::string &lightsName)
|
||||||
|
{
|
||||||
|
return lights.get(lightsName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ class Mesh;
|
|||||||
class Material;
|
class Material;
|
||||||
class Shader;
|
class Shader;
|
||||||
class Entity;
|
class Entity;
|
||||||
|
class Lights;
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -19,12 +20,14 @@ public:
|
|||||||
static void setMaterial(const std::string &materialName, Material* myMaterial);
|
static void setMaterial(const std::string &materialName, Material* myMaterial);
|
||||||
static void setShader(const std::string &shaderName, Shader* myShader);
|
static void setShader(const std::string &shaderName, Shader* myShader);
|
||||||
static void setEntity(const std::string &entityName, Entity* myEntity);
|
static void setEntity(const std::string &entityName, Entity* myEntity);
|
||||||
|
static void setLights(const std::string &lightsName, Lights* myLights);
|
||||||
|
|
||||||
static Texture* getTexture(const std::string &textureName);
|
static Texture* getTexture(const std::string &textureName);
|
||||||
static Mesh* getMesh(const std::string &meshName);
|
static Mesh* getMesh(const std::string &meshName);
|
||||||
static Material* getMaterial(const std::string &materialName);
|
static Material* getMaterial(const std::string &materialName);
|
||||||
static Shader* getShader(const std::string &shaderName);
|
static Shader* getShader(const std::string &shaderName);
|
||||||
static Entity* getEntity(const std::string &entityName);
|
static Entity* getEntity(const std::string &entityName);
|
||||||
|
static Lights* getLights(const std::string &lightsName);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -54,6 +57,7 @@ protected:
|
|||||||
static DataBase<Material> materials;
|
static DataBase<Material> materials;
|
||||||
static DataBase<Shader> shaders;
|
static DataBase<Shader> shaders;
|
||||||
static DataBase<Entity> entities;
|
static DataBase<Entity> entities;
|
||||||
|
static DataBase<Lights> lights;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RESOURCEBASE_H
|
#endif // RESOURCEBASE_H
|
||||||
|
52
shader.cpp
52
shader.cpp
@ -1,5 +1,5 @@
|
|||||||
#include "shader.h"
|
|
||||||
#include <glew/glew.h>
|
#include <glew/glew.h>
|
||||||
|
#include "shader.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "glassert.h"
|
#include "glassert.h"
|
||||||
#include <glm/ext.hpp>
|
#include <glm/ext.hpp>
|
||||||
@ -35,6 +35,41 @@ Shader::Shader(const std::string &vertexSource, const std::string &fragmentSourc
|
|||||||
glAssert(glDeleteShader(fragmentShaderId));
|
glAssert(glDeleteShader(fragmentShaderId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Shader::Shader(const std::string &vertexSource, const std::string &geometrySource, const std::string &fragmentSource)
|
||||||
|
{
|
||||||
|
program = glAssert(glCreateProgram());
|
||||||
|
|
||||||
|
GLuint vertexShaderId = createShader(vertexSource, GL_VERTEX_SHADER);
|
||||||
|
GLuint geometryShaderId = createShader(geometrySource, GL_GEOMETRY_SHADER);
|
||||||
|
GLuint fragmentShaderId = createShader(fragmentSource, GL_FRAGMENT_SHADER);
|
||||||
|
|
||||||
|
glAssert(glAttachShader(program, vertexShaderId));
|
||||||
|
glAssert(glAttachShader(program, geometryShaderId));
|
||||||
|
glAssert(glAttachShader(program, fragmentShaderId));
|
||||||
|
|
||||||
|
glAssert(glBindAttribLocation(program, 0, "inPosition"));
|
||||||
|
glAssert(glBindAttribLocation(program, 1, "inNormal"));
|
||||||
|
glAssert(glBindAttribLocation(program, 2, "inTexCoord"));
|
||||||
|
|
||||||
|
glAssert(glLinkProgram(program));
|
||||||
|
|
||||||
|
// check errors
|
||||||
|
GLint linked;
|
||||||
|
glAssert(glGetProgramiv(program, GL_LINK_STATUS, &linked));
|
||||||
|
if (!linked) {
|
||||||
|
std::cerr << "Program not linked" << std::endl;
|
||||||
|
printProgramInfoLog(program);
|
||||||
|
program = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
glAssert(glDetachShader(program, vertexShaderId));
|
||||||
|
glAssert(glDetachShader(program, geometryShaderId));
|
||||||
|
glAssert(glDetachShader(program, fragmentShaderId));
|
||||||
|
glAssert(glDeleteShader(vertexShaderId));
|
||||||
|
glAssert(glDeleteShader(geometryShaderId));
|
||||||
|
glAssert(glDeleteShader(fragmentShaderId));
|
||||||
|
}
|
||||||
|
|
||||||
Shader::~Shader()
|
Shader::~Shader()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
@ -55,7 +90,20 @@ GLuint Shader::createShader(const std::string &source, GLenum shaderType)
|
|||||||
GLint compiled;
|
GLint compiled;
|
||||||
glAssert(glGetShaderiv(shaderId, GL_COMPILE_STATUS, &compiled));
|
glAssert(glGetShaderiv(shaderId, GL_COMPILE_STATUS, &compiled));
|
||||||
if (!compiled) {
|
if (!compiled) {
|
||||||
std::cerr << (shaderType == GL_VERTEX_SHADER ? "Vertex" : "Fragment") << "shader not compiled : " << std::endl;
|
std::string type_str;
|
||||||
|
switch(shaderType)
|
||||||
|
{
|
||||||
|
case GL_VERTEX_SHADER:
|
||||||
|
type_str = "Vertex";
|
||||||
|
break;
|
||||||
|
case GL_GEOMETRY_SHADER:
|
||||||
|
type_str = "Geometry";
|
||||||
|
break;
|
||||||
|
case GL_FRAGMENT_SHADER:
|
||||||
|
type_str = "Fragment";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
std::cerr << type_str << " shader not compiled : " << std::endl;
|
||||||
printShaderInfoLog(shaderId);
|
printShaderInfoLog(shaderId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
1
shader.h
1
shader.h
@ -14,6 +14,7 @@ class Shader
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Shader(const std::string &vertexSource, const std::string &fragmentSource);
|
Shader(const std::string &vertexSource, const std::string &fragmentSource);
|
||||||
|
Shader(const std::string &vertexSource, const std::string &geometrySource, const std::string &fragmentSource);
|
||||||
~Shader();
|
~Shader();
|
||||||
GLuint getLocation(std::string attribName);
|
GLuint getLocation(std::string attribName);
|
||||||
|
|
||||||
|
@ -4,20 +4,24 @@
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core
|
QT += core gui opengl widgets
|
||||||
|
|
||||||
TARGET = sparrowRenderer
|
|
||||||
|
Debug:TARGET = sparrowRendererDebug
|
||||||
|
Release:TARGET = sparrowRenderer
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += c++11
|
CONFIG += c++11 staticlib
|
||||||
|
|
||||||
INCLUDEPATH += ../cpp_dependencies/include
|
INCLUDEPATH += ../cpp_dependencies/include
|
||||||
win32 {
|
win32 {
|
||||||
LIBS += -L../../cpp_dependencies/lib/win32
|
DESTDIR = $$PWD/../cpp_dependencies/lib/win32
|
||||||
LIBS += -lopengl32 -lglew32 -lglu32
|
LIBS += -L../../cpp_dependencies/lib/win32
|
||||||
|
LIBS += -lglew32 -lopengl32 -lglu32
|
||||||
}
|
}
|
||||||
unix {
|
unix {
|
||||||
LIBS += -L../../cpp_dependencies/lib/linux
|
DESTDIR = $$PWD/../cpp_dependencies/lib/linux
|
||||||
LIBS += -lGL -lGLEW -lGLU
|
LIBS += -L../../cpp_dependencies/lib/linux
|
||||||
|
LIBS += -lGL -lGLEW -lGLU
|
||||||
}
|
}
|
||||||
|
|
||||||
SOURCES += shader.cpp \
|
SOURCES += shader.cpp \
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "sparrowrenderer.h"
|
|
||||||
#include <glew/glew.h>
|
#include <glew/glew.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "sparrowrenderer.h"
|
||||||
#include "glassert.h"
|
#include "glassert.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "basicmodule.h"
|
#include "basicmodule.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user