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

OpenGL Rendering Implemented #229

Merged
merged 103 commits into from Aug 30, 2019
Merged
Changes from 1 commit
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
fc884a3
first commit
sckorpio Mar 31, 2019
2739080
grid implemented
sckorpio May 23, 2019
f410803
tempentities added
sckorpio May 31, 2019
b39de56
grid clipping resolved
sckorpio Jun 2, 2019
7c564d7
panning with correct y direction temporary
sckorpio Jun 2, 2019
a589542
final correct viewport all OK
sckorpio Jun 2, 2019
8af6bcc
Context saving and restoring OK
sckorpio Jun 5, 2019
928639f
Roatation matrix implemented OK
sckorpio Jun 6, 2019
da330e5
Simplified CTM matrix implemented OK
sckorpio Jun 11, 2019
5c28e68
correct paperbackground OK
sckorpio Jun 15, 2019
660c6bd
correct entity storage OK
sckorpio Jun 15, 2019
0ca1731
conflict resolved
sckorpio Jun 15, 2019
7f7959a
All_OK_before_caching
sckorpio Jun 15, 2019
3faa94f
caching started
sckorpio Jun 21, 2019
4a402df
caching fixed , basic caching all ok
sckorpio Jun 21, 2019
2abd75f
code cleaned
sckorpio Jun 24, 2019
d46dfb0
syncing
sckorpio Jun 25, 2019
a680cfa
storage fix after sync
sckorpio Jun 25, 2019
b7a075f
final merge
sckorpio Jun 25, 2019
deb96e9
document canvas conflict resolved
sckorpio Jun 25, 2019
11f0028
draw() logic moved to entity class
sckorpio Jun 30, 2019
1ece39b
removed some unnecessary functions
sckorpio Jun 30, 2019
dec9c97
Base class for entities implemented
sckorpio Jun 30, 2019
3024896
gradient implented, temporary without math
sckorpio Jul 1, 2019
fd9c35f
gradient completed with correct math
sckorpio Jul 1, 2019
f0b2787
Finally correct coordinate system
sckorpio Jul 2, 2019
8fddf9a
Update color_vertex_shader.shader
sckorpio Jul 7, 2019
b75f17f
Update color_vertex_shader.shader
sckorpio Jul 7, 2019
69497c8
few files changed
sckorpio Jul 7, 2019
122e7ec
trying to fix strange issue with gradient launch
sckorpio Jul 7, 2019
e5b0c78
using delete instead calling destructor
sckorpio Jul 13, 2019
45bc324
Added OpenGL debug methods
sckorpio Jul 16, 2019
f59f952
version 330 shaders added
sckorpio Jul 16, 2019
2793f5a
removed gl_Frag Color from shaders
sckorpio Jul 16, 2019
3605a20
testing with GL_TRIANGLE_FAN
sckorpio Jul 17, 2019
897df62
seperated freeing gpu call from destructor
sckorpio Jul 18, 2019
0b66448
gl_pack freed after deletion
sckorpio Jul 18, 2019
6b44b40
shaders book implemented
sckorpio Jul 24, 2019
15b4516
Code revamped now it runs using GL_LINE_STRIP_ADJACENCY
sckorpio Jul 25, 2019
a2f3fe6
all Ok Just before Thickline Implementation
sckorpio Jul 26, 2019
f34c929
Shader class updated to support Geometry Shader & a new thickline sha…
sckorpio Jul 27, 2019
c680b7e
LineWidth / Thicklines with Mitter joints Implemented
sckorpio Jul 28, 2019
90e51f0
all OK before linepatterns
sckorpio Jul 28, 2019
e9949e2
thickline shader fixed for NVIDIA
sckorpio Jul 28, 2019
c4f4c9c
LinePattern Implemented(Constant)
sckorpio Jul 31, 2019
cdab488
all OK before variable Dash Pattern from UI
sckorpio Jul 31, 2019
7a8d468
variable line pattern(from UI) implemented
sckorpio Aug 2, 2019
16d4d31
Enabled transparency
sckorpio Aug 2, 2019
27f63c7
fixed a minor segmentation fault because of a garbage value of uninit…
sckorpio Aug 2, 2019
2e409bb
merged with main repo LibreCAD_3 (2nd time)
sckorpio Aug 4, 2019
81dc618
merged 3rd time
sckorpio Aug 7, 2019
665a3a3
Freetype integrated, GL_Font and Font_Book implemented , working OK
sckorpio Aug 13, 2019
35d318d
Text Entity Implemented , Working OK
sckorpio Aug 13, 2019
8482643
Removed some Deprecated OpenGL calls related to Textures
sckorpio Aug 13, 2019
8cf5c9d
Testing Entities with Font, magnified/non-magnified Working OK
sckorpio Aug 13, 2019
b13289d
Finished Abstracting Text Rendering, Working all OK
sckorpio Aug 14, 2019
15af822
quadratic & cubic bezier curve implemented
sckorpio Aug 17, 2019
ed75cb0
Ellipse Implemented, Working OK
sckorpio Aug 18, 2019
6e2be81
Saving Absolute paths of Resources at compilation implemented ,workin…
sckorpio Aug 19, 2019
0bb36d4
codebase cleaned according to LC3 syntax rules
sckorpio Aug 20, 2019
e79e414
shader/font paths settings implemented by ModuleSettings.h
sckorpio Aug 21, 2019
f7dd03c
Single instance of ModuleSetting used for resources path
sckorpio Aug 21, 2019
b3f0ebd
Unused/Dead Codes Removed
sckorpio Aug 21, 2019
18bc5a9
Removed Debug calls from lcUI
sckorpio Aug 21, 2019
ad4874f
Removed Debug calls from lcviewernoqt
sckorpio Aug 21, 2019
65f57d1
Removed Debug calls from viewer::opengl
sckorpio Aug 21, 2019
a2d09ec
Final Code Cleaned, working all OK
sckorpio Aug 21, 2019
f2ab7b7
Extended Character Rendering Implemented
sckorpio Aug 22, 2019
0182dbe
Text Extends Implemented
sckorpio Aug 22, 2019
470c15c
Fixed the arc rendering
sckorpio Aug 22, 2019
fd5f0ec
Final commit , working all OK
sckorpio Aug 22, 2019
93428a9
Final Fix with arcs
sckorpio Aug 22, 2019
6283656
Updated Travis.yml
sckorpio Aug 23, 2019
9f20f71
Update .travis.yml
sckorpio Aug 23, 2019
3b98072
Reset Unnecessary Changed files
sckorpio Aug 23, 2019
56abf9d
Folder names changed from UPPERCASE to lowercase
sckorpio Aug 23, 2019
8296ee7
Indentation Cleaned!!!
sckorpio Aug 23, 2019
ce9b26c
Indentation Cleaned 2!!!
sckorpio Aug 23, 2019
110685e
Indentation Cleaned 3 !!!
sckorpio Aug 23, 2019
2beee65
Added QT_QTOPENGL_INCLUDE_DIR in lcUI CmakeList.txt
sckorpio Aug 23, 2019
f5b7326
Added QT_QTOPENGL_INCLUDE_DIR in lcviewernoqt CmakeList.txt
sckorpio Aug 23, 2019
2f3bb65
findPackage(Qt5OpenGL) added in CmakeList.txt
sckorpio Aug 23, 2019
3b5dbc0
update lcUI CmakeList.txt
sckorpio Aug 23, 2019
d28856d
update lcUI CmakeList.txt -2
sckorpio Aug 23, 2019
842b0f5
resolving codefactor issues
sckorpio Aug 23, 2019
cc34e50
resolving codefactor issues -2
sckorpio Aug 23, 2019
d8ad2a4
MERGE- Updated Travis Ubuntu Version
sckorpio Aug 24, 2019
5982c98
update travis.yml
sckorpio Aug 24, 2019
8dd70b1
update travis.yml-2
sckorpio Aug 24, 2019
743cc96
Fixing for Rendering test
sckorpio Aug 24, 2019
69d3d92
ViewerSettings Name Changed
sckorpio Aug 24, 2019
64a9e7b
Shifted QOpenGLContext from lcviewernoqt to lcUI
sckorpio Aug 24, 2019
b9e88d7
Cleaned CMakeLists.txt of lcUI and lcviewernoqt
sckorpio Aug 24, 2019
40ab208
resolving codefactor issues -3
sckorpio Aug 24, 2019
dbe5df6
resolving codefactor issues -4
sckorpio Aug 24, 2019
a0f216a
used codecvt instead of QString in GL_Font
sckorpio Aug 24, 2019
4b43e5f
Fixed Ellipse 4th Quadrant issue
sckorpio Aug 25, 2019
4836630
Removing Code duplication in renderer & cacher- Abstraction
sckorpio Aug 26, 2019
14f5331
Removed Code duplication from render & cacher openglpainters - Abstra…
sckorpio Aug 27, 2019
e894d28
Added new default font
sckorpio Aug 27, 2019
4798f4a
Used LC LOGGER
sckorpio Aug 27, 2019
c4e2af6
setted opengl major and minor version
sckorpio Aug 28, 2019
c91ca47
Set Opengl version 3.0
sckorpio Aug 29, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Base class for entities implemented

  • Loading branch information...
