├── .gitignore ├── LICENSE ├── README.md ├── pe-core ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── saar │ │ └── core │ │ ├── camera │ │ ├── Camera.kt │ │ ├── ICamera.kt │ │ ├── Projection.kt │ │ └── projection │ │ │ ├── NullProjection.java │ │ │ ├── OrthographicProjection.java │ │ │ ├── PerspectiveProjection.java │ │ │ ├── ScreenPerspectiveProjection.java │ │ │ ├── SimpleOrthographicProjection.java │ │ │ └── SimplePerspectiveProjection.java │ │ ├── common │ │ ├── Commons.java │ │ ├── components │ │ │ ├── AccelerationComponent.kt │ │ │ ├── FocusRotationComponent.kt │ │ │ ├── KeyboardMovementComponent.kt │ │ │ ├── KeyboardMovementScrollVelocityComponent.kt │ │ │ ├── KeyboardRotationComponent.kt │ │ │ ├── MouseDragRotationComponent.kt │ │ │ ├── MouseRotationComponent.kt │ │ │ ├── RandomMovementComponent.kt │ │ │ ├── SmoothMouseRotationComponent.kt │ │ │ ├── ThirdPersonViewComponent.kt │ │ │ ├── TransformComponent.kt │ │ │ └── VelocityComponent.kt │ │ ├── flatreflected │ │ │ ├── FlatReflected.kt │ │ │ ├── FlatReflectedDeferredRenderer.kt │ │ │ ├── FlatReflectedMeshBuilder.kt │ │ │ ├── FlatReflectedMeshWriter.kt │ │ │ ├── FlatReflectedModel.kt │ │ │ ├── FlatReflectedNode.kt │ │ │ ├── FlatReflectedNodeBatch.kt │ │ │ ├── FlatReflectedRenderer.kt │ │ │ └── FlatReflectedVertex.kt │ │ ├── inference │ │ │ └── weak │ │ │ │ ├── WeakInference.kt │ │ │ │ ├── WeakInstance.java │ │ │ │ ├── WeakMesh.java │ │ │ │ └── WeakVertex.java │ │ ├── normalmap │ │ │ ├── NormalMapped.kt │ │ │ ├── NormalMappedDeferredRenderer.kt │ │ │ ├── NormalMappedMeshBuilder.kt │ │ │ ├── NormalMappedMeshLoader.kt │ │ │ ├── NormalMappedMeshReader.kt │ │ │ ├── NormalMappedMeshWriter.kt │ │ │ ├── NormalMappedModel.kt │ │ │ ├── NormalMappedNode.kt │ │ │ ├── NormalMappedNodeBatch.kt │ │ │ ├── NormalMappedRenderer.kt │ │ │ └── NormalMappedVertex.kt │ │ ├── obj │ │ │ ├── Obj.kt │ │ │ ├── ObjDeferredRenderer.kt │ │ │ ├── ObjMeshBuffers.kt │ │ │ ├── ObjMeshBuilder.kt │ │ │ ├── ObjMeshLoader.kt │ │ │ ├── ObjMeshReader.kt │ │ │ ├── ObjMeshWriter.kt │ │ │ ├── ObjModel.kt │ │ │ ├── ObjNode.kt │ │ │ ├── ObjNodeBatch.kt │ │ │ ├── ObjRenderer.kt │ │ │ └── ObjVertex.kt │ │ ├── particles │ │ │ ├── Particles.kt │ │ │ ├── ParticlesDeferredRenderer.kt │ │ │ ├── ParticlesInstance.kt │ │ │ ├── ParticlesMesh.kt │ │ │ ├── ParticlesMeshBuffers.kt │ │ │ ├── ParticlesMeshBuilder.kt │ │ │ ├── ParticlesMeshReader.kt │ │ │ ├── ParticlesMeshWriter.kt │ │ │ ├── ParticlesModel.kt │ │ │ ├── ParticlesNode.kt │ │ │ ├── ParticlesNodeBatch.kt │ │ │ ├── ParticlesRenderer.kt │ │ │ └── components │ │ │ │ ├── ParticlesControlComponent.kt │ │ │ │ ├── ParticlesMeshUpdateComponent.kt │ │ │ │ └── ParticlesModelComponent.kt │ │ ├── r2d │ │ │ ├── MeshBuilder2D.kt │ │ │ ├── MeshWriter2D.kt │ │ │ ├── Model2D.kt │ │ │ ├── Node2D.kt │ │ │ ├── NodeBatch2D.kt │ │ │ ├── R2D.kt │ │ │ ├── Renderer2D.kt │ │ │ └── Vertex2D.kt │ │ ├── r3d │ │ │ ├── DeferredRenderer3D.kt │ │ │ ├── Instance3D.kt │ │ │ ├── MeshBuilder3D.kt │ │ │ ├── MeshWriter3D.kt │ │ │ ├── Model3D.kt │ │ │ ├── Node3D.kt │ │ │ ├── NodeBatch3D.kt │ │ │ ├── R3D.kt │ │ │ ├── Renderer3D.kt │ │ │ └── Vertex3D.kt │ │ └── terrain │ │ │ ├── Terrain.kt │ │ │ ├── TerrainFactory.kt │ │ │ ├── Terrains.java │ │ │ ├── World.kt │ │ │ ├── colour │ │ │ ├── AlterColourGenerator.kt │ │ │ ├── ColourGenerator.java │ │ │ ├── HeightColour.kt │ │ │ ├── HeightColourGenerator.kt │ │ │ ├── NormalColour.kt │ │ │ └── NormalColourGenerator.kt │ │ │ ├── height │ │ │ ├── FlatHeightGenerator.java │ │ │ ├── HeightGenerator.java │ │ │ └── NoiseHeightGenerator.java │ │ │ ├── lowpoly │ │ │ ├── LowPolyTerrain.kt │ │ │ ├── LowPolyTerrainFactory.kt │ │ │ └── LowPolyWorld.kt │ │ │ └── mesh │ │ │ ├── DiamondMeshGenerator.kt │ │ │ ├── MeshGenerator.kt │ │ │ ├── SquareMeshGenerator.kt │ │ │ └── TriangleMeshGenerator.kt │ │ ├── engine │ │ ├── Application.kt │ │ ├── Engine.kt │ │ └── PlanetEngine.kt │ │ ├── fog │ │ ├── Fog.kt │ │ ├── FogDistance.kt │ │ ├── FogUniformValue.kt │ │ └── IFog.kt │ │ ├── light │ │ ├── Attenuation.kt │ │ ├── DirectionalLight.kt │ │ ├── DirectionalLightUniformValue.kt │ │ ├── IDirectionalLight.kt │ │ ├── IPointLight.kt │ │ ├── PointLight.kt │ │ ├── PointLightUniformValue.kt │ │ ├── ViewSpaceDirectionalLightUniform.kt │ │ └── ViewSpacePointLightUniform.kt │ │ ├── mesh │ │ ├── DrawCallMesh.kt │ │ ├── Instance.java │ │ ├── Mesh.java │ │ ├── MeshBuilder.kt │ │ ├── Model.kt │ │ ├── UnloadedMesh.java │ │ ├── Vertex.java │ │ ├── async │ │ │ ├── FutureMesh.java │ │ │ └── FutureMeshHelper.java │ │ ├── buffer │ │ │ ├── DataMeshBuffer.kt │ │ │ ├── DataMeshBufferBuilder.kt │ │ │ ├── IndexMeshBuffer.kt │ │ │ ├── IndexMeshBufferBuilder.kt │ │ │ ├── MeshBuffer.kt │ │ │ └── MeshBufferBuilder.kt │ │ ├── common │ │ │ └── QuadMesh.kt │ │ ├── lod │ │ │ ├── IndexLodMesh.java │ │ │ ├── LevelOfDetail.java │ │ │ ├── LodMesh.java │ │ │ └── LodMeshHelper.java │ │ ├── reader │ │ │ ├── IndexedMeshReader.kt │ │ │ ├── InstancedMeshReader.kt │ │ │ └── VertexMeshReader.kt │ │ └── writer │ │ │ ├── FloatVertexWriter.kt │ │ │ ├── IndexedMeshWriter.kt │ │ │ ├── InstancedMeshWriter.kt │ │ │ ├── Mat4VertexWriter.kt │ │ │ ├── Vec2VertexWriter.kt │ │ │ ├── Vec3VertexWriter.kt │ │ │ ├── Vec4VertexWriter.kt │ │ │ ├── VertexDataWriter.kt │ │ │ └── VertexMeshWriter.kt │ │ ├── node │ │ ├── ChildNode.kt │ │ ├── ComposableNode.kt │ │ ├── Node.kt │ │ ├── NodeComponent.kt │ │ ├── NodeComponentGroup.kt │ │ └── ParentNode.kt │ │ ├── painting │ │ ├── Painter.kt │ │ └── painters │ │ │ ├── FBMPainter.kt │ │ │ ├── Random2fPainter.kt │ │ │ ├── Random3fPainter.kt │ │ │ └── RandomPainter.kt │ │ ├── postprocessing │ │ ├── PostProcessingBuffers.kt │ │ ├── PostProcessor.kt │ │ └── processors │ │ │ ├── ContrastPostProcessor.kt │ │ │ ├── FxaaPostProcessor.kt │ │ │ ├── GammaCorrectionPostProcessor.kt │ │ │ ├── GaussianBlurPostProcessor.kt │ │ │ ├── MultiplyPostProcessor.kt │ │ │ ├── SkyboxPostProcessor.kt │ │ │ ├── Swizzle.kt │ │ │ └── SwizzlePostProcessor.kt │ │ ├── renderer │ │ ├── RenderContext.java │ │ ├── Renderer.java │ │ ├── RendererMethodsBase.kt │ │ ├── RendererPrototype.java │ │ ├── RendererPrototypeHelper.kt │ │ ├── RendererPrototypeWrapper.kt │ │ ├── Renderers.java │ │ ├── RenderingOutput.kt │ │ ├── RenderingPath.java │ │ ├── RenderingPathPipeline.kt │ │ ├── RenderingPathScreenPrototype.kt │ │ ├── SimpleRenderingPath.kt │ │ ├── deferred │ │ │ ├── DeferredRenderNode.kt │ │ │ ├── DeferredRenderNodeGroup.kt │ │ │ ├── DeferredRenderPass.kt │ │ │ ├── DeferredRenderingBuffers.kt │ │ │ ├── DeferredRenderingPath.kt │ │ │ ├── DeferredRenderingPipeline.kt │ │ │ ├── DeferredScreenPrototype.kt │ │ │ └── passes │ │ │ │ ├── DeferredGeometryPass.kt │ │ │ │ ├── LightRenderPass.kt │ │ │ │ ├── ShadowsRenderPass.kt │ │ │ │ └── SsaoRenderPass.kt │ │ ├── forward │ │ │ ├── ForwardRenderNode.kt │ │ │ ├── ForwardRenderNodeGroup.kt │ │ │ ├── ForwardRenderPass.kt │ │ │ ├── ForwardRenderingBuffers.kt │ │ │ ├── ForwardRenderingPath.kt │ │ │ ├── ForwardRenderingPipeline.kt │ │ │ ├── ForwardScreenPrototype.kt │ │ │ └── passes │ │ │ │ ├── FogRenderPass.kt │ │ │ │ └── ForwardGeometryPass.kt │ │ ├── p2d │ │ │ ├── GeometryPass2D.kt │ │ │ ├── RenderNode2D.kt │ │ │ ├── RenderPass2D.kt │ │ │ ├── RenderingBuffers2D.kt │ │ │ ├── RenderingPath2D.kt │ │ │ ├── RenderingPipeline2D.kt │ │ │ └── ScreenPrototype2D.kt │ │ ├── reflection │ │ │ └── Reflection.java │ │ ├── renderpass │ │ │ ├── RenderPass.kt │ │ │ ├── RenderPassBuffers.kt │ │ │ ├── RenderPassPrototype.kt │ │ │ └── RenderPassPrototypeWrapper.kt │ │ ├── shaders │ │ │ ├── ShaderPropertiesLocator.java │ │ │ ├── ShaderProperty.java │ │ │ └── ShadersHelper.java │ │ ├── shadow │ │ │ ├── ShadowsBuffers.kt │ │ │ ├── ShadowsCamera.java │ │ │ ├── ShadowsQuality.java │ │ │ ├── ShadowsRenderNode.kt │ │ │ ├── ShadowsRenderNodeGroup.kt │ │ │ ├── ShadowsRenderingPath.kt │ │ │ └── ShadowsScreenPrototype.kt │ │ └── uniforms │ │ │ ├── UniformPropertiesLocator.java │ │ │ ├── UniformProperty.java │ │ │ ├── UniformTrigger.java │ │ │ └── UniformsHelper.java │ │ ├── screen │ │ ├── MainScreen.kt │ │ ├── OffScreen.java │ │ ├── Screen.java │ │ ├── ScreenBase.java │ │ ├── ScreenImagePrototype.kt │ │ ├── ScreenImagesLocator.java │ │ ├── ScreenPrototype.java │ │ ├── ScreenPrototypeWrapper.java │ │ ├── Screens.kt │ │ ├── SimpleScreen.java │ │ ├── annotations │ │ │ └── ScreenImageProperty.java │ │ ├── exceptions │ │ │ ├── MissingDrawAttachmentsException.java │ │ │ └── MissingReadAttachmentException.java │ │ └── image │ │ │ ├── ScreenImage.java │ │ │ └── SimpleScreenImage.java │ │ └── util │ │ ├── Fps.java │ │ ├── Time.kt │ │ └── reflection │ │ └── FieldsLocator.java │ └── resources │ └── shaders │ ├── common │ ├── fog │ │ ├── fog.header.glsl │ │ ├── fog.source.glsl │ │ └── fog.struct.glsl │ ├── light │ │ ├── light.header.glsl │ │ ├── light.source.glsl │ │ └── light.struct.glsl │ ├── noise │ │ ├── noise.header.glsl │ │ └── noise.source.glsl │ ├── quad │ │ └── quad.vertex.glsl │ ├── random │ │ ├── random.header.glsl │ │ └── random.source.glsl │ └── transform │ │ ├── transform.header.glsl │ │ ├── transform.source.glsl │ │ └── transform.struct.glsl │ ├── deferred │ ├── light │ │ └── light.fragment.glsl │ ├── shadow │ │ └── shadow.fragment.glsl │ └── ssao │ │ ├── light.fragment.glsl │ │ └── ssao.fragment.glsl │ ├── flat-reflected │ ├── flat-reflected.dfragment.glsl │ ├── flat-reflected.fragment.glsl │ └── flat-reflected.vertex.glsl │ ├── normal-map │ ├── normal-map.dfragment.glsl │ ├── normal-map.fragment.glsl │ └── normal-map.vertex.glsl │ ├── obj │ ├── obj.dfragment.glsl │ ├── obj.fragment.glsl │ └── obj.vertex.glsl │ ├── painting │ ├── fbm.fragment.glsl │ ├── random.fragment.glsl │ ├── random2f.fragment.glsl │ └── random3f.fragment.glsl │ ├── particles │ ├── particles.dfragment.glsl │ ├── particles.fragment.glsl │ └── particles.vertex.glsl │ ├── postprocessing │ ├── contrast.pass.glsl │ ├── fog.pass.glsl │ ├── fxaa.pass.glsl │ ├── gamma-correction.pass.glsl │ ├── gaussian-blur.pass.glsl │ ├── multiply.pass.glsl │ ├── skybox.pass.glsl │ ├── skybox.vertex.glsl │ └── swizzle.pass.glsl │ ├── r2d │ ├── r2d.fragment.glsl │ └── r2d.vertex.glsl │ └── r3d │ ├── r3d.dfragment.glsl │ ├── r3d.fragment.glsl │ └── r3d.vertex.glsl ├── pe-gui ├── pom.xml └── src │ └── main │ ├── kotlin │ └── org │ │ └── saar │ │ └── gui │ │ ├── MouseDetection.kt │ │ ├── UIActiveElement.kt │ │ ├── UIBlock.kt │ │ ├── UIChildNode.kt │ │ ├── UIComponent.kt │ │ ├── UIDisplay.kt │ │ ├── UIElement.kt │ │ ├── UIInputHelper.kt │ │ ├── UIMutableParent.kt │ │ ├── UINode.kt │ │ ├── UINullNode.kt │ │ ├── UIParentNode.kt │ │ ├── UIText.kt │ │ ├── block │ │ └── UIBlockRenderer.kt │ │ ├── component │ │ ├── UIButton.kt │ │ ├── UICaret.kt │ │ ├── UICheckbox.kt │ │ ├── UISlider.kt │ │ └── UITextField.kt │ │ ├── event │ │ ├── EventListener.kt │ │ ├── KeyboardEvent.kt │ │ └── MouseEvent.kt │ │ ├── font │ │ ├── Font.kt │ │ ├── FontCharacter.kt │ │ ├── FontLoader.kt │ │ ├── UILetter.kt │ │ └── UILetterRenderer.kt │ │ ├── graphics │ │ ├── BufferedGraphics.kt │ │ ├── Graphics.kt │ │ └── RenderGraphics.kt │ │ └── style │ │ ├── BlockStyle.kt │ │ ├── Colour.kt │ │ ├── Colours.kt │ │ ├── ComponentStyle.kt │ │ ├── ElementStyle.kt │ │ ├── Extensions.kt │ │ ├── NoStyle.kt │ │ ├── ParentStyle.kt │ │ ├── Style.kt │ │ ├── StyleProperty.kt │ │ ├── TextStyle.kt │ │ ├── WindowStyle.kt │ │ ├── alignment │ │ ├── Alignment.kt │ │ ├── AlignmentValue.kt │ │ ├── AlignmentValues.kt │ │ ├── NoAlignment.kt │ │ └── ReadonlyAlignment.kt │ │ ├── arrangement │ │ ├── Arrangement.kt │ │ ├── ArrangementValue.kt │ │ ├── ArrangementValues.kt │ │ ├── NoArrangement.kt │ │ └── ReadonlyArrangement.kt │ │ ├── axisalignment │ │ ├── AxisAlignment.kt │ │ ├── AxisAlignmentValue.kt │ │ ├── AxisAlignmentValues.kt │ │ ├── NoAxisAlignment.kt │ │ └── ReadonlyAxisAlignment.kt │ │ ├── backgroundcolour │ │ ├── BackgroundColour.kt │ │ ├── BackgroundColourValue.kt │ │ ├── BackgroundColourValues.kt │ │ ├── NoBackgroundColour.kt │ │ └── ReadonlyBackgroundColour.kt │ │ ├── backgroundimage │ │ ├── BackgroundImage.kt │ │ ├── BackgroundImageValue.kt │ │ ├── BackgroundImageValues.kt │ │ ├── NoBackgroundImage.kt │ │ └── ReadonlyBackgroundImage.kt │ │ ├── border │ │ ├── BorderValue.kt │ │ ├── BorderValues.kt │ │ ├── Borders.kt │ │ ├── NoBorders.kt │ │ └── ReadonlyBorders.kt │ │ ├── bordercolour │ │ ├── BorderColour.kt │ │ ├── BorderColourValue.kt │ │ ├── BorderColourValues.kt │ │ ├── NoBorderColour.kt │ │ └── ReadonlyBorderColour.kt │ │ ├── boxsizing │ │ ├── BoxSizing.kt │ │ ├── NoBoxSizing.kt │ │ └── ReadonlyBoxSizing.kt │ │ ├── colourmodifier │ │ ├── ColourModifier.kt │ │ ├── ColourModifierValue.kt │ │ ├── ColourModifierValues.kt │ │ ├── NoColourModifier.kt │ │ └── ReadonlyColourModifier.kt │ │ ├── coordinate │ │ ├── Coordinate.kt │ │ ├── CoordinateValue.kt │ │ ├── CoordinateValues.kt │ │ ├── Coordinates.kt │ │ └── ReadonlyCoordinate.kt │ │ ├── discardmap │ │ ├── DiscardMap.kt │ │ ├── DiscardMapValue.kt │ │ ├── DiscardMapValues.kt │ │ ├── NoDiscardMap.kt │ │ └── ReadonlyDiscardMap.kt │ │ ├── font │ │ ├── FontFamily.kt │ │ ├── FontFamilyValue.kt │ │ ├── FontFamilyValues.kt │ │ ├── NoFontFamily.kt │ │ └── ReadonlyFontFamily.kt │ │ ├── fontcolour │ │ ├── FontColour.kt │ │ ├── FontColourValue.kt │ │ ├── FontColourValues.kt │ │ ├── NoFontColour.kt │ │ └── ReadonlyFontColour.kt │ │ ├── fontsize │ │ ├── FontSize.kt │ │ ├── FontSizeValue.kt │ │ ├── FontSizeValues.kt │ │ ├── NoFontSize.kt │ │ └── ReadonlyFontSize.kt │ │ ├── length │ │ ├── Length.kt │ │ ├── LengthValue.kt │ │ ├── LengthValues.kt │ │ ├── Lengths.kt │ │ ├── NoLength.kt │ │ └── ReadonlyLength.kt │ │ ├── margin │ │ ├── Margin.kt │ │ ├── MarginValue.kt │ │ ├── MarginValues.kt │ │ ├── NoMargin.kt │ │ └── ReadonlyMargin.kt │ │ ├── padding │ │ ├── NoPadding.kt │ │ ├── Padding.kt │ │ ├── PaddingValue.kt │ │ ├── PaddingValues.kt │ │ └── ReadonlyPadding.kt │ │ ├── position │ │ ├── Position.kt │ │ ├── PositionValue.kt │ │ ├── PositionValues.kt │ │ └── ReadonlyPosition.kt │ │ └── redius │ │ ├── NoRadius.kt │ │ ├── Radius.kt │ │ ├── RadiusValue.kt │ │ ├── RadiusValues.kt │ │ └── ReadonlyRadius.kt │ └── resources │ ├── assets │ └── gui │ │ └── checkbox.png │ └── shaders │ └── gui │ ├── graphics │ ├── graphics.fragment.glsl │ └── graphics.vertex.glsl │ └── render │ ├── gui.fragment.glsl │ ├── gui.vertex.glsl │ ├── letter.fragment.glsl │ └── letter.vertex.glsl ├── pe-lwjgl-binding ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── saar │ └── lwjgl │ ├── assimp │ ├── AssimpComponent.java │ ├── AssimpException.java │ ├── AssimpMesh.java │ ├── AssimpUtil.java │ └── component │ │ ├── AssimpBiTangentComponent.java │ │ ├── AssimpIndexComponent.java │ │ ├── AssimpNormalComponent.java │ │ ├── AssimpPositionComponent.java │ │ ├── AssimpTangentComponent.java │ │ └── AssimpTexCoordComponent.java │ ├── glfw │ ├── GlfwUtils.java │ ├── event │ │ ├── DoubleValueChange.java │ │ ├── Event.java │ │ ├── EventListener.java │ │ ├── EventListenersHelper.java │ │ ├── IntValueChange.java │ │ └── OnAction.java │ ├── input │ │ ├── Modifiers.kt │ │ ├── keyboard │ │ │ ├── KeyEvent.kt │ │ │ ├── KeyMapper.kt │ │ │ ├── KeyState.kt │ │ │ └── Keyboard.java │ │ └── mouse │ │ │ ├── ClickEvent.kt │ │ │ ├── Mouse.java │ │ │ ├── MouseButton.kt │ │ │ ├── MouseButtonState.kt │ │ │ ├── MouseCursor.kt │ │ │ ├── MoveEvent.kt │ │ │ └── ScrollEvent.kt │ └── window │ │ ├── Monitor.java │ │ ├── OpenGlProfileType.java │ │ ├── PositionEvent.java │ │ ├── ResizeEvent.java │ │ ├── Window.java │ │ ├── WindowBuilder.java │ │ ├── WindowHint.java │ │ ├── WindowHintType.java │ │ └── WindowHints.kt │ ├── openal │ ├── constants │ │ └── BufferFormat.java │ └── objects │ │ ├── Listener.java │ │ ├── SoundBuffer.java │ │ └── Source.java │ ├── opengl │ ├── attribute │ │ ├── Attribute.kt │ │ ├── Attributes.kt │ │ ├── IAttribute.kt │ │ ├── divisor │ │ │ ├── AttributeDivisor.kt │ │ │ ├── InstancedAttributeDivisor.kt │ │ │ └── NoAttributeDivisor.kt │ │ └── pointer │ │ │ ├── AttributePointer.kt │ │ │ ├── FloatAttributePointer.kt │ │ │ └── IntegerAttributePointer.kt │ ├── blend │ │ ├── BlendFunction.kt │ │ ├── BlendState.kt │ │ ├── BlendTest.kt │ │ └── BlendValue.kt │ ├── buffer │ │ ├── BoundBuffer.java │ │ ├── BufferAccess.java │ │ ├── BufferObject.java │ │ ├── BufferTarget.java │ │ ├── BufferUsage.java │ │ ├── IBufferObject.java │ │ ├── ReadonlyBufferObject.java │ │ └── WritableBufferObject.java │ ├── clear │ │ ├── ClearColour.kt │ │ └── ClearDepth.kt │ ├── clipplane │ │ ├── ClipPlane.kt │ │ └── ClipPlaneTest.kt │ ├── constants │ │ ├── Comparator.kt │ │ ├── DataType.java │ │ ├── Face.kt │ │ ├── FormatType.java │ │ ├── InternalFormat.java │ │ └── RenderMode.java │ ├── cullface │ │ ├── CullFace.kt │ │ ├── CullFaceOrder.kt │ │ └── CullFaceState.kt │ ├── depth │ │ ├── DepthFunction.kt │ │ ├── DepthMask.kt │ │ ├── DepthState.kt │ │ └── DepthTest.kt │ ├── drawcall │ │ ├── ArraysDrawCall.java │ │ ├── DrawCall.java │ │ ├── ElementsDrawCall.java │ │ ├── InstancedArraysDrawCall.java │ │ └── InstancedElementsDrawCall.java │ ├── exceptions │ │ ├── GLBufferOverflowException.java │ │ ├── TwoIndexBuffersException.java │ │ └── VboTooSmallException.java │ ├── fbo │ │ ├── BoundFbo.java │ │ ├── DrawableFbo.java │ │ ├── Fbo.java │ │ ├── FboBlitFilter.java │ │ ├── FboStatus.java │ │ ├── FboTarget.java │ │ ├── IFbo.java │ │ ├── ModifiableFbo.java │ │ ├── ReadOnlyFbo.java │ │ ├── ReadableFbo.java │ │ ├── ScreenFbo.java │ │ ├── attachment │ │ │ ├── Attachment.java │ │ │ ├── AttachmentType.java │ │ │ ├── IAttachment.java │ │ │ ├── allocation │ │ │ │ ├── AllocationStrategy.kt │ │ │ │ ├── MultisampledAllocationStrategy.kt │ │ │ │ └── SimpleAllocationStrategy.kt │ │ │ ├── buffer │ │ │ │ ├── AttachmentBuffer.kt │ │ │ │ ├── RenderBufferAttachmentBuffer.kt │ │ │ │ └── TextureAttachmentBuffer.kt │ │ │ └── index │ │ │ │ ├── AttachmentIndex.kt │ │ │ │ ├── BasicAttachmentIndex.kt │ │ │ │ └── ColourAttachmentIndex.kt │ │ ├── copy │ │ │ ├── BlitCopyStrategy.kt │ │ │ └── CopyStrategy.kt │ │ ├── exceptions │ │ │ ├── FboAttachmentMissingException.java │ │ │ ├── FboIncompleteAttachmentException.java │ │ │ ├── FboIncompleteDrawBufferException.java │ │ │ ├── FboIncompleteLayerTargetsException.java │ │ │ ├── FboIncompleteMissingAttachmentException.java │ │ │ ├── FboIncompleteMultisampleException.java │ │ │ ├── FboIncompleteReadBufferException.java │ │ │ ├── FboUndefinedException.java │ │ │ ├── FboUnsupportedException.java │ │ │ └── FrameBufferException.java │ │ └── rendertarget │ │ │ ├── DrawRenderTarget.kt │ │ │ ├── DrawRenderTargetComposite.kt │ │ │ ├── IndexRenderTarget.kt │ │ │ ├── ReadRenderTarget.kt │ │ │ ├── RenderTarget.kt │ │ │ └── SingleRenderTarget.kt │ ├── pbo │ │ ├── PackPbo.java │ │ └── ReadablePbo.java │ ├── polygonmode │ │ ├── PolygonMode.kt │ │ ├── PolygonModeState.kt │ │ └── PolygonModeValue.kt │ ├── primitive │ │ ├── GlFloat.java │ │ ├── GlFloat2.java │ │ ├── GlFloat3.java │ │ ├── GlFloat4.java │ │ ├── GlFloat4x4.java │ │ ├── GlInt.java │ │ ├── GlInt2.java │ │ ├── GlInt3.java │ │ ├── GlInt4.java │ │ ├── GlPrimitive.java │ │ ├── GlPrimitiveBase.java │ │ ├── GlPrimitives.java │ │ ├── GlUInt.java │ │ ├── GlUInt2.java │ │ ├── GlUInt3.java │ │ └── GlUInt4.java │ ├── provokingvertex │ │ ├── ProvokingVertex.kt │ │ └── ProvokingVertexValue.kt │ ├── renderbuffer │ │ ├── BoundRenderBuffer.java │ │ └── RenderBuffer.java │ ├── shader │ │ ├── BoundProgram.java │ │ ├── GlslVersion.java │ │ ├── Shader.java │ │ ├── ShaderCode.java │ │ ├── ShaderCodeLoader.java │ │ ├── ShaderCompileException.java │ │ ├── ShaderLoaderException.java │ │ ├── ShaderType.java │ │ ├── ShadersProgram.java │ │ └── uniforms │ │ │ ├── BooleanUniform.kt │ │ │ ├── BooleanUniformValue.kt │ │ │ ├── FloatUniform.kt │ │ │ ├── FloatUniformValue.kt │ │ │ ├── IntUniform.kt │ │ │ ├── IntUniformValue.kt │ │ │ ├── Mat4Uniform.kt │ │ │ ├── Mat4UniformValue.kt │ │ │ ├── TextureUniform.kt │ │ │ ├── TextureUniformValue.kt │ │ │ ├── UIntUniform.kt │ │ │ ├── UIntUniformValue.kt │ │ │ ├── Uniform.kt │ │ │ ├── UniformArray.kt │ │ │ ├── UniformContainer.kt │ │ │ ├── UniformWrapper.kt │ │ │ ├── Vec2Uniform.kt │ │ │ ├── Vec2UniformValue.kt │ │ │ ├── Vec2iUniform.kt │ │ │ ├── Vec2iUniformValue.kt │ │ │ ├── Vec3Uniform.kt │ │ │ ├── Vec3UniformValue.kt │ │ │ ├── Vec3iUniform.kt │ │ │ ├── Vec3iUniformValue.kt │ │ │ ├── Vec4Uniform.kt │ │ │ ├── Vec4UniformValue.kt │ │ │ ├── Vec4iUniform.kt │ │ │ └── Vec4iUniformValue.kt │ ├── stencil │ │ ├── StencilFunction.kt │ │ ├── StencilMask.kt │ │ ├── StencilOperation.kt │ │ ├── StencilState.kt │ │ ├── StencilTest.kt │ │ └── StencilValue.kt │ ├── texture │ │ ├── ActiveTexture.java │ │ ├── BoundTexture.java │ │ ├── ColourTexture.kt │ │ ├── CubeMapFace.java │ │ ├── CubeMapTexture.java │ │ ├── CubeMapTextureBuilder.java │ │ ├── MultiTexture.kt │ │ ├── MutableTexture.java │ │ ├── MutableTexture2D.java │ │ ├── ReadOnlyTexture.java │ │ ├── ReadOnlyTexture2D.java │ │ ├── Texture2D.java │ │ ├── TextureCache.java │ │ ├── TextureInfo.kt │ │ ├── TextureLoader.kt │ │ ├── TextureObject.java │ │ ├── TextureTarget.java │ │ ├── WritableTexture2D.java │ │ ├── parameter │ │ │ ├── TextureAnisotropicFilterParameter.java │ │ │ ├── TextureBorderColourParameter.java │ │ │ ├── TextureFloatParameterParameter.java │ │ │ ├── TextureFloatsParameterParameter.java │ │ │ ├── TextureIntParameterParameter.java │ │ │ ├── TextureLodBiasParameter.java │ │ │ ├── TextureMagFilterParameter.java │ │ │ ├── TextureMinFilterParameter.java │ │ │ ├── TextureParameter.java │ │ │ ├── TextureSWrapParameter.java │ │ │ └── TextureTWrapParameter.java │ │ └── values │ │ │ ├── MagFilterValue.java │ │ │ ├── MinFilterValue.java │ │ │ └── WrapValue.java │ ├── utils │ │ ├── GlBuffer.java │ │ ├── GlConfigs.java │ │ ├── GlRendering.java │ │ └── GlUtils.java │ ├── vao │ │ ├── BoundVao.java │ │ ├── IVao.java │ │ ├── ReadOnlyVao.java │ │ ├── Vao.java │ │ ├── WritableVao.java │ │ └── linking │ │ │ ├── InterleavedLinkingStrategy.kt │ │ │ └── LinkingStrategy.kt │ └── vbo │ │ ├── DataBuffer.java │ │ ├── IVbo.java │ │ ├── IndexBuffer.java │ │ ├── ReadOnlyVbo.java │ │ ├── Vbo.java │ │ ├── VboAccess.java │ │ ├── VboTarget.java │ │ ├── VboUsage.java │ │ ├── Vbos.java │ │ └── WritableVbo.java │ ├── stb │ ├── TrueTypeBitmap.kt │ ├── TrueTypeCharacter.kt │ ├── TrueTypeCharacterBitmap.kt │ ├── TrueTypeCodepointHMetrics.kt │ ├── TrueTypeFontInfo.kt │ ├── TrueTypeFontLoader.kt │ ├── TrueTypeFontVMetrics.kt │ └── exceptions │ │ ├── STBBufferOverflowException.kt │ │ └── STBInitializationException.kt │ └── util │ ├── ByteListWriter.kt │ ├── DataReader.kt │ ├── DataWriter.kt │ ├── FileLoader.kt │ ├── LwjglUtil.java │ └── buffer │ ├── BufferBuilder.kt │ ├── BufferReader.java │ ├── BufferWriter.java │ ├── DynamicBufferBuilder.kt │ ├── FixedBufferBuilder.kt │ ├── LwjglBuffer.java │ ├── LwjglByteBuffer.java │ └── ReadonlyLwjglBuffer.java ├── pe-math ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── saar │ └── maths │ ├── Angle.java │ ├── Box2f.kt │ ├── Box2i.kt │ ├── JomlDelegates.kt │ ├── JomlOperators.kt │ ├── MoreDelegates.kt │ ├── noise │ ├── LayeredNoise1f.java │ ├── LayeredNoise2f.java │ ├── LayeredNoise3f.java │ ├── MultipliedNoise2f.java │ ├── Noise1f.java │ ├── Noise2f.java │ ├── Noise3f.java │ └── SpreadNoise2f.java │ ├── objects │ ├── Dimensions.java │ ├── Ellipsoid.java │ ├── Plane.java │ ├── Planef.java │ ├── Polygon.java │ ├── Rectangle.java │ ├── RectangleI.java │ └── Triangle.java │ ├── transform │ ├── NullTransform.kt │ ├── Position.java │ ├── ReadonlyPosition.java │ ├── ReadonlyRotation.java │ ├── ReadonlyScale.java │ ├── ReadonlyTransform.kt │ ├── Rotation.java │ ├── Scale.java │ ├── SimpleTransform.java │ └── Transform.kt │ └── utils │ ├── Maths.java │ ├── Matrix3.java │ ├── Matrix4.java │ ├── ObjectPool.java │ ├── Quaternion.java │ ├── Vector2.java │ ├── Vector3.java │ └── Vector4.java ├── planet-examples ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── saar │ │ └── example │ │ ├── CircleExample.kt │ │ ├── Example.java │ │ ├── ExamplesUtils.java │ │ ├── InstancedModelExample.java │ │ ├── MultisamplingExample.java │ │ ├── PaintingExample.java │ │ ├── ParticlesExample.kt │ │ ├── ParticlesSphereExample.kt │ │ ├── RendererExample.java │ │ ├── StencilExample.java │ │ ├── WindowBuilderExample.java │ │ ├── deferred │ │ └── DeferredExample.java │ │ ├── gui │ │ ├── GuiExample.kt │ │ ├── HelloWorldExample.kt │ │ ├── LoginPageApplication.kt │ │ ├── LoginPageExample.kt │ │ ├── MyUIComponent.kt │ │ ├── TextExample.kt │ │ ├── UIAlignmentExample.kt │ │ ├── UIButtonExample.kt │ │ └── UISliderExample.kt │ │ ├── inference │ │ └── WeakExample.java │ │ ├── light │ │ └── PointLightExample.kt │ │ ├── normalmapping │ │ └── NormalMappingExample.java │ │ ├── obj │ │ └── ObjRendererExample.java │ │ ├── postprocessing │ │ └── PostProcessingExample.java │ │ ├── reflected │ │ └── ReflectionExample.java │ │ ├── renderer3d │ │ ├── ManyCubesExample.java │ │ └── Renderer3DExample.java │ │ ├── screen │ │ ├── MyScreenPrototype.java │ │ └── ScreenExample.java │ │ ├── shadow │ │ └── ShadowExample.java │ │ └── terrain │ │ ├── ForestExample.java │ │ └── TerrainExample.java │ └── resources │ ├── assets │ ├── barrel │ │ ├── barrel.diffuse.png │ │ ├── barrel.model.obj │ │ └── barrel.normal.png │ ├── boulder │ │ ├── boulder.diffuse.png │ │ ├── boulder.model.obj │ │ └── boulder.normal.png │ ├── bunny │ │ ├── bunny.model.obj │ │ └── bunny.normal.png │ ├── cottage │ │ ├── cottage.obj │ │ ├── cottage_diffuse.png │ │ └── cottage_normal.png │ ├── crate │ │ ├── crate.diffuse.png │ │ ├── crate.model.obj │ │ └── crate.normal.png │ ├── cube │ │ └── cube.obj │ ├── dragon │ │ └── dragon.model.obj │ ├── particles.png │ ├── skybox │ │ ├── back.jpg │ │ ├── bottom.jpg │ │ ├── front.jpg │ │ ├── left.jpg │ │ ├── right.jpg │ │ └── top.jpg │ ├── stall │ │ ├── stall.diffuse.png │ │ └── stall.model.obj │ └── tree │ │ ├── tree.diffuse.png │ │ └── tree.model.obj │ ├── circle.fragment.glsl │ ├── fragment.glsl │ ├── simple.fragment.glsl │ ├── simple.vertex.glsl │ └── vertex.glsl └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # File-based project format 2 | *.iws 3 | 4 | # IntelliJ 5 | .idea 6 | out/ 7 | 8 | # maven 9 | target/ 10 | pom.xml.tag 11 | pom.xml.releaseBackup 12 | pom.xml.versionsBackup 13 | pom.xml.next 14 | release.properties 15 | dependency-reduced-pom.xml 16 | buildNumber.properties 17 | .mvn/timing.properties 18 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar 19 | .mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/camera/ICamera.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.camera 2 | 3 | import org.joml.Matrix4fc 4 | import org.saar.maths.transform.Transform 5 | 6 | interface ICamera { 7 | val transform: Transform 8 | val projection: Projection 9 | val viewMatrix: Matrix4fc 10 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/camera/Projection.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.camera 2 | 3 | import org.joml.Matrix4fc 4 | 5 | interface Projection { 6 | val matrix: Matrix4fc 7 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/Commons.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.common; 2 | 3 | public final class Commons { 4 | 5 | private Commons() { 6 | throw new AssertionError("Cannot create instance of class " 7 | + getClass().getSimpleName()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/components/AccelerationComponent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.components 2 | 3 | import org.joml.Vector3f 4 | import org.saar.core.node.NodeComponent 5 | import org.saar.core.node.ComposableNode 6 | import org.saar.maths.utils.Vector3 7 | 8 | class AccelerationComponent : NodeComponent { 9 | 10 | private lateinit var velocityComponent: VelocityComponent 11 | 12 | val direction: Vector3f = Vector3.create() 13 | 14 | override fun start(node: ComposableNode) { 15 | this.velocityComponent = node.components.get() 16 | } 17 | 18 | override fun update(node: ComposableNode) { 19 | this.velocityComponent.direction.add(this.direction) 20 | } 21 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/components/FocusRotationComponent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.components 2 | 3 | import org.saar.core.node.ComposableNode 4 | import org.saar.core.node.NodeComponent 5 | import org.saar.maths.transform.ReadonlyPosition 6 | import org.saar.maths.transform.lookAt 7 | 8 | class FocusRotationComponent(private val focus: ReadonlyPosition) : NodeComponent { 9 | 10 | private lateinit var transformComponent: TransformComponent 11 | 12 | override fun start(node: ComposableNode) { 13 | this.transformComponent = node.components.get() 14 | } 15 | 16 | override fun update(node: ComposableNode) { 17 | this.transformComponent.transform.lookAt(focus) 18 | } 19 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/components/TransformComponent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.components 2 | 3 | import org.saar.core.node.NodeComponent 4 | import org.saar.maths.transform.SimpleTransform 5 | import org.saar.maths.transform.Transform 6 | 7 | class TransformComponent(val transform: Transform = SimpleTransform()) : NodeComponent -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/components/VelocityComponent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.components 2 | 3 | import org.joml.Vector3f 4 | import org.saar.core.node.NodeComponent 5 | import org.saar.core.node.ComposableNode 6 | import org.saar.maths.utils.Vector3 7 | 8 | class VelocityComponent : NodeComponent { 9 | 10 | private lateinit var transformComponent 11 | : TransformComponent 12 | 13 | val direction: Vector3f = Vector3.create() 14 | 15 | override fun start(node: ComposableNode) { 16 | this.transformComponent = node.components.get() 17 | } 18 | 19 | override fun update(node: ComposableNode) { 20 | this.transformComponent.transform.position.add(this.direction) 21 | } 22 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/flatreflected/FlatReflectedMeshWriter.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.flatreflected 2 | 3 | import org.saar.core.mesh.writer.IndexedMeshWriter 4 | import org.saar.core.mesh.writer.VertexMeshWriter 5 | import org.saar.lwjgl.util.DataWriter 6 | 7 | class FlatReflectedMeshWriter( 8 | private val positionWriter: DataWriter, 9 | private val indexWriter: DataWriter, 10 | ) : VertexMeshWriter, IndexedMeshWriter { 11 | 12 | override fun writeVertex(vertex: FlatReflectedVertex) { 13 | this.positionWriter.write3f(vertex.position3f) 14 | } 15 | 16 | override fun writeIndex(index: Int) = this.indexWriter.writeInt(index) 17 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/flatreflected/FlatReflectedVertex.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.flatreflected 2 | 3 | import org.joml.Vector3fc 4 | import org.saar.core.mesh.Vertex 5 | 6 | interface FlatReflectedVertex : Vertex { 7 | val position3f: Vector3fc 8 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/normalmap/NormalMappedModel.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.normalmap 2 | 3 | import org.saar.core.mesh.Mesh 4 | import org.saar.core.mesh.Model 5 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture 6 | import org.saar.maths.transform.SimpleTransform 7 | import org.saar.maths.transform.Transform 8 | 9 | class NormalMappedModel( 10 | override val mesh: Mesh, 11 | val texture: ReadOnlyTexture, 12 | val normalMap: ReadOnlyTexture, 13 | val transform: Transform, 14 | ) : Model { 15 | 16 | constructor(mesh: Mesh, texture: ReadOnlyTexture, normalMap: ReadOnlyTexture) 17 | : this(mesh, texture, normalMap, SimpleTransform()) 18 | 19 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/normalmap/NormalMappedVertex.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.normalmap 2 | 3 | import org.joml.Vector2fc 4 | import org.joml.Vector3fc 5 | import org.saar.core.mesh.Vertex 6 | 7 | interface NormalMappedVertex : Vertex { 8 | val position3f: Vector3fc 9 | val uvCoord2f: Vector2fc 10 | val normal3f: Vector3fc 11 | val tangent3f: Vector3fc 12 | val biTangent3f: Vector3fc 13 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/obj/ObjModel.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.obj 2 | 3 | import org.saar.core.mesh.Mesh 4 | import org.saar.core.mesh.Model 5 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture 6 | import org.saar.maths.transform.SimpleTransform 7 | import org.saar.maths.transform.Transform 8 | 9 | class ObjModel @JvmOverloads constructor( 10 | override val mesh: Mesh, 11 | val texture: ReadOnlyTexture, 12 | val transform: Transform = SimpleTransform(), 13 | ) : Model -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/obj/ObjVertex.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.obj 2 | 3 | import org.joml.Vector2fc 4 | import org.joml.Vector3fc 5 | import org.saar.core.mesh.Vertex 6 | 7 | interface ObjVertex : Vertex { 8 | val position3f: Vector3fc 9 | val uvCoord2f: Vector2fc 10 | val normal3f: Vector3fc 11 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/particles/ParticlesInstance.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.particles 2 | 3 | import org.joml.Vector3fc 4 | import org.saar.core.mesh.Instance 5 | 6 | interface ParticlesInstance : Instance { 7 | val position3f: Vector3fc 8 | val birth: Int 9 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/particles/ParticlesMesh.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.particles 2 | 3 | import org.saar.core.mesh.Mesh 4 | import org.saar.lwjgl.opengl.drawcall.InstancedArraysDrawCall 5 | import org.saar.lwjgl.opengl.vao.IVao 6 | 7 | class ParticlesMesh( 8 | private val vao: IVao, 9 | private val drawCall: InstancedArraysDrawCall, 10 | val buffers: ParticlesMeshBuffers, 11 | ) : Mesh { 12 | override fun draw() { 13 | this.vao.bind() 14 | this.drawCall.doDrawCall() 15 | } 16 | 17 | override fun delete() = this.vao.delete() 18 | 19 | var instancesCount: Int by this.drawCall::instances 20 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/particles/ParticlesMeshReader.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.particles 2 | 3 | import org.saar.core.mesh.reader.InstancedMeshReader 4 | import org.saar.lwjgl.util.DataReader 5 | 6 | class ParticlesMeshReader( 7 | private val positionReader: DataReader, 8 | private val birthReader: DataReader, 9 | ) : InstancedMeshReader { 10 | 11 | override fun readInstance() = Particles.instance( 12 | this.positionReader.read3f(), 13 | this.birthReader.readInt() 14 | ) 15 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/particles/ParticlesMeshWriter.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.particles 2 | 3 | import org.saar.core.mesh.writer.InstancedMeshWriter 4 | import org.saar.lwjgl.util.DataWriter 5 | 6 | class ParticlesMeshWriter( 7 | private val positionWriter: DataWriter, 8 | private val birthWriter: DataWriter, 9 | ) : InstancedMeshWriter { 10 | 11 | override fun writeInstance(instance: ParticlesInstance) { 12 | this.positionWriter.write3f(instance.position3f) 13 | this.birthWriter.writeInt(instance.birth) 14 | } 15 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/particles/ParticlesModel.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.particles 2 | 3 | import org.saar.core.mesh.Model 4 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 5 | import org.saar.maths.transform.SimpleTransform 6 | 7 | class ParticlesModel @JvmOverloads constructor( 8 | override val mesh: ParticlesMesh, 9 | val texture: ReadOnlyTexture2D, 10 | val textureAtlasSize: Int, 11 | val maxAge: Int, 12 | val transform: SimpleTransform = SimpleTransform(), 13 | ) : Model -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/particles/components/ParticlesMeshUpdateComponent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.particles.components 2 | 3 | import org.saar.core.node.ComposableNode 4 | import org.saar.core.node.NodeComponent 5 | 6 | class ParticlesMeshUpdateComponent : NodeComponent { 7 | 8 | private lateinit var modelComponent: ParticlesModelComponent 9 | 10 | override fun start(node: ComposableNode) { 11 | this.modelComponent = node.components.get() 12 | } 13 | 14 | override fun update(node: ComposableNode) { 15 | this.modelComponent.model.mesh.buffers.store(0) 16 | } 17 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/particles/components/ParticlesModelComponent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.particles.components 2 | 3 | import org.saar.core.common.particles.ParticlesModel 4 | import org.saar.core.node.NodeComponent 5 | 6 | class ParticlesModelComponent(val model: ParticlesModel) : NodeComponent { 7 | 8 | var instancesCount: Int by model.mesh::instancesCount 9 | 10 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/r2d/MeshWriter2D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.r2d 2 | 3 | import org.saar.core.mesh.writer.IndexedMeshWriter 4 | import org.saar.core.mesh.writer.VertexMeshWriter 5 | import org.saar.lwjgl.util.DataWriter 6 | 7 | class MeshWriter2D( 8 | private val positionWriter: DataWriter, 9 | private val colourWriter: DataWriter, 10 | private val indexWriter: DataWriter, 11 | ) : VertexMeshWriter, IndexedMeshWriter { 12 | 13 | override fun writeVertex(vertex: Vertex2D) { 14 | this.positionWriter.write2f(vertex.position2f) 15 | this.colourWriter.write3f(vertex.colour3f) 16 | } 17 | 18 | override fun writeIndex(index: Int) = this.indexWriter.writeInt(index) 19 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/r2d/Model2D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.r2d 2 | 3 | import org.saar.core.mesh.Mesh 4 | import org.saar.core.mesh.Model 5 | 6 | class Model2D(override val mesh: Mesh) : Model -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/r2d/Node2D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.r2d 2 | 3 | import org.saar.core.node.Node 4 | import org.saar.core.renderer.RenderContext 5 | import org.saar.core.renderer.forward.ForwardRenderNode 6 | import org.saar.core.renderer.p2d.RenderNode2D 7 | 8 | class Node2D(val model: Model2D) : Node, RenderNode2D, ForwardRenderNode { 9 | 10 | override fun render2D(context: RenderContext) { 11 | Renderer2D.render(context, this.model) 12 | } 13 | 14 | override fun renderForward(context: RenderContext) { 15 | Renderer2D.render(context, this.model) 16 | } 17 | 18 | override fun delete() { 19 | this.model.delete() 20 | } 21 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/r2d/Vertex2D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.r2d 2 | 3 | import org.joml.Vector2fc 4 | import org.joml.Vector3fc 5 | import org.saar.core.mesh.Vertex 6 | 7 | interface Vertex2D : Vertex { 8 | val position2f: Vector2fc 9 | val colour3f: Vector3fc 10 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/r3d/Instance3D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.r3d 2 | 3 | import org.saar.core.mesh.Instance 4 | import org.saar.maths.transform.Transform 5 | 6 | interface Instance3D : Instance { 7 | val transform: Transform 8 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/r3d/Model3D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.r3d 2 | 3 | import org.saar.core.mesh.Mesh 4 | import org.saar.core.mesh.Model 5 | import org.saar.maths.transform.SimpleTransform 6 | 7 | class Model3D(override val mesh: Mesh, val transform: SimpleTransform) : Model { 8 | constructor(mesh: Mesh) : this(mesh, SimpleTransform()) 9 | 10 | var specular: Float = 1f 11 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/r3d/Vertex3D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.r3d 2 | 3 | import org.joml.Vector3fc 4 | import org.saar.core.mesh.Vertex 5 | 6 | interface Vertex3D : Vertex { 7 | val position3f: Vector3fc 8 | val normal3f: Vector3fc 9 | val colour3f: Vector3fc 10 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/Terrain.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain 2 | 3 | import org.saar.core.node.Node 4 | 5 | interface Terrain : Node { 6 | 7 | /** 8 | * Return the height of the terrain at world coordinates x and z 9 | * 10 | * @param x the x world coordinate 11 | * @param z the z world coordinate 12 | */ 13 | fun getHeight(x: Float, z: Float): Float 14 | 15 | /** 16 | * Return whether the terrain contains the given coordinates 17 | * 18 | * @param x the x world coordinate 19 | * @param z the z world coordinate 20 | */ 21 | fun contains(x: Float, z: Float): Boolean 22 | 23 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/TerrainFactory.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain 2 | 3 | import org.joml.Vector2ic 4 | 5 | interface TerrainFactory { 6 | 7 | fun create(position: Vector2ic): Terrain 8 | 9 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/Terrains.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain; 2 | 3 | public final class Terrains { 4 | 5 | private Terrains() { 6 | throw new AssertionError("Cannot create instance of class " 7 | + getClass().getSimpleName()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/World.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain 2 | 3 | import org.saar.core.node.ParentNode 4 | 5 | interface World : ParentNode { 6 | 7 | override val children: List 8 | 9 | fun getHeight(x: Float, z: Float): Float 10 | 11 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/colour/AlterColourGenerator.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain.colour 2 | 3 | import org.joml.Vector3fc 4 | import org.saar.maths.utils.Vector3 5 | import kotlin.random.Random 6 | 7 | class AlterColourGenerator(private val max: Float, private val generator: ColourGenerator) : ColourGenerator { 8 | 9 | override fun generateColour(position: Vector3fc, normal: Vector3fc): Vector3fc { 10 | val colour = this.generator.generateColour(position, normal) 11 | return Vector3.of(colour).add( 12 | Random.nextFloat() * this.max, 13 | Random.nextFloat() * this.max, 14 | Random.nextFloat() * this.max, 15 | ) 16 | } 17 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/colour/ColourGenerator.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain.colour; 2 | 3 | import org.joml.Vector3fc; 4 | 5 | public interface ColourGenerator { 6 | 7 | Vector3fc generateColour(Vector3fc position, Vector3fc normal); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/colour/HeightColour.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain.colour 2 | 3 | import org.joml.Vector3fc 4 | 5 | data class HeightColour(val y: Float, val colour: Vector3fc) -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/colour/NormalColour.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain.colour 2 | 3 | import org.joml.Vector3fc 4 | 5 | data class NormalColour(val product: Float, val colour: Vector3fc) -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/height/FlatHeightGenerator.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain.height; 2 | 3 | public class FlatHeightGenerator implements HeightGenerator { 4 | 5 | private final float height; 6 | 7 | public FlatHeightGenerator(float height) { 8 | this.height = height; 9 | } 10 | 11 | @Override 12 | public float generateHeight(float x, float z) { 13 | return this.height; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/height/HeightGenerator.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain.height; 2 | 3 | public interface HeightGenerator { 4 | 5 | float generateHeight(float x, float z); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/height/NoiseHeightGenerator.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain.height; 2 | 3 | import org.saar.maths.noise.Noise2f; 4 | 5 | public class NoiseHeightGenerator implements HeightGenerator { 6 | 7 | private final Noise2f noise; 8 | 9 | public NoiseHeightGenerator(Noise2f noise) { 10 | this.noise = noise; 11 | } 12 | 13 | @Override 14 | public float generateHeight(float x, float z) { 15 | return this.noise.noise(x, z); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/common/terrain/mesh/MeshGenerator.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.common.terrain.mesh 2 | 3 | import org.joml.Vector2f 4 | 5 | interface MeshGenerator { 6 | fun generateVertices(): Collection 7 | fun generateIndices(): Collection 8 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/engine/Application.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.engine 2 | 3 | import org.saar.lwjgl.glfw.window.Window 4 | 5 | interface Application { 6 | 7 | fun initialize(window: Window) 8 | 9 | fun update(window: Window) 10 | 11 | fun render(window: Window) 12 | 13 | fun close(window: Window) 14 | 15 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/engine/Engine.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.engine 2 | 3 | interface Engine { 4 | 5 | fun run(application: Application) 6 | 7 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/fog/Fog.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.fog 2 | 3 | import org.joml.Vector3fc 4 | 5 | data class Fog( 6 | override val colour: Vector3fc, 7 | override val start: Float, 8 | override val end: Float 9 | ) : IFog -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/fog/FogDistance.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.fog 2 | 3 | enum class FogDistance { 4 | DEPTH, Y, XZ, XYZ 5 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/fog/IFog.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.fog 2 | 3 | import org.joml.Vector3fc 4 | 5 | interface IFog { 6 | 7 | val colour: Vector3fc 8 | 9 | val start: Float 10 | 11 | val end: Float 12 | 13 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/light/DirectionalLight.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.light 2 | 3 | import org.joml.Vector3f 4 | import org.saar.maths.utils.Vector3 5 | 6 | class DirectionalLight : IDirectionalLight { 7 | override val direction: Vector3f = Vector3.create() 8 | override val colour: Vector3f = Vector3.create() 9 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/light/IDirectionalLight.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.light 2 | 3 | import org.joml.Vector3fc 4 | 5 | interface IDirectionalLight { 6 | val direction: Vector3fc 7 | val colour: Vector3fc 8 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/light/IPointLight.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.light 2 | 3 | import org.joml.Vector3fc 4 | 5 | interface IPointLight { 6 | val position: Vector3fc 7 | val attenuation: Attenuation 8 | val colour: Vector3fc 9 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/DrawCallMesh.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh 2 | 3 | import org.saar.lwjgl.opengl.drawcall.DrawCall 4 | import org.saar.lwjgl.opengl.vao.IVao 5 | 6 | class DrawCallMesh( 7 | private val vao: IVao, 8 | private val drawCall: DrawCall, 9 | ) : Mesh { 10 | 11 | override fun draw() { 12 | this.vao.bind() 13 | this.drawCall.doDrawCall() 14 | } 15 | 16 | override fun delete() { 17 | this.vao.delete() 18 | } 19 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/Instance.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh; 2 | 3 | public interface Instance { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/Mesh.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh; 2 | 3 | public interface Mesh { 4 | 5 | void draw(); 6 | 7 | void delete(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/MeshBuilder.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh 2 | 3 | interface MeshBuilder : UnloadedMesh -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/Model.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh 2 | 3 | interface Model { 4 | val mesh: Mesh 5 | 6 | fun draw() = mesh.draw() 7 | 8 | fun delete() = mesh.delete() 9 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/UnloadedMesh.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh; 2 | 3 | public interface UnloadedMesh { 4 | 5 | void delete(); 6 | 7 | Mesh load(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/Vertex.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh; 2 | 3 | public interface Vertex { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/buffer/MeshBuffer.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh.buffer 2 | 3 | import org.saar.lwjgl.opengl.vao.WritableVao 4 | import org.saar.lwjgl.util.DataReader 5 | import org.saar.lwjgl.util.DataWriter 6 | 7 | interface MeshBuffer { 8 | 9 | val writer: DataWriter 10 | 11 | val reader: DataReader 12 | 13 | fun store(offset: Long) 14 | 15 | fun loadInVao(vao: WritableVao) 16 | 17 | fun delete() 18 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/buffer/MeshBufferBuilder.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh.buffer 2 | 3 | import org.saar.lwjgl.opengl.vbo.VboTarget 4 | import org.saar.lwjgl.util.DataWriter 5 | 6 | interface MeshBufferBuilder { 7 | 8 | val writer: DataWriter 9 | 10 | fun build(target: VboTarget): MeshBuffer 11 | 12 | fun delete() 13 | 14 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/common/QuadMesh.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh.common 2 | 3 | import org.saar.core.mesh.Mesh 4 | import org.saar.lwjgl.opengl.constants.RenderMode 5 | import org.saar.lwjgl.opengl.vao.Vao 6 | import org.saar.lwjgl.opengl.utils.GlRendering 7 | 8 | object QuadMesh : Mesh { 9 | 10 | override fun draw() { 11 | Vao.EMPTY.bind() 12 | GlRendering.drawArrays(RenderMode.TRIANGLE_STRIP, 0, 4) 13 | } 14 | 15 | override fun delete() { 16 | } 17 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/reader/IndexedMeshReader.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh.reader 2 | 3 | interface IndexedMeshReader { 4 | fun readIndex(): Int 5 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/reader/InstancedMeshReader.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh.reader 2 | 3 | import org.saar.core.mesh.Instance 4 | 5 | interface InstancedMeshReader { 6 | fun readInstance(): V 7 | } 8 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/reader/VertexMeshReader.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh.reader 2 | 3 | import org.saar.core.mesh.Vertex 4 | 5 | interface VertexMeshReader { 6 | fun readVertex(): V 7 | } 8 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/writer/FloatVertexWriter.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh.writer 2 | 3 | import org.saar.lwjgl.opengl.constants.DataType 4 | import org.saar.lwjgl.opengl.attribute.pointer.AttributePointer 5 | import org.saar.lwjgl.opengl.attribute.pointer.FloatAttributePointer 6 | import org.saar.lwjgl.util.DataWriter 7 | 8 | class FloatVertexWriter(private val dataWriter: DataWriter) : VertexDataWriter { 9 | 10 | val attributePointer: AttributePointer = 11 | FloatAttributePointer(1, DataType.FLOAT, false) 12 | 13 | override val attributePointers: List = listOf(this.attributePointer) 14 | 15 | fun write(value: Float) = this.dataWriter.writeFloat(value) 16 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/writer/IndexedMeshWriter.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh.writer 2 | 3 | interface IndexedMeshWriter { 4 | fun writeIndex(index: Int) 5 | } 6 | 7 | fun IndexedMeshWriter.writeIndices(indices: IntArray) = 8 | indices.forEach { writeIndex(it) } 9 | 10 | fun IndexedMeshWriter.writeIndices(indices: Array) = 11 | indices.forEach { writeIndex(it) } 12 | 13 | fun IndexedMeshWriter.writeIndices(indices: Iterable) = 14 | indices.forEach { writeIndex(it) } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/writer/InstancedMeshWriter.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh.writer 2 | 3 | import org.saar.core.mesh.Instance 4 | 5 | interface InstancedMeshWriter { 6 | fun writeInstance(instance: I) 7 | } 8 | 9 | fun InstancedMeshWriter.writeInstances(instances: Array) = 10 | instances.forEach { writeInstance(it) } 11 | 12 | fun InstancedMeshWriter.writeInstances(instances: Iterable) = 13 | instances.forEach { writeInstance(it) } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/mesh/writer/VertexMeshWriter.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.mesh.writer 2 | 3 | import org.saar.core.mesh.Vertex 4 | 5 | interface VertexMeshWriter { 6 | fun writeVertex(vertex: V) 7 | } 8 | 9 | fun VertexMeshWriter.writeVertices(vertices: Array) = 10 | vertices.forEach { writeVertex(it) } 11 | 12 | fun VertexMeshWriter.writeVertices(vertices: Iterable) = 13 | vertices.forEach { writeVertex(it) } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/node/ChildNode.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.node 2 | 3 | interface ChildNode : Node { 4 | val parent: Node 5 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/node/ComposableNode.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.node 2 | 3 | interface ComposableNode : Node { 4 | 5 | val components: NodeComponentGroup 6 | 7 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/node/Node.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.node 2 | 3 | interface Node { 4 | 5 | fun update() = Unit 6 | 7 | fun delete() = Unit 8 | 9 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/node/NodeComponent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.node 2 | 3 | import org.saar.core.node.ComposableNode 4 | 5 | interface NodeComponent { 6 | 7 | /** 8 | * Initialize the component 9 | * 10 | * @param node the node that is influenced by the component 11 | */ 12 | fun start(node: ComposableNode) = Unit 13 | 14 | /** 15 | * Update the component 16 | * 17 | * @param node the node that is influenced by the component 18 | */ 19 | fun update(node: ComposableNode) = Unit 20 | 21 | /** 22 | * Delete the component 23 | * 24 | * @param node the node that is influenced by the component 25 | */ 26 | fun delete(node: ComposableNode) = Unit 27 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/node/ParentNode.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.node 2 | 3 | interface ParentNode : Node { 4 | 5 | val children: List 6 | 7 | override fun update() { 8 | this.children.forEach { it.update() } 9 | } 10 | 11 | override fun delete() { 12 | this.children.forEach { it.delete() } 13 | } 14 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/postprocessing/PostProcessingBuffers.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.postprocessing 2 | 3 | import org.saar.core.renderer.p2d.RenderingBuffers2D 4 | 5 | typealias PostProcessingBuffers = RenderingBuffers2D -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/postprocessing/PostProcessor.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.postprocessing 2 | 3 | import org.saar.core.renderer.renderpass.RenderPass 4 | 5 | typealias PostProcessor = RenderPass -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/postprocessing/processors/Swizzle.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.postprocessing.processors 2 | 3 | enum class Swizzle { 4 | R, G, B, A 5 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/RenderContext.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer; 2 | 3 | import org.saar.core.camera.ICamera; 4 | 5 | public class RenderContext { 6 | 7 | private final ICamera camera; 8 | 9 | public RenderContext(ICamera camera) { 10 | this.camera = camera; 11 | } 12 | 13 | public ICamera getCamera() { 14 | return this.camera; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/Renderer.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer; 2 | 3 | public interface Renderer { 4 | 5 | void delete(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/RendererMethodsBase.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer 2 | 3 | interface RendererMethodsBase : Renderer { 4 | 5 | fun render(context: C, models: Iterable) 6 | 7 | fun render(context: C, vararg models: M) { 8 | render(context, models.asIterable()) 9 | } 10 | 11 | fun render(context: C, model: M) { 12 | render(context, listOf(model)) 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/RendererPrototype.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer; 2 | 3 | public interface RendererPrototype { 4 | 5 | default String[] vertexAttributes() { 6 | return new String[0]; 7 | } 8 | 9 | default String[] fragmentOutputs() { 10 | return new String[0]; 11 | } 12 | 13 | default void onRenderCycle(RenderContext context) { 14 | } 15 | 16 | default void onInstanceDraw(RenderContext context, T instance) { 17 | } 18 | 19 | void doInstanceDraw(RenderContext context, T instance); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/RendererPrototypeWrapper.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer 2 | 3 | abstract class RendererPrototypeWrapper(prototype: RendererPrototype) : Renderer { 4 | 5 | private val helper = RendererPrototypeHelper(prototype) 6 | 7 | fun render(context: RenderContext, models: Iterable) { 8 | this.helper.render(context, models) 9 | } 10 | 11 | fun render(context: RenderContext, vararg models: T) { 12 | render(context, models.asIterable()) 13 | } 14 | 15 | final override fun delete() { 16 | this.helper.delete() 17 | } 18 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/RenderingOutput.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer 2 | 3 | import org.saar.core.renderer.renderpass.RenderPassBuffers 4 | import org.saar.core.screen.MainScreen 5 | import org.saar.core.screen.Screen 6 | 7 | class RenderingOutput( 8 | private val screen: Screen, 9 | val buffers: T) { 10 | 11 | fun to(screen: Screen) = this.screen.copyTo(screen) 12 | 13 | fun toMainScreen() = to(MainScreen) 14 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/RenderingPath.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer; 2 | 3 | import org.saar.core.renderer.renderpass.RenderPassBuffers; 4 | 5 | public interface RenderingPath { 6 | 7 | RenderingOutput render(); 8 | 9 | void delete(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/RenderingPathScreenPrototype.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer 2 | 3 | import org.saar.core.renderer.renderpass.RenderPassBuffers 4 | import org.saar.core.screen.ScreenPrototype 5 | 6 | interface RenderingPathScreenPrototype : ScreenPrototype { 7 | val buffers: T 8 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/deferred/DeferredRenderNode.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.deferred 2 | 3 | import org.saar.core.node.Node 4 | import org.saar.core.renderer.RenderContext 5 | 6 | interface DeferredRenderNode : Node { 7 | 8 | fun renderDeferred(context: RenderContext) 9 | 10 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/deferred/DeferredRenderNodeGroup.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.deferred 2 | 3 | import org.saar.core.node.ParentNode 4 | import org.saar.core.renderer.RenderContext 5 | 6 | class DeferredRenderNodeGroup(vararg children: DeferredRenderNode) : ParentNode, DeferredRenderNode { 7 | 8 | override val children: MutableList = children.toMutableList() 9 | 10 | override fun renderDeferred(context: RenderContext) = this.children.forEach { it.renderDeferred(context) } 11 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/deferred/DeferredRenderPass.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.deferred 2 | 3 | import org.saar.core.renderer.renderpass.RenderPass 4 | 5 | typealias DeferredRenderPass = RenderPass -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/deferred/DeferredRenderingBuffers.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.deferred 2 | 3 | import org.saar.core.renderer.forward.ForwardRenderingBuffers 4 | import org.saar.core.renderer.renderpass.NormalSpecularBuffer 5 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 6 | 7 | interface DeferredRenderingBuffers : ForwardRenderingBuffers, NormalSpecularBuffer { 8 | override val albedo: ReadOnlyTexture2D 9 | override val normalSpecular: ReadOnlyTexture2D 10 | override val depth: ReadOnlyTexture2D 11 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/deferred/DeferredRenderingPath.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.deferred 2 | 3 | import org.saar.core.camera.ICamera 4 | import org.saar.core.renderer.RenderingPath 5 | import org.saar.core.renderer.SimpleRenderingPath 6 | 7 | class DeferredRenderingPath( 8 | camera: ICamera, 9 | pipeline: DeferredRenderingPipeline, 10 | ) : RenderingPath { 11 | 12 | private val path = SimpleRenderingPath(camera, pipeline, DeferredScreenPrototype()) 13 | 14 | override fun render() = this.path.render() 15 | 16 | override fun delete() = this.path.delete() 17 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/deferred/DeferredRenderingPipeline.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.deferred 2 | 3 | import org.saar.core.renderer.RenderingPathPipeline 4 | 5 | class DeferredRenderingPipeline( 6 | override vararg val passes: DeferredRenderPass, 7 | ) : RenderingPathPipeline -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/forward/ForwardRenderNode.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.forward 2 | 3 | import org.saar.core.node.Node 4 | import org.saar.core.renderer.RenderContext 5 | 6 | interface ForwardRenderNode : Node { 7 | 8 | fun renderForward(context: RenderContext) 9 | 10 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/forward/ForwardRenderNodeGroup.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.forward 2 | 3 | import org.saar.core.node.ParentNode 4 | import org.saar.core.renderer.RenderContext 5 | 6 | class ForwardRenderNodeGroup(vararg children: ForwardRenderNode) : ParentNode, ForwardRenderNode { 7 | 8 | override val children: List = children.toMutableList() 9 | 10 | override fun renderForward(context: RenderContext) = this.children.forEach { it.renderForward(context) } 11 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/forward/ForwardRenderPass.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.forward 2 | 3 | import org.saar.core.renderer.renderpass.RenderPass 4 | 5 | typealias ForwardRenderPass = RenderPass -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/forward/ForwardRenderingBuffers.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.forward 2 | 3 | import org.saar.core.postprocessing.PostProcessingBuffers 4 | import org.saar.core.renderer.renderpass.DepthBuffer 5 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 6 | 7 | interface ForwardRenderingBuffers : PostProcessingBuffers, DepthBuffer { 8 | override val albedo: ReadOnlyTexture2D 9 | override val depth: ReadOnlyTexture2D 10 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/forward/ForwardRenderingPath.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.forward 2 | 3 | import org.saar.core.camera.ICamera 4 | import org.saar.core.renderer.RenderingPath 5 | import org.saar.core.renderer.SimpleRenderingPath 6 | 7 | class ForwardRenderingPath( 8 | camera: ICamera, 9 | pipeline: ForwardRenderingPipeline, 10 | ) : RenderingPath { 11 | 12 | private val path = SimpleRenderingPath(camera, pipeline, ForwardScreenPrototype()) 13 | 14 | override fun render() = this.path.render() 15 | 16 | override fun delete() = this.path.delete() 17 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/forward/ForwardRenderingPipeline.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.forward 2 | 3 | import org.saar.core.renderer.RenderingPathPipeline 4 | 5 | class ForwardRenderingPipeline( 6 | override vararg val passes: ForwardRenderPass, 7 | ) : RenderingPathPipeline -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/p2d/GeometryPass2D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.p2d 2 | 3 | import org.saar.core.renderer.RenderContext 4 | 5 | class GeometryPass2D(private vararg val children: RenderNode2D) : RenderPass2D { 6 | 7 | override fun render(context: RenderContext, buffers: RenderingBuffers2D) { 8 | this.children.forEach { it.render2D(RenderContext(context.camera)) } 9 | } 10 | 11 | override fun delete() = this.children.forEach { it.delete() } 12 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/p2d/RenderNode2D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.p2d 2 | 3 | import org.saar.core.node.Node 4 | import org.saar.core.renderer.RenderContext 5 | 6 | interface RenderNode2D : Node { 7 | fun render2D(context: RenderContext) 8 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/p2d/RenderPass2D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.p2d 2 | 3 | import org.saar.core.renderer.renderpass.RenderPass 4 | 5 | typealias RenderPass2D = RenderPass -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/p2d/RenderingBuffers2D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.p2d 2 | 3 | import org.saar.core.renderer.renderpass.AlbedoBuffer 4 | import org.saar.core.renderer.renderpass.RenderPassBuffers 5 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 6 | 7 | interface RenderingBuffers2D : RenderPassBuffers, AlbedoBuffer { 8 | override val albedo: ReadOnlyTexture2D 9 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/p2d/RenderingPath2D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.p2d 2 | 3 | import org.saar.core.camera.ICamera 4 | import org.saar.core.renderer.RenderingPath 5 | import org.saar.core.renderer.SimpleRenderingPath 6 | 7 | class RenderingPath2D(camera: ICamera, pipeline: RenderingPipeline2D) : RenderingPath { 8 | 9 | private val path = SimpleRenderingPath(camera, pipeline, ScreenPrototype2D()) 10 | 11 | override fun render() = this.path.render() 12 | 13 | override fun delete() = this.path.delete() 14 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/p2d/RenderingPipeline2D.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.p2d 2 | 3 | import org.saar.core.renderer.RenderingPathPipeline 4 | 5 | class RenderingPipeline2D( 6 | override vararg val passes: RenderPass2D, 7 | ) : RenderingPathPipeline -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/renderpass/RenderPass.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.renderpass 2 | 3 | import org.saar.core.renderer.RenderContext 4 | 5 | interface RenderPass { 6 | 7 | fun prepare(context: RenderContext, buffers: T) = Unit 8 | 9 | fun render(context: RenderContext, buffers: T) 10 | 11 | fun delete() 12 | 13 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/renderpass/RenderPassBuffers.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.renderpass 2 | 3 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 4 | 5 | interface RenderPassBuffers 6 | 7 | interface AlbedoBuffer : RenderPassBuffers { 8 | val albedo: ReadOnlyTexture2D 9 | } 10 | 11 | interface DepthBuffer : RenderPassBuffers { 12 | val depth: ReadOnlyTexture2D 13 | } 14 | 15 | interface NormalBuffer : RenderPassBuffers { 16 | val normal: ReadOnlyTexture2D 17 | } 18 | 19 | interface SpecularBuffer : RenderPassBuffers { 20 | val specular: ReadOnlyTexture2D 21 | } 22 | 23 | interface NormalSpecularBuffer : RenderPassBuffers { 24 | val normalSpecular: ReadOnlyTexture2D 25 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/renderpass/RenderPassPrototype.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.renderpass 2 | 3 | import org.saar.lwjgl.opengl.shader.GlslVersion 4 | import org.saar.lwjgl.opengl.shader.Shader 5 | import org.saar.lwjgl.opengl.shader.ShaderCode 6 | 7 | private val vertexShaderCode = ShaderCode.loadSource( 8 | "/shaders/common/quad/quad.vertex.glsl") 9 | 10 | interface RenderPassPrototype { 11 | 12 | val vertexShader: Shader get() = Shader.createVertex(GlslVersion.V400, vertexShaderCode) 13 | 14 | val fragmentShader: Shader 15 | 16 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/shaders/ShaderProperty.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.shaders; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface ShaderProperty { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/shadow/ShadowsBuffers.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.shadow 2 | 3 | import org.saar.core.renderer.renderpass.DepthBuffer 4 | import org.saar.core.renderer.renderpass.RenderPassBuffers 5 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 6 | 7 | interface ShadowsBuffers : RenderPassBuffers, DepthBuffer { 8 | override val depth: ReadOnlyTexture2D 9 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/shadow/ShadowsRenderNode.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.shadow 2 | 3 | import org.saar.core.node.Node 4 | import org.saar.core.renderer.RenderContext 5 | 6 | interface ShadowsRenderNode : Node { 7 | 8 | fun renderShadows(context: RenderContext) 9 | 10 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/shadow/ShadowsRenderNodeGroup.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.shadow 2 | 3 | import org.saar.core.node.ParentNode 4 | import org.saar.core.renderer.RenderContext 5 | 6 | class ShadowsRenderNodeGroup(vararg children: ShadowsRenderNode) : ParentNode, ShadowsRenderNode { 7 | 8 | override val children: MutableList = children.toMutableList() 9 | 10 | override fun renderShadows(context: RenderContext) = this.children.forEach { it.renderShadows(context) } 11 | } -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/uniforms/UniformProperty.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.uniforms; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface UniformProperty { 11 | 12 | UniformTrigger value() default UniformTrigger.ALWAYS; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/renderer/uniforms/UniformTrigger.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.renderer.uniforms; 2 | 3 | public enum UniformTrigger { 4 | 5 | PER_INSTANCE, 6 | PER_RENDER_CYCLE, 7 | ALWAYS 8 | 9 | } 10 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/screen/OffScreen.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.screen; 2 | 3 | public interface OffScreen extends Screen { 4 | 5 | void resize(int width, int height); 6 | 7 | default void assureSize(int width, int height) { 8 | if (width != getWidth() || height != getHeight()) { 9 | resize(width, height); 10 | } 11 | } 12 | 13 | default void resizeToMainScreen() { 14 | final int width = MainScreen.INSTANCE.getWidth(); 15 | final int height = MainScreen.INSTANCE.getHeight(); 16 | assureSize(width, height); 17 | } 18 | 19 | void delete(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/screen/Screen.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.screen; 2 | 3 | import org.saar.lwjgl.opengl.fbo.FboBlitFilter; 4 | import org.saar.lwjgl.opengl.utils.GlBuffer; 5 | 6 | public interface Screen { 7 | 8 | int getWidth(); 9 | 10 | int getHeight(); 11 | 12 | default void copyTo(Screen other) { 13 | copyTo(other, FboBlitFilter.LINEAR, GlBuffer.COLOUR); 14 | } 15 | 16 | void copyTo(Screen other, FboBlitFilter filter, GlBuffer... buffers); 17 | 18 | void setAsDraw(); 19 | 20 | void setAsRead(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/screen/ScreenImagePrototype.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.screen 2 | 3 | import org.saar.lwjgl.opengl.fbo.attachment.buffer.AttachmentBuffer 4 | import org.saar.lwjgl.opengl.fbo.attachment.index.AttachmentIndex 5 | 6 | data class ScreenImagePrototype( 7 | val index: AttachmentIndex, 8 | val buffer: AttachmentBuffer, 9 | val draw: Boolean = true, 10 | val read: Boolean = false, 11 | ) -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/screen/ScreenImagesLocator.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.screen; 2 | 3 | import org.saar.core.screen.annotations.ScreenImageProperty; 4 | import org.saar.core.util.reflection.FieldsLocator; 5 | 6 | import java.util.List; 7 | 8 | public final class ScreenImagesLocator { 9 | 10 | private final FieldsLocator fieldsLocator; 11 | 12 | public ScreenImagesLocator(ScreenPrototype prototype) { 13 | this.fieldsLocator = new FieldsLocator(prototype); 14 | } 15 | 16 | public List getScreenImagePrototypes() { 17 | return this.fieldsLocator.getFilteredValues(ScreenImagePrototype.class, ScreenImageProperty.class); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/screen/ScreenPrototype.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.screen; 2 | 3 | public interface ScreenPrototype { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/screen/annotations/ScreenImageProperty.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.screen.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface ScreenImageProperty { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/screen/image/ScreenImage.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.screen.image; 2 | 3 | import org.saar.lwjgl.opengl.fbo.ReadOnlyFbo; 4 | import org.saar.lwjgl.opengl.fbo.attachment.IAttachment; 5 | import org.saar.lwjgl.opengl.fbo.attachment.index.AttachmentIndex; 6 | 7 | public interface ScreenImage { 8 | 9 | IAttachment getAttachment(); 10 | 11 | default void init(ReadOnlyFbo fbo, AttachmentIndex index) { 12 | getAttachment().init(fbo, index); 13 | } 14 | 15 | default void delete() { 16 | getAttachment().delete(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/screen/image/SimpleScreenImage.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.screen.image; 2 | 3 | import org.saar.lwjgl.opengl.fbo.attachment.IAttachment; 4 | 5 | public class SimpleScreenImage implements ScreenImage { 6 | 7 | private final IAttachment attachment; 8 | 9 | public SimpleScreenImage(IAttachment attachment) { 10 | this.attachment = attachment; 11 | } 12 | 13 | @Override 14 | public IAttachment getAttachment() { 15 | return this.attachment; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/util/Fps.java: -------------------------------------------------------------------------------- 1 | package org.saar.core.util; 2 | 3 | import org.lwjgl.glfw.GLFW; 4 | 5 | public class Fps { 6 | 7 | private double last; 8 | 9 | public Fps() { 10 | this.last = current(); 11 | } 12 | 13 | private static double current() { 14 | return GLFW.glfwGetTime(); 15 | } 16 | 17 | public void update() { 18 | this.last = current(); 19 | } 20 | 21 | public double delta() { 22 | return current() - this.last; 23 | } 24 | 25 | public double fps() { 26 | return 1 / delta(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pe-core/src/main/java/org/saar/core/util/Time.kt: -------------------------------------------------------------------------------- 1 | package org.saar.core.util 2 | 3 | import java.time.Duration 4 | 5 | class Time { 6 | 7 | private var last: Long = System.currentTimeMillis() 8 | 9 | fun delta(): Duration = Duration.ofMillis( 10 | System.currentTimeMillis() - this.last) 11 | 12 | fun update() { 13 | this.last = System.currentTimeMillis() 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/common/fog/fog.header.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Fog Header file 4 | * 5 | **/ 6 | 7 | float calcFogAmount(float distance, Fog fog); 8 | 9 | vec3 calcFogColour(float distance, Fog fog); 10 | 11 | vec3 applyFogColour(float distance, Fog fog, vec3 colour); -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/common/fog/fog.source.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Fog source file 4 | * 5 | **/ 6 | 7 | float calcFogAmount(float distance, Fog fog) { 8 | float amount = (fog.end - distance) / (fog.end - fog.start); 9 | return smoothstep(0, 1, clamp(amount, 0, 1)); 10 | } 11 | 12 | vec3 calcFogColour(float distance, Fog fog) { 13 | float amount = calcFogAmount(distance, fog); 14 | return amount * fog.colour; 15 | } 16 | 17 | vec3 applyFogColour(float distance, Fog fog, vec3 colour) { 18 | float amount = calcFogAmount(distance, fog); 19 | return mix(fog.colour, colour, amount); 20 | } -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/common/fog/fog.struct.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Fog Structs file 4 | * 5 | **/ 6 | 7 | struct Fog { 8 | vec3 colour; 9 | float start; 10 | float end; 11 | }; -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/common/light/light.struct.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Light Structs file 4 | * 5 | **/ 6 | 7 | // Point light 8 | struct PointLight { 9 | vec3 position; 10 | vec3 attenuation; 11 | vec3 colour; 12 | }; 13 | 14 | // Directional light 15 | struct DirectionalLight { 16 | vec3 direction; 17 | vec3 colour; 18 | }; -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/common/noise/noise.header.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Noise Header file 4 | * 5 | **/ 6 | 7 | float noise(float seed); 8 | float noise(vec2 seed); -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/common/quad/quad.vertex.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Simple full screen quad vertex shader 4 | * 5 | */ 6 | 7 | // Consts 8 | const vec2[] vertices = vec2[]( 9 | vec2(+0, +0), vec2(+1, +0), 10 | vec2(+0, +1), vec2(+1, +1) 11 | ); 12 | 13 | // Vertex outputs 14 | out vec2 v_position; 15 | 16 | void main(void) { 17 | v_position = vertices[gl_VertexID]; 18 | 19 | gl_Position = vec4(v_position * 2 - 1, 0, 1); 20 | } 21 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/common/random/random.header.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Random Header file 4 | * 5 | **/ 6 | 7 | float random(float seed); 8 | float random(vec2 seed); 9 | float random(vec3 seed); 10 | float random(vec4 seed); -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/common/random/random.source.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Random source file 4 | * 5 | **/ 6 | 7 | #define RANDOM(seed) (fract(sin(seed) * 43758.5453)) 8 | 9 | float random(float seed) { 10 | float root = 12.9898; 11 | return RANDOM(seed * root); 12 | } 13 | 14 | float random(vec2 seed) { 15 | vec2 root = vec2(12.9898, 78.233); 16 | return RANDOM(dot(seed, root)); 17 | } 18 | 19 | float random(vec3 seed) { 20 | vec3 root = vec3(12.9898, 78.233, 45.164); 21 | return RANDOM(dot(seed, root)); 22 | } 23 | 24 | float random(vec4 seed) { 25 | vec4 root = vec4(12.9898, 78.233, 45.164, 94.673); 26 | return RANDOM(dot(seed, root)); 27 | } -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/common/transform/transform.struct.glsl: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Transform Structs file 4 | * 5 | **/ -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/normal-map/normal-map.dfragment.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec2 v_uvCoord; 3 | in mat3 v_TBN; 4 | 5 | // Uniforms 6 | uniform sampler2D u_texture; 7 | uniform sampler2D u_normalMap; 8 | uniform float u_specular; 9 | uniform mat4 u_normalMatrix; 10 | 11 | // Fragment outputs 12 | layout (location = 0) out vec4 f_colour; 13 | layout (location = 1) out vec4 f_normalSpecular; 14 | 15 | void main(void) { 16 | f_colour = texture(u_texture, v_uvCoord); 17 | 18 | vec3 normal = texture(u_normalMap, v_uvCoord).rgb; 19 | normal = normalize(v_TBN * (normal * 2.0 - 1.0)); 20 | normal = (u_normalMatrix * vec4(normal, 0)).xyz; 21 | 22 | f_normalSpecular = vec4(normal, u_specular); 23 | } 24 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/normal-map/normal-map.fragment.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec2 v_uvCoord; 3 | in mat3 v_TBN; 4 | 5 | // Uniforms 6 | uniform sampler2D u_texture; 7 | uniform sampler2D u_normalMap; 8 | uniform mat4 u_normalMatrix; 9 | 10 | // Fragment outputs 11 | layout (location = 0) out vec4 f_colour; 12 | 13 | void main(void) { 14 | f_colour = texture(u_texture, v_uvCoord); 15 | 16 | vec3 normal = texture(u_normalMap, v_uvCoord).rgb; 17 | normal = normalize(v_TBN * (normal * 2.0 - 1.0)); 18 | normal = (u_normalMatrix * vec4(normal, 0)).xyz; 19 | } 20 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/obj/obj.dfragment.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec2 v_uvCoord; 3 | in vec3 v_normal; 4 | 5 | // Uniforms 6 | uniform sampler2D u_texture; 7 | uniform float u_specular; 8 | 9 | // Fragment outputs 10 | layout (location = 0) out vec4 f_colour; 11 | layout (location = 1) out vec4 f_normalSpecular; 12 | 13 | void main(void) { 14 | f_colour = texture(u_texture, v_uvCoord); 15 | f_normalSpecular = vec4(v_normal, u_specular); 16 | } 17 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/obj/obj.fragment.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec2 v_uvCoord; 3 | 4 | // Uniforms 5 | uniform sampler2D u_texture; 6 | 7 | // Fragment outputs 8 | layout (location = 0) out vec4 f_colour; 9 | 10 | void main(void) { 11 | f_colour = texture(u_texture, v_uvCoord); 12 | } 13 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/painting/random.fragment.glsl: -------------------------------------------------------------------------------- 1 | #include "/shaders/common/random/random" 2 | 3 | // Vertex outputs 4 | in vec2 v_position; 5 | 6 | // Fragment outputs 7 | layout (location = 0) out vec4 f_colour; 8 | 9 | void main(void) { 10 | float random = random(v_position.xyxy); 11 | 12 | f_colour = vec4(vec3(random), 1); 13 | } 14 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/painting/random2f.fragment.glsl: -------------------------------------------------------------------------------- 1 | #include "/shaders/common/random/random" 2 | 3 | // Vertex outputs 4 | in vec2 v_position; 5 | 6 | // Fragment outputs 7 | layout (location = 0) out vec4 f_colour; 8 | 9 | void main(void) { 10 | float x = random(v_position.xy); 11 | float y = random(v_position.xy * x * 156.562); 12 | 13 | f_colour = vec4(x, y, 0, 1); 14 | } 15 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/painting/random3f.fragment.glsl: -------------------------------------------------------------------------------- 1 | #include "/shaders/common/random/random" 2 | 3 | // Vertex outputs 4 | in vec2 v_position; 5 | 6 | // Fragment outputs 7 | layout (location = 0) out vec4 f_colour; 8 | 9 | void main(void) { 10 | float x = random(v_position.xy); 11 | float y = random(v_position.xy * x * 156.562); 12 | float z = random(v_position.xy * y * 913.874); 13 | 14 | f_colour = vec4(x, y, z, 1); 15 | } 16 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/particles/particles.dfragment.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec2 v_uvCoords1; 3 | in vec2 v_uvCoords2; 4 | in float v_blend; 5 | 6 | // Uniforms 7 | uniform sampler2D u_texture; 8 | 9 | // Fragment outputs 10 | layout (location = 0) out vec4 f_colour; 11 | layout (location = 1) out vec4 f_normalSpecular; 12 | 13 | void main(void) { 14 | vec4 colour1 = texture(u_texture, v_uvCoords1); 15 | vec4 colour2 = texture(u_texture, v_uvCoords2); 16 | f_colour = mix(colour1, colour2, v_blend); 17 | f_normalSpecular = vec4(0, 0, 1, .1); 18 | } 19 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/particles/particles.fragment.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec3 v_uvCoords; 3 | 4 | // Uniforms 5 | uniform sampler2D u_texture; 6 | 7 | // Fragment outputs 8 | layout (location = 0) out vec4 f_colour; 9 | 10 | void main(void) { 11 | f_colour = texture(u_texture, v_uvCoords); 12 | } 13 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/postprocessing/contrast.pass.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec2 v_position; 3 | 4 | // Uniforms 5 | uniform sampler2D u_texture; 6 | uniform float u_contrast; 7 | 8 | // Fragment outputs 9 | layout (location = 0) out vec4 f_colour; 10 | 11 | void main(void) { 12 | vec4 colour = texture(u_texture, v_position); 13 | f_colour = (colour - .5) * u_contrast + .5; 14 | } 15 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/postprocessing/gamma-correction.pass.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec2 v_position; 3 | 4 | // Uniforms 5 | uniform sampler2D u_texture; 6 | uniform float u_gamma; 7 | 8 | // Fragment outputs 9 | layout (location = 0) out vec4 f_colour; 10 | 11 | void main(void) { 12 | vec4 colour = texture(u_texture, v_position); 13 | colour.rgb = pow(colour.rgb, vec3(1.0 / u_gamma)); 14 | f_colour = colour; 15 | } 16 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/postprocessing/skybox.pass.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec2 v_position; 3 | in vec3 v_viewDirection; 4 | 5 | // Uniforms 6 | uniform samplerCube u_cubeMap; 7 | 8 | // Fragment outputs 9 | layout (location = 0) out vec4 f_colour; 10 | 11 | void main(void) { 12 | f_colour = texture(u_cubeMap, v_viewDirection); 13 | } 14 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/postprocessing/skybox.vertex.glsl: -------------------------------------------------------------------------------- 1 | // Consts 2 | const vec2[] vertices = vec2[]( 3 | vec2(+0, +0), vec2(+1, +0), 4 | vec2(+0, +1), vec2(+1, +1) 5 | ); 6 | 7 | // Uniforms 8 | uniform mat4 u_projectionMatrixInv; 9 | uniform mat4 u_viewMatrixInv; 10 | 11 | // Vertex outputs 12 | out vec2 v_position; 13 | out vec3 v_viewDirection; 14 | 15 | void main(void) { 16 | v_position = vertices[gl_VertexID]; 17 | 18 | v_viewDirection = mat3(u_viewMatrixInv) * (u_projectionMatrixInv * vec4(v_position * 2 - 1, 0, 1)).xyz; 19 | 20 | gl_Position = vec4(v_position * 2 - 1, 0, 1); 21 | } 22 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/postprocessing/swizzle.pass.glsl: -------------------------------------------------------------------------------- 1 | // Definitions 2 | #ifndef R 3 | #define R r 4 | #endif 5 | #ifndef G 6 | #define G g 7 | #endif 8 | #ifndef B 9 | #define B b 10 | #endif 11 | #ifndef A 12 | #define A a 13 | #endif 14 | 15 | // Vertex outputs 16 | in vec2 v_position; 17 | 18 | // Uniforms 19 | uniform sampler2D u_texture; 20 | uniform float u_contrast; 21 | 22 | // Fragment outputs 23 | layout (location = 0) out vec4 f_colour; 24 | 25 | void main(void) { 26 | vec4 colour = texture(u_texture, v_position); 27 | f_colour = vec4(colour.R, colour.G, colour.B, colour.A); 28 | } 29 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/r2d/r2d.fragment.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec2 v_position; 3 | in vec3 v_colour; 4 | 5 | // Fragment outputs 6 | layout (location = 0) out vec4 f_colour; 7 | 8 | void main(void) { 9 | f_colour = vec4(v_colour, 1.0); 10 | } 11 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/r2d/r2d.vertex.glsl: -------------------------------------------------------------------------------- 1 | // Per Vertex attibutes 2 | layout (location = 0) in vec2 in_position; 3 | layout (location = 1) in vec3 in_colour; 4 | 5 | // Vertex outputs 6 | out vec2 v_position; 7 | out vec3 v_colour; 8 | 9 | void main(void) { 10 | v_position = in_position; 11 | v_colour = in_colour; 12 | 13 | gl_Position = vec4(in_position, 0.0, 1.0); 14 | } 15 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/r3d/r3d.dfragment.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | flat in vec3 v_colour; 3 | flat in vec3 v_normal; 4 | 5 | // Uniforms 6 | uniform float u_specular; 7 | 8 | // Fragment outputs 9 | layout (location = 0) out vec4 f_colour; 10 | layout (location = 1) out vec4 f_normalSpecular; 11 | 12 | void main(void) { 13 | f_colour = vec4(v_colour, 1); 14 | f_normalSpecular = vec4(v_normal, u_specular); 15 | } 16 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/r3d/r3d.fragment.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | flat in vec3 v_colour; 3 | flat in vec3 v_normal; 4 | 5 | // Fragment outputs 6 | layout (location = 0) out vec4 f_colour; 7 | 8 | void main(void) { 9 | f_colour = vec4(v_colour, 1.0); 10 | } 11 | -------------------------------------------------------------------------------- /pe-core/src/main/resources/shaders/r3d/r3d.vertex.glsl: -------------------------------------------------------------------------------- 1 | // Per Vertex attibutes 2 | layout (location = 0) in vec3 in_position; 3 | layout (location = 1) in vec3 in_normal; 4 | layout (location = 2) in vec3 in_colour; 5 | layout (location = 3) in mat4 in_transformation; 6 | 7 | // Uniforms 8 | uniform mat4 u_mvpMatrix; 9 | uniform mat4 u_normalMatrix; 10 | 11 | // Vertex outputs 12 | flat out vec3 v_colour; 13 | flat out vec3 v_normal; 14 | 15 | void main(void) { 16 | v_colour = in_colour; 17 | 18 | v_normal = (u_normalMatrix * vec4(in_normal, 0.0)).xyz; 19 | 20 | vec4 world_position = u_mvpMatrix * in_transformation * vec4(in_position, 1.0); 21 | 22 | gl_Position = world_position; 23 | } 24 | -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/UIActiveElement.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui 2 | 3 | object UIActiveElement { 4 | 5 | var current: UINode = UINullNode 6 | 7 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/UIChildNode.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui 2 | 3 | interface UIChildNode : UINode { 4 | 5 | var parent: UIParentNode 6 | 7 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/UIMutableParent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui 2 | 3 | interface UIMutableParent : UIParentNode { 4 | 5 | override val children: List 6 | 7 | fun add(uiNode: UIChildNode) 8 | 9 | fun remove(uiNode: UIChildNode) 10 | 11 | operator fun UIChildNode.unaryPlus() = this@UIMutableParent.add(this@unaryPlus) 12 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/UINullNode.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui 2 | 3 | import org.saar.gui.style.NoStyle 4 | 5 | object UINullNode : UIParentNode { 6 | 7 | override val style = NoStyle 8 | 9 | override val children = emptyList() 10 | 11 | override val uiInputHelper = UIInputHelper(this) 12 | 13 | override fun contains(x: Int, y: Int) = false 14 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/event/EventListener.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.event 2 | 3 | fun interface EventListener { 4 | fun handle(event: T) 5 | } 6 | 7 | fun EventListener.andThen(listener: EventListener) = EventListener { event: T -> 8 | handle(event) 9 | listener.handle(event) 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/event/KeyboardEvent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.event 2 | 3 | import org.saar.lwjgl.glfw.input.Modifiers 4 | import org.saar.lwjgl.glfw.input.keyboard.KeyEvent 5 | 6 | class KeyboardEvent( 7 | val code: Int, 8 | val key: Int, 9 | val modifiers: Modifiers = Modifiers(0), 10 | ) 11 | 12 | fun KeyEvent.asKeyboardEvent() = KeyboardEvent( 13 | code = this.code, 14 | key = this.key, 15 | modifiers = this.modifiers, 16 | ) -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/font/Font.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.font 2 | 3 | import org.saar.lwjgl.opengl.texture.Texture2D 4 | 5 | interface Font { 6 | val size: Float 7 | val bitmap: Texture2D 8 | val characters: List 9 | val lineGap: Float 10 | 11 | val lineHeight: Float get() = this.size + this.lineGap 12 | 13 | fun delete() = this.bitmap.delete() 14 | 15 | val defaultCharacter get() = this.characters[0] 16 | 17 | fun getCharacter(char: Char) = this.characters.find { it.char == char } 18 | 19 | fun getCharacterOrDefault(char: Char) = getCharacter(char) ?: this.defaultCharacter 20 | } 21 | -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/font/FontCharacter.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.font 2 | 3 | import org.saar.maths.Box2i 4 | 5 | data class FontCharacter( 6 | val char: Char, 7 | val bitmapBox: Box2i, 8 | val localBox: Box2i, 9 | val xAdvance: Float 10 | ) -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/font/UILetter.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.font 2 | 3 | import org.joml.Vector2fc 4 | import org.saar.gui.UIText 5 | import org.saar.gui.style.Style 6 | 7 | class UILetter( 8 | val parent: UIText, val font: Font, 9 | val character: FontCharacter, val offset: Vector2fc, 10 | ) { 11 | 12 | val style: Style get() = this.parent.style 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/graphics/Graphics.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.graphics 2 | 3 | import org.saar.gui.style.Colour 4 | import org.saar.maths.objects.Polygon 5 | 6 | interface Graphics { 7 | 8 | var colour: Colour 9 | 10 | fun drawLine(x1: Int, y1: Int, x2: Int, y2: Int) 11 | 12 | fun drawRectangle(x: Int, y: Int, w: Int, h: Int) 13 | 14 | fun fillRectangle(x: Int, y: Int, w: Int, h: Int) 15 | 16 | fun drawOval(cx: Int, cy: Int, a: Int, b: Int) 17 | 18 | fun fillOval(cx: Int, cy: Int, a: Int, b: Int) 19 | 20 | fun fillPolygon(polygon: Polygon) 21 | 22 | fun clear(clearColour: Colour) 23 | 24 | fun process() 25 | 26 | fun delete() 27 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/Colour.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style 2 | 3 | class Colour(val red: Int, val green: Int, val blue: Int, val alpha: Float) { 4 | 5 | fun asInt(): Int = (this.red shl 0x18) + 6 | (this.green shl 0x10) + 7 | (this.blue shl 0x08) + 8 | (this.alpha * 255).toInt() 9 | 10 | override fun toString(): String { 11 | return "Colour(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})" 12 | } 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/StyleProperty.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style 2 | 3 | interface StyleProperty -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/alignment/Alignment.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.alignment 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.UIParentNode 5 | 6 | class Alignment(private val container: UIParentNode, default: AlignmentValue = AlignmentValues.horizontal) : ReadonlyAlignment { 7 | 8 | override var value: AlignmentValue = default 9 | 10 | override fun getX(child: UIChildNode) = this.value.computeAxisX(this.container, child) 11 | 12 | override fun getY(child: UIChildNode) = this.value.computeAxisY(this.container, child) 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/alignment/AlignmentValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.alignment 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.UIParentNode 5 | 6 | interface AlignmentValue { 7 | fun computeAxisX(container: UIParentNode, child: UIChildNode): Int 8 | 9 | fun computeAxisY(container: UIParentNode, child: UIChildNode): Int 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/alignment/NoAlignment.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.alignment 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | object NoAlignment : ReadonlyAlignment { 6 | override val value: AlignmentValue = AlignmentValues.none 7 | 8 | override fun getX(child: UIChildNode) = 0 9 | 10 | override fun getY(child: UIChildNode) = 0 11 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/alignment/ReadonlyAlignment.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.alignment 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.style.StyleProperty 5 | 6 | interface ReadonlyAlignment : StyleProperty { 7 | 8 | val value: AlignmentValue 9 | 10 | fun getX(child: UIChildNode): Int 11 | 12 | fun getY(child: UIChildNode): Int 13 | 14 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/arrangement/Arrangement.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.arrangement 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.UIParentNode 5 | 6 | class Arrangement(private val container: UIParentNode, default: ArrangementValue = ArrangementValues.start) : ReadonlyArrangement { 7 | 8 | override var value: ArrangementValue = default 9 | 10 | override fun getX(child: UIChildNode) = this.value.computeAxisX(this.container, child) 11 | 12 | override fun getY(child: UIChildNode) = this.value.computeAxisY(this.container, child) 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/arrangement/ArrangementValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.arrangement 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.UIParentNode 5 | 6 | interface ArrangementValue { 7 | fun computeAxisX(container: UIParentNode, child: UIChildNode): Int 8 | 9 | fun computeAxisY(container: UIParentNode, child: UIChildNode): Int 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/arrangement/NoArrangement.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.arrangement 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | object NoArrangement : ReadonlyArrangement { 6 | override val value: ArrangementValue = ArrangementValues.start 7 | 8 | override fun getX(child: UIChildNode) = 0 9 | 10 | override fun getY(child: UIChildNode) = 0 11 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/arrangement/ReadonlyArrangement.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.arrangement 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.style.StyleProperty 5 | 6 | interface ReadonlyArrangement : StyleProperty { 7 | 8 | val value: ArrangementValue 9 | 10 | fun getX(child: UIChildNode): Int 11 | 12 | fun getY(child: UIChildNode): Int 13 | 14 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/axisalignment/AxisAlignment.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.axisalignment 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.UIParentNode 5 | 6 | class AxisAlignment(private val container: UIParentNode, default: AxisAlignmentValue = AxisAlignmentValues.start) : ReadonlyAxisAlignment { 7 | 8 | override var value: AxisAlignmentValue = default 9 | 10 | override fun getX(child: UIChildNode) = this.value.computeAxisX(this.container, child) 11 | 12 | override fun getY(child: UIChildNode) = this.value.computeAxisY(this.container, child) 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/axisalignment/AxisAlignmentValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.axisalignment 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.UIParentNode 5 | 6 | interface AxisAlignmentValue { 7 | fun computeAxisX(container: UIParentNode, child: UIChildNode): Int 8 | 9 | fun computeAxisY(container: UIParentNode, child: UIChildNode): Int 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/axisalignment/NoAxisAlignment.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.axisalignment 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | object NoAxisAlignment : ReadonlyAxisAlignment { 6 | override val value: AxisAlignmentValue = AxisAlignmentValues.start 7 | 8 | override fun getX(child: UIChildNode) = 0 9 | 10 | override fun getY(child: UIChildNode) = 0 11 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/axisalignment/ReadonlyAxisAlignment.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.axisalignment 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.style.StyleProperty 5 | 6 | interface ReadonlyAxisAlignment : StyleProperty { 7 | 8 | val value: AxisAlignmentValue 9 | 10 | fun getX(child: UIChildNode): Int 11 | 12 | fun getY(child: UIChildNode): Int 13 | 14 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/backgroundcolour/BackgroundColourValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.backgroundcolour 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.style.Colour 5 | 6 | interface BackgroundColourValue { 7 | 8 | fun computeTopRight(container: UIChildNode): Colour 9 | 10 | fun computeTopLeft(container: UIChildNode): Colour 11 | 12 | fun computeBottomRight(container: UIChildNode): Colour 13 | 14 | fun computeBottomLeft(container: UIChildNode): Colour 15 | 16 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/backgroundcolour/NoBackgroundColour.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.backgroundcolour 2 | 3 | import org.saar.gui.style.Colours 4 | 5 | object NoBackgroundColour : ReadonlyBackgroundColour { 6 | 7 | override val topRight = Colours.TRANSPARENT 8 | override val topLeft = Colours.TRANSPARENT 9 | override val bottomRight = Colours.TRANSPARENT 10 | override val bottomLeft = Colours.TRANSPARENT 11 | 12 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/backgroundcolour/ReadonlyBackgroundColour.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.backgroundcolour 2 | 3 | import org.joml.Vector4i 4 | import org.saar.gui.style.Colour 5 | 6 | interface ReadonlyBackgroundColour { 7 | 8 | val topRight: Colour 9 | val topLeft: Colour 10 | val bottomRight: Colour 11 | val bottomLeft: Colour 12 | 13 | fun asVector4i(vector4i: Vector4i): Vector4i = vector4i.set( 14 | this.topRight.asInt(), this.topLeft.asInt(), 15 | this.bottomRight.asInt(), this.bottomLeft.asInt()) 16 | 17 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/backgroundimage/BackgroundImage.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.backgroundimage 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 5 | 6 | class BackgroundImage(private val container: UIChildNode, default: BackgroundImageValue = BackgroundImageValues.inherit) : ReadonlyBackgroundImage { 7 | 8 | var value: BackgroundImageValue = default 9 | 10 | override val texture get() = this.value.compute(this.container) 11 | 12 | fun set(value: BackgroundImageValue) { 13 | this.value = value 14 | } 15 | 16 | fun set(value: ReadOnlyTexture2D) { 17 | this.value = BackgroundImageValues.of(value) 18 | } 19 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/backgroundimage/BackgroundImageValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.backgroundimage 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 5 | 6 | fun interface BackgroundImageValue { 7 | 8 | fun compute(container: UIChildNode): ReadOnlyTexture2D 9 | 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/backgroundimage/BackgroundImageValues.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.backgroundimage 2 | 3 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 4 | import org.saar.lwjgl.opengl.texture.Texture2D 5 | 6 | object BackgroundImageValues { 7 | 8 | @JvmField 9 | val inherit: BackgroundImageValue = BackgroundImageValue { it.parent.style.backgroundImage.texture } 10 | 11 | @JvmField 12 | val none: BackgroundImageValue = BackgroundImageValue { Texture2D.NULL } 13 | 14 | @JvmStatic 15 | fun of(value: ReadOnlyTexture2D): BackgroundImageValue = BackgroundImageValue { value } 16 | 17 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/backgroundimage/NoBackgroundImage.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.backgroundimage 2 | 3 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 4 | import org.saar.lwjgl.opengl.texture.Texture2D 5 | 6 | object NoBackgroundImage : ReadonlyBackgroundImage { 7 | 8 | override val texture: ReadOnlyTexture2D = Texture2D.NULL 9 | 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/backgroundimage/ReadonlyBackgroundImage.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.backgroundimage 2 | 3 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 4 | 5 | interface ReadonlyBackgroundImage { 6 | 7 | val texture: ReadOnlyTexture2D 8 | 9 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/border/BorderValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.border 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | interface BorderValue { 6 | fun computeTop(container: UIChildNode): Int 7 | 8 | fun computeRight(container: UIChildNode): Int 9 | 10 | fun computeBottom(container: UIChildNode): Int 11 | 12 | fun computeLeft(container: UIChildNode): Int 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/border/NoBorders.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.border 2 | 3 | object NoBorders : ReadonlyBorders { 4 | override val top = 0 5 | override val right = 0 6 | override val bottom = 0 7 | override val left = 0 8 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/border/ReadonlyBorders.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.border 2 | 3 | import org.joml.Vector4i 4 | import org.saar.gui.style.StyleProperty 5 | 6 | interface ReadonlyBorders : StyleProperty { 7 | 8 | val top: Int 9 | val right: Int 10 | val bottom: Int 11 | val left: Int 12 | 13 | fun asVector4i(vector4i: Vector4i): Vector4i = vector4i.set( 14 | this.left, this.top, this.right, this.bottom) 15 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/bordercolour/BorderColour.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.bordercolour 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.style.Colour 5 | 6 | class BorderColour(private val container: UIChildNode, default: BorderColourValue = BorderColourValues.inherit) : ReadonlyBorderColour { 7 | 8 | var value: BorderColourValue = default 9 | 10 | override val colour get() = this.value.compute(this.container) 11 | 12 | fun set(colour: Colour) { 13 | this.value = BorderColourValues.of(colour) 14 | } 15 | 16 | fun set(value: BorderColourValue) { 17 | this.value = value 18 | } 19 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/bordercolour/BorderColourValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.bordercolour 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.style.Colour 5 | 6 | fun interface BorderColourValue { 7 | 8 | fun compute(container: UIChildNode): Colour 9 | 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/bordercolour/BorderColourValues.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.bordercolour 2 | 3 | import org.saar.gui.style.Colour 4 | 5 | object BorderColourValues { 6 | 7 | @JvmField 8 | val inherit: BorderColourValue = BorderColourValue { it.parent.style.borderColour.colour } 9 | 10 | @JvmStatic 11 | fun of(value: Colour): BorderColourValue = BorderColourValue { value } 12 | 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/bordercolour/NoBorderColour.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.bordercolour 2 | 3 | import org.saar.gui.style.Colours 4 | 5 | object NoBorderColour : ReadonlyBorderColour { 6 | 7 | override val colour = Colours.BLACK 8 | 9 | override fun toString() = "[BorderColour: $colour]" 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/bordercolour/ReadonlyBorderColour.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.bordercolour 2 | 3 | import org.saar.gui.style.Colour 4 | import org.saar.gui.style.StyleProperty 5 | 6 | interface ReadonlyBorderColour : StyleProperty { 7 | 8 | val colour: Colour 9 | 10 | fun asInt() = this.colour.asInt() 11 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/boxsizing/NoBoxSizing.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.boxsizing 2 | 3 | object NoBoxSizing : ReadonlyBoxSizing { 4 | 5 | override fun getContentWidth(): Int = 0 6 | 7 | override fun getContentHeight(): Int = 0 8 | 9 | override fun getBoxWidth(): Int = 0 10 | 11 | override fun getBoxHeight(): Int = 0 12 | 13 | override fun getSpaceWidth(): Int = 0 14 | 15 | override fun getSpaceHeight(): Int = 0 16 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/boxsizing/ReadonlyBoxSizing.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.boxsizing 2 | 3 | import org.saar.gui.style.StyleProperty 4 | 5 | interface ReadonlyBoxSizing : StyleProperty { 6 | 7 | fun getContentWidth(): Int 8 | 9 | fun getContentHeight(): Int 10 | 11 | fun getBoxWidth(): Int 12 | 13 | fun getBoxHeight(): Int 14 | 15 | fun getSpaceWidth(): Int 16 | 17 | fun getSpaceHeight(): Int 18 | 19 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/colourmodifier/ColourModifierValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.colourmodifier 2 | 3 | import org.joml.Vector4fc 4 | import org.saar.gui.UIChildNode 5 | 6 | fun interface ColourModifierValue { 7 | 8 | fun compute(container: UIChildNode): Vector4fc 9 | 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/colourmodifier/ColourModifierValues.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.colourmodifier 2 | 3 | import org.joml.Vector4fc 4 | 5 | object ColourModifierValues { 6 | 7 | @JvmField 8 | val inherit: ColourModifierValue = ColourModifierValue { it.parent.style.colourModifier.multiply } 9 | 10 | @JvmStatic 11 | fun of(value: Vector4fc): ColourModifierValue = ColourModifierValue { value } 12 | 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/colourmodifier/NoColourModifier.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.colourmodifier 2 | 3 | import org.joml.Vector4fc 4 | import org.saar.maths.utils.Vector4 5 | 6 | object NoColourModifier : ReadonlyColourModifier { 7 | 8 | override val multiply: Vector4fc = Vector4.of(1f) 9 | 10 | override fun toString() = "[Corners: ${this.multiply}]" 11 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/colourmodifier/ReadonlyColourModifier.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.colourmodifier 2 | 3 | import org.joml.Vector4fc 4 | import org.saar.gui.style.StyleProperty 5 | 6 | interface ReadonlyColourModifier : StyleProperty { 7 | val multiply: Vector4fc 8 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/coordinate/Coordinate.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.coordinate 2 | 3 | abstract class Coordinate(default: CoordinateValue = CoordinateValues.zero) : ReadonlyCoordinate { 4 | 5 | var value: CoordinateValue = default 6 | 7 | fun set(value: CoordinateValue) { 8 | this.value = value 9 | } 10 | 11 | fun set(pixels: Int) { 12 | this.value = CoordinateValues.pixels(pixels) 13 | } 14 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/coordinate/CoordinateValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.coordinate 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | interface CoordinateValue { 6 | fun computeAxisX(container: UIChildNode): Int 7 | 8 | fun computeAxisY(container: UIChildNode): Int 9 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/coordinate/Coordinates.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.coordinate 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | object Coordinates { 6 | 7 | class X(private val container: UIChildNode, default: CoordinateValue = CoordinateValues.zero) : Coordinate(default) { 8 | 9 | override fun get(): Int = this.value.computeAxisX(this.container) 10 | } 11 | 12 | class Y(private val container: UIChildNode, default: CoordinateValue = CoordinateValues.zero) : Coordinate(default) { 13 | 14 | override fun get(): Int = this.value.computeAxisY(this.container) 15 | } 16 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/coordinate/ReadonlyCoordinate.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.coordinate 2 | 3 | fun interface ReadonlyCoordinate { 4 | 5 | fun get(): Int 6 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/discardmap/DiscardMap.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.discardmap 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 5 | 6 | class DiscardMap(private val container: UIChildNode, default: DiscardMapValue = DiscardMapValues.inherit) : ReadonlyDiscardMap { 7 | 8 | var value: DiscardMapValue = default 9 | 10 | override val texture get() = this.value.compute(this.container) 11 | 12 | fun set(value: DiscardMapValue) { 13 | this.value = value 14 | } 15 | 16 | fun set(value: ReadOnlyTexture2D) { 17 | this.value = DiscardMapValues.of(value) 18 | } 19 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/discardmap/DiscardMapValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.discardmap 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 5 | 6 | fun interface DiscardMapValue { 7 | 8 | fun compute(container: UIChildNode): ReadOnlyTexture2D 9 | 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/discardmap/DiscardMapValues.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.discardmap 2 | 3 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 4 | import org.saar.lwjgl.opengl.texture.Texture2D 5 | 6 | object DiscardMapValues { 7 | 8 | @JvmField 9 | val inherit: DiscardMapValue = DiscardMapValue { it.parent.style.discardMap.texture } 10 | 11 | @JvmField 12 | val none: DiscardMapValue = DiscardMapValue { Texture2D.NULL } 13 | 14 | @JvmStatic 15 | fun of(value: ReadOnlyTexture2D): DiscardMapValue = DiscardMapValue { value } 16 | 17 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/discardmap/NoDiscardMap.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.discardmap 2 | 3 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 4 | import org.saar.lwjgl.opengl.texture.Texture2D 5 | 6 | object NoDiscardMap : ReadonlyDiscardMap { 7 | 8 | override val texture: ReadOnlyTexture2D = Texture2D.NULL 9 | 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/discardmap/ReadonlyDiscardMap.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.discardmap 2 | 3 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture2D 4 | 5 | interface ReadonlyDiscardMap { 6 | 7 | val texture: ReadOnlyTexture2D 8 | 9 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/font/FontFamily.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.font 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.font.Font 5 | 6 | class FontFamily(private val container: UIChildNode, default: FontFamilyValue = FontFamilyValues.inherit) : ReadonlyFontFamily { 7 | 8 | var value: FontFamilyValue = default 9 | 10 | override val family get() = this.value.compute(this.container) 11 | 12 | fun set(value: FontFamilyValue) { 13 | this.value = value 14 | } 15 | 16 | fun set(value: Font) { 17 | this.value = FontFamilyValues.of(value) 18 | } 19 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/font/FontFamilyValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.font 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.font.Font 5 | 6 | fun interface FontFamilyValue { 7 | 8 | fun compute(container: UIChildNode): Font 9 | 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/font/FontFamilyValues.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.font 2 | 3 | import org.saar.gui.font.Font 4 | import org.saar.gui.font.FontLoader 5 | 6 | object FontFamilyValues { 7 | 8 | @JvmField 9 | val inherit: FontFamilyValue = FontFamilyValue { it.parent.style.font.family } 10 | 11 | @JvmField 12 | val default: FontFamilyValue = FontFamilyValue { FontLoader.DEFAULT_FONT } 13 | 14 | @JvmStatic 15 | fun of(value: Font): FontFamilyValue = FontFamilyValue { value } 16 | 17 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/font/NoFontFamily.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.font 2 | 3 | import org.saar.gui.font.FontLoader 4 | 5 | object NoFontFamily : ReadonlyFontFamily { 6 | 7 | override val family = FontLoader.DEFAULT_FONT 8 | 9 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/font/ReadonlyFontFamily.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.font 2 | 3 | import org.saar.gui.font.Font 4 | 5 | interface ReadonlyFontFamily { 6 | 7 | val family: Font 8 | 9 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/fontcolour/FontColour.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.fontcolour 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.style.Colour 5 | import org.saar.gui.style.fontcolour.FontColourValues.of 6 | 7 | class FontColour(private val container: UIChildNode, default: FontColourValue = FontColourValues.inherit) : ReadonlyFontColour { 8 | 9 | var value: FontColourValue = default 10 | 11 | override val colour get() = this.value.compute(this.container) 12 | 13 | fun set(colour: Colour) { 14 | this.value = of(colour) 15 | } 16 | 17 | fun set(value: FontColourValue) { 18 | this.value = value 19 | } 20 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/fontcolour/FontColourValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.fontcolour 2 | 3 | import org.saar.gui.UIChildNode 4 | import org.saar.gui.style.Colour 5 | 6 | fun interface FontColourValue { 7 | 8 | fun compute(container: UIChildNode): Colour 9 | 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/fontcolour/FontColourValues.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.fontcolour 2 | 3 | import org.saar.gui.style.Colour 4 | 5 | object FontColourValues { 6 | 7 | @JvmField 8 | val inherit: FontColourValue = FontColourValue { container -> 9 | container.parent.style.fontColour.colour 10 | } 11 | 12 | @JvmStatic 13 | fun of(value: Colour): FontColourValue = FontColourValue { value } 14 | 15 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/fontcolour/NoFontColour.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.fontcolour 2 | 3 | import org.saar.gui.style.Colours 4 | 5 | object NoFontColour : ReadonlyFontColour { 6 | 7 | override val colour = Colours.BLACK 8 | 9 | override fun toString() = "[FontColour: $colour]" 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/fontcolour/ReadonlyFontColour.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.fontcolour 2 | 3 | import org.saar.gui.style.Colour 4 | import org.saar.gui.style.StyleProperty 5 | 6 | interface ReadonlyFontColour : StyleProperty { 7 | 8 | val colour: Colour 9 | 10 | fun asInt() = this.colour.asInt() 11 | 12 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/fontsize/FontSize.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.fontsize 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | class FontSize(private val container: UIChildNode, default: FontSizeValue = FontSizeValues.inherit) : ReadonlyFontSize { 6 | 7 | var value: FontSizeValue = default 8 | 9 | override val size get() = this.value.compute(this.container) 10 | 11 | fun set(value: FontSizeValue) { 12 | this.value = value 13 | } 14 | 15 | fun set(pixels: Int) { 16 | this.value = FontSizeValues.pixels(pixels) 17 | } 18 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/fontsize/FontSizeValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.fontsize 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | fun interface FontSizeValue { 6 | 7 | fun compute(container: UIChildNode): Int 8 | 9 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/fontsize/FontSizeValues.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.fontsize 2 | 3 | object FontSizeValues { 4 | 5 | @JvmField 6 | val inherit: FontSizeValue = FontSizeValue { it.parent.style.fontSize.size } 7 | 8 | @JvmField 9 | val none: FontSizeValue = FontSizeValue { 0 } 10 | 11 | @JvmStatic 12 | fun pixels(value: Int): FontSizeValue = FontSizeValue { value } 13 | 14 | @JvmStatic 15 | fun percent(value: Float): FontSizeValue = FontSizeValue { (it.parent.style.height.getMax() * value).toInt() } 16 | 17 | @JvmStatic 18 | fun percentWidth(value: Float): FontSizeValue = FontSizeValue { (it.parent.style.width.getMax() * value).toInt() } 19 | 20 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/fontsize/NoFontSize.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.fontsize 2 | 3 | object NoFontSize : ReadonlyFontSize { 4 | 5 | override val size = 16 6 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/fontsize/ReadonlyFontSize.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.fontsize 2 | 3 | interface ReadonlyFontSize { 4 | 5 | val size: Int 6 | 7 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/length/Length.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.length 2 | 3 | abstract class Length(default: LengthValue = LengthValues.fit) : ReadonlyLength { 4 | 5 | var value: LengthValue = default 6 | 7 | fun set(value: LengthValue) { 8 | this.value = value 9 | } 10 | 11 | fun set(pixels: Int) { 12 | this.value = LengthValues.pixels(pixels) 13 | } 14 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/length/NoLength.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.length 2 | 3 | object NoLength : ReadonlyLength { 4 | override fun get() = 0 5 | 6 | override fun getMin() = 0 7 | 8 | override fun getMax() = 0 9 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/length/ReadonlyLength.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.length 2 | 3 | interface ReadonlyLength { 4 | 5 | fun get(): Int 6 | 7 | fun getMin(): Int 8 | 9 | fun getMax(): Int 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/margin/MarginValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.margin 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | interface MarginValue { 6 | fun computeTop(container: UIChildNode): Int 7 | 8 | fun computeRight(container: UIChildNode): Int 9 | 10 | fun computeBottom(container: UIChildNode): Int 11 | 12 | fun computeLeft(container: UIChildNode): Int 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/margin/NoMargin.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.margin 2 | 3 | object NoMargin : ReadonlyMargin { 4 | override val top = 0 5 | override val right = 0 6 | override val bottom = 0 7 | override val left = 0 8 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/margin/ReadonlyMargin.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.margin 2 | 3 | import org.joml.Vector4i 4 | import org.saar.gui.style.StyleProperty 5 | 6 | interface ReadonlyMargin : StyleProperty { 7 | 8 | val top: Int 9 | val right: Int 10 | val bottom: Int 11 | val left: Int 12 | 13 | fun asVector4i(vector4i: Vector4i): Vector4i = vector4i.set( 14 | this.top, this.right, this.bottom, this.left) 15 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/padding/NoPadding.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.padding 2 | 3 | object NoPadding : ReadonlyPadding { 4 | override val top = 0 5 | override val right = 0 6 | override val bottom = 0 7 | override val left = 0 8 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/padding/PaddingValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.padding 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | interface PaddingValue { 6 | fun computeTop(container: UIChildNode): Int 7 | 8 | fun computeRight(container: UIChildNode): Int 9 | 10 | fun computeBottom(container: UIChildNode): Int 11 | 12 | fun computeLeft(container: UIChildNode): Int 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/padding/ReadonlyPadding.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.padding 2 | 3 | import org.joml.Vector4i 4 | import org.saar.gui.style.StyleProperty 5 | 6 | interface ReadonlyPadding : StyleProperty { 7 | 8 | val top: Int 9 | val right: Int 10 | val bottom: Int 11 | val left: Int 12 | 13 | fun asVector4i(vector4i: Vector4i): Vector4i = vector4i.set( 14 | this.top, this.right, this.bottom, this.left) 15 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/position/Position.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.position 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | class Position(private val container: UIChildNode, default: PositionValue = PositionValues.relative) : ReadonlyPosition { 6 | 7 | override var value: PositionValue = default 8 | 9 | override fun getX() = this.value.computeAxisX(this.container) 10 | 11 | override fun getY() = this.value.computeAxisY(this.container) 12 | 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/position/PositionValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.position 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | interface PositionValue { 6 | fun computeAxisX(container: UIChildNode): Int 7 | 8 | fun computeAxisY(container: UIChildNode): Int 9 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/position/ReadonlyPosition.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.position 2 | 3 | interface ReadonlyPosition { 4 | 5 | val value: PositionValue 6 | 7 | fun getX(): Int 8 | 9 | fun getY(): Int 10 | 11 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/redius/NoRadius.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.redius 2 | 3 | object NoRadius : ReadonlyRadius { 4 | override val topRight = 0 5 | override val topLeft = 0 6 | override val bottomRight = 0 7 | override val bottomLeft = 0 8 | 9 | override fun isZero(): Boolean = true 10 | } -------------------------------------------------------------------------------- /pe-gui/src/main/kotlin/org/saar/gui/style/redius/RadiusValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.gui.style.redius 2 | 3 | import org.saar.gui.UIChildNode 4 | 5 | interface RadiusValue { 6 | fun computeTopRight(container: UIChildNode): Int 7 | 8 | fun computeTopLeft(container: UIChildNode): Int 9 | 10 | fun computeBottomRight(container: UIChildNode): Int 11 | 12 | fun computeBottomLeft(container: UIChildNode): Int 13 | } -------------------------------------------------------------------------------- /pe-gui/src/main/resources/assets/gui/checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/pe-gui/src/main/resources/assets/gui/checkbox.png -------------------------------------------------------------------------------- /pe-gui/src/main/resources/shaders/gui/graphics/graphics.fragment.glsl: -------------------------------------------------------------------------------- 1 | out vec4 fragColour; 2 | 3 | uniform uint colour; 4 | 5 | vec4 getColour() { 6 | float r = ((colour << 0 ) >> 24); 7 | float g = ((colour << 8 ) >> 24); 8 | float b = ((colour << 16) >> 24); 9 | float a = ((colour << 24) >> 24); 10 | return vec4(r, g, b, a) / 255; 11 | } 12 | 13 | void main(void) { 14 | fragColour = getColour(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /pe-gui/src/main/resources/shaders/gui/graphics/graphics.vertex.glsl: -------------------------------------------------------------------------------- 1 | layout (location = 0) in vec2 in_position; 2 | 3 | uniform ivec2 positionOnScreen; 4 | uniform ivec2 windowSize; 5 | 6 | vec2 calculatePosition() { 7 | vec2 position = positionOnScreen / windowSize; 8 | return position * 2 - 1 + in_position; 9 | } 10 | 11 | void main(void) { 12 | vec2 position = calculatePosition(); 13 | 14 | gl_Position = vec4(pos, 0, 1); 15 | gl_ClipDistance[0] = 0; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /pe-gui/src/main/resources/shaders/gui/render/letter.fragment.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec2 v_uvCoords; 3 | 4 | // Uniforms 5 | uniform sampler2D u_bitmap; 6 | uniform uint u_fontColour; 7 | 8 | // Fragment outputs 9 | out vec4 f_colour; 10 | 11 | // Methods 12 | vec4 getFontColour(void) { 13 | float r = ((u_fontColour << 0x00) >> 0x18); 14 | float g = ((u_fontColour << 0x08) >> 0x18); 15 | float b = ((u_fontColour << 0x10) >> 0x18); 16 | float a = ((u_fontColour << 0x18) >> 0x18); 17 | return vec4(r, g, b, a) / 255; 18 | } 19 | 20 | // Main 21 | void main(void) { 22 | f_colour = texture(u_bitmap, v_uvCoords).rrrr * getFontColour(); 23 | } 24 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/assimp/AssimpComponent.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.assimp; 2 | 3 | public interface AssimpComponent { 4 | 5 | int count(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/assimp/AssimpException.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.assimp; 2 | 3 | public class AssimpException extends RuntimeException { 4 | 5 | public AssimpException() { 6 | } 7 | 8 | public AssimpException(String message) { 9 | super(message); 10 | } 11 | 12 | public AssimpException(String message, Throwable cause) { 13 | super(message, cause); 14 | } 15 | 16 | public AssimpException(Throwable cause) { 17 | super(cause); 18 | } 19 | 20 | public AssimpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 21 | super(message, cause, enableSuppression, writableStackTrace); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/GlfwUtils.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw; 2 | 3 | import org.lwjgl.glfw.GLFW; 4 | 5 | public final class GlfwUtils { 6 | 7 | private GlfwUtils() { 8 | throw new UnsupportedOperationException("Cannot make instance of GlfwUtils class"); 9 | } 10 | 11 | public static void init() { 12 | if (!GLFW.glfwInit()) { 13 | throw new IllegalStateException("Unable to initialize GLFW"); 14 | } 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/event/DoubleValueChange.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.event; 2 | 3 | public class DoubleValueChange { 4 | 5 | private final double before; 6 | private final double after; 7 | 8 | public DoubleValueChange(double before, double after) { 9 | this.before = before; 10 | this.after = after; 11 | } 12 | 13 | public double getBefore() { 14 | return this.before; 15 | } 16 | 17 | public double getAfter() { 18 | return this.after; 19 | } 20 | 21 | public double getDifference() { 22 | return getBefore() - getAfter(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/event/Event.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.event; 2 | 3 | public abstract class Event { 4 | } 5 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/event/EventListener.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.event; 2 | 3 | public interface EventListener { 4 | 5 | void onEvent(T e); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/event/IntValueChange.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.event; 2 | 3 | public class IntValueChange { 4 | 5 | private final int before; 6 | private final int after; 7 | 8 | public IntValueChange(int before, int after) { 9 | this.before = before; 10 | this.after = after; 11 | } 12 | 13 | public int getBefore() { 14 | return this.before; 15 | } 16 | 17 | public int getAfter() { 18 | return this.after; 19 | } 20 | 21 | public int getDifference() { 22 | return getBefore() - getAfter(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/event/OnAction.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.event; 2 | 3 | public interface OnAction { 4 | 5 | void perform(EventListener listener); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/input/Modifiers.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.input 2 | 3 | import org.lwjgl.glfw.GLFW 4 | 5 | class Modifiers(private val modifiers: Int) { 6 | 7 | fun isShift(): Boolean = checkBit(GLFW.GLFW_MOD_SHIFT) 8 | 9 | fun isCtrl(): Boolean = checkBit(GLFW.GLFW_MOD_CONTROL) 10 | 11 | fun isAlt(): Boolean = checkBit(GLFW.GLFW_MOD_ALT) 12 | 13 | fun isSuper(): Boolean = checkBit(GLFW.GLFW_MOD_SUPER) 14 | 15 | fun isCapsLock(): Boolean = checkBit(GLFW.GLFW_MOD_CAPS_LOCK) 16 | 17 | fun isNumLock(): Boolean = checkBit(GLFW.GLFW_MOD_NUM_LOCK) 18 | 19 | private fun checkBit(mask: Int) = this.modifiers and mask != 0 20 | 21 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/input/keyboard/KeyEvent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.input.keyboard 2 | 3 | import org.saar.lwjgl.glfw.event.Event 4 | import org.saar.lwjgl.glfw.input.Modifiers 5 | 6 | class KeyEvent( 7 | val code: Int, 8 | val modifiers: Modifiers, 9 | val key: Int, 10 | ) : Event() -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/input/keyboard/KeyState.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.input.keyboard 2 | 3 | import org.lwjgl.glfw.GLFW 4 | 5 | enum class KeyState(private val value: Int) { 6 | 7 | RELEASE(GLFW.GLFW_RELEASE), 8 | PRESS(GLFW.GLFW_PRESS), 9 | REPEAT(GLFW.GLFW_REPEAT), 10 | ; 11 | 12 | fun get() = this.value 13 | 14 | companion object { 15 | @JvmStatic 16 | fun valueOf(value: Int) = when (value) { 17 | RELEASE.value -> RELEASE 18 | PRESS.value -> PRESS 19 | REPEAT.value -> REPEAT 20 | else -> throw IllegalArgumentException("KeyState non found: $value") 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/input/mouse/ClickEvent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.input.mouse 2 | 3 | import org.saar.lwjgl.glfw.event.Event 4 | import org.saar.lwjgl.glfw.input.Modifiers 5 | 6 | class ClickEvent( 7 | val mouse: Mouse, 8 | val button: MouseButton, 9 | val isDown: Boolean, 10 | val modifiers: Modifiers, 11 | ) : Event() -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/input/mouse/MouseButtonState.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.input.mouse 2 | 3 | import org.lwjgl.glfw.GLFW 4 | 5 | enum class MouseButtonState(private val value: Int) { 6 | 7 | RELEASE(GLFW.GLFW_RELEASE), 8 | PRESS(GLFW.GLFW_PRESS), 9 | ; 10 | 11 | fun get() = this.value 12 | 13 | companion object { 14 | @JvmStatic 15 | fun valueOf(value: Int): MouseButtonState = when (value) { 16 | RELEASE.value -> RELEASE 17 | PRESS.value -> PRESS 18 | else -> throw IllegalArgumentException("MouseButtonState non found: $value") 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/input/mouse/MouseCursor.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.input.mouse 2 | 3 | import org.lwjgl.glfw.GLFW 4 | 5 | enum class MouseCursor(private val value: Int) { 6 | 7 | NORMAL(GLFW.GLFW_CURSOR_NORMAL), 8 | HIDDEN(GLFW.GLFW_CURSOR_HIDDEN), 9 | DISABLED(GLFW.GLFW_CURSOR_DISABLED), 10 | ; 11 | 12 | fun get() = this.value 13 | 14 | companion object { 15 | @JvmStatic 16 | fun valueOf(value: Int) = when (value) { 17 | NORMAL.value -> NORMAL 18 | HIDDEN.value -> HIDDEN 19 | DISABLED.value -> DISABLED 20 | else -> throw IllegalArgumentException("MouseCursor non found: $value") 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/input/mouse/MoveEvent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.input.mouse 2 | 3 | import org.saar.lwjgl.glfw.event.Event 4 | import org.saar.lwjgl.glfw.event.IntValueChange 5 | 6 | class MoveEvent( 7 | val mouse: Mouse, 8 | val x: IntValueChange, 9 | val y: IntValueChange, 10 | ) : Event() -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/input/mouse/ScrollEvent.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.input.mouse 2 | 3 | import org.saar.lwjgl.glfw.event.Event 4 | 5 | class ScrollEvent( 6 | val mouse: Mouse, 7 | val offset: Double, 8 | ) : Event() -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/window/OpenGlProfileType.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.window; 2 | 3 | import org.lwjgl.glfw.GLFW; 4 | 5 | public enum OpenGlProfileType { 6 | 7 | ANY(GLFW.GLFW_OPENGL_ANY_PROFILE), 8 | CORE(GLFW.GLFW_OPENGL_CORE_PROFILE), 9 | COMPATIBILITY(GLFW.GLFW_OPENGL_COMPAT_PROFILE), 10 | ; 11 | 12 | private final int value; 13 | 14 | OpenGlProfileType(int value) { 15 | this.value = value; 16 | } 17 | 18 | public int get() { 19 | return this.value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/window/PositionEvent.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.window; 2 | 3 | import org.saar.lwjgl.glfw.event.IntValueChange; 4 | import org.saar.lwjgl.glfw.event.Event; 5 | 6 | public class PositionEvent extends Event { 7 | 8 | private final IntValueChange x; 9 | private final IntValueChange y; 10 | 11 | public PositionEvent(IntValueChange x, IntValueChange y) { 12 | this.x = x; 13 | this.y = y; 14 | } 15 | 16 | public IntValueChange getWidth() { 17 | return this.x; 18 | } 19 | 20 | public IntValueChange getHeight() { 21 | return this.y; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/window/ResizeEvent.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.window; 2 | 3 | import org.saar.lwjgl.glfw.event.IntValueChange; 4 | import org.saar.lwjgl.glfw.event.Event; 5 | 6 | public class ResizeEvent extends Event { 7 | 8 | private final IntValueChange width; 9 | private final IntValueChange height; 10 | 11 | public ResizeEvent(IntValueChange width, IntValueChange height) { 12 | this.width = width; 13 | this.height = height; 14 | } 15 | 16 | public IntValueChange getWidth() { 17 | return this.width; 18 | } 19 | 20 | public IntValueChange getHeight() { 21 | return this.height; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/glfw/window/WindowHint.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.glfw.window; 2 | 3 | public interface WindowHint { 4 | 5 | void apply(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/openal/constants/BufferFormat.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.openal.constants; 2 | 3 | import org.lwjgl.openal.AL11; 4 | 5 | public enum BufferFormat { 6 | 7 | FORMAT_MONO8(AL11.AL_FORMAT_MONO8), 8 | FORMAT_MONO16(AL11.AL_FORMAT_MONO16), 9 | FORMAT_STEREO8(AL11.AL_FORMAT_STEREO8), 10 | FORMAT_STEREO16(AL11.AL_FORMAT_STEREO16), 11 | ; 12 | 13 | private final int value; 14 | 15 | BufferFormat(int value) { 16 | this.value = value; 17 | } 18 | 19 | public int getValue() { 20 | return value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/attribute/IAttribute.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.attribute 2 | 3 | interface IAttribute { 4 | 5 | fun enable() 6 | 7 | fun disable() 8 | 9 | fun link(stride: Int, offset: Int) 10 | 11 | val bytesPerVertex: Int 12 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/attribute/divisor/AttributeDivisor.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.attribute.divisor 2 | 3 | interface AttributeDivisor { 4 | 5 | fun divide(index: Int) 6 | 7 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/attribute/divisor/InstancedAttributeDivisor.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.attribute.divisor 2 | 3 | import org.lwjgl.opengl.GL33 4 | 5 | class InstancedAttributeDivisor(private val instances: Int) : AttributeDivisor { 6 | 7 | override fun divide(index: Int) = GL33.glVertexAttribDivisor(index, this.instances) 8 | 9 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/attribute/divisor/NoAttributeDivisor.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.attribute.divisor 2 | 3 | class NoAttributeDivisor : AttributeDivisor { 4 | 5 | override fun divide(index: Int) = Unit 6 | 7 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/attribute/pointer/AttributePointer.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.attribute.pointer 2 | 3 | interface AttributePointer { 4 | fun point(index: Int, stride: Int, offset: Int) 5 | val bytesPerVertex: Int 6 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/attribute/pointer/FloatAttributePointer.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.attribute.pointer 2 | 3 | import org.lwjgl.opengl.GL20 4 | import org.saar.lwjgl.opengl.constants.DataType 5 | 6 | class FloatAttributePointer( 7 | private val componentCount: Int, 8 | private val componentType: DataType, 9 | private val normalized: Boolean, 10 | ) : AttributePointer { 11 | 12 | override fun point(index: Int, stride: Int, offset: Int) = 13 | GL20.glVertexAttribPointer(index, this.componentCount, 14 | this.componentType.get(), this.normalized, stride, offset.toLong()) 15 | 16 | override val bytesPerVertex get() = this.componentCount * this.componentType.bytes 17 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/attribute/pointer/IntegerAttributePointer.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.attribute.pointer 2 | 3 | import org.lwjgl.opengl.GL30 4 | import org.saar.lwjgl.opengl.constants.DataType 5 | 6 | class IntegerAttributePointer( 7 | private val componentCount: Int, 8 | private val componentType: DataType, 9 | ) : AttributePointer { 10 | 11 | override fun point(index: Int, stride: Int, offset: Int) = 12 | GL30.glVertexAttribIPointer(index, this.componentCount, 13 | this.componentType.get(), stride, offset.toLong()) 14 | 15 | override val bytesPerVertex get() = this.componentCount * this.componentType.bytes 16 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/blend/BlendFunction.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.blend 2 | 3 | data class BlendFunction( 4 | val source: BlendValue, 5 | val destination: BlendValue, 6 | ) -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/blend/BlendState.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.blend 2 | 3 | data class BlendState( 4 | val enabled: Boolean, 5 | val function: BlendFunction, 6 | ) { 7 | constructor(function: BlendFunction) : this(true, function) 8 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/buffer/BufferAccess.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.buffer; 2 | 3 | import org.lwjgl.opengl.GL15; 4 | 5 | public enum BufferAccess { 6 | 7 | READ_ONLY(GL15.GL_READ_ONLY), 8 | WRITE_ONLY(GL15.GL_WRITE_ONLY), 9 | READ_WRITE(GL15.GL_READ_WRITE), 10 | ; 11 | 12 | private final int value; 13 | 14 | BufferAccess(int value) { 15 | this.value = value; 16 | } 17 | 18 | public int get() { 19 | return this.value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/buffer/BufferTarget.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.buffer; 2 | 3 | import org.lwjgl.opengl.GL15; 4 | import org.lwjgl.opengl.GL21; 5 | import org.lwjgl.opengl.GL31; 6 | 7 | public enum BufferTarget { 8 | 9 | ARRAY(GL15.GL_ARRAY_BUFFER), 10 | ELEMENT_ARRAY(GL15.GL_ELEMENT_ARRAY_BUFFER), 11 | UNIFORM(GL31.GL_UNIFORM_BUFFER), 12 | PACK(GL21.GL_PIXEL_PACK_BUFFER), 13 | UNPACK(GL21.GL_PIXEL_UNPACK_BUFFER); 14 | 15 | private final int value; 16 | 17 | BufferTarget(int value) { 18 | this.value = value; 19 | } 20 | 21 | public int get() { 22 | return this.value; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/buffer/IBufferObject.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.buffer; 2 | 3 | public interface IBufferObject extends WritableBufferObject { 4 | 5 | /** 6 | * Delete the buffer object 7 | */ 8 | void delete(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/clear/ClearDepth.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.clear 2 | 3 | import org.lwjgl.opengl.GL11 4 | 5 | object ClearDepth { 6 | 7 | private var value = 1.0 8 | 9 | fun set(value: Float) = set(value.toDouble()) 10 | 11 | @JvmStatic 12 | fun set(value: Double) { 13 | if (this.value != value) { 14 | this.value = value 15 | 16 | setDepth() 17 | } 18 | } 19 | 20 | private fun setDepth() { 21 | GL11.glClearDepth(this.value) 22 | } 23 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/constants/Comparator.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.constants 2 | 3 | import org.lwjgl.opengl.GL11 4 | 5 | enum class Comparator(val value: Int) { 6 | 7 | NEVER(GL11.GL_NEVER), 8 | ALWAYS(GL11.GL_ALWAYS), 9 | 10 | EQUAL(GL11.GL_EQUAL), 11 | NOT_EQUAL(GL11.GL_NOTEQUAL), 12 | 13 | LESS(GL11.GL_LESS), 14 | LESS_EQUAL(GL11.GL_LEQUAL), 15 | 16 | GREATER(GL11.GL_GREATER), 17 | GREATER_EQUAL(GL11.GL_GEQUAL), 18 | 19 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/constants/Face.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.constants 2 | 3 | import org.lwjgl.opengl.GL11 4 | 5 | enum class Face(val value: Int) { 6 | 7 | FRONT(GL11.GL_FRONT), 8 | BACK(GL11.GL_BACK), 9 | FRONT_AND_BACK(GL11.GL_FRONT_AND_BACK), 10 | 11 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/cullface/CullFaceOrder.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.cullface 2 | 3 | import org.lwjgl.opengl.GL11 4 | 5 | enum class CullFaceOrder(val value: Int) { 6 | 7 | CLOCKWISE(GL11.GL_CW), 8 | COUNTER_CLOCKWISE(GL11.GL_CCW) 9 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/cullface/CullFaceState.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.cullface 2 | 3 | import org.saar.lwjgl.opengl.constants.Face 4 | 5 | data class CullFaceState( 6 | val enabled: Boolean, 7 | val face: Face, 8 | val order: CullFaceOrder, 9 | ) { 10 | constructor(face: Face, order: CullFaceOrder) : this(true, face, order) 11 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/depth/DepthFunction.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.depth 2 | 3 | import org.saar.lwjgl.opengl.constants.Comparator 4 | 5 | data class DepthFunction(val comparator: Comparator) -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/depth/DepthMask.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.depth 2 | 3 | data class DepthMask(val value: Boolean) { 4 | 5 | companion object { 6 | @JvmField 7 | val READ = DepthMask(false) 8 | 9 | @JvmField 10 | val WRITE = DepthMask(true) 11 | } 12 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/depth/DepthState.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.depth 2 | 3 | data class DepthState( 4 | val enabled: Boolean, 5 | val function: DepthFunction, 6 | val mask: DepthMask, 7 | ) { 8 | constructor(function: DepthFunction, mask: DepthMask) : this(true, function, mask) 9 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/drawcall/DrawCall.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.drawcall; 2 | 3 | public interface DrawCall { 4 | 5 | void doDrawCall(); 6 | } 7 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/DrawableFbo.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo; 2 | 3 | public interface DrawableFbo extends ReadOnlyFbo { 4 | 5 | /** 6 | * Set as read fbo 7 | */ 8 | void bindAsDraw(); 9 | } 10 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/FboBlitFilter.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | 5 | public enum FboBlitFilter { 6 | 7 | NEAREST(GL11.GL_NEAREST), 8 | LINEAR(GL11.GL_LINEAR); 9 | 10 | private final int value; 11 | 12 | FboBlitFilter(int value) { 13 | this.value = value; 14 | } 15 | 16 | public int get() { 17 | return this.value; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/FboTarget.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo; 2 | 3 | import org.lwjgl.opengl.GL30; 4 | 5 | public enum FboTarget { 6 | 7 | FRAMEBUFFER(GL30.GL_FRAMEBUFFER), 8 | DRAW_FRAMEBUFFER(GL30.GL_DRAW_FRAMEBUFFER), 9 | READ_FRAMEBUFFER(GL30.GL_READ_FRAMEBUFFER); 10 | 11 | private final int value; 12 | 13 | FboTarget(int value) { 14 | this.value = value; 15 | } 16 | 17 | public int get() { 18 | return value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/IFbo.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo; 2 | 3 | public interface IFbo extends ReadOnlyFbo, ReadableFbo, DrawableFbo, ModifiableFbo { 4 | 5 | /** 6 | * Sets the size of the fbo 7 | * *NOTE* you must resize the attachments too 8 | * 9 | * @param width the width 10 | * @param height the height 11 | */ 12 | void resize(int width, int height); 13 | 14 | /** 15 | * Delete the fbo 16 | */ 17 | void delete(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/ReadableFbo.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo; 2 | 3 | import org.saar.lwjgl.opengl.utils.GlBuffer; 4 | 5 | public interface ReadableFbo extends ReadOnlyFbo { 6 | 7 | /** 8 | * Set as read fbo 9 | */ 10 | void bindAsRead(); 11 | 12 | /** 13 | * Blit the fbo into the bound read fbo 14 | */ 15 | void blitFramebuffer(int x1, int y1, int w1, int h1, int x2, int y2, int w2, 16 | int h2, FboBlitFilter filter, GlBuffer[] buffers); 17 | } 18 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/attachment/AttachmentType.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.attachment; 2 | 3 | import org.lwjgl.opengl.GL30; 4 | 5 | public enum AttachmentType { 6 | 7 | COLOUR(GL30.GL_COLOR_ATTACHMENT0), 8 | DEPTH(GL30.GL_DEPTH_ATTACHMENT), 9 | STENCIL(GL30.GL_STENCIL_ATTACHMENT), 10 | DEPTH_STENCIL(GL30.GL_DEPTH_STENCIL_ATTACHMENT), 11 | ; 12 | 13 | private final int value; 14 | 15 | AttachmentType(int value) { 16 | this.value = value; 17 | } 18 | 19 | public int get() { 20 | return value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/attachment/IAttachment.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.attachment; 2 | 3 | import org.saar.lwjgl.opengl.fbo.ReadOnlyFbo; 4 | import org.saar.lwjgl.opengl.fbo.attachment.index.AttachmentIndex; 5 | 6 | public interface IAttachment { 7 | 8 | void init(ReadOnlyFbo fbo, AttachmentIndex index); 9 | 10 | void delete(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/attachment/allocation/AllocationStrategy.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.attachment.allocation 2 | 3 | import org.saar.lwjgl.opengl.fbo.attachment.buffer.AttachmentBuffer 4 | 5 | interface AllocationStrategy { 6 | 7 | fun allocate(buffer: AttachmentBuffer, width: Int, height: Int) 8 | 9 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/attachment/allocation/MultisampledAllocationStrategy.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.attachment.allocation 2 | 3 | import org.saar.lwjgl.opengl.fbo.attachment.buffer.AttachmentBuffer 4 | 5 | class MultisampledAllocationStrategy(private val samples: Int) : AllocationStrategy { 6 | 7 | override fun allocate(buffer: AttachmentBuffer, width: Int, height: Int) = 8 | buffer.allocateMultisampled(width, height, this.samples) 9 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/attachment/allocation/SimpleAllocationStrategy.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.attachment.allocation 2 | 3 | import org.saar.lwjgl.opengl.fbo.attachment.buffer.AttachmentBuffer 4 | 5 | class SimpleAllocationStrategy : AllocationStrategy { 6 | 7 | override fun allocate(buffer: AttachmentBuffer, width: Int, height: Int) = 8 | buffer.allocate(width, height) 9 | 10 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/attachment/buffer/AttachmentBuffer.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.attachment.buffer 2 | 3 | import org.saar.lwjgl.opengl.fbo.attachment.index.AttachmentIndex 4 | 5 | interface AttachmentBuffer { 6 | 7 | fun allocate(width: Int, height: Int) 8 | 9 | fun allocateMultisampled(width: Int, height: Int, samples: Int) 10 | 11 | fun attachToFbo(index: AttachmentIndex) 12 | 13 | fun delete() 14 | 15 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/attachment/index/AttachmentIndex.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.attachment.index 2 | 3 | import org.saar.lwjgl.opengl.fbo.attachment.AttachmentType 4 | 5 | sealed interface AttachmentIndex { 6 | val type: AttachmentType 7 | val value: Int 8 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/attachment/index/BasicAttachmentIndex.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.attachment.index 2 | 3 | import org.saar.lwjgl.opengl.fbo.attachment.AttachmentType 4 | 5 | class BasicAttachmentIndex(override val type: AttachmentType) : AttachmentIndex { 6 | 7 | override val value = this.type.get() 8 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/attachment/index/ColourAttachmentIndex.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.attachment.index 2 | 3 | import org.saar.lwjgl.opengl.fbo.attachment.AttachmentType 4 | 5 | class ColourAttachmentIndex(index: Int) : AttachmentIndex { 6 | 7 | override val value = AttachmentType.COLOUR.get() + index 8 | 9 | override val type = AttachmentType.COLOUR 10 | 11 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/copy/CopyStrategy.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.copy 2 | 3 | import org.saar.lwjgl.opengl.fbo.DrawableFbo 4 | import org.saar.lwjgl.opengl.fbo.ReadableFbo 5 | 6 | interface CopyStrategy { 7 | 8 | fun copy(from: ReadableFbo, to: DrawableFbo) 9 | 10 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/rendertarget/DrawRenderTarget.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.rendertarget 2 | 3 | interface DrawRenderTarget { 4 | 5 | fun setAsDraw() 6 | 7 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/rendertarget/DrawRenderTargetComposite.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.rendertarget 2 | 3 | import org.lwjgl.opengl.GL20 4 | 5 | class DrawRenderTargetComposite(vararg drawBuffers: SingleRenderTarget) : DrawRenderTarget { 6 | 7 | private val buffers = drawBuffers.map { it.index.value }.toIntArray() 8 | 9 | override fun setAsDraw() = GL20.glDrawBuffers(this.buffers) 10 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/rendertarget/IndexRenderTarget.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.rendertarget 2 | 3 | import org.lwjgl.opengl.GL11 4 | import org.lwjgl.opengl.GL20 5 | import org.saar.lwjgl.opengl.fbo.attachment.index.AttachmentIndex 6 | 7 | class IndexRenderTarget(override val index: AttachmentIndex) : SingleRenderTarget, RenderTarget { 8 | 9 | override fun setAsRead() = GL11.glReadBuffer(this.index.value) 10 | 11 | override fun setAsDraw() = GL20.glDrawBuffer(this.index.value) 12 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/rendertarget/ReadRenderTarget.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.rendertarget 2 | 3 | interface ReadRenderTarget { 4 | 5 | fun setAsRead() 6 | 7 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/rendertarget/RenderTarget.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.rendertarget 2 | 3 | interface RenderTarget : ReadRenderTarget, DrawRenderTarget { 4 | 5 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/fbo/rendertarget/SingleRenderTarget.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.fbo.rendertarget 2 | 3 | import org.saar.lwjgl.opengl.fbo.attachment.index.AttachmentIndex 4 | 5 | interface SingleRenderTarget { 6 | 7 | val index: AttachmentIndex 8 | 9 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/pbo/ReadablePbo.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.pbo; 2 | 3 | import org.saar.lwjgl.opengl.constants.DataType; 4 | import org.saar.lwjgl.opengl.constants.InternalFormat; 5 | 6 | public interface ReadablePbo { 7 | 8 | void readPixels(int x, int y, int width, int height, InternalFormat format, DataType dataType); 9 | 10 | void delete(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/polygonmode/PolygonModeState.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.polygonmode 2 | 3 | import org.saar.lwjgl.opengl.constants.Face 4 | 5 | data class PolygonModeState( 6 | val face: Face, 7 | val mode: PolygonModeValue, 8 | ) -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/polygonmode/PolygonModeValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.polygonmode 2 | 3 | import org.lwjgl.opengl.GL11 4 | 5 | enum class PolygonModeValue(val value: Int) { 6 | 7 | POINT(GL11.GL_POINT), 8 | LINE(GL11.GL_LINE), 9 | FILL(GL11.GL_FILL), 10 | 11 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/primitive/GlPrimitive.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.primitive; 2 | 3 | import org.saar.lwjgl.opengl.constants.DataType; 4 | import org.saar.lwjgl.opengl.attribute.IAttribute; 5 | import org.saar.lwjgl.util.DataWriter; 6 | 7 | public interface GlPrimitive { 8 | 9 | void loadUniform(int location); 10 | 11 | IAttribute[] attribute(int index, boolean normalized, int instances); 12 | 13 | void write(DataWriter writer); 14 | 15 | DataType getDataType(); 16 | 17 | int getComponentCount(); 18 | 19 | int getSize(); 20 | } 21 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/primitive/GlPrimitiveBase.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.primitive; 2 | 3 | public abstract class GlPrimitiveBase implements GlPrimitive { 4 | 5 | @Override 6 | public final int getSize() { 7 | final int components = getComponentCount(); 8 | final int bytes = getDataType().getBytes(); 9 | return components * bytes; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/provokingvertex/ProvokingVertexValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.provokingvertex 2 | 3 | import org.lwjgl.opengl.GL32 4 | 5 | enum class ProvokingVertexValue(val value: Int) { 6 | 7 | FIRST(GL32.GL_FIRST_VERTEX_CONVENTION), 8 | LAST(GL32.GL_LAST_VERTEX_CONVENTION), 9 | 10 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/renderbuffer/BoundRenderBuffer.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.renderbuffer; 2 | 3 | final class BoundRenderBuffer { 4 | 5 | private static int bound = 0; 6 | 7 | private BoundRenderBuffer() { 8 | throw new AssertionError("Cannot create instance of class " 9 | + getClass().getSimpleName()); 10 | } 11 | 12 | public static boolean isBound(int id) { 13 | return BoundRenderBuffer.get() == id; 14 | } 15 | 16 | public static void set(int id) { 17 | BoundRenderBuffer.bound = id; 18 | } 19 | 20 | public static int get() { 21 | return BoundRenderBuffer.bound; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/BoundProgram.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader; 2 | 3 | public final class BoundProgram { 4 | 5 | private static int bound = 0; 6 | 7 | private BoundProgram() { 8 | throw new AssertionError("Cannot create instance of class " 9 | + getClass().getSimpleName()); 10 | } 11 | 12 | public static boolean isBound(int id) { 13 | return BoundProgram.get() == id; 14 | } 15 | 16 | public static void set(int id) { 17 | BoundProgram.bound = id; 18 | } 19 | 20 | public static int get() { 21 | return BoundProgram.bound; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/ShaderCode.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader; 2 | 3 | public class ShaderCode { 4 | 5 | private final String code; 6 | 7 | private ShaderCode(String code) { 8 | this.code = code; 9 | } 10 | 11 | public static ShaderCode define(String name, String value) { 12 | return new ShaderCode("#define " + name + " " + value); 13 | } 14 | 15 | public static ShaderCode loadSource(String file) throws Exception { 16 | final String code = ShaderCodeLoader.loadSource(file); 17 | return new ShaderCode(code); 18 | } 19 | 20 | public String getCode() { 21 | return this.code; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/ShaderType.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader; 2 | 3 | import org.lwjgl.opengl.GL20; 4 | import org.lwjgl.opengl.GL32; 5 | import org.lwjgl.opengl.GL40; 6 | 7 | public enum ShaderType { 8 | 9 | VERTEX(GL20.GL_VERTEX_SHADER), 10 | FRAGMENT(GL20.GL_FRAGMENT_SHADER), 11 | GEOMETRY(GL32.GL_GEOMETRY_SHADER), 12 | TESS_CONTROL(GL40.GL_TESS_CONTROL_SHADER), 13 | TESS_EVALUATION(GL40.GL_TESS_EVALUATION_SHADER), 14 | ; 15 | 16 | private final int value; 17 | 18 | ShaderType(int value) { 19 | this.value = value; 20 | } 21 | 22 | public int get() { 23 | return value; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/BooleanUniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.lwjgl.opengl.GL20 4 | 5 | abstract class BooleanUniform : Uniform { 6 | 7 | final override fun load(location: Int) { 8 | val value: Boolean = this.value 9 | GL20.glUniform1i(location, if (value) 1 else 0) 10 | } 11 | 12 | abstract val value: Boolean 13 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/BooleanUniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | class BooleanUniformValue( 4 | override val name: String, 5 | override var value: Boolean = false 6 | ) : BooleanUniform() -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/FloatUniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.lwjgl.opengl.GL20 4 | 5 | abstract class FloatUniform : Uniform { 6 | 7 | final override fun load(location: Int) { 8 | val value: Float = this.value 9 | GL20.glUniform1f(location, value) 10 | } 11 | 12 | abstract val value: Float 13 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/FloatUniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | class FloatUniformValue( 4 | override val name: String, 5 | override var value: Float = 0f 6 | ) : FloatUniform() -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/IntUniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.lwjgl.opengl.GL20 4 | 5 | abstract class IntUniform : Uniform { 6 | 7 | final override fun load(location: Int) { 8 | val value: Int = this.value 9 | GL20.glUniform1i(location, value) 10 | } 11 | 12 | abstract val value: Int 13 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/IntUniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | class IntUniformValue( 4 | override val name: String, 5 | override var value: Int = 0 6 | ) : IntUniform() -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Mat4Uniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Matrix4fc 4 | import org.lwjgl.opengl.GL20 5 | import org.lwjgl.system.MemoryStack 6 | 7 | abstract class Mat4Uniform : Uniform { 8 | 9 | final override fun load(location: Int) { 10 | val value: Matrix4fc = this.value 11 | MemoryStack.stackPush().use { stack -> 12 | val buffer = value.get(stack.callocFloat(16)) 13 | GL20.glUniformMatrix4fv(location, this.transpose, buffer) 14 | } 15 | } 16 | 17 | abstract val value: Matrix4fc 18 | abstract val transpose: Boolean 19 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Mat4UniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Matrix4f 4 | import org.saar.maths.JomlDelegates 5 | import org.saar.maths.utils.Matrix4 6 | 7 | class Mat4UniformValue( 8 | override val name: String, 9 | initialValue: Matrix4f = Matrix4.create(), 10 | override val transpose: Boolean = false 11 | ) : Mat4Uniform() { 12 | override var value: Matrix4f by JomlDelegates.CachedMatrix4f(Matrix4.of(initialValue)) 13 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/TextureUniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.lwjgl.opengl.GL20 4 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture 5 | 6 | abstract class TextureUniform : Uniform { 7 | 8 | final override fun load(location: Int) { 9 | GL20.glUniform1i(location, this.unit) 10 | this.value.bind(this.unit) 11 | } 12 | 13 | abstract val value: ReadOnlyTexture 14 | abstract val unit: Int 15 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/TextureUniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.saar.lwjgl.opengl.texture.ReadOnlyTexture 4 | import org.saar.lwjgl.opengl.texture.Texture2D 5 | 6 | class TextureUniformValue( 7 | override val name: String, 8 | override var unit: Int, 9 | override var value: ReadOnlyTexture = Texture2D.NULL, 10 | ) : TextureUniform() -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/UIntUniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.lwjgl.opengl.GL30 4 | 5 | abstract class UIntUniform : Uniform { 6 | 7 | final override fun load(location: Int) { 8 | val value: Int = this.value 9 | GL30.glUniform1ui(location, value) 10 | } 11 | 12 | abstract val value: Int 13 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/UIntUniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | class UIntUniformValue( 4 | override val name: String, 5 | override var value: Int = 0 6 | ) : UIntUniform() -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Uniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | interface Uniform : UniformContainer { 4 | val name: String 5 | fun load(location: Int) 6 | 7 | override val subUniforms: List get() = listOf(this) 8 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/UniformArray.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | class UniformArray( 4 | name: String, size: Int, supplier: (String, Int) -> T 5 | ) : Iterable, UniformContainer { 6 | 7 | private val array = (0 until size).map { supplier("$name[$it]", it) } 8 | 9 | override val subUniforms = array.flatMap { it.subUniforms } 10 | 11 | override fun iterator() = this.array.listIterator() 12 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/UniformContainer.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | interface UniformContainer { 4 | val subUniforms: List 5 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/UniformWrapper.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | class UniformWrapper(private val location: Int, private val uniform: Uniform) { 4 | 5 | fun load() { 6 | if (this.location >= 0) { 7 | this.uniform.load(this.location) 8 | } 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec2Uniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector2fc 4 | import org.lwjgl.opengl.GL20 5 | 6 | abstract class Vec2Uniform : Uniform { 7 | 8 | final override fun load(location: Int) { 9 | val value: Vector2fc = this.value 10 | GL20.glUniform2f(location, value.x(), value.y()) 11 | } 12 | 13 | abstract val value: Vector2fc 14 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec2UniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector2f 4 | import org.joml.Vector2fc 5 | import org.saar.maths.JomlDelegates 6 | 7 | class Vec2UniformValue( 8 | override val name: String, 9 | initialValue: Vector2fc = Vector2f(0f, 0f) 10 | ) : Vec2Uniform() { 11 | override var value: Vector2fc by JomlDelegates.CachedVector2f(Vector2f(initialValue)) 12 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec2iUniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector2ic 4 | import org.lwjgl.opengl.GL20 5 | 6 | abstract class Vec2iUniform : Uniform { 7 | 8 | final override fun load(location: Int) { 9 | val value: Vector2ic = this.value 10 | GL20.glUniform2i(location, value.x(), value.y()) 11 | } 12 | 13 | abstract val value: Vector2ic 14 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec2iUniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector2i 4 | import org.joml.Vector2ic 5 | import org.saar.maths.JomlDelegates 6 | 7 | class Vec2iUniformValue( 8 | override val name: String, 9 | initialValue: Vector2ic = Vector2i(0, 0) 10 | ) : Vec2iUniform() { 11 | override var value: Vector2ic by JomlDelegates.CachedVector2i(Vector2i(initialValue)) 12 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec3Uniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector3fc 4 | import org.lwjgl.opengl.GL20 5 | 6 | abstract class Vec3Uniform : Uniform { 7 | 8 | final override fun load(location: Int) { 9 | val value: Vector3fc = this.value 10 | GL20.glUniform3f(location, value.x(), value.y(), value.z()) 11 | } 12 | 13 | abstract val value: Vector3fc 14 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec3UniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector3f 4 | import org.joml.Vector3fc 5 | import org.saar.maths.JomlDelegates 6 | 7 | class Vec3UniformValue( 8 | override val name: String, 9 | initialValue: Vector3fc = Vector3f(0f, 0f, 0f) 10 | ) : Vec3Uniform() { 11 | override var value: Vector3f by JomlDelegates.CachedVector3f(Vector3f(initialValue)) 12 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec3iUniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector3ic 4 | import org.lwjgl.opengl.GL20 5 | 6 | abstract class Vec3iUniform : Uniform { 7 | 8 | final override fun load(location: Int) { 9 | val value: Vector3ic = this.value 10 | GL20.glUniform3i(location, value.x(), value.y(), value.z()) 11 | } 12 | 13 | abstract val value: Vector3ic 14 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec3iUniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector3i 4 | import org.joml.Vector3ic 5 | import org.saar.maths.JomlDelegates 6 | 7 | class Vec3iUniformValue( 8 | override val name: String, 9 | initialValue: Vector3ic = Vector3i(0, 0, 0) 10 | ) : Vec3iUniform() { 11 | override var value: Vector3i by JomlDelegates.CachedVector3i(Vector3i(initialValue)) 12 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec4Uniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector4fc 4 | import org.lwjgl.opengl.GL20 5 | 6 | abstract class Vec4Uniform : Uniform { 7 | 8 | final override fun load(location: Int) { 9 | val value: Vector4fc = this.value 10 | GL20.glUniform4f(location, value.x(), value.y(), value.z(), value.w()) 11 | } 12 | 13 | abstract val value: Vector4fc 14 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec4UniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector4f 4 | import org.joml.Vector4fc 5 | import org.saar.maths.JomlDelegates 6 | 7 | class Vec4UniformValue( 8 | override val name: String, 9 | initialValue: Vector4fc = Vector4f(0f, 0f, 0f, 0f) 10 | ) : Vec4Uniform() { 11 | override val value: Vector4f by JomlDelegates.CachedVector4f(Vector4f(initialValue)) 12 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec4iUniform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector4ic 4 | import org.lwjgl.opengl.GL20 5 | 6 | abstract class Vec4iUniform : Uniform { 7 | 8 | final override fun load(location: Int) { 9 | val value: Vector4ic = this.value 10 | GL20.glUniform4i(location, value.x(), value.y(), value.z(), value.w()) 11 | } 12 | 13 | abstract val value: Vector4ic 14 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/shader/uniforms/Vec4iUniformValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.shader.uniforms 2 | 3 | import org.joml.Vector4i 4 | import org.joml.Vector4ic 5 | import org.saar.maths.JomlDelegates 6 | 7 | class Vec4iUniformValue( 8 | override val name: String, 9 | initialValue: Vector4ic = Vector4i(0, 0, 0, 0) 10 | ) : Vec4iUniform() { 11 | override var value: Vector4i by JomlDelegates.CachedVector4i(Vector4i(initialValue)) 12 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/stencil/StencilFunction.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.stencil 2 | 3 | import org.saar.lwjgl.opengl.constants.Comparator 4 | 5 | data class StencilFunction( 6 | val comparator: Comparator, 7 | val reference: Int, 8 | val mask: Int = -1 9 | ) -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/stencil/StencilMask.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.stencil 2 | 3 | data class StencilMask(val value: Int) { 4 | 5 | companion object { 6 | @JvmField 7 | val ZERO = StencilMask(0) 8 | 9 | @JvmField 10 | val UNCHANGED = StencilMask(-1) 11 | } 12 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/stencil/StencilOperation.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.stencil 2 | 3 | data class StencilOperation( 4 | val sFail: StencilValue, 5 | val dFail: StencilValue, 6 | val pass: StencilValue 7 | ) { 8 | companion object { 9 | @JvmField 10 | val ALWAYS_KEEP = StencilOperation(StencilValue.KEEP, StencilValue.KEEP, StencilValue.KEEP) 11 | 12 | @JvmField 13 | val REPLACE_ON_PASS = StencilOperation(StencilValue.KEEP, StencilValue.KEEP, StencilValue.REPLACE) 14 | } 15 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/stencil/StencilState.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.stencil 2 | 3 | data class StencilState( 4 | val enabled: Boolean, 5 | val operation: StencilOperation, 6 | val function: StencilFunction, 7 | val mask: StencilMask, 8 | ) { 9 | constructor(operation: StencilOperation, function: StencilFunction, mask: StencilMask) : 10 | this(true, operation, function, mask) 11 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/stencil/StencilValue.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.stencil 2 | 3 | import org.lwjgl.opengl.GL11 4 | import org.lwjgl.opengl.GL14 5 | 6 | enum class StencilValue(val value: Int) { 7 | 8 | KEEP(GL11.GL_KEEP), 9 | REPLACE(GL11.GL_REPLACE), 10 | INVERT(GL11.GL_INVERT), 11 | ZERO(GL11.GL_ZERO), 12 | 13 | INCREMENT(GL11.GL_INCR), 14 | INCREMENT_WRAP(GL14.GL_INCR_WRAP), 15 | 16 | DECREMENT(GL11.GL_DECR), 17 | DECREMENT_WRAP(GL14.GL_DECR_WRAP), 18 | 19 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/ActiveTexture.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture; 2 | 3 | public final class ActiveTexture { 4 | 5 | private static int active = 0; 6 | 7 | private ActiveTexture() { 8 | throw new AssertionError("Cannot create instance of class " 9 | + getClass().getSimpleName()); 10 | } 11 | 12 | public static boolean isActive(int unit) { 13 | return ActiveTexture.active == unit; 14 | } 15 | 16 | public static void set(int unit) { 17 | ActiveTexture.active = unit; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/MutableTexture.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture; 2 | 3 | import org.saar.lwjgl.opengl.texture.parameter.TextureParameter; 4 | 5 | public interface MutableTexture extends ReadOnlyTexture { 6 | 7 | void applyParameters(TextureParameter[] parameters); 8 | 9 | void generateMipmap(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/ReadOnlyTexture.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture; 2 | 3 | public interface ReadOnlyTexture { 4 | 5 | void bind(int unit); 6 | 7 | void bind(); 8 | 9 | void unbind(); 10 | 11 | void delete(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/ReadOnlyTexture2D.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture; 2 | 3 | public interface ReadOnlyTexture2D extends ReadOnlyTexture { 4 | 5 | int getWidth(); 6 | 7 | int getHeight(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/TextureCache.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public final class TextureCache { 7 | 8 | private static final Map CACHE = new HashMap<>(); 9 | 10 | private TextureCache() { 11 | 12 | } 13 | 14 | public static void addToCache(String file, ReadOnlyTexture texture) { 15 | CACHE.put(file, texture); 16 | } 17 | 18 | public static ReadOnlyTexture getTexture(String file) { 19 | return CACHE.get(file); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/TextureInfo.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture 2 | 3 | import org.saar.lwjgl.opengl.constants.DataType 4 | import org.saar.lwjgl.opengl.constants.FormatType 5 | import java.nio.ByteBuffer 6 | 7 | data class TextureInfo( 8 | val width: Int, 9 | val height: Int, 10 | val formatType: FormatType, 11 | val dataType: DataType, 12 | val data: ByteBuffer 13 | ) -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/WritableTexture2D.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture; 2 | 3 | import org.saar.lwjgl.opengl.constants.DataType; 4 | import org.saar.lwjgl.opengl.constants.FormatType; 5 | 6 | import java.nio.ByteBuffer; 7 | 8 | public interface WritableTexture2D extends MutableTexture, ReadOnlyTexture2D { 9 | 10 | void load(int level, int xOffset, int yOffset, int width, 11 | int height, FormatType format, DataType type, ByteBuffer data); 12 | 13 | default void load(int level, FormatType format, DataType type, ByteBuffer data) { 14 | load(level, 0, 0, getWidth(), getHeight(), format, type, data); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/parameter/TextureBorderColourParameter.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.parameter; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | 5 | public class TextureBorderColourParameter extends TextureFloatsParameterParameter implements TextureParameter { 6 | 7 | private static final int pName = GL11.GL_TEXTURE_BORDER_COLOR; 8 | 9 | public TextureBorderColourParameter(float r, float g, float b, float a) { 10 | super(TextureBorderColourParameter.pName, r, g, b, a); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/parameter/TextureFloatParameterParameter.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.parameter; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | import org.saar.lwjgl.opengl.texture.TextureTarget; 5 | 6 | abstract class TextureFloatParameterParameter implements TextureParameter { 7 | 8 | private final int name; 9 | private final float value; 10 | 11 | TextureFloatParameterParameter(int name, float value) { 12 | this.name = name; 13 | this.value = value; 14 | } 15 | 16 | @Override 17 | public final void apply(TextureTarget target) { 18 | GL11.glTexParameterf(target.get(), this.name, this.value); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/parameter/TextureFloatsParameterParameter.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.parameter; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | import org.saar.lwjgl.opengl.texture.TextureTarget; 5 | 6 | abstract class TextureFloatsParameterParameter implements TextureParameter { 7 | 8 | private final int name; 9 | private final float[] value; 10 | 11 | TextureFloatsParameterParameter(int name, float... value) { 12 | this.name = name; 13 | this.value = value; 14 | } 15 | 16 | @Override 17 | public final void apply(TextureTarget target) { 18 | GL11.glTexParameterfv(target.get(), this.name, this.value); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/parameter/TextureIntParameterParameter.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.parameter; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | import org.saar.lwjgl.opengl.texture.TextureTarget; 5 | 6 | abstract class TextureIntParameterParameter implements TextureParameter { 7 | 8 | private final int name; 9 | private final int value; 10 | 11 | TextureIntParameterParameter(int name, int value) { 12 | this.name = name; 13 | this.value = value; 14 | } 15 | 16 | @Override 17 | public final void apply(TextureTarget target) { 18 | GL11.glTexParameteri(target.get(), this.name, this.value); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/parameter/TextureLodBiasParameter.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.parameter; 2 | 3 | import org.lwjgl.opengl.GL14; 4 | 5 | public class TextureLodBiasParameter extends TextureFloatParameterParameter implements TextureParameter { 6 | 7 | private static final int pName = GL14.GL_TEXTURE_LOD_BIAS; 8 | 9 | public TextureLodBiasParameter(float lodBias) { 10 | super(TextureLodBiasParameter.pName, lodBias); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/parameter/TextureMagFilterParameter.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.parameter; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | import org.saar.lwjgl.opengl.texture.values.MagFilterValue; 5 | 6 | public class TextureMagFilterParameter extends TextureIntParameterParameter implements TextureParameter { 7 | 8 | private static final int pName = GL11.GL_TEXTURE_MAG_FILTER; 9 | 10 | public TextureMagFilterParameter(MagFilterValue magFilter) { 11 | super(TextureMagFilterParameter.pName, magFilter.get()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/parameter/TextureMinFilterParameter.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.parameter; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | import org.saar.lwjgl.opengl.texture.values.MinFilterValue; 5 | 6 | public class TextureMinFilterParameter extends TextureIntParameterParameter implements TextureParameter { 7 | 8 | private static final int pName = GL11.GL_TEXTURE_MIN_FILTER; 9 | 10 | public TextureMinFilterParameter(MinFilterValue minFilter) { 11 | super(TextureMinFilterParameter.pName, minFilter.get()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/parameter/TextureParameter.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.parameter; 2 | 3 | import org.saar.lwjgl.opengl.texture.TextureTarget; 4 | 5 | public interface TextureParameter { 6 | 7 | void apply(TextureTarget target); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/parameter/TextureSWrapParameter.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.parameter; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | import org.saar.lwjgl.opengl.texture.values.WrapValue; 5 | 6 | public class TextureSWrapParameter extends TextureIntParameterParameter implements TextureParameter { 7 | 8 | private static final int pName = GL11.GL_TEXTURE_WRAP_S; 9 | 10 | public TextureSWrapParameter(WrapValue wrap) { 11 | super(TextureSWrapParameter.pName, wrap.get()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/parameter/TextureTWrapParameter.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.parameter; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | import org.saar.lwjgl.opengl.texture.values.WrapValue; 5 | 6 | public class TextureTWrapParameter extends TextureIntParameterParameter implements TextureParameter { 7 | 8 | private static final int pName = GL11.GL_TEXTURE_WRAP_T; 9 | 10 | public TextureTWrapParameter(WrapValue wrap) { 11 | super(TextureTWrapParameter.pName, wrap.get()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/values/MagFilterValue.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.values; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | 5 | public enum MagFilterValue { 6 | 7 | NEAREST(GL11.GL_NEAREST), 8 | LINEAR(GL11.GL_LINEAR); 9 | 10 | private final int value; 11 | 12 | MagFilterValue(int value) { 13 | this.value = value; 14 | } 15 | 16 | public int get() { 17 | return value; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/values/MinFilterValue.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.values; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | 5 | public enum MinFilterValue { 6 | 7 | NEAREST(GL11.GL_NEAREST), 8 | LINEAR(GL11.GL_LINEAR), 9 | 10 | NEAREST_MIPMAP_NEAREST(GL11.GL_NEAREST_MIPMAP_NEAREST), 11 | LINEAR_MIPMAP_NEAREST(GL11.GL_LINEAR_MIPMAP_NEAREST), 12 | NEAREST_MIPMAP_LINEAR(GL11.GL_NEAREST_MIPMAP_LINEAR), 13 | LINEAR_MIPMAP_LINEAR(GL11.GL_LINEAR_MIPMAP_LINEAR); 14 | 15 | private final int value; 16 | 17 | MinFilterValue(int value) { 18 | this.value = value; 19 | } 20 | 21 | public int get() { 22 | return value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/texture/values/WrapValue.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.texture.values; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | import org.lwjgl.opengl.GL12; 5 | import org.lwjgl.opengl.GL13; 6 | import org.lwjgl.opengl.GL14; 7 | 8 | public enum WrapValue { 9 | 10 | CLAMP(GL11.GL_CLAMP), 11 | REPEAT(GL11.GL_REPEAT), 12 | CLAMP_TO_EDGE(GL12.GL_CLAMP_TO_EDGE), 13 | CLAMP_TO_BORDER(GL13.GL_CLAMP_TO_BORDER), 14 | MIRRORED_REPEAT(GL14.GL_MIRRORED_REPEAT); 15 | 16 | private final int value; 17 | 18 | WrapValue(int value) { 19 | this.value = value; 20 | } 21 | 22 | public int get() { 23 | return value; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/utils/GlConfigs.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.utils; 2 | 3 | public final class GlConfigs { 4 | 5 | private GlConfigs() { 6 | 7 | } 8 | 9 | public static final boolean CACHE_STATE = false; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/vao/BoundVao.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.vao; 2 | 3 | final class BoundVao { 4 | 5 | private static int bound = 0; 6 | 7 | private BoundVao() { 8 | throw new AssertionError("Cannot create instance of class " 9 | + getClass().getSimpleName()); 10 | } 11 | 12 | public static boolean isBound(int id) { 13 | return BoundVao.get() == id; 14 | } 15 | 16 | public static void set(int id) { 17 | BoundVao.bound = id; 18 | } 19 | 20 | public static int get() { 21 | return BoundVao.bound; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/vao/IVao.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.vao; 2 | 3 | public interface IVao extends WritableVao { 4 | 5 | /** 6 | * Delete this vao and its related buffers 7 | */ 8 | void delete(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/vao/ReadOnlyVao.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.vao; 2 | 3 | public interface ReadOnlyVao { 4 | 5 | /** 6 | * Bind the vao 7 | */ 8 | void bind(); 9 | 10 | /** 11 | * Unbind the vao 12 | */ 13 | void unbind(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/vao/linking/LinkingStrategy.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.vao.linking 2 | 3 | import org.saar.lwjgl.opengl.attribute.IAttribute 4 | 5 | interface LinkingStrategy { 6 | 7 | fun link(attributes: Array) 8 | 9 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/vbo/IVbo.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.vbo; 2 | 3 | public interface IVbo extends WritableVbo { 4 | 5 | /** 6 | * Delete the vbo 7 | */ 8 | void delete(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/vbo/ReadOnlyVbo.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.vbo; 2 | 3 | public interface ReadOnlyVbo { 4 | 5 | /** 6 | * Returns the capacity allocated to the buffer object in bytes 7 | * 8 | * @return the capacity allocated to the buffer object in bytes 9 | */ 10 | long getCapacity(); 11 | 12 | /** 13 | * Bind the vbo 14 | */ 15 | void bind(); 16 | 17 | /** 18 | * Unbind the vbo 19 | */ 20 | void unbind(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/vbo/VboAccess.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.vbo; 2 | 3 | import org.saar.lwjgl.opengl.buffer.BufferAccess; 4 | 5 | public enum VboAccess { 6 | 7 | READ_ONLY(BufferAccess.READ_ONLY), 8 | WRITE_ONLY(BufferAccess.WRITE_ONLY), 9 | READ_WRITE(BufferAccess.READ_WRITE); 10 | 11 | private final BufferAccess value; 12 | 13 | VboAccess(BufferAccess value) { 14 | this.value = value; 15 | } 16 | 17 | public BufferAccess get() { 18 | return value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/opengl/vbo/VboTarget.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.opengl.vbo; 2 | 3 | import org.saar.lwjgl.opengl.buffer.BufferTarget; 4 | 5 | public enum VboTarget { 6 | 7 | ARRAY_BUFFER(BufferTarget.ARRAY), 8 | ELEMENT_ARRAY_BUFFER(BufferTarget.ELEMENT_ARRAY), 9 | ; 10 | 11 | private final BufferTarget value; 12 | 13 | VboTarget(BufferTarget value) { 14 | this.value = value; 15 | } 16 | 17 | public BufferTarget get() { 18 | return this.value; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/stb/TrueTypeBitmap.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.stb 2 | 3 | import org.saar.lwjgl.util.buffer.LwjglByteBuffer 4 | 5 | data class TrueTypeBitmap(val bitmap: LwjglByteBuffer, 6 | val characters: List, 7 | val lineGap: Float) : AutoCloseable { 8 | 9 | override fun close() = this.bitmap.close() 10 | 11 | } 12 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/stb/TrueTypeCharacter.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.stb 2 | 3 | import org.saar.maths.Box2i 4 | 5 | data class TrueTypeCharacter( 6 | val char: Char, 7 | val bitmapBox: Box2i, 8 | val localBox: Box2i, 9 | val xAdvance: Float 10 | ) -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/stb/TrueTypeCharacterBitmap.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.stb 2 | 3 | import org.saar.lwjgl.util.buffer.LwjglByteBuffer 4 | 5 | data class TrueTypeCharacterBitmap(val bitmap: LwjglByteBuffer, 6 | val width: Int, 7 | val height: Int, 8 | val xOffset: Int, 9 | val yOffset: Int) : AutoCloseable { 10 | 11 | override fun close() = this.bitmap.close() 12 | } 13 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/stb/TrueTypeCodepointHMetrics.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.stb 2 | 3 | data class TrueTypeCodepointHMetrics( 4 | val advanceWidth: Int, 5 | val leftSideBearing: Int 6 | ) 7 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/stb/TrueTypeFontVMetrics.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.stb 2 | 3 | data class TrueTypeFontVMetrics( 4 | val ascent: Int, 5 | val descent: Int, 6 | val lineGap: Int 7 | ) 8 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/stb/exceptions/STBBufferOverflowException.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.stb.exceptions 2 | 3 | class STBBufferOverflowException : Exception { 4 | 5 | constructor() : super() 6 | 7 | constructor(message: String) : super(message) 8 | 9 | constructor(message: String, cause: Throwable) : super(message, cause) 10 | 11 | constructor(cause: Throwable) : super(cause) 12 | 13 | constructor(message: String, cause: Throwable, enableSuppression: Boolean, writableStackTrace: Boolean) : 14 | super(message, cause, enableSuppression, writableStackTrace) 15 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/stb/exceptions/STBInitializationException.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.stb.exceptions 2 | 3 | class STBInitializationException : Exception { 4 | 5 | constructor() : super() 6 | 7 | constructor(message: String) : super(message) 8 | 9 | constructor(message: String, cause: Throwable) : super(message, cause) 10 | 11 | constructor(cause: Throwable) : super(cause) 12 | 13 | constructor(message: String, cause: Throwable, enableSuppression: Boolean, writableStackTrace: Boolean) : 14 | super(message, cause, enableSuppression, writableStackTrace) 15 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/util/FileLoader.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.util 2 | 3 | import java.io.FileNotFoundException 4 | import java.util.* 5 | 6 | object FileLoader { 7 | 8 | @JvmStatic 9 | fun loadTextFile(fileName: String): String { 10 | val resource = FileLoader::class.java.getResourceAsStream(fileName) 11 | ?: throw FileNotFoundException("$fileName not found") 12 | 13 | return resource.use { Scanner(resource, "UTF-8").useDelimiter("\\A").next() } 14 | } 15 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/util/LwjglUtil.java: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.util; 2 | 3 | public final class LwjglUtil { 4 | 5 | private LwjglUtil() { 6 | throw new AssertionError("Cannot create instance of class " 7 | + getClass().getSimpleName()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/util/buffer/BufferBuilder.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.util.buffer 2 | 3 | import org.saar.lwjgl.util.DataWriter 4 | 5 | interface BufferBuilder { 6 | 7 | val writer: DataWriter 8 | 9 | fun build(): LwjglBuffer 10 | 11 | fun delete() 12 | 13 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/util/buffer/DynamicBufferBuilder.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.util.buffer 2 | 3 | import org.saar.lwjgl.util.ByteListWriter 4 | import org.saar.lwjgl.util.DataWriter 5 | 6 | class DynamicBufferBuilder : BufferBuilder { 7 | 8 | private val storage = mutableListOf() 9 | 10 | override val writer: DataWriter = ByteListWriter(this.storage) 11 | 12 | override fun build(): LwjglBuffer = LwjglByteBuffer.allocate(this.storage.size) 13 | .also { buffer -> this.storage.forEach { byte -> buffer.put(byte) } } 14 | 15 | override fun delete() = this.storage.clear() 16 | } -------------------------------------------------------------------------------- /pe-lwjgl-binding/src/main/java/org/saar/lwjgl/util/buffer/FixedBufferBuilder.kt: -------------------------------------------------------------------------------- 1 | package org.saar.lwjgl.util.buffer 2 | 3 | import org.saar.lwjgl.util.DataWriter 4 | 5 | class FixedBufferBuilder(capacity: Int) : BufferBuilder { 6 | 7 | private val storage = LwjglByteBuffer.allocate(capacity) 8 | 9 | override val writer: DataWriter = this.storage.writer 10 | 11 | override fun build(): LwjglBuffer = this.storage 12 | 13 | override fun delete() = this.storage.close() 14 | } -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/Box2f.kt: -------------------------------------------------------------------------------- 1 | package org.saar.maths 2 | 3 | data class Box2f(val x0: Float, val y0: Float, 4 | val x1: Float, val y1: Float) { 5 | 6 | val width: Float get() = this.x1 - this.x0 7 | 8 | val height: Float get() = this.y1 - this.y0 9 | 10 | fun offset(x: Float, y: Float): Box2f = Box2f( 11 | x + this.x0, y + this.y0, 12 | x + this.x1, y + this.y1) 13 | 14 | } -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/noise/MultipliedNoise2f.java: -------------------------------------------------------------------------------- 1 | package org.saar.maths.noise; 2 | 3 | public class MultipliedNoise2f implements Noise2f { 4 | 5 | private final int multiply; 6 | private final Noise2f noise2f; 7 | 8 | public MultipliedNoise2f(int multiply, Noise2f noise2f) { 9 | this.multiply = multiply; 10 | this.noise2f = noise2f; 11 | } 12 | 13 | @Override 14 | public float noise(float x, float y) { 15 | return this.noise2f.noise(x, y) * this.multiply; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/noise/Noise1f.java: -------------------------------------------------------------------------------- 1 | package org.saar.maths.noise; 2 | 3 | public interface Noise1f { 4 | 5 | float noise(float x); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/noise/Noise2f.java: -------------------------------------------------------------------------------- 1 | package org.saar.maths.noise; 2 | 3 | import org.joml.Vector2f; 4 | 5 | public interface Noise2f { 6 | 7 | float noise(float x, float y); 8 | 9 | default float noise(Vector2f v) { 10 | return noise(v.x, v.y); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/noise/Noise3f.java: -------------------------------------------------------------------------------- 1 | package org.saar.maths.noise; 2 | 3 | import org.joml.Vector3f; 4 | 5 | public interface Noise3f { 6 | 7 | float noise(float x, float y, float z); 8 | 9 | default float noise(Vector3f v) { 10 | return noise(v.x, v.y, v.z); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/noise/SpreadNoise2f.java: -------------------------------------------------------------------------------- 1 | package org.saar.maths.noise; 2 | 3 | public class SpreadNoise2f implements Noise2f { 4 | 5 | private final int division; 6 | private final Noise2f noise2f; 7 | 8 | public SpreadNoise2f(int division, Noise2f noise2f) { 9 | this.division = division; 10 | this.noise2f = noise2f; 11 | } 12 | 13 | @Override 14 | public float noise(float x, float y) { 15 | return this.noise2f.noise(x / this.division, y / this.division); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/objects/Dimensions.java: -------------------------------------------------------------------------------- 1 | package org.saar.maths.objects; 2 | 3 | public class Dimensions { 4 | 5 | private final int w; 6 | private final int h; 7 | 8 | public Dimensions(int width, int height) { 9 | this.w = width; 10 | this.h = height; 11 | } 12 | 13 | public int getWidth() { 14 | return this.w; 15 | } 16 | 17 | public int getHeight() { 18 | return this.h; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return String.format("[Dimensions: w=%d, h=%d]", w, h); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/objects/Polygon.java: -------------------------------------------------------------------------------- 1 | package org.saar.maths.objects; 2 | 3 | import org.joml.Vector2f; 4 | import org.saar.maths.utils.Vector2; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class Polygon { 10 | 11 | private final List vertices = new ArrayList<>(); 12 | 13 | public void addVertex(float x, float y) { 14 | vertices.add(Vector2.of(x, y)); 15 | } 16 | 17 | public List getVertices() { 18 | return vertices; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/transform/NullTransform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.maths.transform 2 | 3 | import org.joml.Matrix4fc 4 | import org.saar.maths.utils.Matrix4 5 | 6 | object NullTransform : ReadonlyTransform { 7 | 8 | override val transformationMatrix: Matrix4fc = Matrix4.create() 9 | 10 | override val position: ReadonlyPosition = Position.create() 11 | override val rotation: ReadonlyRotation = Rotation.create() 12 | override val scale: ReadonlyScale = Scale.create() 13 | } -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/transform/ReadonlyPosition.java: -------------------------------------------------------------------------------- 1 | package org.saar.maths.transform; 2 | 3 | import org.joml.Vector3fc; 4 | import org.jproperty.ObservableValue; 5 | 6 | public interface ReadonlyPosition extends ObservableValue { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/transform/ReadonlyRotation.java: -------------------------------------------------------------------------------- 1 | package org.saar.maths.transform; 2 | 3 | import org.joml.Quaternionfc; 4 | import org.joml.Vector3f; 5 | import org.joml.Vector3fc; 6 | import org.jproperty.ObservableValue; 7 | 8 | public interface ReadonlyRotation extends ObservableValue { 9 | 10 | Vector3fc getEulerAngles(); 11 | 12 | Vector3f getDirection(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/transform/ReadonlyScale.java: -------------------------------------------------------------------------------- 1 | package org.saar.maths.transform; 2 | 3 | import org.joml.Vector3fc; 4 | import org.jproperty.ObservableValue; 5 | 6 | public interface ReadonlyScale extends ObservableValue { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/transform/ReadonlyTransform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.maths.transform 2 | 3 | import org.joml.Matrix4fc 4 | 5 | interface ReadonlyTransform { 6 | val transformationMatrix: Matrix4fc 7 | val position: ReadonlyPosition 8 | val rotation: ReadonlyRotation 9 | val scale: ReadonlyScale 10 | } -------------------------------------------------------------------------------- /pe-math/src/main/java/org/saar/maths/transform/Transform.kt: -------------------------------------------------------------------------------- 1 | package org.saar.maths.transform 2 | 3 | import org.joml.Matrix4fc 4 | import org.saar.maths.utils.Vector3 5 | 6 | interface Transform : ReadonlyTransform { 7 | override val transformationMatrix: Matrix4fc 8 | override val position: Position 9 | override val rotation: Rotation 10 | override val scale: Scale 11 | } 12 | 13 | 14 | fun Transform.lookAt(position: ReadonlyPosition) { 15 | val direction = Vector3.sub(position.value, this.position.value) 16 | this.rotation.lookAlong(direction) 17 | } -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/barrel/barrel.diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/barrel/barrel.diffuse.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/barrel/barrel.normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/barrel/barrel.normal.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/boulder/boulder.diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/boulder/boulder.diffuse.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/boulder/boulder.normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/boulder/boulder.normal.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/bunny/bunny.normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/bunny/bunny.normal.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/cottage/cottage_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/cottage/cottage_diffuse.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/cottage/cottage_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/cottage/cottage_normal.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/crate/crate.diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/crate/crate.diffuse.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/crate/crate.normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/crate/crate.normal.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/particles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/particles.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/skybox/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/skybox/back.jpg -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/skybox/bottom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/skybox/bottom.jpg -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/skybox/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/skybox/front.jpg -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/skybox/left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/skybox/left.jpg -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/skybox/right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/skybox/right.jpg -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/skybox/top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/skybox/top.jpg -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/stall/stall.diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/stall/stall.diffuse.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/assets/tree/tree.diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Saar25/PlanetEngine/015bd8c61db2a0f08d4144ad60a49e6e9b8d3f90/planet-examples/src/main/resources/assets/tree/tree.diffuse.png -------------------------------------------------------------------------------- /planet-examples/src/main/resources/fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 400 2 | 3 | // Vertex outputs 4 | in vec2 v_position; 5 | in vec3 v_colour; 6 | 7 | // Fragment outputs 8 | layout (location = 0) out vec4 f_colour; 9 | 10 | void main(void) { 11 | f_colour = vec4(v_colour, 1.0); 12 | } 13 | -------------------------------------------------------------------------------- /planet-examples/src/main/resources/simple.fragment.glsl: -------------------------------------------------------------------------------- 1 | // Vertex outputs 2 | in vec2 v_position; 3 | in vec3 v_colour; 4 | 5 | // Fragment outputs 6 | layout (location = 0) out vec4 f_colour; 7 | 8 | void main(void) { 9 | f_colour = vec4(v_colour, 1.0); 10 | } 11 | -------------------------------------------------------------------------------- /planet-examples/src/main/resources/simple.vertex.glsl: -------------------------------------------------------------------------------- 1 | // Per Vertex attibutes 2 | layout (location = 0) in vec2 in_position; 3 | layout (location = 1) in vec3 in_colour; 4 | 5 | // Vertex outputs 6 | out vec2 v_position; 7 | out vec3 v_colour; 8 | 9 | void main(void) { 10 | v_position = in_position; 11 | v_colour = in_colour; 12 | 13 | gl_Position = vec4(in_position, 0.0, 1.0); 14 | } 15 | -------------------------------------------------------------------------------- /planet-examples/src/main/resources/vertex.glsl: -------------------------------------------------------------------------------- 1 | #version 400 2 | 3 | // Per Vertex attibutes 4 | layout (location = 0) in vec2 in_position; 5 | layout (location = 1) in vec3 in_colour; 6 | layout (location = 2) in float in_offset; 7 | 8 | // Vertex outputs 9 | out vec2 v_position; 10 | out vec3 v_colour; 11 | 12 | void main(void) { 13 | v_position = in_position; 14 | v_colour = in_colour + in_offset; 15 | 16 | gl_Position = vec4(in_position + in_offset, 0.0, 1.0); 17 | } 18 | --------------------------------------------------------------------------------