Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 20, 2025

When creating new vertex or fragment shader files through the UI (RMB -> New -> Vertex Shader... or RMB -> New -> Fragment Shader...), the resulting files were empty instead of being initialized with the proper template content.

Root Cause

The CopyTemplateHandler only handled file extensions that start with "j3" or equal "blend", but did not include shader file extensions ("frag" and "vert"). This caused NetBeans' default template engine to process these files as text templates, which resulted in empty files being created instead of copying the template content directly.

Solution

Added "frag" and "vert" extensions to the CopyTemplateHandler.accept() method so that shader template files are copied directly like other template files (j3o, j3m, blend, etc.).

Before:

return ext.startsWith("j3") || ext.equals("blend");

After:

return ext.startsWith("j3") || ext.equals("blend") || ext.equals("frag") || ext.equals("vert");

Impact

Users can now create shader files through the SDK menus and receive properly initialized files containing:

  • Fragment shaders: Basic fragment shader with main() function and gl_FragColor output
  • Vertex shaders: Basic vertex shader with uniforms, attributes, and gl_Position output

This follows the same pattern used for other working template files in the SDK.

Fixes #679.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • archive.apache.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.6-bin/afr5mpiioh2wthjmwnkmdsd5w/gradle-8.6/lib/gradle-launcher-8.6.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.6-bin/afr5mpiioh2wthjmwnkmdsd5w/gradle-8.6/lib/agents/gradle-instrumentation-agent-8.6.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.6 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…tensions to CopyTemplateHandler

Co-authored-by: neph1 <7988802+neph1@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Fragment and vertex shader file templates initialize empty files Fix shader template files creating empty files instead of proper template content Sep 20, 2025
@Copilot Copilot AI requested a review from neph1 September 20, 2025 05:41
@neph1 neph1 marked this pull request as ready for review September 20, 2025 06:32
@neph1
Copy link
Contributor

neph1 commented Sep 20, 2025

@grizeldi It was actually one of your files I modified. I'm not an expert at the glsl editor, so maybe you can take a glance at it to make sure I didn't break anything else? :)

For context, indent must be >=0, and the -1 caused an exception while parsing. So, this occurred on empty lines

@neph1 neph1 requested a review from Copilot September 20, 2025 06:34
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where shader template files were creating empty files instead of proper template content when created through the SDK UI. The fix ensures that .frag and .vert shader files are properly handled by the template system.

  • Added shader file extensions to the CopyTemplateHandler to ensure proper template copying
  • Fixed bounds checking in GlslIndentTask to prevent potential IndexOutOfBoundsException
  • Ensured shader templates are initialized with proper boilerplate content

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@grizeldi
Copy link
Member

I'll take a look, but it's been forever and even back then I didn't understand the netbeans API too well, so I'm basically starting from scratch.

@neph1 neph1 merged commit 7b6d8a9 into master Sep 25, 2025
3 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.

Fragment and vertex shader file templates initialize empty files
3 participants