sckorpio committed Jun 30, 2019
commit dec9c97214825929ab49a4fa6791282bf8ae8563
@@ -65,7 +65,7 @@ drawitems/lcvinsert.cpp
${PROJECT_SOURCE_DIR}/painters/opengl/SOURCES/vertexbuffer.cpp
This conversation was marked as resolved by sckorpio

This comment has been minimized.

Copy link
@feragon

feragon Aug 22, 2019

Member

It's better to not keep a SOURCES folder here, and keep the .h and .cpp in opengl folder.
I don't see a problem for RES folder, but keep names lowercase please.

Don't forget to use a good IDE to do this in few minutes

${PROJECT_SOURCE_DIR}/painters/opengl/SOURCES/indexbuffer.cpp
${PROJECT_SOURCE_DIR}/painters/opengl/SOURCES/vertexarray.cpp
${PROJECT_SOURCE_DIR}/painters/opengl/SOURCES/gl_entity.cpp
${PROJECT_SOURCE_DIR}/painters/opengl/SOURCES/shape_entity.cpp
${PROJECT_SOURCE_DIR}/painters/opengl/SOURCES/gl_pack.cpp
${PROJECT_SOURCE_DIR}/painters/opengl/SOURCES/cacher.cpp
${PROJECT_SOURCE_DIR}/painters/opengl/SOURCES/renderer.cpp
@@ -127,6 +127,7 @@ ${PROJECT_SOURCE_DIR}/painters/opengl/HEADERS/indexbuffer.h
${PROJECT_SOURCE_DIR}/painters/opengl/HEADERS/vertexarray.h
${PROJECT_SOURCE_DIR}/painters/opengl/HEADERS/vertexbufferlayout.h
${PROJECT_SOURCE_DIR}/painters/opengl/HEADERS/gl_entity.h
${PROJECT_SOURCE_DIR}/painters/opengl/HEADERS/shape_entity.h
${PROJECT_SOURCE_DIR}/painters/opengl/HEADERS/gl_pack.h
${PROJECT_SOURCE_DIR}/painters/opengl/HEADERS/cacher.h
${PROJECT_SOURCE_DIR}/painters/opengl/HEADERS/renderer.h
@@ -14,6 +14,7 @@
#include <iterator>
#include <map>

