Improve: add a new, experimental 3D mapper (#8087)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
This adds an experimental, new 3D mapper that uses shaders, more modern
openGL, and a far better code reorganization that makes it an easier
foundation to build upon.
The new 3D mapper is here side by side with the original and can be
toggled on for experimentation. There's a lot of work to be done, so I'd
rather merge it early instead of making a mega-PR.
#### Motivation for adding to Mudlet
So we have a new foundation to build upon and improve.
#### Other info (issues closed, discussion etc)
Old and new mapper can be toggled dynamically with:
```lua
-- this can be a keybinding
setConfig("experiment.3dmap.modernmapper", not getConfig("experiment.3dmap.modernmapper"))
```
Smooth movement is one experiment in the new mapper, and it can be
enabled with:
```lua
lua setConfig("experiment.rendering.smooth-camera", true)
```
As you notice an experiments system has been added so we can implement
things at once and experiment to choose the one that works best. This
system can be used in other places in Mudlet as well.
<details><summary>Details</summary>
<p>
## Experiments System
### Overview
Allows enabling/disabling experimental features via
`setConfig`/`getConfig` with validation against a predefined
whitelist.
### Usage
```lua
-- Enable experiment
setConfig("experiment.rendering.more-transparent", true)
-- Check if enabled
local enabled = getConfig("experiment.rendering.more-transparent") --
returns true/false
-- Get active experiment in group
local active = getConfig("experiment.rendering.active") -- returns
"more-transparent"
-- List all valid experiments
local experiments = getConfig("experiment.list") -- returns table of
valid keys
```
### Behavior
- Grouped experiments: Mutually exclusive (enabling one disables others in same group)
- Validation: Only predefined experiments allowed, invalid keys return errors
- Persistence: Experiment states saved/loaded with profiles
### Adding New Experiments
Edit Host::mValidExperiments in src/Host.cpp:
```cpp
const QSet<QString> Host::mValidExperiments = {
qsl("experiment.rendering.originalish"),
qsl("experiment.rendering.more-transparent"),
qsl("experiment.newfeature.option1"), // Add here
};
```
### Current Experiments
- experiment.rendering.originalish
- experiment.rendering.more-transparent
</p>
</details>
---------
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
2025-08-29 12:15:48 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2025 by Vadim Peretokin - vadim.peretokin@mudlet.org *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "RenderCommandQueue.h"
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
|
|
RenderCommandQueue::RenderCommandQueue() {}
|
|
|
|
|
|
|
|
|
|
RenderCommandQueue::~RenderCommandQueue()
|
|
|
|
|
{
|
|
|
|
|
cleanup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderCommandQueue::initialize()
|
|
|
|
|
{
|
|
|
|
|
if (mInitialized) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-10-21 15:11:09 +01:00
|
|
|
|
Improve: add a new, experimental 3D mapper (#8087)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
This adds an experimental, new 3D mapper that uses shaders, more modern
openGL, and a far better code reorganization that makes it an easier
foundation to build upon.
The new 3D mapper is here side by side with the original and can be
toggled on for experimentation. There's a lot of work to be done, so I'd
rather merge it early instead of making a mega-PR.
#### Motivation for adding to Mudlet
So we have a new foundation to build upon and improve.
#### Other info (issues closed, discussion etc)
Old and new mapper can be toggled dynamically with:
```lua
-- this can be a keybinding
setConfig("experiment.3dmap.modernmapper", not getConfig("experiment.3dmap.modernmapper"))
```
Smooth movement is one experiment in the new mapper, and it can be
enabled with:
```lua
lua setConfig("experiment.rendering.smooth-camera", true)
```
As you notice an experiments system has been added so we can implement
things at once and experiment to choose the one that works best. This
system can be used in other places in Mudlet as well.
<details><summary>Details</summary>
<p>
## Experiments System
### Overview
Allows enabling/disabling experimental features via
`setConfig`/`getConfig` with validation against a predefined
whitelist.
### Usage
```lua
-- Enable experiment
setConfig("experiment.rendering.more-transparent", true)
-- Check if enabled
local enabled = getConfig("experiment.rendering.more-transparent") --
returns true/false
-- Get active experiment in group
local active = getConfig("experiment.rendering.active") -- returns
"more-transparent"
-- List all valid experiments
local experiments = getConfig("experiment.list") -- returns table of
valid keys
```
### Behavior
- Grouped experiments: Mutually exclusive (enabling one disables others in same group)
- Validation: Only predefined experiments allowed, invalid keys return errors
- Persistence: Experiment states saved/loaded with profiles
### Adding New Experiments
Edit Host::mValidExperiments in src/Host.cpp:
```cpp
const QSet<QString> Host::mValidExperiments = {
qsl("experiment.rendering.originalish"),
qsl("experiment.rendering.more-transparent"),
qsl("experiment.newfeature.option1"), // Add here
};
```
### Current Experiments
- experiment.rendering.originalish
- experiment.rendering.more-transparent
</p>
</details>
---------
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
2025-08-29 12:15:48 +02:00
|
|
|
initializeOpenGLFunctions();
|
|
|
|
|
mInitialized = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderCommandQueue::cleanup()
|
|
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
mInitialized = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderCommandQueue::addCommand(std::unique_ptr<RenderCommand> command)
|
|
|
|
|
{
|
|
|
|
|
if (command) {
|
|
|
|
|
mCommands.push_back(std::move(command));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderCommandQueue::executeAll(QOpenGLShaderProgram* shader,
|
|
|
|
|
GeometryManager* geometryManager,
|
|
|
|
|
ResourceManager* resourceManager,
|
|
|
|
|
QOpenGLVertexArrayObject& vao,
|
|
|
|
|
QOpenGLBuffer& vertexBuffer,
|
|
|
|
|
QOpenGLBuffer& colorBuffer,
|
|
|
|
|
QOpenGLBuffer& normalBuffer,
|
2025-10-22 07:36:33 +01:00
|
|
|
QOpenGLBuffer& indexBuffer,
|
|
|
|
|
QOpenGLBuffer& texCoordBuffer)
|
Improve: add a new, experimental 3D mapper (#8087)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
This adds an experimental, new 3D mapper that uses shaders, more modern
openGL, and a far better code reorganization that makes it an easier
foundation to build upon.
The new 3D mapper is here side by side with the original and can be
toggled on for experimentation. There's a lot of work to be done, so I'd
rather merge it early instead of making a mega-PR.
#### Motivation for adding to Mudlet
So we have a new foundation to build upon and improve.
#### Other info (issues closed, discussion etc)
Old and new mapper can be toggled dynamically with:
```lua
-- this can be a keybinding
setConfig("experiment.3dmap.modernmapper", not getConfig("experiment.3dmap.modernmapper"))
```
Smooth movement is one experiment in the new mapper, and it can be
enabled with:
```lua
lua setConfig("experiment.rendering.smooth-camera", true)
```
As you notice an experiments system has been added so we can implement
things at once and experiment to choose the one that works best. This
system can be used in other places in Mudlet as well.
<details><summary>Details</summary>
<p>
## Experiments System
### Overview
Allows enabling/disabling experimental features via
`setConfig`/`getConfig` with validation against a predefined
whitelist.
### Usage
```lua
-- Enable experiment
setConfig("experiment.rendering.more-transparent", true)
-- Check if enabled
local enabled = getConfig("experiment.rendering.more-transparent") --
returns true/false
-- Get active experiment in group
local active = getConfig("experiment.rendering.active") -- returns
"more-transparent"
-- List all valid experiments
local experiments = getConfig("experiment.list") -- returns table of
valid keys
```
### Behavior
- Grouped experiments: Mutually exclusive (enabling one disables others in same group)
- Validation: Only predefined experiments allowed, invalid keys return errors
- Persistence: Experiment states saved/loaded with profiles
### Adding New Experiments
Edit Host::mValidExperiments in src/Host.cpp:
```cpp
const QSet<QString> Host::mValidExperiments = {
qsl("experiment.rendering.originalish"),
qsl("experiment.rendering.more-transparent"),
qsl("experiment.newfeature.option1"), // Add here
};
```
### Current Experiments
- experiment.rendering.originalish
- experiment.rendering.more-transparent
</p>
</details>
---------
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
2025-08-29 12:15:48 +02:00
|
|
|
{
|
|
|
|
|
if (!mInitialized) {
|
|
|
|
|
qWarning() << "RenderCommandQueue: Not initialized";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!shader) {
|
|
|
|
|
qWarning() << "RenderCommandQueue: No shader program provided";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!geometryManager) {
|
|
|
|
|
qWarning() << "RenderCommandQueue: No geometry manager provided";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!resourceManager) {
|
|
|
|
|
qWarning() << "RenderCommandQueue: No resource manager provided";
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-10-21 15:11:09 +01:00
|
|
|
|
Improve: add a new, experimental 3D mapper (#8087)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
This adds an experimental, new 3D mapper that uses shaders, more modern
openGL, and a far better code reorganization that makes it an easier
foundation to build upon.
The new 3D mapper is here side by side with the original and can be
toggled on for experimentation. There's a lot of work to be done, so I'd
rather merge it early instead of making a mega-PR.
#### Motivation for adding to Mudlet
So we have a new foundation to build upon and improve.
#### Other info (issues closed, discussion etc)
Old and new mapper can be toggled dynamically with:
```lua
-- this can be a keybinding
setConfig("experiment.3dmap.modernmapper", not getConfig("experiment.3dmap.modernmapper"))
```
Smooth movement is one experiment in the new mapper, and it can be
enabled with:
```lua
lua setConfig("experiment.rendering.smooth-camera", true)
```
As you notice an experiments system has been added so we can implement
things at once and experiment to choose the one that works best. This
system can be used in other places in Mudlet as well.
<details><summary>Details</summary>
<p>
## Experiments System
### Overview
Allows enabling/disabling experimental features via
`setConfig`/`getConfig` with validation against a predefined
whitelist.
### Usage
```lua
-- Enable experiment
setConfig("experiment.rendering.more-transparent", true)
-- Check if enabled
local enabled = getConfig("experiment.rendering.more-transparent") --
returns true/false
-- Get active experiment in group
local active = getConfig("experiment.rendering.active") -- returns
"more-transparent"
-- List all valid experiments
local experiments = getConfig("experiment.list") -- returns table of
valid keys
```
### Behavior
- Grouped experiments: Mutually exclusive (enabling one disables others in same group)
- Validation: Only predefined experiments allowed, invalid keys return errors
- Persistence: Experiment states saved/loaded with profiles
### Adding New Experiments
Edit Host::mValidExperiments in src/Host.cpp:
```cpp
const QSet<QString> Host::mValidExperiments = {
qsl("experiment.rendering.originalish"),
qsl("experiment.rendering.more-transparent"),
qsl("experiment.newfeature.option1"), // Add here
};
```
### Current Experiments
- experiment.rendering.originalish
- experiment.rendering.more-transparent
</p>
</details>
---------
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
2025-08-29 12:15:48 +02:00
|
|
|
for (const auto& command : mCommands) {
|
|
|
|
|
if (command) {
|
2025-10-22 07:36:33 +01:00
|
|
|
command->execute(this, shader, geometryManager, resourceManager, vao, vertexBuffer, colorBuffer, normalBuffer, indexBuffer, texCoordBuffer);
|
2025-10-21 15:11:09 +01:00
|
|
|
|
Improve: add a new, experimental 3D mapper (#8087)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
This adds an experimental, new 3D mapper that uses shaders, more modern
openGL, and a far better code reorganization that makes it an easier
foundation to build upon.
The new 3D mapper is here side by side with the original and can be
toggled on for experimentation. There's a lot of work to be done, so I'd
rather merge it early instead of making a mega-PR.
#### Motivation for adding to Mudlet
So we have a new foundation to build upon and improve.
#### Other info (issues closed, discussion etc)
Old and new mapper can be toggled dynamically with:
```lua
-- this can be a keybinding
setConfig("experiment.3dmap.modernmapper", not getConfig("experiment.3dmap.modernmapper"))
```
Smooth movement is one experiment in the new mapper, and it can be
enabled with:
```lua
lua setConfig("experiment.rendering.smooth-camera", true)
```
As you notice an experiments system has been added so we can implement
things at once and experiment to choose the one that works best. This
system can be used in other places in Mudlet as well.
<details><summary>Details</summary>
<p>
## Experiments System
### Overview
Allows enabling/disabling experimental features via
`setConfig`/`getConfig` with validation against a predefined
whitelist.
### Usage
```lua
-- Enable experiment
setConfig("experiment.rendering.more-transparent", true)
-- Check if enabled
local enabled = getConfig("experiment.rendering.more-transparent") --
returns true/false
-- Get active experiment in group
local active = getConfig("experiment.rendering.active") -- returns
"more-transparent"
-- List all valid experiments
local experiments = getConfig("experiment.list") -- returns table of
valid keys
```
### Behavior
- Grouped experiments: Mutually exclusive (enabling one disables others in same group)
- Validation: Only predefined experiments allowed, invalid keys return errors
- Persistence: Experiment states saved/loaded with profiles
### Adding New Experiments
Edit Host::mValidExperiments in src/Host.cpp:
```cpp
const QSet<QString> Host::mValidExperiments = {
qsl("experiment.rendering.originalish"),
qsl("experiment.rendering.more-transparent"),
qsl("experiment.newfeature.option1"), // Add here
};
```
### Current Experiments
- experiment.rendering.originalish
- experiment.rendering.more-transparent
</p>
</details>
---------
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
2025-08-29 12:15:48 +02:00
|
|
|
// Update statistics
|
|
|
|
|
mTotalCommandsExecuted++;
|
|
|
|
|
const char* commandName = command->getCommandName();
|
|
|
|
|
if (strcmp(commandName, "RenderCube") == 0) {
|
|
|
|
|
mCubeCommandsExecuted++;
|
|
|
|
|
} else if (strcmp(commandName, "RenderLines") == 0) {
|
|
|
|
|
mLineCommandsExecuted++;
|
|
|
|
|
} else if (strcmp(commandName, "RenderTriangles") == 0) {
|
|
|
|
|
mTriangleCommandsExecuted++;
|
|
|
|
|
} else if (strcmp(commandName, "GLState") == 0) {
|
|
|
|
|
mStateCommandsExecuted++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-21 15:11:09 +01:00
|
|
|
|
Improve: add a new, experimental 3D mapper (#8087)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
This adds an experimental, new 3D mapper that uses shaders, more modern
openGL, and a far better code reorganization that makes it an easier
foundation to build upon.
The new 3D mapper is here side by side with the original and can be
toggled on for experimentation. There's a lot of work to be done, so I'd
rather merge it early instead of making a mega-PR.
#### Motivation for adding to Mudlet
So we have a new foundation to build upon and improve.
#### Other info (issues closed, discussion etc)
Old and new mapper can be toggled dynamically with:
```lua
-- this can be a keybinding
setConfig("experiment.3dmap.modernmapper", not getConfig("experiment.3dmap.modernmapper"))
```
Smooth movement is one experiment in the new mapper, and it can be
enabled with:
```lua
lua setConfig("experiment.rendering.smooth-camera", true)
```
As you notice an experiments system has been added so we can implement
things at once and experiment to choose the one that works best. This
system can be used in other places in Mudlet as well.
<details><summary>Details</summary>
<p>
## Experiments System
### Overview
Allows enabling/disabling experimental features via
`setConfig`/`getConfig` with validation against a predefined
whitelist.
### Usage
```lua
-- Enable experiment
setConfig("experiment.rendering.more-transparent", true)
-- Check if enabled
local enabled = getConfig("experiment.rendering.more-transparent") --
returns true/false
-- Get active experiment in group
local active = getConfig("experiment.rendering.active") -- returns
"more-transparent"
-- List all valid experiments
local experiments = getConfig("experiment.list") -- returns table of
valid keys
```
### Behavior
- Grouped experiments: Mutually exclusive (enabling one disables others in same group)
- Validation: Only predefined experiments allowed, invalid keys return errors
- Persistence: Experiment states saved/loaded with profiles
### Adding New Experiments
Edit Host::mValidExperiments in src/Host.cpp:
```cpp
const QSet<QString> Host::mValidExperiments = {
qsl("experiment.rendering.originalish"),
qsl("experiment.rendering.more-transparent"),
qsl("experiment.newfeature.option1"), // Add here
};
```
### Current Experiments
- experiment.rendering.originalish
- experiment.rendering.more-transparent
</p>
</details>
---------
Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
2025-08-29 12:15:48 +02:00
|
|
|
// Clear the queue after execution
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderCommandQueue::clear()
|
|
|
|
|
{
|
|
|
|
|
mCommands.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t RenderCommandQueue::getCommandCount() const
|
|
|
|
|
{
|
|
|
|
|
return mCommands.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderCommandQueue::printStatistics() const
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "RenderCommandQueue Statistics:";
|
|
|
|
|
qDebug() << " Total commands executed:" << mTotalCommandsExecuted;
|
|
|
|
|
qDebug() << " Cube commands:" << mCubeCommandsExecuted;
|
|
|
|
|
qDebug() << " Line commands:" << mLineCommandsExecuted;
|
|
|
|
|
qDebug() << " Triangle commands:" << mTriangleCommandsExecuted;
|
|
|
|
|
qDebug() << " State commands:" << mStateCommandsExecuted;
|
|
|
|
|
}
|