Skip to content

Commit

Permalink
Format with Spotless (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n authored Apr 2, 2024
1 parent 5e87703 commit df388c3
Show file tree
Hide file tree
Showing 180 changed files with 2,041 additions and 2,447 deletions.
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ plugins {
id 'com.github.ben-manes.versions' version '0.39.0'
id 'org.javamodularity.moduleplugin' version '1.8.7'
id 'net.neoforged.licenser' version '0.7.2' apply false
id 'net.neoforged.gradleutils' version '3.0.0-alpha.10'
id 'com.diffplug.spotless' version '6.22.0' apply false
id 'net.neoforged.gradleutils' version "${gradleutils_version}"
id 'net.neoforged.gradleutils.spotless' version "${gradleutils_version}" apply false
}

changelog {
Expand All @@ -26,7 +28,9 @@ allprojects {
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'org.javamodularity.moduleplugin'
apply plugin: 'net.neoforged.licenser'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'net.neoforged.gradleutils'
apply plugin: 'net.neoforged.gradleutils.spotless'

gradleutils {
setupSigning(signAllPublications: true)
Expand All @@ -35,6 +39,8 @@ allprojects {
group = 'net.neoforged.fancymodloader'
version = rootProject.version

spotlessUtils.configure(spotless)

repositories {
mavenCentral()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ public Colour foreground() {

public record Colour(int red, int green, int blue) {
public float redf() {
return ((float)red)/255f;
return ((float) red) / 255f;
}

public float greenf() {
return ((float)green)/255f;
return ((float) green) / 255f;
}

public float bluef() {
return ((float)blue)/255f;
return ((float) blue) / 255f;
}

public int packedint(int a) {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

package net.neoforged.fml.earlydisplay;

import java.nio.IntBuffer;

import static net.neoforged.fml.earlydisplay.RenderElement.clamp;
import static org.lwjgl.opengl.GL32C.*;

import java.nio.IntBuffer;

public class EarlyFramebuffer {
private final int framebuffer;
private final int texture;
Expand All @@ -23,7 +22,7 @@ public class EarlyFramebuffer {
glBindFramebuffer(GL_FRAMEBUFFER, this.framebuffer);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, this.texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, context.width() * context.scale(), context.height() * context.scale(), 0, GL_RGBA, GL_UNSIGNED_BYTE, (IntBuffer)null);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, context.width() * context.scale(), context.height() * context.scale(), 0, GL_RGBA, GL_UNSIGNED_BYTE, (IntBuffer) null);
glTexParameterIi(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterIi(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, this.texture, 0);
Expand All @@ -39,13 +38,13 @@ void deactivate() {
}

void draw(int windowFBWidth, int windowFBHeight) {
var wscale = ((float)windowFBWidth / this.context.width());
var hscale = ((float)windowFBHeight / this.context.height());
var wscale = ((float) windowFBWidth / this.context.width());
var hscale = ((float) windowFBHeight / this.context.height());
var scale = this.context.scale() * Math.min(wscale, hscale) / 2f;
var wleft = (int)(windowFBWidth * 0.5f - scale * this.context.width());
var wtop = (int)(windowFBHeight * 0.5f - scale * this.context.height());
var wright = (int)(windowFBWidth * 0.5f + scale * this.context.width());
var wbottom = (int)(windowFBHeight * 0.5f + scale * this.context.height());
var wleft = (int) (windowFBWidth * 0.5f - scale * this.context.width());
var wtop = (int) (windowFBHeight * 0.5f - scale * this.context.height());
var wright = (int) (windowFBWidth * 0.5f + scale * this.context.width());
var wbottom = (int) (windowFBHeight * 0.5f + scale * this.context.height());
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, this.framebuffer);
final var colour = this.context.colourScheme().background();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package net.neoforged.fml.earlydisplay;


import static org.lwjgl.opengl.GL32C.*;

public class ElementShader {
Expand All @@ -20,36 +19,36 @@ public void init() {

// Bind the source of our shaders to the ones created above
glShaderSource(fragmentShader, """
#version 150 core
uniform sampler2D tex;
uniform int rendertype;
in vec2 fTex;
in vec4 fColour;
out vec4 fragColor;
void main() {
if (rendertype == 0)
fragColor = vec4(1,1,1,texture(tex, fTex).r) * fColour;
if (rendertype == 1)
fragColor = texture(tex, fTex) * fColour;
if (rendertype == 2)
fragColor = fColour;
}
""");
#version 150 core
uniform sampler2D tex;
uniform int rendertype;
in vec2 fTex;
in vec4 fColour;
out vec4 fragColor;
void main() {
if (rendertype == 0)
fragColor = vec4(1,1,1,texture(tex, fTex).r) * fColour;
if (rendertype == 1)
fragColor = texture(tex, fTex) * fColour;
if (rendertype == 2)
fragColor = fColour;
}
""");
glShaderSource(vertexShader, """
#version 150 core
in vec2 position;
in vec2 tex;
in vec4 colour;
uniform vec2 screenSize;
out vec2 fTex;
out vec4 fColour;
void main() {
fTex = tex;
fColour = colour;
gl_Position = vec4((position/screenSize) * 2 - 1, 0.0, 1.0);
}
""");
#version 150 core
in vec2 position;
in vec2 tex;
in vec4 colour;
uniform vec2 screenSize;
out vec2 fTex;
out vec4 fColour;
void main() {
fTex = tex;
fColour = colour;
gl_Position = vec4((position/screenSize) * 2 - 1, 0.0, 1.0);
}
""");

// Compile the vertex and fragment elementShader so that we can use them
glCompileShader(vertexShader);
Expand Down Expand Up @@ -87,6 +86,7 @@ void main() {
public void activate() {
glUseProgram(program);
}

public void updateTextureUniform(int textureNumber) {
glUniform1i(textureUniform, textureNumber);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
package net.neoforged.fml.earlydisplay;

import com.sun.management.OperatingSystemMXBean;

import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryUsage;

public class PerformanceInfo {

private final OperatingSystemMXBean osBean;
private final MemoryMXBean memoryBean;
float memory;
Expand Down
Loading

0 comments on commit df388c3

Please sign in to comment.