#include "shape_entity.h"
#include "gl_entity.h"
#include "gl_pack.h"
#include "shader.h"
@@ -7,10 +7,7 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

#include "vertexbuffer.h"
#include "indexbuffer.h"
#include "vertexarray.h"
#include "vertexbufferlayout.h"

#include "shader.h"


@@ -24,38 +21,26 @@ namespace lc

class GL_Entity
{
private:
VertexArray VAO;
VertexBuffer VBO;
IndexBuffer IBO; // GPU Buffer Objects (vertex data)

glm::mat4 _model; // model matrix

GLenum _render_mode; //mode for render
GLenum _fill_mode; //mode for filling
float _linewidth; //linewidth

Shader* _basic_shader;
public:
GL_Entity();
~GL_Entity();
void LoadData(float* vertices,int size,unsigned int* indices,int count);
void ClearData();
virtual ~GL_Entity() = default;
virtual void LoadData(float* vertices,int size,unsigned int* indices,int count) = 0;
virtual void ClearData() = 0;

void Bind();
void UnBind();
virtual void Bind() = 0;
virtual void UnBind() = 0;

void SetShader(Shader* shader);
void SetModelMatrix(glm::mat4 model);
void SetRenderMode(GLenum rendermode);
void SetFillMode(GLenum fillmode);
void SetLineWidth(float width);
void SetColor(float R,float G,float B,float A);
virtual void SetShader(Shader* shader) = 0;
virtual void SetModelMatrix(glm::mat4 model) = 0;
virtual void SetRenderMode(GLenum rendermode) = 0;
virtual void SetFillMode(GLenum fillmode) = 0;
virtual void SetLineWidth(float width) = 0;
virtual void SetColor(float R,float G,float B,float A) = 0;


void Delete();
virtual void Delete() = 0;

void Draw(glm::mat4 proj,glm::mat4 view);
virtual void Draw(glm::mat4 proj,glm::mat4 view) = 0;
};


