Skip to content

Commit

Permalink
Merge pull request #11 from DominicDolan/develop
Browse files Browse the repository at this point in the history
Merging develop to Master
  • Loading branch information
DominicDolan authored May 17, 2020
2 parents cda0cc3 + 921be8b commit c3f803e
Show file tree
Hide file tree
Showing 288 changed files with 9,940 additions and 6,162 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
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

6 changes: 6 additions & 0 deletions .gitignore
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/
8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

8 changes: 8 additions & 0 deletions application-interface/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

plugins {
kotlin("jvm")
}

dependencies {
implementation(project(":common"))
}
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)
}
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")
}
}
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>
}
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)
}
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

}
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
}
}
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
}
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)

}
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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.mechanica.engine.models

interface Bindable {
fun bind()
}
Loading

0 comments on commit c3f803e

Please sign in to comment.