Skip to content

Commit

Permalink
v.1.7 WiP - Updated to v4.0 WiP: vGizmo3D, ImGuIZMOquat and vgMath
Browse files Browse the repository at this point in the history
  • Loading branch information
BrutPitt committed Feb 3, 2025
1 parent e51c9ec commit 5f256bb
Show file tree
Hide file tree
Showing 34 changed files with 2,241 additions and 9,734 deletions.
17 changes: 10 additions & 7 deletions Shaders/oglAxesFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
// Copyright (c) 2018-2024 Michele Morrone
// All rights reserved.
//
// https://michelemorrone.eu - https://glchaosp.com - https://brutpitt.com
// https://michelemorrone.eu - https://brutpitt.com
//
// X: https://x.com/BrutPitt - GitHub: https://github.com/BrutPitt
//
// direct mail: brutpitt(at)gmail.com - me(at)michelemorrone.eu
//
// This software is distributed under the terms of the BSD 2-Clause license
//------------------------------------------------------------------------------
#line 13 //#version dynamically inserted
#line 14

out vec4 color;
uniform vec3 zoomF;
uniform vec3 light_position;


#ifdef GL_ES
Expand All @@ -33,9 +34,9 @@ in vsOut {
const float ambientInt = 0.3;
const float specularInt = 0.5; // vec4(1.0, 1.0, 1.0, 1.0);\n"
const float shininessExp = 10.f;
vec3 light_position = vec3(10.0f, 10.0f, 5.0f);
float far = 10.0;
float near = .0001;
const float near = .001;
const float far = 10.0;


float LinearizeDepth(float depth)
{
Expand All @@ -50,10 +51,12 @@ void main()
vec3 halfVec = normalize(lightDir + normalize(vsWorldPos));
float diffuse = max(0.0, dot(vsNormal, lightDir));
float specular = pow(max(0.0, dot(vsNormal, halfVec)), shininessExp);
//gl_FragDepth = .z;

// draw in [-1, 1]
gl_FragDepth = LinearizeDepth(vsPos.z);
// draw in zNDC [-1, 1]
float depth = LinearizeDepth(vsPos.z);

color = vsColor * ambientInt + vsColor * diffuse + vec4(specular * specularInt) /*- distAtten*/;

gl_FragDepth = depth;
}
11 changes: 6 additions & 5 deletions Shaders/oglAxesVert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
// Copyright (c) 2018-2024 Michele Morrone
// All rights reserved.
//
// https://michelemorrone.eu - https://glchaosp.com - https://brutpitt.com
// https://michelemorrone.eu - https://brutpitt.com
//
// X: https://x.com/BrutPitt - GitHub: https://github.com/BrutPitt
//
// direct mail: brutpitt(at)gmail.com - me(at)michelemorrone.eu
//
// This software is distributed under the terms of the BSD 2-Clause license
//------------------------------------------------------------------------------
#line 13 //#version dynamically inserted

#line 14
layout (location = 1) in vec3 vPos;
layout (location = 2) in vec3 normal;

// cant use direct location... for EMS and webgl
// I cant use direct location... for EMS and webgl
//layout (location = 4) uniform mat4 pMat;
//layout (location = 5) uniform mat4 mvMat;
//layout (location = 6) uniform mat4 zoomF;
Expand All @@ -31,7 +30,7 @@ out gl_PerVertex
};
#endif

// cant use blocks... for EMS and webgl
// I cant use blocks... for EMS and webgl

#ifdef GL_ES
out vec4 vsColor;
Expand All @@ -51,6 +50,7 @@ const vec4 blue = vec4(0.10, 0.10, 0.70, 1.0);
const vec4 green = vec4(0.10, 0.70, 0.10, 1.0);
const vec4 red = vec4(0.70, 0.10, 0.10, 1.0);


//fast 90' rotation around fixzed axis
vec3 rotOnX(vec3 v) { return vec3(v.x, v.z, -v.y); }
vec3 rotOnY(vec3 v) { return vec3(v.z, v.y, -v.x); }
Expand All @@ -70,4 +70,5 @@ void main(void)
vsNormal = normalize(mat3(mvMat) * newNorm);

gl_Position = position;
//gl_Position =
}
9 changes: 5 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ set(SRC "${CMAKE_SOURCE_DIR}/src")
${SRC}/tools/mmFBO.h
${SRC}/tools/transforms.h
${SRC}/tools/vgMath.h
${SRC}/tools/vgConfig.h
${SRC}/tools/vGizmo.h
${SRC}/tools/vgMath_config.h
${SRC}/tools/vGizmo3D.h
${SRC}/ui/uiAttractorsDlg.cpp
${SRC}/ui/uiMainDlg.cpp
${SRC}/ui/uiMainDlg.h
Expand Down Expand Up @@ -282,9 +282,9 @@ if(BUILD_wglChAoSP OR BUILD_wglChAoSP_lowres)
#endif()
include_directories(${SRC})
include_directories(${SRC}/tools)
include_directories(${SRC}/tools/gizmos)
include_directories(${SRC}/libs)
include_directories(${SRC}/libs)
#add also environment include
include_directories(${SRC}/../../Shaders) #JetBrains: to show files, located in a different dir, into project toolWindow
#include_directories(AFTER $ENV{INCLUDE})

