-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dungine: remove libGDX and improve the ECS approach (thesis/concept s…
…tudy) (#1652) siehe #1652 (review)
- Loading branch information
1 parent
da6ebac
commit a0b9364
Showing
278 changed files
with
29,446 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#version 330 core | ||
|
||
#include "/shaders/util/TextureAtlas.fsh" | ||
|
||
in vec2 gsTexCoord; | ||
flat in int gsAtlasEntry; | ||
|
||
|
||
out vec4 color; | ||
|
||
void main() { | ||
color = textureAtlas(gsAtlasEntry, gsTexCoord); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#version 330 core | ||
|
||
layout (points) in; | ||
layout (triangle_strip, max_vertices = 4) out; | ||
|
||
flat in int vsAtlasEntry[]; | ||
|
||
uniform mat4 uProjection; | ||
uniform mat4 uView; | ||
uniform mat4 uModel; | ||
|
||
out vec2 gsTexCoord; | ||
flat out int gsAtlasEntry; | ||
|
||
void main() { | ||
gl_Position = uProjection * uView * uModel * gl_in[0].gl_Position; | ||
gsTexCoord = vec2(0.0, 0.0); | ||
gsAtlasEntry = vsAtlasEntry[0]; | ||
EmitVertex(); | ||
|
||
gl_Position = uProjection * uView * uModel * (gl_in[0].gl_Position + vec4(0.0, 0.0, 1.0, 0.0)); | ||
gsTexCoord = vec2(0.0, 1.0); | ||
gsAtlasEntry = vsAtlasEntry[0]; | ||
EmitVertex(); | ||
|
||
gl_Position = uProjection * uView * uModel * (gl_in[0].gl_Position + vec4(1.0, 0.0, 0.0, 0.0)); | ||
gsTexCoord = vec2(1.0, 0.0); | ||
gsAtlasEntry = vsAtlasEntry[0]; | ||
EmitVertex(); | ||
|
||
gl_Position = uProjection * uView * uModel * (gl_in[0].gl_Position + vec4(1.0, 0.0, 1.0, 0.0)); | ||
gsTexCoord = vec2(1.0, 1.0); | ||
gsAtlasEntry = vsAtlasEntry[0]; | ||
EmitVertex(); | ||
|
||
EndPrimitive(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#version 330 core | ||
|
||
layout (location = 0) in vec3 aPosition; | ||
layout (location = 1) in int aAtlasEntry; | ||
|
||
flat out int vsAtlasEntry; | ||
|
||
void main() { | ||
gl_Position = vec4(aPosition, 1.0); | ||
vsAtlasEntry = aAtlasEntry; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#version 330 core | ||
|
||
#include "/shaders/util/TextureAtlas.fsh" | ||
|
||
in vec2 gsTexCoord; | ||
flat in int gsTextureIndex; | ||
|
||
out vec4 fragColor; | ||
|
||
void main() { | ||
if (gsTextureIndex == -1) { | ||
fragColor = vec4(1.0f, 0.08f, 0.58f, 1.0f); | ||
return; | ||
} | ||
fragColor = textureAtlas(gsTextureIndex, gsTexCoord); | ||
//fragColor = vec4(1.0f, 0, 0, 1.0f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#version 330 core | ||
|
||
#define FACE_UP 0x20 | ||
#define FACE_DOWN 0x10 | ||
#define FACE_NORTH 0x08 | ||
#define FACE_SOUTH 0x04 | ||
#define FACE_WEST 0x02 | ||
#define FACE_EAST 0x01 | ||
|
||
layout (points) in; | ||
layout (triangle_strip, max_vertices = 24) out; | ||
|
||
flat in int vsFaces[]; | ||
flat in ivec3 vsAtlasEntries[]; | ||
|
||
uniform mat4 uProjection; | ||
uniform mat4 uView; | ||
uniform mat4 uModel; | ||
|
||
out vec2 gsTexCoord; | ||
flat out int gsTextureIndex; | ||
|
||
void vertex(int x, int y, int z, float u, float v, int entry); | ||
|
||
void main() { | ||
int faces = vsFaces[0]; | ||
if (faces == 0) { | ||
//No faces to render | ||
return; | ||
} | ||
|
||
if ((faces & FACE_UP) == FACE_UP) { | ||
int atlasEntry = (vsAtlasEntries[0].x >> 16) & 0xFFFF; | ||
vertex(0, 1, 0, 0, 0, atlasEntry); | ||
vertex(0, 1, 1, 1, 0, atlasEntry); | ||
vertex(1, 1, 0, 0, 1, atlasEntry); | ||
vertex(1, 1, 1, 1, 1, atlasEntry); | ||
EndPrimitive(); | ||
} | ||
if ((faces & FACE_DOWN) == FACE_DOWN) { | ||
int atlasEntry = (vsAtlasEntries[0].x) & 0xFFFF; | ||
vertex(0, 0, 0, 0, 0, atlasEntry); | ||
vertex(1, 0, 0, 1, 0, atlasEntry); | ||
vertex(0, 0, 1, 0, 1, atlasEntry); | ||
vertex(1, 0, 1, 1, 1, atlasEntry); | ||
EndPrimitive(); | ||
} | ||
if ((faces & FACE_NORTH) == FACE_NORTH) { | ||
int atlasEntry = (vsAtlasEntries[0].y >> 16) & 0xFFFF; | ||
vertex(0, 0, 1, 0, 0, atlasEntry); | ||
vertex(1, 0, 1, 1, 0, atlasEntry); | ||
vertex(0, 1, 1, 0, 1, atlasEntry); | ||
vertex(1, 1, 1, 1, 1, atlasEntry); | ||
EndPrimitive(); | ||
} | ||
if ((faces & FACE_SOUTH) == FACE_SOUTH) { | ||
int atlasEntry = (vsAtlasEntries[0].y) & 0xFFFF; | ||
vertex(1, 0, 0, 0, 0, atlasEntry); | ||
vertex(0, 0, 0, 1, 0, atlasEntry); | ||
vertex(1, 1, 0, 0, 1, atlasEntry); | ||
vertex(0, 1, 0, 1, 1, atlasEntry); | ||
EndPrimitive(); | ||
} | ||
if ((faces & FACE_WEST) == FACE_WEST) { | ||
int atlasEntry = (vsAtlasEntries[0].z >> 16) & 0xFFFF; | ||
vertex(0, 0, 0, 0, 0, atlasEntry); | ||
vertex(0, 0, 1, 1, 0, atlasEntry); | ||
vertex(0, 1, 0, 0, 1, atlasEntry); | ||
vertex(0, 1, 1, 1, 1, atlasEntry); | ||
EndPrimitive(); | ||
} | ||
if ((faces & FACE_EAST) == FACE_EAST) { | ||
int atlasEntry = (vsAtlasEntries[0].z) & 0xFFFF; | ||
vertex(1, 0, 1, 0, 0, atlasEntry); | ||
vertex(1, 0, 0, 1, 0, atlasEntry); | ||
vertex(1, 1, 1, 0, 1, atlasEntry); | ||
vertex(1, 1, 0, 1, 1, atlasEntry); | ||
EndPrimitive(); | ||
} | ||
} | ||
|
||
void vertex(int x, int y, int z, float u, float v, int entry) { | ||
vec3 pos = gl_in[0].gl_Position.xyz + vec3(x, y, z); | ||
gl_Position = uProjection * uView * uModel * vec4(pos, 1.0f); | ||
gsTexCoord = vec2(u, v); | ||
gsTextureIndex = entry; | ||
EmitVertex(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#version 330 core | ||
#define MAX_ATLASENTRIES 65536 | ||
|
||
in ivec3 aPosition; | ||
in int aFaces; | ||
in ivec3 aAtlasEntries; | ||
|
||
flat out int vsFaces; | ||
flat out ivec3 vsAtlasEntries; | ||
|
||
void main() { | ||
gl_Position = vec4(aPosition, 1.0); | ||
vsFaces = aFaces; | ||
vsAtlasEntries = aAtlasEntries; | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform | ||
|
||
plugins { | ||
id 'application' | ||
} | ||
|
||
|
||
dependencies { | ||
implementation project(":dungine") | ||
|
||
// JUnit 4 and Mockito for testing | ||
testImplementation supportDependencies.junit | ||
testImplementation supportDependencies.mockito_core | ||
} | ||
|
||
|
||
sourceSets.main.java.srcDirs = ['src/'] | ||
sourceSets.main.resources.srcDirs = ['assets/'] | ||
|
||
sourceSets.test.java.srcDirs = ['test/'] | ||
sourceSets.test.resources.srcDirs = ['test_resources/'] | ||
|
||
application.mainClass = "dungine.Main" | ||
|
||
OperatingSystem os = DefaultNativePlatform.currentOperatingSystem; | ||
if(os.isMacOsX()) { | ||
applicationDefaultJvmArgs = ["-XstartOnFirstThread"] // Required for MacOS | ||
} | ||
|
||
jar { | ||
dependsOn ":dungine:jar" | ||
manifest.attributes.put("Main-Class", "dungine.Main") | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
from { | ||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package dungine; | ||
|
||
import de.fwatermann.dungine.window.GameWindow; | ||
import org.joml.Vector2i; | ||
|
||
/** The `Dungine` class is the main entry point for the Dungine-Demo. */ | ||
public class Dungine extends GameWindow { | ||
|
||
/** | ||
* Constructs a new GameWindow. | ||
* | ||
* @param debug the debug state of the game window | ||
*/ | ||
public Dungine(boolean debug) { | ||
super("Dungine", new Vector2i(1280, 720), true, debug); | ||
} | ||
|
||
@Override | ||
public void init() {} | ||
|
||
@Override | ||
public void cleanup() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dungine; | ||
|
||
import dungine.state.StateMainMenu; | ||
import dungine.state.StateTransition; | ||
|
||
/** | ||
* Main class of the Dungine demo application. It contains the main method that starts the Dungine | ||
* game engine and initializes the game state. | ||
*/ | ||
public class Main { | ||
|
||
/** | ||
* Main method of the Dungine demo application. It starts the Dungine game engine and initializes | ||
* the game state. | ||
* | ||
* @param args Command-line arguments | ||
*/ | ||
public static void main(String[] args) { | ||
Dungine dungine = new Dungine(false); | ||
dungine.setState(new StateMainMenu(dungine)); | ||
dungine.setStateTransition(new StateTransition(dungine)); | ||
dungine.start(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package dungine.components; | ||
|
||
import de.fwatermann.dungine.ecs.Component; | ||
|
||
/** A component that marks an entity as the focus point of the camera. */ | ||
public class CameraComponent extends Component { | ||
|
||
/** Constructs a new CameraComponent object. */ | ||
public CameraComponent() { | ||
super(false); | ||
} | ||
} |
Oops, something went wrong.