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

Mymaster enhanced icons #105

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8653dfc
Add xdg directory for linux desktop file and app icons.
wdaniau Jan 27, 2023
c92fbe0
Add a draw mode with a light source on top right
wdaniau Jan 27, 2023
97468c8
Added parameters to the shading program that are then send by Canvas …
wdaniau Jan 28, 2023
9131abc
Added a preference window for light shader customization.
wdaniau Jan 30, 2023
03ea3fc
Save shader preference window position
wdaniau Jan 30, 2023
8afbaee
Force C locale to force decimal point use in entries.
wdaniau Jan 30, 2023
339e8d9
Remove redefinition of closeEvent on ShaderLightPrefs
wdaniau Jan 31, 2023
784bac5
Save geometry of ShaderLightPrefs on resize
wdaniau Jan 31, 2023
be79c50
Cosmetic changes on ShaderLightPrefs
wdaniau Jan 31, 2023
e789305
Merge branch 'master' into willDevXDG
wdaniau Jan 31, 2023
b63fed1
Merge branch 'master' into willDevCustomizableShader
wdaniau Jan 31, 2023
2bbb68d
Merge branch 'master' into willDevXDG
wdaniau Feb 1, 2023
922c2d1
Merge branch 'master' into willDevCustomizableShader
wdaniau Feb 1, 2023
0dabb07
Merge branch 'willDevCustomizableShader' into mymaster
wdaniau Feb 1, 2023
936e262
Removed the preferences entry from the Draw menu.
wdaniau Feb 1, 2023
9c6a6c6
Removed the preferences entry from the Draw menu.
wdaniau Feb 1, 2023
d95ac38
Merge branch 'willDevCustomizableShader' into mymaster
wdaniau Feb 1, 2023
b61796c
Add fullscreen option in menu associated with key F11
wdaniau Feb 1, 2023
a08b58e
Merge branch 'willDevFullscreen' into mymaster
wdaniau Feb 1, 2023
25a12b8
Change some shortcuts. Add ability to cycle through shaders with up a…
wdaniau Feb 1, 2023
243eb3c
Merge branch 'master' into mymaster
wdaniau Feb 1, 2023
52b4901
Merge branch 'mymaster' into mymaster_cycle_shortcuts
wdaniau Feb 1, 2023
3da47ec
Regroup shortcuts on top of window.cpp file in static variables
wdaniau Feb 2, 2023
5a97d14
Added method to resize window for a given canvas size
wdaniau Feb 2, 2023
8a666f9
Write canvas size when drawing axes
wdaniau Feb 2, 2023
990b5e4
Add some icons
wdaniau Feb 3, 2023
25d540a
Add preferences icon
wdaniau Feb 4, 2023
58a3008
Add more icons and a toolbar.
wdaniau Feb 4, 2023
639bf4a
Add set viewport size menu.
wdaniau Feb 4, 2023
1cd7051
Correct problem on fullscreen_action state when restoring fullscreen …
wdaniau Feb 6, 2023
4e4f908
Add geometry shader calc_altitudes.glsl to compute distance from the …
wdaniau Feb 10, 2023
dccb65b
Add parameters, Qsettings keys, default values for optional wire in m…
wdaniau Feb 11, 2023
eaae8c4
Add getters and setters for new parameters
wdaniau Feb 11, 2023
b3e8445
Remove unused value in mesh_light.frag
wdaniau Feb 11, 2023
271e35f
Add wireframe parameters to shaderlightprefs
wdaniau Feb 11, 2023
19bd521
Add a fallback mode to glsl 120 if available glsl version is less tha…
wdaniau Feb 11, 2023
5eaba1f
change back in to varying for glsl 120 shaders
wdaniau Feb 11, 2023
9681916
Save hide menu state
wdaniau Feb 13, 2023
d316255
Use a regular expression instead of a simple toDouble to get glsl ver…
wdaniau Feb 14, 2023
6d0a2e0
Instead of tryng to guess glsl supported version, try to load the
wdaniau Feb 14, 2023
04ec17b
Add W shortcut to toggle use of wireframe on top of meshlight shader
wdaniau Feb 16, 2023
ac51204
Only toggle checkbox if enabled
wdaniau Feb 16, 2023
a236a6c
Process events to avoid warnings
wdaniau Feb 24, 2023
b627905
Reduce requirement on Qt version to 5.12 to be able to compile on ubu…
wdaniau Feb 24, 2023
f38a295
Merge branch 'master' into mymaster_enhanced_icons
wdaniau May 28, 2023
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
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ src/glmesh.cpp
src/loader.cpp
src/main.cpp
src/mesh.cpp
src/window.cpp)
src/window.cpp
src/shaderlightprefs.cpp)