@@ -13,6 +13,7 @@
#include <vector>

#include "gl_entity.h"
#include "shape_entity.h"
#include "shader.h"
#include "gl_pack.h"
#include "cacher.h"
@@ -121,7 +122,7 @@ class Renderer

void Use_GL_Entity(unsigned int id);

void Add_New_GL_Entity();
void Add_New_Shape_Entity();

void Add_Vertex(float x,float y,float z=0.0f);

@@ -0,0 +1,69 @@
#ifndef SHAPE_ENTITY_H
#define SHAPE_ENTITY_H
#include <GL/glew.h>
#include <GL/gl.h>

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

#include "vertexbuffer.h"
#include "indexbuffer.h"
#include "vertexarray.h"
#include "vertexbufferlayout.h"
#include "shader.h"
#include "gl_entity.h"


namespace lc
{
namespace viewer
{
namespace opengl
{


class Shape_Entity : public GL_Entity
{
private:
VertexArray VAO;
VertexBuffer VBO;
IndexBuffer IBO; // GPU Buffer Objects (vertex data)

glm::mat4 _model; // model matrix

GLenum _render_mode; //mode for render
GLenum _fill_mode; //mode for filling
float _linewidth; //linewidth

Shader* _basic_shader;
public:
Shape_Entity();
~Shape_Entity();
void LoadData(float* vertices,int size,unsigned int* indices,int count);
void ClearData();

void Bind();
void UnBind();

void SetShader(Shader* shader);
void SetModelMatrix(glm::mat4 model);
void SetRenderMode(GLenum rendermode);
void SetFillMode(GLenum fillmode);
void SetLineWidth(float width);
void SetColor(float R,float G,float B,float A);


void Delete();

void Draw(glm::mat4 proj,glm::mat4 view);
};



}
}

}

#endif // SHAPE_ENTITY_H
@@ -131,7 +131,7 @@ using namespace lc::viewer::opengl;