# -o ${PROJECT_NAME}.html -> CMAKE_EXECUTABLE_SUFFIX .html .bc, .js (default), etc
Expand Down Expand Up @@ -474,6 +474,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${SRC}/libs)
#target_include_directories(${PROJECT_NAME} PUBLIC $ENV{INCLUDE})

add_definitions(-DVGM_USES_TEMPLATE -DGLFW_INCLUDE_NONE -DIMGUI_IMPL_OPENGL_LOADER_GLAD -DGLM_ENABLE_EXPERIMENTAL -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS)
target_compile_definitions(${PROJECT_NAME} PUBLIC -D_GLIBCXX_USE_CXX11_ABI=0)

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(WIN32)
Expand Down
2 changes: 1 addition & 1 deletion src/src/ShadersClasses.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2018-2024 Michele Morrone
// Copyright (c) 2018-2025 Michele Morrone
// All rights reserved.
//
// https://michelemorrone.eu - https://glchaosp.com - https://brutpitt.com
Expand Down
40 changes: 15 additions & 25 deletions src/src/glApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,38 +237,28 @@ void toggleFullscreenOnOff(GLFWwindow* window)

GLFWmonitor* getCurrentMonitor(GLFWwindow *window)
{
int nmonitors, i;
int wx, wy, ww, wh;
int mx, my, mw, mh;
int overlap, bestoverlap;
GLFWmonitor *bestmonitor;
GLFWmonitor **monitors;
const GLFWvidmode *mode;

bestoverlap = 0;
bestmonitor = NULL;

glfwGetWindowPos(window, &wx, &wy);
glfwGetWindowSize(window, &ww, &wh);
monitors = glfwGetMonitors(&nmonitors);

for (i = 0; i < nmonitors; i++) {
mode = glfwGetVideoMode(monitors[i]);
glfwGetMonitorPos(monitors[i], &mx, &my);
mw = mode->width;
mh = mode->height;

overlap =
std::max(0, std::min(wx + ww, mx + mw) - std::max(wx, mx)) *
std::max(0, std::min(wy + wh, my + mh) - std::max(wy, my));
int nmonitors, bestoverlap {0};;
GLFWmonitor *bestmonitor = nullptr;
GLFWmonitor **monitors = glfwGetMonitors(&nmonitors);

int wx, wy; glfwGetWindowPos (window, &wx, &wy);
int ww, wh; glfwGetWindowSize(window, &ww, &wh);

for (int i = 0; i < nmonitors; i++) {
const GLFWvidmode *mode = glfwGetVideoMode(monitors[i]);
int mx, my; glfwGetMonitorPos(monitors[i], &mx, &my);

const int overlap = std::max(0, std::min(wx + ww, mx + mode->width ) - std::max(wx, mx)) *
std::max(0, std::min(wy + wh, my + mode->height) - std::max(wy, my));

if (bestoverlap < overlap) {
bestoverlap = overlap;
bestmonitor = monitors[i];
}
}
return bestmonitor;
return bestmonitor ? bestmonitor : throw "no monitor found!";
}

#endif

// Interface
Expand Down
2 changes: 0 additions & 2 deletions src/src/glApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ class glWindow;
#endif

bool fileExist(const char *filename);


/*
///////////////////////////////////////////
//Data Init for 32/64 bit systems
Expand Down
1 change: 1 addition & 0 deletions src/src/glWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void glWindow::onInit()
vgizmo.setDollyControl((vgButtons) GLFW_MOUSE_BUTTON_RIGHT, (vgModifiers) 0);
vgizmo.setPanControl( (vgButtons) GLFW_MOUSE_BUTTON_RIGHT, (vgModifiers) GLFW_MOD_CONTROL|GLFW_MOD_SUPER);

vgizmo.setGizmoSecondaryRotControl((vgButtons) GLFW_MOUSE_BUTTON_RIGHT, (vgModifiers) GLFW_MOD_ALT);

vgizmo.setRotationCenter(attractorsList.get()->getTGT());
vgizmo.viewportSize(theApp->GetWidth(), theApp->GetHeight());
Expand Down
Loading

0 comments on commit 5f256bb

Please sign in to comment.