#set project headers.
set(Project_Headers src/app.h
Expand All @@ -42,7 +43,8 @@ src/canvas.h
src/glmesh.h
src/loader.h
src/mesh.h
src/window.h)
src/window.h
src/shaderlightprefs.h)

#set project resources and icon resource
set(Project_Resources qt/qt.qrc gl/gl.qrc)
Expand All @@ -52,7 +54,7 @@ set(Icon_Resource exe/fstl.rc)
set(OpenGL_GL_PREFERENCE GLVND)

#find required packages.
find_package(Qt5 5.14 REQUIRED COMPONENTS Core Gui Widgets OpenGL)
find_package(Qt5 5.12 REQUIRED COMPONENTS Core Gui Widgets OpenGL)
find_package(OpenGL REQUIRED)
find_package(Threads REQUIRED)

Expand Down
64 changes: 64 additions & 0 deletions gl/calc_altitudes.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#version 330

layout (triangles) in;
layout (triangle_strip, max_vertices = 3) out;

out vec3 ec_pos;
noperspective out vec3 altitude;

uniform vec2 portSize;

void main() {
vec4 p0 = gl_in[0].gl_Position;
vec4 p1 = gl_in[1].gl_Position;
vec4 p2 = gl_in[2].gl_Position;

vec2 p0_f = p0.xy/p0.w;
vec2 p1_f = p1.xy/p1.w;
vec2 p2_f = p2.xy/p2.w;

// Altitude calculation :
// vp0p1 is the p0p1 vector
// vp0p2 is the p0p2 vector
// det(vp0p1,vp0p2) is the area of the parallelogram defined by the two vectors vp0p1 and vp0p2
// h0 is the altitude from p0 in the triangle (p0 p1 p2)
// h0 multiplied by p1p2 which is the length of vp0p1-vp0p2 is also the area of the parallelogram defined by the two vectors vp0p1 and vp0p2
// this leads to h0
//
// portSize is used to have an altitude in pixel
//

// Calculate h0 altitude from p0
vec2 vp0p1 = portSize*(p1_f-p0_f);
vec2 vp0p2 = portSize*(p2_f-p0_f);
float h0 = abs(determinant(mat2(vp0p1,vp0p2))) / length(vp0p1-vp0p2);
// release values
gl_Position = p0;
ec_pos = gl_Position.xyz;
altitude = vec3(h0*p0.w, 0.0, 0.0);
EmitVertex();

// calculate h1 altitude from p1
vec2 vp1p0 = portSize*(p0_f-p1_f);
vec2 vp1p2 = portSize*(p2_f-p1_f);
float h1 = abs(determinant(mat2(vp1p0,vp1p2))) / length(vp1p0-vp1p2);
// release values
gl_Position = p1;
ec_pos = gl_Position.xyz;
altitude = vec3(0.0, h1*p1.w, 0.0);
EmitVertex();

// calculate h2 altitude from p2
vec2 vp2p0 = portSize*(p0_f-p2_f);
vec2 vp2p1 = portSize*(p1_f-p2_f);
float h2 = abs(determinant(mat2(vp2p0,vp2p1))) / length(vp2p0-vp2p1);
// release values
gl_Position = p2;
ec_pos = gl_Position.xyz;
altitude = vec3(0.0, 0.0, h2*p2.w);
EmitVertex();

EndPrimitive();

}