void Cacher::Set_New_GL_Entity()
{
current_gl_entity = new GL_Entity();
current_gl_entity = new Shape_Entity();
current_gl_entity->SetShader(basic_shader);
}

@@ -189,12 +189,12 @@ void Renderer::Restore()

//------------------------------------------

void Renderer::Add_New_GL_Entity()
void Renderer::Add_New_Shape_Entity()
{
if(current_gl_entity!=NULL)
current_gl_entity->Delete();

current_gl_entity = new GL_Entity();
current_gl_entity = new Shape_Entity();
current_gl_entity->SetShader(&basic_shader);
}

@@ -253,7 +253,7 @@ void Renderer::Render()
Clear_Data();

//Adding a new entity( Shape_entity )
Add_New_GL_Entity();
Add_New_Shape_Entity();

}

@@ -1,21 +1,21 @@
#include "gl_entity.h"
#include "shape_entity.h"

using namespace lc::viewer::opengl;

GL_Entity :: GL_Entity()
Shape_Entity :: Shape_Entity()
{
_fill_mode=GL_LINE;
_render_mode=GL_LINES;
_linewidth=1.0f;
_model=glm::mat4(1.0f);
}

GL_Entity::~GL_Entity()
Shape_Entity::~Shape_Entity()
{

}

void GL_Entity::LoadData(float* vertices,int size,unsigned int* indices,int count)
void Shape_Entity::LoadData(float* vertices,int size,unsigned int* indices,int count)
{

//--------VAO-----------
@@ -36,7 +36,7 @@ void GL_Entity::LoadData(float* vertices,int size,unsigned int* indices,int coun

}

void GL_Entity::Bind()
void Shape_Entity::Bind()
{
//---------bind--------------
VBO.Bind();
@@ -45,65 +45,65 @@ void GL_Entity::Bind()

}

void GL_Entity::UnBind()
void Shape_Entity::UnBind()
{
//---------unbind--------------
VBO.UnBind();
VAO.UnBind();
IBO.UnBind();
}

void GL_Entity::ClearData()
void Shape_Entity::ClearData()
{

}

void GL_Entity::SetShader(Shader* shader)
void Shape_Entity::SetShader(Shader* shader)
{
_basic_shader=shader;
}

void GL_Entity::SetModelMatrix(glm::mat4 model)
void Shape_Entity::SetModelMatrix(glm::mat4 model)
{
_model=model;
}

void GL_Entity::SetRenderMode(GLenum rendermode)
void Shape_Entity::SetRenderMode(GLenum rendermode)
{
_render_mode=rendermode;
}

void GL_Entity::SetFillMode(GLenum fillmode)
void Shape_Entity::SetFillMode(GLenum fillmode)
{
_fill_mode=fillmode;
}

void GL_Entity::SetLineWidth(float width)
void Shape_Entity::SetLineWidth(float width)
{
_linewidth=width;
}


void GL_Entity::SetColor(float R,float G,float B,float A)
void Shape_Entity::SetColor(float R,float G,float B,float A)
{
_basic_shader->Bind();
_basic_shader->SetUniform4f("u_Color",R,G,B,A);
_basic_shader->UnBind();
}


void GL_Entity::Delete()
void Shape_Entity::Delete()
{

VBO.~VertexBuffer();
IBO.~IndexBuffer();
VAO.~VertexArray();

this->~GL_Entity();
this->~Shape_Entity();
}


void GL_Entity::Draw(glm::mat4 _proj,glm::mat4 _view)
void Shape_Entity::Draw(glm::mat4 _proj,glm::mat4 _view)
{
//Set the Fill Mode
glPolygonMode(GL_FRONT_AND_BACK, _fill_mode);
@@ -17,7 +17,7 @@ LcOpenGLPainter::LcOpenGLPainter(unsigned int width, unsigned int height)
if(CC!=0)
{
ReadyShaderProgram();
RND.Add_New_GL_Entity();
RND.Add_New_Shape_Entity();
}


ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.