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

Add secondary viewport #32

Merged
merged 28 commits into from
Apr 5, 2022
Merged

Add secondary viewport #32

merged 28 commits into from
Apr 5, 2022

Conversation

Troy-Boy
Copy link
Contributor

draft PR for reviewing

@CHrlS98 CHrlS98 marked this pull request as draft March 21, 2022 19:03
@CHrlS98 CHrlS98 changed the title Add viewport [WIP] Add secondary viewport Mar 21, 2022
Copy link
Collaborator

@CHrlS98 CHrlS98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two lines caught my attention. Might be the source of some problems.

Éventuellement enlève les tabs que tu as ajouté dans application.h/.cpp aussi, stp.

Engine/src/application.cpp Outdated Show resolved Hide resolved
Engine/src/application.cpp Outdated Show resolved Hide resolved
@CHrlS98
Copy link
Collaborator

CHrlS98 commented Mar 24, 2022

Super cool! Some comments on the behaviour.

  1. The secondary camera does not scale on window resize (the aspect ratio is wrong and the image appears stretched out).
  2. The slider does not work properly for scaling the window. The arrows do the job but the slider always gets back to its previous position when the mouse button is released.
  3. However, since there are only 4 options maybe it'd look better if we used radio buttons for the subwindow size? We could label them 1/2, 1/3, 1/4 and 1/5.

Copy link
Collaborator

@CHrlS98 CHrlS98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Très cool! Rien de majeur, merge upstream aussi.

.gitignore Outdated Show resolved Hide resolved
Engine/include/application.h Outdated Show resolved Hide resolved
Engine/include/application.h Outdated Show resolved Hide resolved
Engine/include/application.h Outdated Show resolved Hide resolved
Engine/include/application.h Outdated Show resolved Hide resolved
Engine/src/application.cpp Outdated Show resolved Hide resolved
Engine/src/application.cpp Outdated Show resolved Hide resolved
Engine/src/application.cpp Outdated Show resolved Hide resolved
Engine/src/gui.cpp Outdated Show resolved Hide resolved
Engine/src/gui.cpp Outdated Show resolved Hide resolved
@CHrlS98 CHrlS98 marked this pull request as ready for review March 24, 2022 13:55
@CHrlS98 CHrlS98 changed the title [WIP] Add secondary viewport Add secondary viewport Mar 24, 2022
Copy link
Collaborator

@CHrlS98 CHrlS98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, beau code clean. qqes trucs de formattage, ça achève 👍

const std::string ICON32_FNAME = "/icons/icon32.png";
const std::string ICON48_FNAME = "/icons/icon48.png";
const std::string ICON64_FNAME = "/icons/icon64.png";
const unsigned int WIN_WIDTH = 800;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks indented

Engine/src/application.cpp Outdated Show resolved Hide resolved
Engine/src/application.cpp Outdated Show resolved Hide resolved
Engine/src/application.cpp Outdated Show resolved Hide resolved
Engine/include/application.h Outdated Show resolved Hide resolved
@@ -50,7 +58,7 @@ class Camera
glm::mat4 viewMatrix;
glm::mat4 projectionMatrix;
};

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespaces are back

Engine/src/application.cpp Outdated Show resolved Hide resolved
Engine/src/application.cpp Outdated Show resolved Hide resolved
Engine/src/camera.cpp Outdated Show resolved Hide resolved
Engine/src/application.cpp Outdated Show resolved Hide resolved
@CHrlS98
Copy link
Collaborator

CHrlS98 commented Mar 31, 2022

Still deformed, try resizing the secondary camera even when magnifying mode is not enabled, to always be up to date. (application.cpp line 312) Also it looks like you use app->magnifyingMode when you should use applicationState-> MagnifyingMode?

image

Engine/src/camera.cpp Outdated Show resolved Hide resolved
mProjectionMatrix = camera.mProjectionMatrix;
mViewMatrix = camera.mViewMatrix;
mBlockRotation = camera.mBlockRotation;
mCamParamsData = camera.mCamParamsData;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to copy this one? It's the GPU binding and I think it should be unique to each instance.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or at least not modified by this method.

Engine/src/application.cpp Outdated Show resolved Hide resolved
Engine/src/application.cpp Outdated Show resolved Hide resolved
Engine/src/application.cpp Outdated Show resolved Hide resolved
@CHrlS98
Copy link
Collaborator

CHrlS98 commented Apr 4, 2022

I'd like to suggest a change for adding a border to the secondary viewport. Here is how to do it:
First, in the anonymous namespace of application.cpp, add

const int SECONDARY_VIEWPORT_BORDER_WIDTH = 2;

Then in application.cpp, replace line 183 by this code snippet:

glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(SECONDARY_VIEWPORT_BORDER_WIDTH,
           SECONDARY_VIEWPORT_BORDER_WIDTH,
           w / scaleFactor - 2 * SECONDARY_VIEWPORT_BORDER_WIDTH,
           h / scaleFactor - 2 * SECONDARY_VIEWPORT_BORDER_WIDTH);
glScissor(SECONDARY_VIEWPORT_BORDER_WIDTH,
          SECONDARY_VIEWPORT_BORDER_WIDTH,
          w / scaleFactor - 2 * SECONDARY_VIEWPORT_BORDER_WIDTH,
          h / scaleFactor - 2 * SECONDARY_VIEWPORT_BORDER_WIDTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
mScene->Render();

Basically what this does is fill the secondary viewport with white and then render the scene in a slightly smaller viewport inside the secondary viewport.

Also can you default to 1/3 I feel like 1/4 is too small.

It would give a visual like this :
image

@Troy-Boy Troy-Boy requested a review from CHrlS98 April 5, 2022 15:24
@Troy-Boy
Copy link
Contributor Author

Troy-Boy commented Apr 5, 2022

image

  • setter à 1/3
  • bordure blanche
  • tout est bien formater (je crois)

@CHrlS98 CHrlS98 merged commit 08028c9 into scilus:main Apr 5, 2022
@Troy-Boy Troy-Boy deleted the addViewport branch April 5, 2022 16:50
Troy-Boy added a commit to Troy-Boy/dmri-explorer that referenced this pull request Apr 7, 2022
* added gl scissor test

* added new data to gitignore

* changer l'endroit de la fonction d'affichage du viewport

* viewport control is good, missing render

* viewport added

* viewport control working

* gotta move the camera boy

* added camera rotation

* almost there

* code cleaning

* camera rotation done

* alias

* main camera zoom too idk y

* camera controls are ok

* fixed camera synchronization

* removed auto formatter tabs

* translation fixed

* add magnifying mode in gui

* fix window resize

* most minor fixes for pr

* final pr fixes

* delete unused fct

* 2d mode switched to camera

* changed 2d mode to camera

* finished merging

* formatting and camera reset fct

* added border to secondary vp

* finished

Co-authored-by: Achille Lanctôt-Saumure <lana2914@dinf-0051-28b.DInf.fsci.usherbrooke.ca>
Co-authored-by: lana2914 <achille.lanctot-saumure@usherbrooke.ca>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants