Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions assets/shaders/default.frag
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#version 450

layout(location = 0) in vec3 fragColor;
layout(location = 1) in vec2 fragTexCoord;

layout(location = 0) out vec4 outColor;

layout(binding = 1) uniform sampler2D texSampler;

void main() {
outColor = vec4(fragColor, 1.0);
outColor = texture(texSampler, fragTexCoord);
}

9 changes: 6 additions & 3 deletions assets/shaders/default.vert
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ layout(binding = 0) uniform UniformBufferObject {

layout(location = 0) in vec2 inPosition;
layout(location = 1) in vec3 inColor;
layout(location = 2) in vec2 inTexCoord;

layout(location = 0) out vec3 fragColor;

layout(location = 1) out vec2 fragTexCoord;

void main() {
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 0.0, 1.0);
fragColor = inColor;
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 0.0, 1.0);
fragColor = inColor;
fragTexCoord = inTexCoord;
}
Binary file added assets/textures/SegFault.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions scripts/compile_shader.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', action='store_true', default=False, help='The full output will be shown')
parser.add_argument('--shader', type=str, default='./', help='The folder containing the shaders')
parser.add_argument('--shader', type=str, required=True, default='./', help='The folder containing the shaders')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether repository callsites invoke compile_shader.py without --shader.
# Expected: ideally zero matches in the second query if keeping required=True.

set -euo pipefail

echo "== All compile_shader.py callsites =="
rg -n -C2 'compile_shader\.py' --type-add 'cmake:*.cmake' -tpy -tsh -tyaml -tcmake -ttoml -tmake

echo
echo "== Likely callsites missing --shader on the same line =="
rg -nP -C2 'compile_shader\.py(?!.*--shader)' --type-add 'cmake:*.cmake' -tpy -tsh -tyaml -tcmake -ttoml -tmake

Repository: kimkulling/Segfault

Length of output: 100


--shader is marked required while also given a default (conflicting CLI contract).

At Line 51, required=True makes default='./' effectively unused. Either remove required=True to keep the default as fallback, or keep required=True and remove the default. No callsites in the repository were found that invoke this script, so the fix should maintain intended behavior for external callers.

Suggested diff (keep backward-compatible default behavior)
-    parser.add_argument('--shader', type=str, required=True, default='./', help='The folder containing the shaders')
+    parser.add_argument('--shader', type=str, default='./', help='The folder containing the shaders')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
parser.add_argument('--shader', type=str, required=True, default='./', help='The folder containing the shaders')
parser.add_argument('--shader', type=str, default='./', help='The folder containing the shaders')
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/compile_shader.py` at line 51, The CLI argument for '--shader' is
declared with both required=True and a default which conflicts; update the
parser.add_argument call for '--shader' (the line creating the argument in
parser.add_argument('--shader', ...)) to keep the backward-compatible default
behavior by removing required=True so the default='./' is used as a fallback,
ensuring external callers without the flag still get the intended path.


args = parser.parse_args()
print("shader folder: " + str(args.shader))
Expand All @@ -62,8 +62,8 @@
if sys.platform == "linux":
copy_shader(shader_out, "../bin/shaders")
elif sys.platform == "win32":
out = Path("../bin/")

Check warning on line 65 in scripts/compile_shader.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the unused local variable "out".

See more on https://sonarcloud.io/project/issues?id=kimkulling_Segfault&issues=AZ0rBraJJp73I62kIRr7&open=AZ0rBraJJp73I62kIRr7&pullRequest=7
if out.exists("debug"):
if os.path.exists("debug"):
copy_shader(shader_out, "../bin/debug/shaders")
else:
copy_shader(shader_out, "../bin/release/shaders")
Expand Down
2 changes: 1 addition & 1 deletion src/contrib/vcpkg
Submodule vcpkg updated 4469 files
4 changes: 3 additions & 1 deletion src/examples/hello_world/hello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ using namespace segfault::core;

int main(int argc, char* argv[]) {
App myApp;
if (!myApp.init("hello_world", 50, 50, 400, 300, "hello, world!", false)) {
uint32_t width = 800;
uint32_t height = 600;
if (!myApp.init("hello_world", 50, 50, width, height, "hello, world!", false)) {
return -1;
}

Expand Down
14 changes: 8 additions & 6 deletions src/runtime/application/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ namespace segfault::application {
namespace {
std::string getStartLog() {
std::string entry = "===========================================================================\n";
entry.append("| SegFault version 0.0.l |\n");
entry.append("| SegFault version 0.0.l inited.\n");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Typo in version string: 0.0.l should likely be 0.0.1.

The version string appears to use a lowercase letter 'l' instead of the number '1'.

✏️ Proposed fix
-            entry.append("| SegFault version 0.0.l inited.\n");
+            entry.append("| SegFault version 0.0.1 inited.\n");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
entry.append("| SegFault version 0.0.l inited.\n");
entry.append("| SegFault version 0.0.1 inited.\n");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime/application/app.cpp` at line 18, The version string in the call
to entry.append in src/runtime/application/app.cpp contains a typo "0.0.l"
(lowercase L) — change that literal to the correct version "0.0.1" in the
entry.append("| SegFault version 0.0.1 inited.\n"); so the logged/printed
version is accurate; locate the entry.append(...) call and update the string
accordingly.

entry.append("===========================================================================");
return entry;
}

std::string getEndLog() {
std::string entry = "===========================================================================\n";
entry.append("|h SegFault run finished ... |\n");
entry.append("| SegFault run ended.\n");
entry.append("===========================================================================");
return entry;
}
Expand Down Expand Up @@ -71,6 +71,8 @@ namespace segfault::application {
return nullptr;
}

logMessage(LogType::Info, "SDL window initiated.");

return sdlWindow;
}
}
Expand Down Expand Up @@ -130,11 +132,11 @@ namespace segfault::application {
}

void App::shutdown() {
if (mSdlWindow == nullptr) {
logMessage(LogType::Error, "Invalid application state, cannot shutdown.");
return;
if (mSdlWindow == nullptr || mState == ModuleState::Shutdown) {
logMessage(LogType::Warn, "App already shutdowned.");
return;
}

Comment on lines 134 to +139
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Grammar issue and potential logic concern in shutdown guard.

  1. Grammar: "shutdowned" is not a valid word. Consider "already shut down" or "shutdown already complete."

  2. Logic concern: The merged condition treats mSdlWindow == nullptr (which could indicate a failed init) the same as mState == ModuleState::Shutdown (legitimate double-shutdown). Previously, the nullptr case logged an error. Consider whether these scenarios should be distinguished.

✏️ Proposed fix (grammar only)
     void App::shutdown() {
         if (mSdlWindow == nullptr || mState == ModuleState::Shutdown) {
-            logMessage(LogType::Warn, "App already shutdowned.");
+            logMessage(LogType::Warn, "App already shut down.");
             return; 
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime/application/app.cpp` around lines 134 - 139, The shutdown guard
in App::shutdown conflates two different cases and has a grammar error; change
the branching to check mState == ModuleState::Shutdown first and return with a
corrected message like "App already shut down." and separately handle mSdlWindow
== nullptr (which likely indicates failed init) by logging an error via
logMessage (e.g., "Cannot shutdown: SDL window not initialized") and returning;
update the log text to use "shut down" instead of "shutdowned" and ensure you
reference App::shutdown, mState, ModuleState::Shutdown, mSdlWindow, and
logMessage when making the changes.

SDL_DestroyWindow(mSdlWindow);
mSdlWindow = nullptr;
mState = ModuleState::Shutdown;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/core/filearchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FileArchive {
virtual FILE *getStream() const;

private:
FILE *mStream;
FILE *mStream{nullptr};
bool mCanRead{false};
bool mCanWrite{false};
};
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/core/segfault.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ namespace segfault::core {
inline void logMessage(LogType type, const char* msg) {
switch (type) {
case LogType::Error:
std::cout << "*Err* : " << msg << std::endl;
std::cout << "*ERR* : " << msg << std::endl;
break;
case LogType::Warn:
std::cout << "*Warn* : " << msg << std::endl;
std::cout << "*WARN* : " << msg << std::endl;
break;
case LogType::Info:
std::cout << "*Info* : " << msg << std::endl;
std::cout << "*INFO* : " << msg << std::endl;
break;
case LogType::Print:
std::cout << msg << std::endl;
Expand Down
Loading
Loading