Skip to content

Conversation

@mardy
Copy link
Collaborator

@mardy mardy commented Jan 25, 2025

This is built on top of #98, so it must be merged only after it.

Introduces support for OpenGL 2.0+ (at the moment only OpenGL 2.0 APIs have been added, but I plan to support later versions as well) and the programmable pipeline.

The trick to implement shaders on the GameCube/Wii is to register a set of callbacks that need to be called:

  1. When shaders are compiled
  2. When the GLSL program gets executed

In the first case, the callback carries a hash (computed via the murmurhash3 algorithm) of the shader source code, which can be used by the developer to identify the shader. At this point the client can inform opengx of the list of attributes and uniform variables used in the program, so that opengx can bind them with the provided variables and vertex arrays. When a geometry is to be drawn, opengx calls another callback, where the client should setup the GPU (mostly, the transformation matrices and the TEV) to simulate the same graphical output that would be obtained executing the shader.

The included example (the famous glgears) can be built by adding -DBUILD_EXAMPLES to the cmake command line (it can also be built for the desktop, which helps in verifying its correctness). It's not totally trivial, in that is uses vertex colouring and lighting. The example shows how the original program just needs to be minimally modified to make a function call at startup time, which registers the callbacks implemented in a separate source file (which can be conditionally built for the console only).

Documentation is not provided yet, because the API provided to application developers is not considered final yet. Also, it does not include any function implement texturing.

This can be safely merged, but it might be not being worth making a release until we add a texturing example too.

https://vkvideo.ru/video7200355_456239312

mardy added 7 commits March 15, 2025 11:40
These are in the public domain.
This is not yet complete and is likely to be buggy in many aspects, but
it allows running a non totally trivial example (the famous glgears),
which will be added in a later commit.

Among the known limitations:
- The API exposed to the client developer for implementing the shaders
  is not finalized.
- Texturing is not yet implemented.
In this way the examples (and any other binary we should add to the
project) will automatically gain an include path to the src/directoy
when building against opengx. This will allow them to find the
"opengx.h" file.
So we can rotate the gears on the console, too.
@WinterMute WinterMute merged commit 282461e into devkitPro:master Mar 15, 2025
2 checks passed
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