“Getting the right basis before jumping into action”
And that’s the reason for the successful finish of Phase 1st. Mentors help was amazing during this period. We got the correct base for the project and finished most of the basic but the major things which will decide the implementation of upcoming challenges.
The things completed till now were–
–> Basic painter following the predefined layout (outermost layer)
–> A strong Renderer class ( which is the core and everything will moves around this)
–> Viewport System ( User-Device-User coordinate system)
–> Matrix Manipulation ( involves a lot of matrix and vector math )
–> Caching mechanism (Crucial part which now enable us high performant rendering )
–> Gradient Rendering
“Feeling the graphics pipeline ;)”
Although even before starting the project i had used and planned the Modern OpenGL way for implementation.
But As the Phase 2 period started i figured out that a lot more simple and familiar functionalities are been “replaced with nothing”!!! And actually it required implementing things using completely scratch and following graphics pipeline.
And here starts the experience of deprecated functionalities of such a low level API. It became more understandable the difference of Legacy and Modern OpenGL and how computer graphics actually works.
“Seriously…Rendering Lines is not easy :)”
Simpler the things seems , the complex they are.
It was all going good, rendered lines seems very nice until i came across ThickLines.
So basically in LibreCAD we have standard linewidths whose thickness can/cannot get enlarged on zooming (its up to the requirement ). Ultimately we needed lines rendered with variable thickness. Now Initially i have planned to simply implement this using the given functions in OpenGL API (glLineWidth().. which is deprecated ).
I discussed alot with the mentors about the strategy( and seriously their guidance at this moment decided the later implementations )
It required almost revamping the codebase at both the CPU and GPU side. On CPU side the GL_LINES/GL_LINE_STRIP/GL_LINE_LOOP were replaced by the GL_LINE_STRIP_ADJACENCY and changing the way renderer works for this.
Then passing the data to GPU , then to Vertex Shader to Geometry Shader to finally Fragment Shader. Basically using 2 triangles for a line, using mitter joints (which required geometry math in shader) and finally it worked.
“Dash – Gap – Dash — — — “
Linepatterns or dash patterns. Here also initially i thought it would be easy and i can use glLineStipple()..( Ah..which again is depreciated : | and actually it can’t render every possible pattern which is the requirement of our LibreCAD , here the user can even generate its own linepattern )
Now this was even more harder , the patterns has any possible combination and that too seamless. So what i did was storing the path length of the point along with their coordinates , passing data from CPU to GPU ( vertex shader -> Geometry shader -> Fragment shader , using the texel coordinates for deciding the dash and gaps and Finally abstracting it properly.
And Yes there can be multiple ways but this suits best for LibreCAD (atleast till now), there are another method(s) like 1D Texture etc.( But the codebase is designed to support those methods and it will only require changes in GPU side or shaders)
“How it looks now”
Overall the 2nd Phase was much more challenging and required more research work before actually coding it. For even simple changes it required a lot revamping code.
Regarding mentors , Armin helped me a lot in understanding the requirements and explaining stuff( which he does very well 🙂 and is also very concerned about the standards.
And Florian is always there for guiding me like always (and is quite friendly and cool 😉 ). For example during this phase we encountered a strange bug(on different graphic cards ) It was almost unreachable for me but he helped me in fixing that step by step, almost a week went into it but finally we got more robust and refined code!!!
The next work to be done is Text Rendering and finishing the remaining painters methods and much more. My college re-opened , getting less time as compared to i was giving till now but will try to manage.