-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from DominicDolan/develop
Merging develop to Master
- Loading branch information
Showing
288 changed files
with
9,940 additions
and
6,162 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# These are explicitly windows files and should use crlf | ||
*.bat text eol=crlf | ||
|
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,6 @@ | ||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build | ||
/.idea/ |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
|
||
plugins { | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":common")) | ||
} |
222 changes: 222 additions & 0 deletions
222
application-interface/src/main/kotlin/com/mechanica/engine/context/GLGeneric.kt
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,222 @@ | ||
package com.mechanica.engine.context | ||
|
||
import java.nio.FloatBuffer | ||
import java.nio.IntBuffer | ||
|
||
interface GLGeneric { | ||
|
||
// --- [ glUniform1f ] --- | ||
/** | ||
* Specifies the value of a float uniform variable for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param v0 the uniform value | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform1f(location: Int, v0: Float) | ||
|
||
// --- [ glUniform2f ] --- | ||
/** | ||
* Specifies the value of a vec2 uniform variable for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param v0 the uniform x value | ||
* @param v1 the uniform y value | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform2f(location: Int, v0: Float, v1: Float) | ||
|
||
// --- [ glUniform3f ] --- | ||
/** | ||
* Specifies the value of a vec3 uniform variable for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param v0 the uniform x value | ||
* @param v1 the uniform y value | ||
* @param v2 the uniform z value | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform3f(location: Int, v0: Float, v1: Float, v2: Float) | ||
|
||
// --- [ glUniform4f ] --- | ||
/** | ||
* Specifies the value of a vec4 uniform variable for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param v0 the uniform x value | ||
* @param v1 the uniform y value | ||
* @param v2 the uniform z value | ||
* @param v3 the uniform w value | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform4f(location: Int, v0: Float, v1: Float, v2: Float, v3: Float) | ||
|
||
// --- [ glUniform1i ] --- | ||
/** | ||
* Specifies the value of an int uniform variable for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param v0 the uniform value | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform1i(location: Int, v0: Int) | ||
|
||
// --- [ glUniform2i ] --- | ||
|
||
/** | ||
* Specifies the value of an ivec2 uniform variable for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param v0 the uniform x value | ||
* @param v1 the uniform y value | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform2i(location: Int, v0: Int, v1: Int) | ||
|
||
// --- [ glUniform3i ] --- | ||
/** | ||
* Specifies the value of an ivec3 uniform variable for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param v0 the uniform x value | ||
* @param v1 the uniform y value | ||
* @param v2 the uniform z value | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform3i(location: Int, v0: Int, v1: Int, v2: Int) | ||
|
||
// --- [ glUniform4i ] --- | ||
/** | ||
* Specifies the value of an ivec4 uniform variable for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param v0 the uniform x value | ||
* @param v1 the uniform y value | ||
* @param v2 the uniform z value | ||
* @param v3 the uniform w value | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform4i(location: Int, v0: Int, v1: Int, v2: Int, v3: Int) | ||
|
||
// --- [ glUniform1fv ] --- | ||
/** | ||
* Specifies the value of a single float uniform variable or a float uniform variable array for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param value a pointer to an array of `count` values that will be used to update the specified uniform variable | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform1fv(location: Int, value: FloatBuffer) | ||
|
||
/** | ||
* Specifies the value of a single vec2 uniform variable or a vec2 uniform variable array for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param value a pointer to an array of `count` values that will be used to update the specified uniform variable | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform2fv(location: Int, value: FloatBuffer) | ||
|
||
/** | ||
* Specifies the value of a single vec3 uniform variable or a vec3 uniform variable array for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param value a pointer to an array of `count` values that will be used to update the specified uniform variable | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform3fv(location: Int, value: FloatBuffer) | ||
|
||
/** | ||
* Specifies the value of a single vec4 uniform variable or a vec4 uniform variable array for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param value a pointer to an array of `count` values that will be used to update the specified uniform variable | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform4fv(location: Int, value: FloatBuffer) | ||
|
||
/** | ||
* Specifies the value of a single int uniform variable or a int uniform variable array for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param value a pointer to an array of `count` values that will be used to update the specified uniform variable | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform1iv(location: Int, value: IntBuffer) | ||
|
||
/** | ||
* Specifies the value of a single ivec2 uniform variable or an ivec2 uniform variable array for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param value a pointer to an array of `count` values that will be used to update the specified uniform variable | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform2iv(location: Int, value: IntBuffer) | ||
|
||
/** | ||
* Specifies the value of a single ivec3 uniform variable or an ivec3 uniform variable array for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param value a pointer to an array of `count` values that will be used to update the specified uniform variable | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform3iv(location: Int, value: IntBuffer) | ||
|
||
/** | ||
* Specifies the value of a single ivec4 uniform variable or an ivec4 uniform variable array for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param value a pointer to an array of `count` values that will be used to update the specified uniform variable | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniform4iv(location: Int, value: IntBuffer) | ||
|
||
/** | ||
* Specifies the value of a single mat2 uniform variable or a mat2 uniform variable array for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param transpose whether to transpose the matrix as the values are loaded into the uniform variable | ||
* @param value a pointer to an array of `count` values that will be used to update the specified uniform variable | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniformMatrix2fv(location: Int, transpose: Boolean, value: FloatBuffer) | ||
|
||
/** | ||
* Specifies the value of a single mat3 uniform variable or a mat3 uniform variable array for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param transpose whether to transpose the matrix as the values are loaded into the uniform variable | ||
* @param value a pointer to an array of `count` values that will be used to update the specified uniform variable | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniformMatrix3fv(location: Int, transpose: Boolean, value: FloatBuffer) | ||
|
||
/** | ||
* Specifies the value of a single mat4 uniform variable or a mat4 uniform variable array for the current program object. | ||
* | ||
* @param location the location of the uniform variable to be modified | ||
* @param transpose whether to transpose the matrix as the values are loaded into the uniform variable | ||
* @param value a pointer to an array of `count` values that will be used to update the specified uniform variable | ||
* | ||
* @see [Reference Page](http://docs.gl/gl4/glUniform) | ||
*/ | ||
fun glUniformMatrix4fv(location: Int, transpose: Boolean, value: FloatBuffer) | ||
} |
15 changes: 15 additions & 0 deletions
15
application-interface/src/main/kotlin/com/mechanica/engine/context/GLInitializer.kt
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 @@ | ||
package com.mechanica.engine.context | ||
|
||
import com.mechanica.engine.context.loader.GLLoader | ||
|
||
object GLInitializer { | ||
private var _loader: GLLoader? = null | ||
internal val loader: GLLoader | ||
get() = _loader ?: throw UninitializedPropertyAccessException("The OpenGL context has not been initialized") | ||
|
||
fun initialize(loader: GLLoader) { | ||
if (_loader == null) { | ||
_loader = loader | ||
} else throw IllegalStateException("The OpenGl context has already been initialized") | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
application-interface/src/main/kotlin/com/mechanica/engine/context/loader/AttributeLoader.kt
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 com.mechanica.engine.context.loader | ||
|
||
import com.mechanica.engine.shader.vars.attributes.AttributeVariable | ||
import com.mechanica.engine.vertices.AttributeArray | ||
import com.mechanica.engine.vertices.VertexBuffer | ||
|
||
|
||
interface AttributeLoader { | ||
fun createAttributeArray(arraySize: Int, variable: AttributeVariable): AttributeArray | ||
fun createAttributeIntArray(arraySize: Int, variable: AttributeVariable): VertexBuffer<IntArray> | ||
fun createAttributeShortArray(arraySize: Int, variable: AttributeVariable): VertexBuffer<ShortArray> | ||
} |
13 changes: 13 additions & 0 deletions
13
application-interface/src/main/kotlin/com/mechanica/engine/context/loader/BufferLoader.kt
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 @@ | ||
package com.mechanica.engine.context.loader | ||
|
||
import java.nio.ByteBuffer | ||
import java.nio.FloatBuffer | ||
import java.nio.IntBuffer | ||
|
||
interface BufferLoader { | ||
fun byteBuffer(size: Int): ByteBuffer | ||
fun intBuffer(size: Int): IntBuffer | ||
fun floatBuffer(size: Int): FloatBuffer | ||
|
||
fun useByteBuffer(size: Int, block: ByteBuffer.() -> Unit) | ||
} |
10 changes: 10 additions & 0 deletions
10
application-interface/src/main/kotlin/com/mechanica/engine/context/loader/FontLoader.kt
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,10 @@ | ||
package com.mechanica.engine.context.loader | ||
|
||
import com.mechanica.engine.text.Font | ||
import com.mechanica.engine.resources.Resource | ||
|
||
interface FontLoader { | ||
val defaultFont: Font | ||
fun font(res: Resource): Font | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
application-interface/src/main/kotlin/com/mechanica/engine/context/loader/GLConstants.kt
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,19 @@ | ||
package com.mechanica.engine.context.loader | ||
|
||
interface GLConstants { | ||
|
||
val vboTypes: VBOTypes | ||
interface VBOTypes { | ||
val arrayBuffer: Int | ||
val elementArrayBuffer: Int | ||
} | ||
|
||
val glPrimitiveTypes: GLPrimitiveTypes | ||
interface GLPrimitiveTypes { | ||
val byte: Int | ||
val short: Int | ||
val int: Int | ||
val float: Int | ||
val double: Int | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
application-interface/src/main/kotlin/com/mechanica/engine/context/loader/GLLoader.kt
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,20 @@ | ||
package com.mechanica.engine.context.loader | ||
|
||
import com.mechanica.engine.context.GLInitializer | ||
import com.mechanica.engine.shader.qualifiers.AttributeQualifier | ||
import com.mechanica.engine.shader.qualifiers.Qualifier | ||
import com.mechanica.engine.vertices.ElementArrayType | ||
|
||
interface GLLoader { | ||
|
||
val constants: GLConstants | ||
val bufferLoader: BufferLoader | ||
val fontLoader: FontLoader | ||
val graphicsLoader: GraphicsLoader | ||
|
||
fun createAttributeLoader(qualifier: AttributeQualifier): AttributeLoader | ||
fun createUniformLoader(qualifier: Qualifier): UniformLoader | ||
fun createElementArray(): ElementArrayType | ||
|
||
companion object : GLLoader by GLInitializer.loader | ||
} |
15 changes: 15 additions & 0 deletions
15
application-interface/src/main/kotlin/com/mechanica/engine/context/loader/GraphicsLoader.kt
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 @@ | ||
package com.mechanica.engine.context.loader | ||
|
||
import com.mechanica.engine.models.Image | ||
import com.mechanica.engine.models.Model | ||
import com.mechanica.engine.resources.Resource | ||
|
||
interface GraphicsLoader { | ||
|
||
fun loadImage(id: Int): Image | ||
fun loadImage(res: Resource): Image | ||
|
||
fun drawArrays(model: Model) | ||
fun drawElements(model: Model) | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
application-interface/src/main/kotlin/com/mechanica/engine/context/loader/UniformLoader.kt
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,14 @@ | ||
package com.mechanica.engine.context.loader | ||
|
||
import com.mechanica.engine.shader.qualifiers.Qualifier | ||
import com.mechanica.engine.shader.vars.uniforms.vars.* | ||
import org.joml.Matrix4f | ||
|
||
interface UniformLoader { | ||
val qualifier: Qualifier | ||
fun createUniformFloat(name: String, initial: Float): UniformFloat | ||
fun createUniformVec2(name: String, x: Number, y: Number): UniformVector2f | ||
fun createUniformVec3(name: String, x: Number, y: Number, z: Number): UniformVector3f | ||
fun createUniformVec4(name: String, x: Number, y: Number, z: Number, w: Number): UniformVector4f | ||
fun createUniformMat4(name: String, initial: Matrix4f): UniformMatrix4f | ||
} |
5 changes: 5 additions & 0 deletions
5
application-interface/src/main/kotlin/com/mechanica/engine/models/Bindable.kt
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,5 @@ | ||
package com.mechanica.engine.models | ||
|
||
interface Bindable { | ||
fun bind() | ||
} |
Oops, something went wrong.