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

Finished Abstracting Text Rendering, Working all OK

  • Loading branch information...
sckorpio committed Aug 14, 2019
commit b13289d3d548e9fd41e94bbe84e933fc0448a0d1
@@ -188,17 +188,19 @@ void LcCacherPainter::new_device_size(unsigned int width, unsigned int height)

void LcCacherPainter::font_size(double size, bool deviceCoords)
{

_cacher.Select_Font_Size(size,deviceCoords);
}

void LcCacherPainter::select_font_face(const char* text_val)
{

_cacher.Select_Font_Face(text_val);
}

void LcCacherPainter::text(const char* text_val)
{
_cacher.Set_New_Text_Entity();
_cacher.Set_New_Text_Entity();
_cacher.Select_Font_Value(text_val);

}

TextExtends LcCacherPainter::text_extends(const char* text_val)
@@ -37,20 +37,30 @@ namespace lc
class Cacher
{
private:
//----------------------------------FOR VERTEX DATA------------
std::vector< glm::vec4 > vertex_data; // for vertex data
std::vector<int> jumps;
std::vector< glm::vec4 > current_vertices; // for current shape(continous)

float path_distance; //distance(scalar) from start point to current
bool closed=false;
//--------------------------------------------

glm::mat4 model; //model matrix


//------------------------------------FOR DASH DATA--------------
float line_width;
std::vector<float> dashes_data; float dashes_sum=0; int dashes_size=0;
bool fill=false;
//--------------------------------------------


//--------------------------------------FOR TEXT DATA-----------------

std::string text_value;
std::string font_style;
float text_height;
bool no_text_magnify;

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

glm::mat4 model; //model matrix

GL_Entity* current_gl_entity;
GL_Pack* current_gl_pack;
@@ -114,6 +124,12 @@ class Cacher

void Select_Dashes(const double* dashes, const int num_dashes, double offset, bool scaled);


void Select_Font_Size(float size, bool deviceCoords);

void Select_Font_Face(const char* text_style);

void Select_Font_Value(const char* text_val);

//----------------------------gradient------------------------------

@@ -49,7 +49,7 @@ class GL_Entity


virtual void SetFont(Font_Book& fonts,const std::string& style) = 0;
virtual void AddTextData(glm::vec4 pos, const char* text_val , float font_size, bool retain) = 0;
virtual void AddTextData(glm::vec4 pos, std::string text_val , float font_size, bool retain) = 0;


virtual void FreeGPU() = 0;
@@ -71,7 +71,7 @@ class Gradient_Entity : public GL_Entity
void ApplyGradient(float* vertices,int size);

void SetFont(Font_Book& fonts,const std::string& style);
void AddTextData(glm::vec4 pos, const char* text_val , float font_size, bool retain);
void AddTextData(glm::vec4 pos, std::string text_val , float font_size, bool retain);

void FreeGPU();

@@ -57,19 +57,29 @@ struct context_att

class Renderer
{
private:
private:
//-------------------------------------FOR VERTEX DATA-----------------
std::vector< glm::vec4 > vertex_data; // for vertex data
std::vector<int> jumps;
std::vector< glm::vec4 > current_vertices; // for current shape(continous)

float path_distance; //distance(scalar) from start point to current
bool closed=false;
bool fill=false;

//--------------------------------------FOR DASH DATA---------------
float line_width;
std::vector<float> dashes_data; float dashes_sum=0; int dashes_size=0;
bool fill=false;

//--------------------------------------FOR TEXT DATA-----------------

Shaders_book shaders;
std::string text_value;
std::string font_style;
float text_height;
bool no_text_magnify;

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


glm::mat4 proj; //projection matrix
glm::mat4 projB;
@@ -78,6 +88,8 @@ class Renderer


std::stack < context_att > context_stack;

Shaders_book shaders;

Font_Book fonts;

@@ -157,7 +169,8 @@ class Renderer
void Add_New_Text_Entity();

void Add_Data_To_GL_Entity();


//---------------Functions to select attributes of entities------------
void Select_Fill();

void Select_Color(float R,float G,float B,float A);
@@ -166,6 +179,12 @@ class Renderer

void Select_Dashes(const double* dashes, const int num_dashes, double offset, bool scaled);

void Select_Font_Size(float size, bool deviceCoords);

void Select_Font_Face(const char* text_style);

void Select_Font_Value(const char* text_val);

//--------------------------for gradient entity----------------------------

void Add_Linear_Gradient(float x0,float y0,float x1,float y1);
@@ -176,6 +195,8 @@ class Renderer

void Render();

void Set_Default();

//-----------------------------rendering cached entities---------------

void Render_Cached_Entity(GL_Entity* entity);
@@ -70,7 +70,7 @@ class Shape_Entity : public GL_Entity
void ApplyGradient(float* vertices,int size);

void SetFont(Font_Book& fonts,const std::string& style);
void AddTextData(glm::vec4 pos, const char* text_val , float font_size, bool retain);
void AddTextData(glm::vec4 pos, std::string text_val , float font_size, bool retain);


void FreeGPU();
@@ -26,7 +26,6 @@ class Text_Entity : public GL_Entity

private:

float px=0.0f,py=0.0f;
std::string _text;
Shader* _shader; //Shader to be used
glm::mat4 _model; // model matrix
@@ -57,7 +56,7 @@ class Text_Entity : public GL_Entity


void SetFont(Font_Book& fonts,const std::string& style);
void AddTextData(glm::vec4 pos, const char* text_val , float font_size, bool retain);
void AddTextData(glm::vec4 pos, std::string text_val , float font_size, bool retain);


void FreeGPU();
@@ -154,8 +154,9 @@ void Cacher::Clear_Data()
fill=false;
path_distance=0.0f;
vertex_data.clear();
current_vertices.clear();
jumps.clear();
current_vertices.clear();
jumps.clear();

}


@@ -171,9 +172,9 @@ void Cacher::Clear_Data()
current_gl_entity->SetDashes(dashes_data,dashes_size,dashes_sum); // THIS Order
current_gl_entity->SetFillMode(fill); // Is Fixed!!!
current_gl_entity->SetType(shaders);
current_gl_entity->SetFont(fonts,"arial");
current_gl_entity->AddTextData(vertex_data[0], "kartik", 0, false);

current_gl_entity->SetFont(fonts,font_style);
current_gl_entity->AddTextData(vertex_data[0], text_value, text_height, no_text_magnify);
}

void Cacher::Select_Fill()
@@ -223,6 +224,23 @@ void Cacher::Clear_Data()
}
}

void Cacher::Select_Font_Size(float size, bool deviceCoords)
{
text_height=size;
no_text_magnify=deviceCoords;
}

void Cacher::Select_Font_Face(const char* text_style)
{
font_style=text_style;
}

void Cacher::Select_Font_Value(const char* text_val)
{
text_value=text_val;
}


//--------------------------gradient--------------------------------

void Cacher::Add_Linear_Gradient(float x0,float y0,float x1,float y1)
@@ -271,6 +289,11 @@ void Cacher::Clear_Data()
Clear_Data();

model=glm::mat4(1.0f);

font_style="arial";
text_value=" ";
text_height=12;
no_text_magnify=false;
}

void Cacher::Ready_For_Next_GL_Entity()
@@ -76,14 +76,14 @@ bool GL_Font::ReadyTTF(const std::string& path)

glGenerateMipmap(GL_TEXTURE_2D);

qDebug("%d [ %c ] = %d , %d , %d , %d , %d , %d",c,c,
/* qDebug("%d [ %c ] = %d , %d , %d , %d , %d , %d",c,c,
face->glyph->bitmap.width,
face->glyph->bitmap.rows,
face->glyph->bitmap_left,
face->glyph->bitmap_top,
face->glyph->advance.x,
face->glyph->advance.y);

*/
//Now saving coordinate data for the glypph

xpos = (float)(face->glyph->bitmap_left);
@@ -151,15 +151,10 @@ void GL_Font::RenderText(std::string text,glm::mat4 proj,glm::mat4 view,glm::mat
std::map<GLchar, Character>::iterator it;

text_shader->Bind();
text_shader->SetUniform4f("u_Color",1,1,0,1);
text_shader->SetUniform1i("u_Texture",0); // same slot of texture (optional)

glActiveTexture(GL_TEXTURE0);

//if no magnification is required
// view=glm::scale(view,glm::vec3(1.0f/view[2][2],1.0f/view[2][2],1.0f/view[2][2]) );


// Iterate through all characters
std::string::const_iterator c;
for (c = text.begin(); c != text.end(); c++)
@@ -197,7 +192,7 @@ void GL_Font::RenderText(std::string text,glm::mat4 proj,glm::mat4 view,glm::mat

}


text_shader->UnBind();


}
@@ -140,7 +140,7 @@ void Gradient_Entity::SetFont(Font_Book& fonts,const std::string& style)
// NO Need (Used by Tex_Entity)
}

void Gradient_Entity::AddTextData(glm::vec4 pos, const char* text_val , float font_size, bool retain)
void Gradient_Entity::AddTextData(glm::vec4 pos, std::string text_val , float font_size, bool retain)
{
// NO Need (Used by Text_Entity)
}
@@ -340,6 +340,7 @@ void Renderer::Clear_Data()
vertex_data.clear();
current_vertices.clear();
jumps.clear();

}

//----------------------------------------------------
@@ -354,8 +355,8 @@ void Renderer::Add_Data_To_GL_Entity()
current_gl_entity->SetDashes(dashes_data,dashes_size,dashes_sum); // THIS Order
current_gl_entity->SetFillMode(fill); // Is Fixed!!!
current_gl_entity->SetType(shaders);
current_gl_entity->SetFont(fonts,"arial");
current_gl_entity->AddTextData(vertex_data[0], "kartik", 0, false);
current_gl_entity->SetFont(fonts,font_style);
current_gl_entity->AddTextData(vertex_data[0], text_value, text_height, no_text_magnify);
}

void Renderer::Select_Fill()
@@ -416,8 +417,30 @@ void Renderer::Select_Color(float R,float G,float B,float A)
shaders.linepattern_shader->Bind();
shaders.linepattern_shader->SetUniform4f("u_Color",R,G,B,A);
shaders.linepattern_shader->UnBind();

shaders.text_shader->Bind();
shaders.text_shader->SetUniform4f("u_Color",R,G,B,A);
shaders.text_shader->UnBind();
}


void Renderer::Select_Font_Size(float size, bool deviceCoords)
{
text_height=size;
no_text_magnify=deviceCoords;
}

void Renderer::Select_Font_Face(const char* text_style)
{
font_style=text_style;
}

void Renderer::Select_Font_Value(const char* text_val)
{
text_value=text_val;
}


//---------------------gradient------------------------

void Renderer::Add_Linear_Gradient(float x0,float y0,float x1,float y1)
@@ -431,7 +454,16 @@ void Renderer::Add_Gradient_Color_Point(float R,float G,float B,float A)
}

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

void Renderer::Set_Default()
{
Clear_Data();

font_style="arial";
text_value=" ";
text_height=12;
no_text_magnify=false;
}

void Renderer::Render()
{
//load data to current entity
@@ -444,7 +476,7 @@ void Renderer::Render()
current_gl_entity->FreeGPU();

//Clear data in buffer(CPU)
Clear_Data();
Set_Default();

//Adding a new entity( Shape_entity )
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.