Commit Graph

55 Commits

Author SHA1 Message Date
Jelle Raaijmakers
a021a7e240 Applications: Support .obj polygons in 3DFileViewer
Our `WavefrontOBJLoader` only supported faces with 3 vertices, but
`.obj` files can specify arbitrary polygons with 4 or more vertices.
2022-04-10 12:08:31 +02:00
Stephan Unverwerth
5bb76e9b63 LibGL+LibGPU+LibSoftGPU: Load SoftGPU driver dynamically
This loads libsoftgpu.so during GLContext creation and instantiates the
device class which is then passed into the GLContext constructor.
2022-04-06 11:32:24 +02:00
Adam Patterson
2ecc608dea 3DFileViewer: Allow escape key to exit fullscreen mode
I went into fullscreen mode, via the View menu, before looking at the
associated key (F11). I had to kill Qemu to be able to escape.

Escape is an intuitive way to exit most fullscreen modes.
2022-04-02 11:07:29 -07:00
James Mintram
14dbd28033 3DViewer: Add support for dropping files 2022-04-01 21:32:27 -07:00
Stephan Unverwerth
086fcd4e44 3DFileViewer: Do not abort model loading when texture is missing 2022-04-01 23:19:06 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Sahan Fernando
05f9146af8 3DFileViewer: Enable smooth shading in viewer + teapot model 2022-03-24 19:22:27 +01:00
Lenny Maiorani
1dd70a6f49 Applications: Change static constexpr variables to constexpr
Function-local `static constexpr` variables can be `constexpr`. This
can reduce memory consumption, binary size, and offer additional
compiler optimizations.
2022-02-28 13:54:27 +01:00
Lenny Maiorani
160bda7228 Applications: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-02-14 22:06:55 +00:00
Mustafa Quraish
ca2c7dced5 3DFileViewer: Use FileSystemAccessClient::try_* APIs
This commit also removed the redundant `filename` parameter from
`GLContextWidget::load_file`, since the filename is already stored
within the file itself.
2022-01-20 10:39:12 +01:00
Dmitry Petrov
1662213737 Userland: Add horizontal mouse scroll support 2022-01-20 10:37:52 +01:00
Jesse Buhagiar
865e7bbe5e LibGL+LibSoftGPU+3DFileViewer: Implement Specular highlighting :^) 2022-01-18 01:48:51 +02:00
Jesse Buhagiar
b397db9948 3DFileViewer: Replace lambertian lighting with GL Lighting 2022-01-12 13:36:56 +01:00
creator1creeper1
c60f05b28e 3DFileViewer: Propagate errors using try_set_main_widget in main 2022-01-09 00:56:11 +01:00
Sahan Fernando
49ed168ced Userland: Use File::lines() range-based for loop where appropriate 2021-12-12 14:06:38 +03:30
Jelle Raaijmakers
a4603fbc06 3DFileViewer: Add checkbox to disable texture 2021-12-01 10:21:13 +01:00
Jelle Raaijmakers
61e4c09514 3DFileViewer: Set correct aspect ratio in view frustum 2021-11-29 22:11:41 +00:00
Jelle Raaijmakers
dcc7d7d566 3DFileViewer: Improve FPS display
We only showed frame times down to the millisecond. Our FPS counter was
based off of that, allowing for a limited set of possible FPS values.

Convert these calculations to floating point so we get more useful FPS
and frame time values.
2021-11-29 11:44:01 +00:00
Brian Gianforcaro
cf4fa936be Everywhere: Use default execpromises argument for Core::System::pledge 2021-11-28 08:04:57 +01:00
Andreas Kling
21a5fb0fa2 LibCore+LibSystem: Move syscall wrappers from LibSystem to LibCore
With this change, System::foo() becomes Core::System::foo().

Since LibCore builds on other systems than SerenityOS, we now have to
make sure that wrappers work with just a standard C library underneath.
2021-11-23 11:33:36 +01:00
Mustafa Quraish
4d302e0e88 Everywhere: Use Application::construct() with Main::Arguments directly
Use the updated API everywhere we are currently manually passing in
`arguments.argc` and `arguments.argv`.
2021-11-22 21:13:42 -08:00
Pedro Pereira
272f7c340e 3DFileViewer: Port to LibMain
Simplified one pledge() and five unveil() by using TRY().
2021-11-22 21:56:04 +01:00
Pedro Pereira
15bc043114 3DFileViewer: Clean some code for increased readability on Mesh
This replaces all usages of 'm_triangle_list[i]' with 'triangle' in
order to improve readability of the code.
2021-11-13 12:52:22 +01:00
Pedro Pereira
ed41f48ea4 3DFileViewer: Calculate face-normal from vertex-normals of the triangle
This change calculates the face-normal of the triangle by adding
the three vertex-normals and then normalizing. This results in an
average of the three vertex-normals.
2021-11-13 12:52:22 +01:00
Pedro Pereira
5fd58a2663 3DFileViewer: Add 'normals' to Mesh constructor
This change allows a Mesh object to be created with a vector of normals.
2021-11-13 12:52:22 +01:00
Pedro Pereira
7fb8af73bf 3DFileViewer: Add vertex normal parsing to WavefrontOBJLoader
This change allows us to parse vertex-normal lines "vn x y z"
and map them to the correct index on face lines ("f v1/vt1/vn1").
2021-11-13 12:52:22 +01:00
Andreas Kling
0de33b3d6c LibGfx: Use ErrorOr<T> for Bitmap::try_create()
Another one that was used in a fajillion places.
2021-11-08 00:35:27 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
Filiph Sandström
d6a0726302 Everywhere: Rename left/right-click to primary/secondary
This resolves #10641.
2021-10-27 22:05:58 +03:00
Brian Gianforcaro
6c0329c806 3DFileViewer: Use ElapsedTimer::start_new() 2021-09-12 17:24:44 +00:00
Timothy
1c78ff1b9f 3DFileViewer: Use unveil and FileSystemAccessServer
This will restrict 3DFileViewer's access to the file system.

