Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icg gl #27

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CFLAGS = -pedantic -std=c++11 -MMD -g3 -g\
-Wsign-promo -Wstrict-null-sentinel -Wswitch-default -Wundef\
-Wzero-as-null-pointer-constant -Wuseless-cast -Wnon-virtual-dtor
INCLUDES = -Iinclude -Itest `sdl2-config --cflags`
LIBS = `sdl2-config --libs` -lSDL2_image -lSDL2_ttf -lSDL2_mixer
LIBS = `sdl2-config --libs` -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lGLEW -lGL -lGLU

TARGET = $(LIB_DIR)/lib$(NAME).a

Expand Down
2,308 changes: 2,308 additions & 0 deletions docs/ijengine-ICG_GL.config

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions include/contextinfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef IJENGINE_CONTEXTINFO_H
#define IJENGINE_CONTEXTINFO_H



//ContextInfo.h
namespace ijengine{

//OpenGL versions
struct ContextInfo
{
int major_version, minor_version;
bool core;

ContextInfo()//default
{
major_version = 3;
minor_version = 3;
core = true;
}

ContextInfo(int majorversion, int minorversion, bool _core)
{
major_version = majorversion;
minor_version = minorversion;
core = _core;
}

};
}

#endif
10 changes: 10 additions & 0 deletions include/data_format.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef DATA_FORMAT_H
#define DATA_FORMAT_H

namespace ijengine {
typedef struct Matrix4f{
float m[4][4];
} matrix4f;
}

#endif
43 changes: 43 additions & 0 deletions include/framebufferinfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef IJENGINE_FRAMEINFO_H
#define IJENGINE_FRAMEINFO_H


#include <SDL2/SDL.h>
//ContextInfo.h
namespace ijengine{

class FramebufferInfo{

public:
unsigned int flags;
int rbuffer = 5;
int gbuffer = 5;
int bbuffer = 5;
int depthsize = 16;
int doublebuffersize = 1;

FramebufferInfo()
{
//default
flags = SDL_WINDOW_OPENGL;
rbuffer = 5;
gbuffer = 5;
bbuffer = 5;
depthsize = 16;
doublebuffersize = 1;
}

FramebufferInfo(int r_buffer_size, int g_buffer_size,int b_buffer_size, int depth_size, int double_buffer_size)
{
rbuffer = r_buffer_size;
gbuffer = g_buffer_size;
bbuffer = b_buffer_size;
depthsize = depth_size;
doublebuffersize = double_buffer_size;
}

//(optional)implement copy constructor and assignment operator
};
}

#endif
25 changes: 25 additions & 0 deletions include/gamemodels.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef GAME_MODELS_H
#define GAME_MODELS_H

#include <vector>
#include <map>
using namespace std;
namespace ijengine {
struct Model{
unsigned int vao;
vector<unsigned int> vbos;
Model(){}
};
class GameModels{
public:
GameModels();
~GameModels();
virtual CreateTriangleModel(const string& gameModelName);
virtual DeleteModel(const string& gameModelName);
unsigned int GetModel(const string& gameModelName);
private:
map<string,Model>GameModelList;
};
}

#endif
30 changes: 30 additions & 0 deletions include/glrenderer3d.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef IJENGINE_GLRENDERER3D_H
#define IJENGINE_GLRENDERER3D_H
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL2/SDL.h>
#include "renderer3d.h"

using namespace ijengine;


class GLrenderer3d : public Renderer3d {
public:
GLrenderer3d(SDL_Window *renderer3d);

// void draw(const Texture *texture, int x, int y);
// void draw_from_rectangle(const Texture *texture, const SDL_Rect source, const SDL_Rect destiny);

void drawTriangle(float x, float y, float z, float scale, int r, int g, int b);

void notifyBeginframe();
void notifyEndFrame();

SDL_Window * renderer3d() const;

private:
SDL_Window *m_renderer3d;
};

#endif
21 changes: 21 additions & 0 deletions include/libgl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef IJENGINE_GL_H
#define IJENGINE_GL_H

#include "libs.h"

namespace ijengine {

class LibGL : public Lib {
public:
~LibGL();

string name() const;
string version() const;

void config(const string& param, const string& value);
void init();
};

}

#endif
14 changes: 14 additions & 0 deletions include/math3D.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef MATH3D_H
#define MATH3D_H
#include "data_format.h"

namespace ijengine {

class Math3D {
public:
~Math3D() = default;
matrix4f Mult(matrix4f Left, matrix4f Right);
};
}

