-
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 #13 from DominicDolan/develop
Merging to master
- Loading branch information
Showing
204 changed files
with
3,322 additions
and
1,491 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,31 @@ | ||
# Introduction | ||
|
||
Thank you for considering contributing to Mechanica. | ||
|
||
This project is very new and it is just now being released as open source. | ||
For that reason we don't have a full cohesive plan just yet. We mainly | ||
just want to make sure everything is working the way we want it to. | ||
|
||
Saying that, there is still a lot of work to do going forward. | ||
So if you do have an idea or a suggestion, or you found a bug, | ||
feel free to create an issue in the issue tracker. | ||
|
||
# Filing Bug Reports | ||
|
||
When filing a bug report, make sure to include the following where necessary: | ||
|
||
1. What operating system are you using? | ||
2. What version of Kotlin are you using? | ||
3. What version of the JDK did you use to compile? | ||
4. What did you do and can you recreate the bug consistently? | ||
5. What did you expect to see or why do you think this is a bug? | ||
|
||
# Suggesting Features or Enhancements | ||
|
||
Because this is a very new project, there are a lot of | ||
features and enhancements to be added. | ||
|
||
Right now there is not a solid plan in place for what features we | ||
are looking for but if you have an idea feel free to create an issue | ||
and make sure to describe the reasons, motivation and benefits of such | ||
a feature |
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,21 @@ | ||
MIT License (MIT) | ||
|
||
Copyright (c) 2020 Dominic Dolan | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
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
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
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
3 changes: 1 addition & 2 deletions
3
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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
package com.mechanica.engine.context.loader | ||
|
||
import com.mechanica.engine.text.Font | ||
import com.mechanica.engine.resources.Resource | ||
import com.mechanica.engine.text.Font | ||
import com.mechanica.engine.text.FontAtlasConfiguration | ||
|
||
interface FontLoader { | ||
val defaultFont: Font | ||
fun font(res: Resource, initializer: FontAtlasConfiguration.() -> Unit): Font | ||
|
||
} |
135 changes: 135 additions & 0 deletions
135
application-interface/src/main/kotlin/com/mechanica/engine/context/loader/GLDrawerLoader.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,135 @@ | ||
package com.mechanica.engine.context.loader | ||
|
||
import com.mechanica.engine.models.Model | ||
import java.nio.IntBuffer | ||
|
||
interface GLDrawerLoader { | ||
/** | ||
* Defines a sequence of geometric primitives using [model]'s | ||
* elements, whose indices are stored in the buffer bound to the | ||
* GL_ELEMENT_ARRAY_BUFFER buffer | ||
*/ | ||
fun drawElements(model: Model) | ||
|
||
/** | ||
* Behaves identically to glDrawElements() except that the ith element | ||
* transferred by the corresponding draw command will be taken from | ||
* element indices`[i]` + basevertex of each enabled vertex attribute array. | ||
*/ | ||
@Suppress("KDocUnresolvedReference") | ||
fun drawElementsBaseVertex(model: Model, baseVertex: Int) | ||
|
||
/** | ||
* This is a restricted form of glDrawElements() in that it forms a contract | ||
* between the application (i.e., you) and OpenGL that guarantees that any | ||
* index contained in the section of the element array buffer referenced by | ||
* indices and model.vertexCount will fall within the range specified by start and end. | ||
*/ | ||
fun drawRangeElements(model: Model, start: Int, end: Int) | ||
|
||
/** | ||
* Forms a contractual agreement between the application similar to that of | ||
* [drawRangeElements], while allowing the base vertex to be specified in | ||
* basevertex. In this case, the contract states that the values stored in the | ||
* element array buffer will fall between start and end before basevertex is added. | ||
*/ | ||
fun drawRangeElementsBaseVertex(model: Model, start: Int, end: Int, baseVertex: Int) | ||
|
||
/** | ||
* Behaves exactly as [drawElements], except that the parameters for the | ||
* drawing command are taken from a structure stored in the buffer bound | ||
* to the GL_DRAW_INDIRECT_BUFFER binding point. | ||
*/ | ||
fun drawElementsIndirect(model: Model) | ||
|
||
/** | ||
* Draws multiple sets of geometric primitives with a single OpenGL | ||
* function call. | ||
*/ | ||
fun multiDrawElements(models: Array<Model>) | ||
|
||
/** | ||
* Draws multiple sets of geometric primitives with a single OpenGL | ||
* function call. first, indices, and baseVertex are arrays of primcount | ||
* parameters that would be valid for a call to | ||
* glDrawElementsBaseVertex(). | ||
*/ | ||
fun multiDrawElementsBaseVertex(models: Array<Model>, baseVertex: IntBuffer) | ||
|
||
/** | ||
* The same as [multiDrawElementsBaseVertex] but the same [baseVertex] is | ||
* passed in for every primitive | ||
*/ | ||
fun multiDrawElementsBaseVertex(models: Array<Model>, baseVertex: Int) | ||
|
||
/** | ||
* Draws primCount instances of the geometric primitives specified by [model] | ||
* as if specified by individual calls to [drawElements]. | ||
* As with [drawArraysInstanced], the built-in variable gl_InstanceID | ||
* is incremented for each instance, and new values are presented to the | ||
* vertex shader for each instanced vertex attribute. | ||
*/ | ||
fun drawElementsInstanced(model: Model, instanceCount: Int) | ||
|
||
/** | ||
* Draws [instanceCount] instances of the geometric primitives specified by [model] | ||
* and [baseVertex] as if specified by individual calls to | ||
* [drawElementsBaseVertex]. As with [drawArraysInstanced], the | ||
* built-in variable gl_InstanceID is incremented for each instance, and | ||
* new values are presented to the vertex shader for each instanced vertex | ||
* attribute. | ||
*/ | ||
fun drawElementsInstancedBaseVertex(model: Model, instanceCount: Int, baseVertex: Int) | ||
|
||
/** | ||
* Draws [instanceCount] instances of the geometric primitives specified by [model] | ||
* as if specified by individual calls to [drawElements]. | ||
* As with [drawArraysInstanced], the built-in variable gl_InstanceID | ||
* is incremented for each instance, and new values are presented to the | ||
* vertex shader for each instanced vertex attribute. Furthermore, the | ||
* implied index used to fetch any instanced vertex attributes is offset by | ||
* the value of [baseInstance] by OpenGL. | ||
*/ | ||
fun drawElementsInstancedBaseInstance(model: Model, instanceCount: Int, baseInstance: Int) | ||
|
||
|
||
/** | ||
* Constructs a sequence of geometric primitives using array elements | ||
* specified within [model] | ||
*/ | ||
fun drawArrays(model: Model) | ||
|
||
/** | ||
* Behaves exactly as [drawArraysInstanced], except that the parameters | ||
* for the drawing command are taken from a structure stored in the buffer | ||
* bound to the GL_DRAW_INDIRECT_BUFFER binding point (the draw | ||
* indirect buffer) | ||
*/ | ||
fun drawArraysIndirect(model: Model) | ||
|
||
/** | ||
* Draws multiple sets of geometric primitives with a single OpenGL | ||
* function call. | ||
*/ | ||
fun multiDrawArrays(models: Array<Model>) | ||
|
||
/** | ||
* Draws [instanceCount] instances of the geometric primitives specified by [model] | ||
* as if specified by individual calls to [drawArrays]. The | ||
* built-in variable gl_InstanceID is incremented for each instance, and | ||
* new values are presented to the vertex shader for each instanced vertex | ||
* attribute. | ||
*/ | ||
fun drawArraysInstanced(model: Model, instanceCount: Int) | ||
|
||
/** | ||
* Draws [instanceCount] instances of the geometric primitives specified by [model] | ||
* as if specified by individual calls to [drawArrays]. The | ||
* built-in variable gl_InstanceID is incremented for each instance, and | ||
* new values are presented to the vertex shader for each instanced vertex | ||
* attribute. Furthermore, the implied index used to fetch any instanced | ||
* vertex attributes is offset by the value of [baseInstance] by OpenGL. | ||
*/ | ||
fun drawArraysInstancedBaseInstance(model: Model, instanceCount: Int, baseInstance: Int) | ||
|
||
} |
10 changes: 6 additions & 4 deletions
10
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 |
---|---|---|
@@ -1,15 +1,17 @@ | ||
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 { | ||
|
||
val glDrawer: GLDrawerLoader | ||
|
||
fun loadImage(id: Int): Image | ||
fun loadImage(res: Resource): Image | ||
|
||
fun drawArrays(model: Model) | ||
fun drawElements(model: Model) | ||
|
||
val glPointDrawer: GLDrawerLoader | ||
val glLineLoopDrawer: GLDrawerLoader | ||
val glLinesDrawer: GLDrawerLoader | ||
val glLineStripDrawer: GLDrawerLoader | ||
} |
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
40 changes: 40 additions & 0 deletions
40
application-interface/src/main/kotlin/com/mechanica/engine/graphics/BaseVertex.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,40 @@ | ||
package com.mechanica.engine.graphics | ||
|
||
import com.mechanica.engine.context.loader.GLDrawerLoader | ||
import com.mechanica.engine.models.Model | ||
import java.nio.IntBuffer | ||
|
||
|
||
class DrawBaseVertex(private val glDrawCommands: GLDrawerLoader) : ElementsDrawCommand, MultiElementsDrawCommand { | ||
var baseVertex: Int = 0 | ||
|
||
override fun elements(model: Model) { | ||
glDrawCommands.drawElementsBaseVertex(model, baseVertex) | ||
} | ||
|
||
override fun elements(models: Array<Model>) { | ||
glDrawCommands.multiDrawElementsBaseVertex(models, baseVertex) | ||
} | ||
} | ||
|
||
class MultiDrawBaseVertex(private val glDrawCommands: GLDrawerLoader) : MultiElementsDrawCommand { | ||
var baseVertex: IntBuffer? = null | ||
|
||
override fun elements(models: Array<Model>) { | ||
val buffer = baseVertex | ||
if (buffer != null) { | ||
glDrawCommands.multiDrawElementsBaseVertex(models, buffer) | ||
} | ||
} | ||
} | ||
|
||
class DrawRangeBaseVertex( | ||
private val glDrawCommands: GLDrawerLoader, | ||
private val drawRange: DrawRange): ElementsDrawCommand { | ||
internal var baseVertex: Int = 0 | ||
|
||
override fun elements(model: Model) { | ||
glDrawCommands.drawRangeElementsBaseVertex(model, drawRange.start, drawRange.end, baseVertex) | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
application-interface/src/main/kotlin/com/mechanica/engine/graphics/DrawCommands.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,31 @@ | ||
package com.mechanica.engine.graphics | ||
|
||
import com.mechanica.engine.models.Model | ||
|
||
interface ArrayDrawCommand { | ||
fun arrays(model: Model) | ||
} | ||
|
||
interface ElementsDrawCommand { | ||
fun elements(model: Model) | ||
} | ||
|
||
interface MultiArrayDrawCommand { | ||
fun arrays(models: Array<Model>) | ||
} | ||
|
||
interface MultiElementsDrawCommand { | ||
fun elements(models: Array<Model>) | ||
} | ||
|
||
interface DrawCommands : ArrayDrawCommand, ElementsDrawCommand { | ||
fun model(model: Model) { | ||
if (model.hasIndexArray) { | ||
elements(model) | ||
} else { | ||
arrays(model) | ||
} | ||
} | ||
} | ||
|
||
interface MultiDrawCommands : DrawCommands, MultiArrayDrawCommand, MultiElementsDrawCommand |
Oops, something went wrong.