5 changes: 4 additions & 1 deletion gl/gl.qrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<RCC>
<qresource prefix="gl/">
<qresource prefix="/gl">
<file>mesh.frag</file>
<file>mesh.vert</file>
<file>mesh_wireframe.frag</file>
<file>mesh_surfaceangle.frag</file>
<file>mesh_light.frag</file>
<file>quad.frag</file>
<file>quad.vert</file>
<file>colored_lines.frag</file>
<file>colored_lines.vert</file>
<file>sphere.stl</file>
<file>calc_altitudes.glsl</file>
<file>mesh_light_120.frag</file>
</qresource>
</RCC>
33 changes: 33 additions & 0 deletions gl/mesh_light.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#version 330

uniform float zoom;
uniform vec4 ambient_light_color;
uniform vec4 directive_light_color;
uniform vec3 directive_light_direction;
uniform bool useWire;
uniform vec3 wireColor;
uniform float wireWidth;

in vec3 ec_pos;
noperspective in vec3 altitude;

void main() {
// Normalize light direction
vec3 dir = normalize(directive_light_direction);

// normal vector
vec3 ec_normal = normalize(cross(dFdx(ec_pos), dFdy(ec_pos)));
ec_normal.z *= zoom;
ec_normal = normalize(ec_normal);


vec3 color = ambient_light_color.w * ambient_light_color.xyz + directive_light_color.w * dot(ec_normal,dir) * directive_light_color.xyz;

if (useWire) {
float d = min(min(altitude.x, altitude.y),altitude.z);
float mixVal = smoothstep(wireWidth-1.0, wireWidth+1.0,d);
color = mix(wireColor,color,mixVal);
}

gl_FragColor = vec4(color, 1.0);
}
23 changes: 23 additions & 0 deletions gl/mesh_light_120.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#version 120

uniform float zoom;
uniform vec4 ambient_light_color;
uniform vec4 directive_light_color;
uniform vec3 directive_light_direction;

varying vec3 ec_pos;

void main() {
// Normalize light direction
vec3 dir = normalize(directive_light_direction);

// normal vector
vec3 ec_normal = normalize(cross(dFdx(ec_pos), dFdy(ec_pos)));
ec_normal.z *= zoom;
ec_normal = normalize(ec_normal);


vec3 color = ambient_light_color.w * ambient_light_color.xyz + directive_light_color.w * dot(ec_normal,dir) * directive_light_color.xyz;

gl_FragColor = vec4(color, 1.0);
}
Binary file added qt/icons/auto_refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/axes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/document-open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/exit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/invert_zoom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/orthographic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/perspective.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/preferences-system.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/reset_rotation_on_load.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/resolution_1_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/sphere_shader1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/sphere_shader2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/sphere_shader3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/sphere_shader4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/view-fullscreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qt/icons/view-refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions qt/qt.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,22 @@
<qresource prefix="/qt">
<file>style.qss</file>
<file>icons/fstl_64x64.png</file>
<file>icons/sphere_shader1.png</file>
<file>icons/sphere_shader2.png</file>
<file>icons/sphere_shader3.png</file>
<file>icons/sphere_shader4.png</file>
<file>icons/document-open.png</file>
<file>icons/exit.png</file>
<file>icons/screenshot.png</file>
<file>icons/view-fullscreen.png</file>
<file>icons/view-refresh.png</file>
<file>icons/preferences-system.png</file>
<file>icons/axes.png</file>
<file>icons/orthographic.png</file>
<file>icons/perspective.png</file>
<file>icons/reset_rotation_on_load.png</file>
<file>icons/invert_zoom.png</file>
<file>icons/auto_refresh.png</file>
<file>icons/resolution_1_32.png</file>
</qresource>
</RCC>
Loading