finished refactoring, sparrowrenderer compiles
This commit is contained in:
parent
209cec4c7c
commit
48e1c4afdc
4974
src/glew.c
4974
src/glew.c
File diff suppressed because it is too large
Load Diff
42
src/glew.h
42
src/glew.h
@ -19700,6 +19700,11 @@ VERSION_MINOR 13
|
||||
VERSION_MICRO 0
|
||||
*/
|
||||
|
||||
#ifdef RENDER_DEBUG
|
||||
#include <stdio.h>
|
||||
#define GLEW_STR(x) #x
|
||||
#endif /* RENDER_DEBUG */
|
||||
|
||||
/* API */
|
||||
#ifdef GLEW_MX
|
||||
|
||||
@ -19712,12 +19717,39 @@ GLEWAPI GLboolean GLEWAPIENTRY glewContextIsSupported (const GLEWContext *ctx, c
|
||||
#define glewIsExtensionSupported(x) glewIsSupported(x)
|
||||
|
||||
#define GLEW_GET_VAR(x) (*(const GLboolean*)&(glewGetContext()->x))
|
||||
|
||||
#ifdef RENDER_DEBUG
|
||||
|
||||
#ifdef _WIN32
|
||||
#define GLEW_GET_FUN(code) \
|
||||
glewGetContext()->code; \
|
||||
{\
|
||||
GLuint err = glGetError(); \
|
||||
if(err != GL_NO_ERROR){ \
|
||||
fprintf(stderr, "OpenGL Error (%s : %d, %s) : %s (%d)\n", __FILE__, __LINE__, GLEW_STR(code), gluErrorString(err), err);\
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define GLEW_GET_FUN(code) \
|
||||
code; \
|
||||
{\
|
||||
GLuint err = glGetError(); \
|
||||
if(err != GL_NO_ERROR){ \
|
||||
fprintf(stderr, "OpenGL Error (%s : %d, %s) : %s (%d)\n", __FILE__, __LINE__, GLEW_STR(code), gluErrorString(err), err);\
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* RENDER_DEBUG */
|
||||
|
||||
#ifdef _WIN32
|
||||
# define GLEW_GET_FUN(x) glewGetContext()->x
|
||||
#else
|
||||
# define GLEW_GET_FUN(x) x
|
||||
#endif
|
||||
|
||||
#endif /* RENDER_DEBUG */
|
||||
|
||||
#else /* GLEW_MX */
|
||||
|
||||
GLEWAPI GLenum GLEWAPIENTRY glewInit (void);
|
||||
@ -19726,21 +19758,19 @@ GLEWAPI GLboolean GLEWAPIENTRY glewIsSupported (const char *name);
|
||||
|
||||
#define GLEW_GET_VAR(x) (*(const GLboolean*)&x)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef RENDER_DEBUG
|
||||
#define STR(x) #x
|
||||
|
||||
#define GLEW_GET_FUN(code) \
|
||||
code; \
|
||||
{\
|
||||
GLuint err = glGetError(); \
|
||||
if(err != GL_NO_ERROR){ \
|
||||
fprintf(stderr, "OpenGL Error (%s : %d, %s) : %s (%d)\n", __FILE__, __LINE__, STR(code), gluErrorString(err), err);\
|
||||
fprintf(stderr, "OpenGL Error (%s : %d, %s) : %s (%d)\n", __FILE__, __LINE__, GLEW_STR(code), gluErrorString(err), err);\
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#else /* RENDER_DEBUG */
|
||||
#define GLEW_GET_FUN(code) code
|
||||
#endif
|
||||
#endif /* RENDER_DEBUG */
|
||||
|
||||
#endif /* GLEW_MX */
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define PARAMETRIC_MESH_H
|
||||
|
||||
#include "mesh.h"
|
||||
#include <cmath>
|
||||
|
||||
class MeshGenerator
|
||||
{
|
||||
|
@ -3,32 +3,22 @@
|
||||
#include <set>
|
||||
|
||||
|
||||
std::vector<unsigned int> Scene::getMeshTypes()
|
||||
void Scene::getMeshTypes(std::vector<unsigned int> &meshTypes)
|
||||
{
|
||||
std::set<unsigned int> typesSet;
|
||||
std::vector<unsigned int> types;
|
||||
for(SceneIterator<GeometryNode*>* geometryIt = scene->getGeometry();
|
||||
geometryIt->isValid(); geometryIt->next())
|
||||
{
|
||||
for(SceneIterator<GeometryNode*>* geometryIt = getGeometry(); geometryIt->isValid(); geometryIt->next())
|
||||
typesSet.emplace(geometryIt->getItem()->mesh->getFlags());
|
||||
}
|
||||
for(unsigned int type : typesSet)
|
||||
types.push_back(type);
|
||||
return types;
|
||||
meshTypes.push_back(type);
|
||||
}
|
||||
|
||||
std::vector<unsigned int> Scene::getLightTypes()
|
||||
void Scene::getLightTypes(std::vector<unsigned int> &lightTypes)
|
||||
{
|
||||
std::set<unsigned int> typesSet;
|
||||
std::vector<unsigned int> types;
|
||||
for(SceneIterator<Light*>* lightIt = scene->getLights();
|
||||
lightIt->isValid(); lightIt->next())
|
||||
{
|
||||
typesSet.emplace(getFlags(geometryIt->getItem()));
|
||||
}
|
||||
for(SceneIterator<Light*>* lightIt = getLights(); lightIt->isValid(); lightIt->next())
|
||||
typesSet.emplace(lightIt->getItem()->getFlags());
|
||||
for(unsigned int type : typesSet)
|
||||
types.push_back(type);
|
||||
return types;
|
||||
lightTypes.push_back(type);
|
||||
}
|
||||
|
||||
BasicScene::~BasicScene()
|
||||
@ -38,7 +28,7 @@ BasicScene::~BasicScene()
|
||||
|
||||
void BasicScene::addMesh(GeometryNode* gn)
|
||||
{
|
||||
geometry->push_back(gn);
|
||||
geometry.push_back(gn);
|
||||
}
|
||||
|
||||
GeometryNode* BasicScene::addMesh(Mesh* m, glm::mat4 transform)
|
||||
|
@ -43,8 +43,8 @@ public:
|
||||
virtual SceneIterator<Light*>* getLights() = 0;
|
||||
virtual SceneIterator<GeometryNode*>* getGeometry() = 0;
|
||||
|
||||
virtual void getMeshTypes(std::vector<unsigned int> &meshTypes);
|
||||
virtual void getLightTypes(std::vector<unsigned int> &lightTypes);
|
||||
void getMeshTypes(std::vector<unsigned int> &meshTypes);
|
||||
void getLightTypes(std::vector<unsigned int> &lightTypes);
|
||||
};
|
||||
|
||||
// A basic implementation :
|
||||
|
@ -31,20 +31,33 @@ void ShaderSource::setSource(const char *source, SourceType type)
|
||||
|
||||
Shader* ShaderSource::compile(unsigned int geomFlags, unsigned int lightFlags)
|
||||
{
|
||||
std::string header = "#version 330 core";
|
||||
std::vector<const char*> defines;
|
||||
|
||||
for(int i=0; i<Mesh::NB_FLAGS; ++i)
|
||||
{
|
||||
if((geomFlags >> i) & 0x00000001)
|
||||
header += "\n#define "+std::string(Mesh::flagStr[i]);
|
||||
defines.push_back(Mesh::flagStr[i]);
|
||||
}
|
||||
|
||||
for(int i=0; i<Light::NB_FLAGS; ++i)
|
||||
{
|
||||
if((lightFlags >> i) & 0x00000001)
|
||||
header += "\n#define "+std::string(Light::flagStr[i]);
|
||||
defines.push_back(Light::flagStr[i]);
|
||||
}
|
||||
|
||||
|
||||
return compile(defines);
|
||||
}
|
||||
|
||||
Shader* ShaderSource::compile(const std::vector<const char*> &defines)
|
||||
{
|
||||
std::string header = "#version 330 core";
|
||||
|
||||
for(int i=0; i<Light::NB_FLAGS; ++i)
|
||||
{
|
||||
for(const char* def : defines)
|
||||
header += "\n#define "+std::string(def);
|
||||
}
|
||||
|
||||
header += "\n#line 1\n";
|
||||
|
||||
if(sources[VERTEX] == NULL || sources[FRAGMENT] == NULL)
|
||||
@ -60,4 +73,3 @@ Shader* ShaderSource::compile(unsigned int geomFlags, unsigned int lightFlags)
|
||||
else
|
||||
return new Shader(compiledSources[VERTEX], compiledSources[FRAGMENT]);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define SHADERSOURCE_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Shader;
|
||||
|
||||
@ -23,6 +24,8 @@ public:
|
||||
|
||||
Shader* compile(unsigned int geomFlags, unsigned int lightFlags);
|
||||
|
||||
Shader* compile(const std::vector<const char*> &defines);
|
||||
|
||||
private:
|
||||
std::string* sources[NB_TYPES];
|
||||
};
|
||||
|
@ -46,10 +46,11 @@ TextureBlur::~TextureBlur()
|
||||
|
||||
void TextureBlur::setSource(ShaderSource* source)
|
||||
{
|
||||
const char* horizontalDefine = "HORIZONTAL_BLUR";
|
||||
horizontal = source->compile(1, &horizontalDefine);
|
||||
const char* verticalDefine = "VERTICAL_BLUR";
|
||||
vertical = source->compile(1, &verticalDefine);
|
||||
std::vector<const char*> defines(1);
|
||||
defines[0] = "HORIZONTAL_BLUR";
|
||||
horizontal = source->compile(defines);
|
||||
defines[0] = "VERTICAL_BLUR";
|
||||
vertical = source->compile(defines);
|
||||
uniformLocations[H_SAMPLER] = horizontal->getLocation("colorSampler");
|
||||
uniformLocations[H_WIDTH] = horizontal->getLocation("width");
|
||||
uniformLocations[H_HEIGHT] = horizontal->getLocation("height");
|
||||
|
Loading…
x
Reference in New Issue
Block a user