3DFileViewer loads a texture based on the path of the model loaded, this
will request access to the texture file before loading.
2021-09-09 02:34:29 +02:00
Dawid Wolosowicz
977b62a213 3DFileViewer: Maintain the FPS counter's position
Without this, any resize of the GLContextWidget might leave the label
somewhere it shouldn't be. Toggling fullscreen is a single example of
that behavior.
2021-09-01 23:04:10 +02:00
Stephan Unverwerth
addbcd42d7 LibGL: Fix triangle winding calculation
Since we operate in screen space where y points down we need to reverse
what is considered clock wise and what is considered counter clockwise.

The rasterizer always expects triangles with a consistent winding order
thus swap 2 vertices if necessary to reverse the winding before passing
the triangle on to the rasterization stage.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
22905daacb LibGL: Fix interpretation of BGRA byte order
This fixes byte order interpretation in several places.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
5e27da20f4 LibGL: Fix glTexCoord behaviour
glTexCoord should behave like glColor. It only updates a gl context
variable that contains the current texture coordinates. The vertex is
only actually created once glVertex is called.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
b6373c2aba LibGL+3DFileViewer: Make glRotatef accept degrees, not radians
This is in accordance with the GL spec. Also adjust rotation values in
3DFileViewer to take the new units into account.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
e405f436b6 3DFileViewer: Allow zooming via mouse wheel 2021-08-12 20:57:19 +02:00
Stephan Unverwerth
3c509cf2f7 3DFileViewer: Add magnification filters to texture menu 2021-08-12 20:57:19 +02:00
Stephan Unverwerth
75bc7be622 3DFileViewer: Add texture menu
This allows setting different texture wrap modes
and setting different texture coordinate scale factors.
2021-08-12 18:58:41 +02:00
K-Adam
9758ba5678 3DFileViewer: Display frame rate optionally
It is turned off by default
2021-08-01 17:41:26 +02:00
Brian Gianforcaro
a51e6547aa Applications: Remove unused header includes 2021-08-01 08:10:16 +02:00
Andreas Kling
687a12d7fb Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus
to it, and then call GUI::Window::set_menubar().

This patch introduces GUI::Window::add_menu() which creates the menubar
automatically and adds items to it. Application code becomes slightly
simpler as a result. :^)
2021-07-21 21:24:26 +02:00
Andreas Kling
c7d891765c LibGfx: Use "try_" prefix for static factory functions
Also mark them as [[nodiscard]].
2021-07-21 18:02:15 +02:00
Noah Rosamilia
2feaf59ab2 3DFileViewer: Add primitive mouse controls 2021-07-03 04:02:52 +02:00
Gunnar Beutner
631d36fd98 Everywhere: Add component declarations
This adds component declarations so that users can select to not build
certain parts of the OS.
2021-06-17 11:03:51 +02:00
Ali Mohammad Pur
51c2c69357 AK+Everywhere: Disallow constructing Functions from incompatible types
Previously, AK::Function would accept _any_ callable type, and try to
call it when called, first with the given set of arguments, then with
zero arguments, and if all of those failed, it would simply not call the
function and **return a value-constructed Out type**.
This lead to many, many, many hard to debug situations when someone
forgot a `const` in their lambda argument types, and many cases of
people taking zero arguments in their lambdas to ignore them.
This commit reworks the Function interface to not include any such
surprising behaviour, if your function instance is not callable with
the declared argument set of the Function, it can simply not be
assigned to that Function instance, end of story.
2021-06-06 00:27:30 +04:30
Stephan Unverwerth
755393e684 LibGL: Implement glBindTexture()
Textures are now initialized with a nullptr upon generation.
They are only actually created once they are bound to a target.
Currently only the GL_TEXTURE_2D target is supported.
The software rasterizer now allows rendering with or without
a bound TEXTURE_2D.
2021-05-30 00:32:37 +01:00
Linus Groh
ffad5b1706 3DFileViewer: Add separator before quit menu action 2021-05-27 18:11:03 +01:00
Erik Biederstadt
3ea256b1c6 3DFileViewer: Add view menu
The view menu contains:
1. A fullscreen option (also accessed by pressing F11).
2. Rotation axis controls (x, y, z, or any combination)
3. Rotation speed controls (No rotation, slow, normal, or fast)
2021-05-27 08:57:13 +01:00
Jesse Buhagiar
343e66b816 3DFileViewer: Support textured models
Models that contain UV co-ordinates are now supported,
and will display with a texture wrapped around it, provided
a `bmp` with the same name as the object is in the same
directory as the 3D Model.
2021-05-26 16:36:53 +04:30