#endif
45 changes: 45 additions & 0 deletions include/mesh.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef MESH_H
#define MESH_H

#include <fstream>
#include <vector>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <list>
#include <math.h>

using namespace std;

namespace ijengine {
typedef struct Listas {
list<float> listaV;
list<float> listaVT;
list<double> listaVN;
list<string> listaF;
float Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
float deltaX, deltaY, deltaZ;
}Lista;

class Mesh
{
public:

Mesh();
~Mesh();

void carregarArquivo(string nomeArquivo);
void jogaParaListaV(float a, float b, float c);
void jogaParaListaVT(float a, float b);
void jogaParaListaVN(double a, double b, double c);
void jogaParaListaF(string a, string b, string c);
void normalizaVetor(double *a, double *b, double *c);
void centralizaObj();
void redimensionaObj();

Lista lista;
};
}

#endif
23 changes: 23 additions & 0 deletions include/model.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef IGAME_OBJECT_H
#define IGAME_OBJECT_H

#include <vector>
#include <iostream>
#include "GL/glew.h"
using namespace std;
namespace ijengine {
class Model:public IGameObject
{
public:
virtual ~IGameObject()=0;
virtual void Draw() = 0 ;
virtual Update() = 0;
virtual void SetProgram(GLuint shaderName) = 0;
virtual void Destroy();
virtual GLuint GetVAO() const = 0;
virtual const vector<GLuint>& GetVbos() const = 0;
};

}

#endif
15 changes: 15 additions & 0 deletions include/renderer3d.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef IJENGINE_RENDERER3D_H
#define IJENGINE_RENDERER3D_H

namespace ijengine {
class Renderer3d {
public:
virtual ~Renderer3d() = default;
// virtual void draw(const Texture *texture, int x, int y) = 0;
virtual void drawTriangle(float x, float y, float z, float scale, int r, int g, int b) = 0;
virtual void notifyBeginframe() = 0;
virtual void notifyEndFrame() = 0;
};
}

#endif
5 changes: 4 additions & 1 deletion include/sdl2window.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "window.h"
#include <SDL2/SDL.h>
#include "canvas.h"
#include "renderer3d.h"

namespace ijengine {

Expand All @@ -16,11 +17,13 @@ namespace ijengine {
int h() const;

Canvas * canvas() const;
Renderer3d * renderer3d() const;
private:
SDL_Window *m_window;
SDL_Renderer *m_renderer;
Canvas *m_canvas;

Renderer3d *m_renderer3d;

int m_w;
int m_h;
};
Expand Down
20 changes: 20 additions & 0 deletions include/sdl3Dvideo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef SDL3DVIDEO_H
#define SDL3DVIDEO_H

#include "video.h"
#include <SDL2/SDL.h>

namespace ijengine {

class SDL3DVideo : public Video {
public:
SDL3DVideo();
~SDL3DVideo();
void setAttribute();

Window * create_window(int w, int h);
};

}

#endif
34 changes: 34 additions & 0 deletions include/sdlglgame.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef SDLGL_GAME_H
#define SDLGL_GAME_H

#include "game.h"
#include "sdl2.h"
#include "libgl.h"
#include "sdl3Dvideo.h"
#include "glrenderer3d.h"
#include "window.h"
#include "shader_manager.h"
#include "transformation.h"

#include <memory>

using std::unique_ptr;
using std::shared_ptr;

namespace ijengine {

class SDLGLGame : public Game {
public:
SDLGLGame();

private:
unique_ptr<LibSDL2> m_lib_sdl;
unique_ptr<LibGL> m_lib_gl;
unique_ptr<SDL3DVideo> m_video;
unique_ptr<ShaderManager>m_shader;
shared_ptr<Window> m_window;
};

}

#endif
28 changes: 28 additions & 0 deletions include/shader_manager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef GLSHADERLOADER_H
#define GLSHADERLOADER_H

#include "shaderloader.h"
#include <iostream>
#include <map>
#include <GL/glew.h>
#include <GL/gl.h>

using namespace std;
namespace ijengine {

class ShaderManager {
public:
ShaderManager();
~ShaderManager();
void CreateProgram (char *ShaderName, char *VertexShaderFileName,
char *FragmentShaderFileName);
static const GLuint GetShader(const string& shaderName);
private:
string ReadShader (char *filename);
GLuint CreateShader(GLenum shaderType, string source, char *shaderName);
static map <string, GLuint> programs;
};

}

#endif
Loading