├── .github
└── ISSUE_TEMPLATE
│ ├── pull_request_template.md
│ ├── pull_request_template.yml
│ └── test-issue-template.md
├── .gitignore
├── .idea
├── .idea.BlockGame.dir
│ └── .idea
│ │ ├── .gitignore
│ │ ├── discord.xml
│ │ ├── indexLayout.xml
│ │ └── vcs.xml
└── .idea.BlockGame
│ └── .idea
│ ├── codeStyles
│ └── codeStyleConfig.xml
│ ├── discord.xml
│ ├── encodings.xml
│ ├── indexLayout.xml
│ ├── projectSettingsUpdater.xml
│ └── vcs.xml
├── .run
└── BlockGame.run.xml
├── BlockGame.csproj
├── BlockGame.csproj.DotSettings
├── BlockGame.sln
├── BlockGame.slnx
├── BlockGameTesting
├── BlockGameTesting.csproj
├── InterpBenchmark.cs
├── WorldgenTesting.cs
└── highNoise.png
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── GUIDE.MD
├── LICENSE
├── README.MD
├── SECURITY.md
├── assets
└── splashes.txt
├── cover1.png
├── cover2.png
├── fonts
├── 6x13.bdf
├── 8x13.bdf
├── Px437_IBM_BIOS-2y.ttf
└── unifont-15.1.04.ttf
├── global.json
├── lib
├── FastNoiseLite.cs
├── FontStashSharp.Base
│ ├── FontStashSharp.Base.csproj
│ └── IFontLoader.cs
├── FontStashSharp.Rasterizers.FreeType
│ ├── FontStashSharp.Rasterizers.FreeType.csproj
│ ├── FreeTypeLoader.cs
│ └── FreeTypeSource.cs
├── FontStashSharp.Rasterizers.SixLabors.Fonts
│ ├── ColorGlyphRenderer.cs
│ ├── FontGlyphSource.cs
│ ├── FontStashSharp.Rasterizers.SixLabors.Fonts.csproj
│ ├── GlyphPath.cs
│ ├── SixLaborsFontLoader.cs
│ └── SixLaborsFontSource.cs
├── FontStashSharp.Rasterizers.StbTrueTypeSharp
│ ├── FontStashSharp.Rasterizers.StbTrueTypeSharp.csproj
│ ├── Int32Map.cs
│ ├── StbTrueTypeSharpLoader.cs
│ ├── StbTrueTypeSharpSettings.cs
│ └── StbTrueTypeSharpSource.cs
├── FontStashSharp
│ ├── Bounds.cs
│ ├── DynamicSpriteFont.cs
│ ├── FSColor.cs
│ ├── FontAtlas.cs
│ ├── FontAtlasNode.cs
│ ├── FontGlyph.cs
│ ├── FontMetrics.cs
│ ├── FontStashSharp.csproj
│ ├── FontSystem.cs
│ ├── FontSystemDefaults.cs
│ ├── FontSystemSettings.cs
│ ├── Glyph.cs
│ ├── GlyphRenderers.cs
│ ├── Int32Map.cs
│ ├── Interfaces
│ │ ├── IFontStashRenderer.cs
│ │ ├── IFontStashRenderer2.cs
│ │ └── ITexture2DManager.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── RichText
│ │ ├── AutoEllipsisMethod.cs
│ │ ├── BaseChunk.cs
│ │ ├── ChunkInfo.cs
│ │ ├── ColorStorage.cs
│ │ ├── FSRenderContext.cs
│ │ ├── IRenderable.cs
│ │ ├── ImageChunk.cs
│ │ ├── LayoutBuilder.cs
│ │ ├── RichTextDefaults.cs
│ │ ├── RichTextLayout.cs
│ │ ├── RichTextSettings.cs
│ │ ├── SpaceChunk.cs
│ │ ├── TextChunk.cs
│ │ ├── TextChunkGlyph.cs
│ │ ├── TextHorizontalAlignment.cs
│ │ ├── TextLine.cs
│ │ └── TextureFragment.cs
│ ├── SpriteFontBase.IFontStashRenderer.cs
│ ├── SpriteFontBase.IFontStashRenderer2.cs
│ ├── SpriteFontBase.cs
│ ├── StaticSpriteFont.cs
│ ├── StringSegment.cs
│ ├── TextColorSource.cs
│ ├── TextSource.cs
│ ├── TextStyle.cs
│ └── Utility.cs
├── Silk.NET.Input.Common
│ ├── Enums
│ │ ├── ButtonName.cs
│ │ ├── CursorMode.cs
│ │ ├── CursorType.cs
│ │ ├── DeadzoneMethod.cs
│ │ ├── Key.cs
│ │ ├── MouseButton.cs
│ │ ├── Position2D.cs
│ │ └── StandardCursor.cs
│ ├── GamepadExtensions.cs
│ ├── InputPlatformAttribute.cs
│ ├── InputWindowExtensions.cs
│ ├── Interfaces
│ │ ├── ICursor.cs
│ │ ├── IGamepad.cs
│ │ ├── IInputContext.cs
│ │ ├── IInputDevice.cs
│ │ ├── IInputPlatform.cs
│ │ ├── IJoystick.cs
│ │ ├── IKeyboard.cs
│ │ ├── IMotor.cs
│ │ └── IMouse.cs
│ ├── Internals
│ │ ├── CastReadOnlyList.cs
│ │ ├── InputContextImplementationBase.cs
│ │ ├── IsConnectedEnumerator.cs
│ │ ├── IsConnectedWrapper.cs
│ │ ├── MouseImplementationBase.cs
│ │ └── ReadOnlyCollectionListAdapter.cs
│ ├── PublicAPI
│ │ ├── net5.0
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ ├── netcoreapp3.1
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ ├── netstandard2.0
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ └── netstandard2.1
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ ├── Silk.NET.Input.Common.csproj
│ ├── Silk.NET.Input.Common.csproj.DotSettings
│ └── Structs
│ │ ├── Axis.cs
│ │ ├── Button.cs
│ │ ├── Deadzone.cs
│ │ ├── Hat.cs
│ │ ├── ScrollWheel.cs
│ │ ├── Thumbstick.cs
│ │ └── Trigger.cs
├── Silk.NET.Input.Extensions
│ ├── CaptureExtensions.cs
│ ├── GamepadState.cs
│ ├── InputSnapshot.cs
│ ├── JoystickState.cs
│ ├── KeyboardState.cs
│ ├── MouseState.cs
│ ├── PublicAPI
│ │ ├── net5.0
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ ├── netcoreapp3.1
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ ├── netstandard2.0
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ └── netstandard2.1
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ └── Silk.NET.Input.Extensions.csproj
├── Silk.NET.Input.Glfw
│ ├── GlfwCursor.cs
│ ├── GlfwEvents.cs
│ ├── GlfwGamepad.cs
│ ├── GlfwInput.cs
│ ├── GlfwInputContext.cs
│ ├── GlfwInputPlatform.cs
│ ├── GlfwJoystick.cs
│ ├── GlfwKeyboard.cs
│ ├── GlfwMouse.cs
│ ├── IGlfwSubscriber.cs
│ ├── PublicAPI
│ │ ├── net5.0
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ ├── netcoreapp3.1
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ ├── netstandard2.0
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ │ └── netstandard2.1
│ │ │ ├── PublicAPI.Shipped.txt
│ │ │ └── PublicAPI.Unshipped.txt
│ ├── Silk.NET.Input.Glfw.csproj
│ └── Silk.NET.Input.Glfw.csproj.DotSettings
├── Silk.NET.Input
│ └── Silk.NET.Input.csproj
├── TrippyGL.Fonts.Building
│ ├── ColorGlyphRenderer.cs
│ ├── FontBuilderExtensions.cs
│ ├── FontGlyphSource.cs
│ └── TrippyGL.Fonts.Building.csproj
├── TrippyGL.Fonts.Extensions
│ ├── TextureFontDataExtensions.cs
│ ├── TextureFontExtensions.cs
│ ├── TrippyFontFileExtensions.cs
│ └── TrippyGL.Fonts.Extensions.csproj
├── TrippyGL.Fonts
│ ├── Exceptions.cs
│ ├── FontBuilder.cs
│ ├── IGlyphSource.cs
│ ├── Rectpack
│ │ ├── PackingHints.cs
│ │ ├── PackingRectangle.cs
│ │ └── RectanglePacker.cs
│ ├── TextureFontData.cs
│ ├── TrippyFontFile.cs
│ └── TrippyGL.Fonts.csproj
├── TrippyGL.ImageSharp
│ ├── FramebufferObjectExtensions.cs
│ ├── ImageUtils.cs
│ ├── Texture1DExtensions.cs
│ ├── Texture2DArrayExtensions.cs
│ ├── Texture2DExtensions.cs
│ ├── TextureCubemapExtensions.cs
│ └── TrippyGL.ImageSharp.csproj
├── TrippyGL
│ ├── ActiveVertexAttrib.cs
│ ├── BlendState.cs
│ ├── BufferObject.cs
│ ├── BufferObjectSubset.cs
│ ├── Color4b.cs
│ ├── DataBufferSubset.cs
│ ├── DepthState.cs
│ ├── DirectionalLight.cs
│ ├── Enums
│ │ ├── AttributeBaseType.cs
│ │ ├── AttributeType.cs
│ │ ├── BatcherBeginMode.cs
│ │ ├── BlendingFactor.cs
│ │ ├── BlendingMode.cs
│ │ ├── BlitFramebufferFilter.cs
│ │ ├── BufferTarget.cs
│ │ ├── BufferUsage.cs
│ │ ├── ClearBuffers.cs
│ │ ├── CubemapFace.cs
│ │ ├── CullingMode.cs
│ │ ├── DebugSeverity.cs
│ │ ├── DebugSource.cs
│ │ ├── DebugType.cs
│ │ ├── DepthFunction.cs
│ │ ├── DepthStencilFormat.cs
│ │ ├── ElementType.cs
│ │ ├── FramebufferAttachmentPoint.cs
│ │ ├── PolygonFace.cs
│ │ ├── PrimitiveType.cs
│ │ ├── ReadPixelsFormat.cs
│ │ ├── RenderbufferFormat.cs
│ │ ├── StencilFunction.cs
│ │ ├── StencilOperation.cs
│ │ ├── TextureImageFormat.cs
│ │ ├── TextureMagFilter.cs
│ │ ├── TextureMinFilter.cs
│ │ ├── TextureType.cs
│ │ ├── TextureWrapMode.cs
│ │ └── UniformType.cs
│ ├── Exceptions.cs
│ ├── Framebuffer2D.cs
│ ├── FramebufferAttachments.cs
│ ├── FramebufferObject.cs
│ ├── GeometryShaderData.cs
│ ├── GraphicsDevice.BindingStates.cs
│ ├── GraphicsDevice.DrawingStates.cs
│ ├── GraphicsDevice.cs
│ ├── GraphicsResource.cs
│ ├── IVertex.cs
│ ├── IndexBufferSubset.cs
│ ├── KerningTextureFont.cs
│ ├── MonospaceTextureFont.cs
│ ├── OBJLoader.cs
│ ├── PositionalLight.cs
│ ├── PrimitiveBatcher.cs
│ ├── RenderbufferObject.cs
│ ├── ShaderBlockUniform.cs
│ ├── ShaderBlockUniformList.cs
│ ├── ShaderProgram.cs
│ ├── ShaderProgramBuilder.cs
│ ├── ShaderUniform.cs
│ ├── ShaderUniformList.cs
│ ├── SimpleShaderProgram.cs
│ ├── SimpleShaderProgramBuilder.cs
│ ├── SpacedTextureFont.cs
│ ├── SpecifiedShaderAttrib.cs
│ ├── StencilState.cs
│ ├── Texture.cs
│ ├── Texture1D.cs
│ ├── Texture2D.cs
│ ├── Texture2DArray.cs
│ ├── TextureBatchItem.cs
│ ├── TextureBatcher.cs
│ ├── TextureCubemap.cs
│ ├── TextureFont.cs
│ ├── TextureMultisamplable.cs
│ ├── TrippyGL.csproj
│ ├── UniformBufferSubset.cs
│ ├── Utils
│ │ ├── TrippyMath.cs
│ │ └── TrippyUtils.cs
│ ├── VertexArray.cs
│ ├── VertexAttribDescription.cs
│ ├── VertexAttribSource.cs
│ ├── VertexBuffer.cs
│ ├── VertexColor.cs
│ ├── VertexColorTexture.cs
│ ├── VertexDataBufferSubset.cs
│ ├── VertexNormal.cs
│ ├── VertexNormalColor.cs
│ ├── VertexNormalColorTexture.cs
│ ├── VertexNormalTexture.cs
│ ├── VertexPosition.cs
│ ├── VertexTexture.cs
│ └── Viewport.cs
└── TrippyTests
│ ├── ComplexVertexFormats
│ ├── ComplexVertex.cs
│ ├── ComplexVertexFormats.cs
│ ├── ComplexVertexFormats.csproj
│ ├── Program.cs
│ ├── fs1.glsl
│ └── vs1.glsl
│ ├── GameOfLifeSim
│ ├── GameOfLifeSim.cs
│ ├── GameOfLifeSim.csproj
│ ├── Program.cs
│ ├── sim_fs.glsl
│ └── sim_vs.glsl
│ ├── IndexedRendering
│ ├── IndexedRendering.cs
│ ├── IndexedRendering.csproj
│ ├── Indices.cs
│ ├── Program.cs
│ ├── SimpleVertex.cs
│ ├── fs.glsl
│ ├── indices.png
│ └── vs.glsl
│ ├── InstancedCubes
│ ├── InstancedCubes.cs
│ ├── InstancedCubes.csproj
│ ├── Program.cs
│ ├── fs.glsl
│ └── vs.glsl
│ ├── ShaderFractals
│ ├── Program.cs
│ ├── ShaderFractals.cs
│ ├── ShaderFractals.csproj
│ ├── fs.glsl
│ └── vs.glsl
│ ├── SimpleCube
│ ├── Program.cs
│ ├── SimpleCube.cs
│ └── SimpleCube.csproj
│ ├── SimpleCubemap
│ ├── Program.cs
│ ├── SimpleCubemap.cs
│ ├── SimpleCubemap.csproj
│ ├── cubemap
│ │ ├── back.png
│ │ ├── bottom.png
│ │ ├── front.png
│ │ ├── left.png
│ │ ├── right.png
│ │ └── top.png
│ ├── fs.glsl
│ └── vs.glsl
│ ├── SimpleShader3D
│ ├── Program.cs
│ ├── SimpleShader3D.cs
│ ├── SimpleShader3D.csproj
│ ├── lamp_texture.png
│ ├── skyFs.glsl
│ └── skyVs.glsl
│ ├── SimpleTriangle
│ ├── Program.cs
│ ├── SimpleTriangle.cs
│ └── SimpleTriangle.csproj
│ ├── TextureBatcherTest
│ ├── Ball.cs
│ ├── Diamond.cs
│ ├── FontLoadHelper.cs
│ ├── Particle.cs
│ ├── Program.cs
│ ├── TextureBatcherTest.cs
│ ├── TextureBatcherTest.csproj
│ ├── ball.png
│ ├── diamond.png
│ ├── particles.png
│ └── rectangle.png
│ ├── TexturedTriangles
│ ├── Program.cs
│ ├── TexturedTriangle.cs
│ ├── TexturedTriangles.csproj
│ ├── satellite.png
│ └── texture.png
│ └── TrippyTestBase
│ ├── InputManager3D.cs
│ ├── TestBase.cs
│ └── TrippyTestBase.csproj
├── logo.png
├── logo_small.png
├── runtimes
└── linux-x64
│ └── native
│ └── libminiaudioex.so
├── shaders
├── batch.frag
├── batch.vert
├── dummyShader.frag
├── dummyShader.vert
├── fxaa.frag
├── fxaa.vert
├── inc
│ └── fog.inc
├── instantVertex.frag
├── instantVertex.vert
├── instantVertexColour.frag
├── instantVertexColour.vert
├── outline.frag
├── outline.vert
├── shader.frag
├── shader.vert
├── simpleBlock.frag
├── simpleBlock.vert
├── waterShader.frag
└── waterShader.vert
├── snd
├── hit
│ ├── wood1.wav
│ ├── wood2.wav
│ └── wood7.wav
├── steps
│ ├── grass_step1.wav
│ ├── grass_step2.wav
│ └── grass_step3.wav
├── stone1.wav
├── stone2.wav
├── stone3.wav
├── stone4.wav
├── stone5.wav
├── tallgrass_step1.wav
├── tests.flac
└── tests.ogg
├── src
├── GL
│ ├── BTexture2D.cs
│ ├── BTextureAtlas.cs
│ ├── BlockTintedVAO.cs
│ ├── BlockVAO.cs
│ ├── BlockVertexPacked.cs
│ ├── BlockVertexTinted.cs
│ ├── ExtremelySharedBlockVAO.cs
│ ├── FloatVAO.cs
│ ├── Graphics.cs
│ ├── InstantDraw.cs
│ ├── MatrixStack.cs
│ ├── Shader.cs
│ ├── SharedBlockVAO.cs
│ ├── SpriteBatch.cs
│ ├── SpriteBatchItem.cs
│ ├── StreamingVAO.cs
│ ├── VAO.cs
│ ├── VertexTinted.cs
│ └── vertexformats
│ │ ├── BVertexColorTexture.cs
│ │ └── Color4b.cs
├── id
│ └── Blocks.cs
├── main
│ ├── Game.cs
│ └── Program.cs
├── render
│ ├── Particle.cs
│ ├── ParticleManager.cs
│ ├── RenderBlock.cs
│ ├── WorldRenderer.SubChunk.cs
│ ├── WorldRenderer.cs
│ └── model
│ │ └── Cube.cs
├── snd
│ └── SoundEngine.cs
├── ui
│ ├── GUI.cs
│ ├── Screen.cs
│ ├── Settings.cs
│ ├── element
│ │ ├── Button.cs
│ │ ├── GUIElement.cs
│ │ ├── Hotbar.cs
│ │ ├── Image.cs
│ │ ├── LevelSelectButton.cs
│ │ ├── Slider.cs
│ │ ├── Text.cs
│ │ ├── TextBox.cs
│ │ └── ToggleButton.cs
│ ├── menu
│ │ ├── ChatMenu.cs
│ │ ├── IngameMenu.cs
│ │ ├── InventoryMenu.cs
│ │ ├── LevelSelectMenu.cs
│ │ ├── LoadingMenu.cs
│ │ ├── MainMenu.cs
│ │ ├── Menu.cs
│ │ ├── PauseMenu.cs
│ │ └── SettingsMenu.cs
│ └── screen
│ │ ├── GameScreen.cs
│ │ └── MainMenuScreen.cs
├── util
│ ├── Block.cs
│ ├── BlockModel.cs
│ ├── ClientOnly.cs
│ ├── Constants.cs
│ ├── Debug.cs
│ ├── Extensions.cs
│ ├── FIFOStack.cs
│ ├── FixedArrayPool.cs
│ ├── ItemSlot.cs
│ ├── ItemStack.cs
│ ├── MemoryUtils.cs
│ ├── Metrics.cs
│ ├── ProgressUpdater.cs
│ ├── ServerOnly.cs
│ ├── TextureManager.cs
│ ├── TimerAction.cs
│ ├── Utils.cs
│ ├── XRandom.cs
│ ├── font
│ │ ├── BDFLoader.cs
│ │ ├── BDFSource.cs
│ │ ├── BdfChar.cs
│ │ ├── BdfFont.cs
│ │ ├── FontLoader.cs
│ │ ├── TextRenderer.cs
│ │ ├── TextRenderer3D.cs
│ │ └── Texture2DManager.cs
│ ├── math
│ │ ├── BoundingBox.cs
│ │ ├── BoundingFrustum.cs
│ │ ├── BoundingSphere.cs
│ │ ├── ContainmentType.cs
│ │ ├── OrientedBoundingBox.cs
│ │ ├── PlaneHelper.cs
│ │ ├── PlaneIntersectionType.cs
│ │ └── Ray.cs
│ └── xNBT
│ │ ├── NBT.cs
│ │ ├── NBTTag.cs
│ │ └── NBTTags.cs
└── world
│ ├── AABB.cs
│ ├── BlockUpdate.cs
│ ├── Entity.cs
│ ├── HeightMap.cs
│ ├── Humanoid.cs
│ ├── Inventory.cs
│ ├── LightNode.cs
│ ├── Player.cs
│ ├── PlayerCamera.cs
│ ├── PlayerRenderer.cs
│ ├── Raycast.cs
│ ├── Region.cs
│ ├── TickAction.cs
│ ├── World.Access.cs
│ ├── World.cs
│ ├── WorldIO.cs
│ ├── chunk
│ ├── ArrayBlockData.cs
│ ├── BlockData.cs
│ ├── Chunk.cs
│ ├── ChunkComparer.cs
│ ├── ChunkCoordComparer.cs
│ ├── ChunkLoadTicket.cs
│ ├── EmptyBlockData.cs
│ └── SubChunk.cs
│ └── worldgen
│ ├── WorldgenUtil.cs
│ ├── feature
│ ├── Cave.cs
│ ├── Feature.cs
│ ├── OreFeature.cs
│ ├── OverlayFeature.cs
│ └── Ravine.cs
│ └── generator
│ ├── OverworldWorldGenerator.Chunk.cs
│ ├── OverworldWorldGenerator.cs
│ ├── PerlinWorldGenerator.Chunk.cs
│ ├── PerlinWorldGenerator.Testing.cs
│ ├── PerlinWorldGenerator.cs
│ ├── SimpleWorldGenerator.Chunk.cs
│ ├── SimpleWorldGenerator.cs
│ ├── TechDemoChunkGenerator.cs
│ ├── TechDemoWorldGenerator.cs
│ └── WorldGenerator.cs
├── textures
├── bg.png
├── blocks.png
├── character.png
├── creative_inventory.png
├── debug.png
├── gui.png
├── inventory.png
├── lightmap.png
├── sun_01.png
├── sun_02.png
├── sun_03.png
├── title.png
└── water.png
├── todolist.txt
└── wglinfo64.exe
/.github/ISSUE_TEMPLATE/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: catchange
3 | about: Change an existing cat.
4 |
5 | ---
6 |
7 | # Cat Change Description
8 | This PR is to change an existing cat type.
9 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/pull_request_template.yml:
--------------------------------------------------------------------------------
1 | name: cats
2 | description: Adding cats!
3 | body:
4 | - type: checkboxes
5 | id: cat-preferences
6 | attributes:
7 | label: What kinds of cats do you like?
8 | description: You may select more than one.
9 | options:
10 | - label: Orange cat (required. Everyone likes orange cats.)
11 | required: true
12 | - label: Black cat
13 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/test-issue-template.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Test issue template
3 | about: This does something, right?
4 | title: "[TEST]"
5 | labels: ''
6 | assignees: Pannoniae
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/.idea.BlockGame.dir/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Rider ignored files
5 | /modules.xml
6 | /contentModel.xml
7 | /projectSettingsUpdater.xml
8 | /.idea.BlockGame.iml
9 | # Editor-based HTTP Client requests
10 | /httpRequests/
11 | # Datasource local storage ignored files
12 | /dataSources/
13 | /dataSources.local.xml
14 |
--------------------------------------------------------------------------------
/.idea/.idea.BlockGame.dir/.idea/discord.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/.idea.BlockGame.dir/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/.idea.BlockGame.dir/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/.idea.BlockGame/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/.idea.BlockGame/.idea/discord.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/.idea.BlockGame/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/.idea.BlockGame/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | shaders
7 |
8 |
9 | fonts
10 | lib
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/.idea.BlockGame/.idea/projectSettingsUpdater.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/.idea.BlockGame/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.run/BlockGame.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/BlockGame.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
3 | False
4 |
--------------------------------------------------------------------------------
/BlockGame.slnx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/BlockGameTesting/BlockGameTesting.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net10.0
5 | latest
6 | enable
7 | enable
8 | false
9 |
10 |
11 |
12 | true
13 |
14 |
15 |
16 |
17 |
18 | all
19 | runtime; build; native; contentfiles; analyzers; buildtransitive
20 |
21 |
22 |
23 |
24 | all
25 | runtime; build; native; contentfiles; analyzers; buildtransitive
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | true
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/BlockGameTesting/WorldgenTesting.cs:
--------------------------------------------------------------------------------
1 | using BlockGame;
2 | using SixLabors.ImageSharp;
3 | using SixLabors.ImageSharp.PixelFormats;
4 |
5 | namespace BlockGameTesting;
6 |
7 | public class WorldgenTesting {
8 |
9 | public PerlinWorldGenerator gen;
10 |
11 | [SetUp]
12 | public void Setup() {
13 | gen = new PerlinWorldGenerator(null!);
14 | gen.setup(1337);
15 | }
16 |
17 | [Test]
18 | public void GenHighNoise() {
19 | // generate an image from the highNoise
20 | var img = new Image(512, 512);
21 | for (int x = 0; x < img.Width; x++) {
22 | for (int y = 0; y < img.Height; y++) {
23 | var val = gen.getNoise3D(gen.highNoise, x / 20f, 0, y / 20f, 1, 2f);
24 | Console.Out.WriteLine(val);
25 | img[x, y] = new Rgba32(
26 | (byte) ((val + 1) * 127.5f),
27 | (byte) ((val + 1) * 127.5f),
28 | (byte) ((val + 1) * 127.5f),
29 | 255);
30 | }
31 | }
32 | img.Save(getPath("highNoise.png"));
33 |
34 | Assert.Pass();
35 | }
36 |
37 | // use the PROJECT folder not the build folder lol
38 | private string getPath(string path) {
39 | var projectDir = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", ".."));
40 | var fullPath = Path.Combine(projectDir, path);
41 | return fullPath;
42 | }
43 | }
--------------------------------------------------------------------------------
/BlockGameTesting/highNoise.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/BlockGameTesting/highNoise.png
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | GitHub keeps nagging me to add one so here is an empty placeholder!
2 | Also don't be a jerk :P
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | The CLA will be set up when someone wants to contribute. Reach out to get started!:P
2 |
--------------------------------------------------------------------------------
/GUIDE.MD:
--------------------------------------------------------------------------------
1 | # Guide to the code/concepts
2 |
3 | ## Terminology
4 | (note, half of this is wrong in the code rn, this is more like an aspiration lol)
5 |
6 | - **World**: A world folder with multiple dimensions.
7 | - **Dimension**: A 3D world with blocks, entities, etc.
8 | - **Chunk**: A 2D chunk, 16x16x128 blocks.
9 | - **SubChunk**: A 3D chunk, 16x16x16 blocks.
10 | - **Block**: A single block in the world.
11 | - **Entity**: A single entity in the world.
12 | - **ChunkCoord**: A 2D coordinate for a chunk, with x, z coordinates.
13 | - **SubChunkCoord**: A 3D coordinate for a subchunk, with x, y, z coordinates.
14 |
15 |
16 | ## Code style/guidelines/conventions
17 |
18 | - If possible, don't refer back to stuff! It creates a mess. For example, if you have a `Slot`, don't create an `Inventory` field for it.
19 | Or if you have an `Entity`, don't create a `World` field for it. Methods which require *both* should live in the parent. (e.g. in `World`).
20 |
21 | This avoids a huge spaghetti mess of references.
22 |
23 |
24 | ## Footguns/noobtraps
25 | - NEVER use the built-in `Random` class. Use `XRandom` instead. The no-arg constructor is good but you can't control the seed -
26 | the seeded constructor has backwards compatibility bullshit, so it's doggone slow.
27 | - NEVER use built-in hashcodes, especially in worldgen/where you want consistent results. IT IS LITERALLY RANDOM ON PURPOSE.
28 | Shitty-ass design. I'll cook something up later but for now, DIY homebrew a solution with XOR or something
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | TODO
2 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | Security....what security?
2 |
--------------------------------------------------------------------------------
/assets/splashes.txt:
--------------------------------------------------------------------------------
1 |
2 | Not enough memory to load the splash!
--------------------------------------------------------------------------------
/cover1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/cover1.png
--------------------------------------------------------------------------------
/cover2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/cover2.png
--------------------------------------------------------------------------------
/fonts/Px437_IBM_BIOS-2y.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/fonts/Px437_IBM_BIOS-2y.ttf
--------------------------------------------------------------------------------
/fonts/unifont-15.1.04.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/fonts/unifont-15.1.04.ttf
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "10.0.0",
4 | "rollForward": "latestMajor",
5 | "allowPrerelease": true
6 | }
7 | }
--------------------------------------------------------------------------------
/lib/FontStashSharp.Base/FontStashSharp.Base.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 |
5 |
6 | true
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/FontStashSharp.Base/IFontLoader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FontStashSharp.Interfaces
4 | {
5 | public interface IFontSource: IDisposable
6 | {
7 | ///
8 | /// Returns font metrics for the specified font size
9 | ///
10 | ///
11 | ///
12 | ///
13 | ///
14 | void GetMetricsForSize(float fontSize, out int ascent, out int descent, out int lineHeight);
15 |
16 | ///
17 | /// Returns Id of a glyph corresponding to a codepoint
18 | /// Null if the codepoint can't be rasterized
19 | ///
20 | ///
21 | ///
22 | int? GetGlyphId(int codepoint);
23 |
24 | ///
25 | /// Returns glyph metrics
26 | ///
27 | ///
28 | ///
29 | ///
30 | ///
31 | ///
32 | ///
33 | ///
34 | void GetGlyphMetrics(int glyphId, float fontSize, out int advance, out int x0, out int y0, out int x1, out int y1);
35 |
36 | ///
37 | /// Renders a glyph
38 | ///
39 | ///
40 | ///
41 | ///
42 | ///
43 | ///
44 | ///
45 | void RasterizeGlyphBitmap(int glyphId, float fontSize, byte[] buffer, int startIndex, int outWidth, int outHeight, int outStride);
46 |
47 | ///
48 | /// Returns kerning
49 | ///
50 | ///
51 | ///
52 | ///
53 | ///
54 | int GetGlyphKernAdvance(int previousGlyphId, int glyphId, float fontSize);
55 | }
56 |
57 | ///
58 | /// Font Rasterization Service
59 | ///
60 | public interface IFontLoader
61 | {
62 | IFontSource Load(byte[] data);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/lib/FontStashSharp.Rasterizers.FreeType/FontStashSharp.Rasterizers.FreeType.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 | net8.0
5 |
6 |
7 | true
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lib/FontStashSharp.Rasterizers.FreeType/FreeTypeLoader.cs:
--------------------------------------------------------------------------------
1 | using FontStashSharp.Interfaces;
2 |
3 | namespace FontStashSharp.Rasterizers.FreeType
4 | {
5 | public class FreeTypeLoader : IFontLoader
6 | {
7 | public IFontSource Load(byte[] data)
8 | {
9 | return new FreeTypeSource(data);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/lib/FontStashSharp.Rasterizers.SixLabors.Fonts/FontStashSharp.Rasterizers.SixLabors.Fonts.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 |
5 |
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/lib/FontStashSharp.Rasterizers.SixLabors.Fonts/GlyphPath.cs:
--------------------------------------------------------------------------------
1 | using SixLabors.ImageSharp;
2 | using SixLabors.ImageSharp.Drawing;
3 |
4 | namespace FontStashSharp.Samples.SixLabors
5 | {
6 | internal class GlyphPath
7 | {
8 | public float Size;
9 | public int Codepoint;
10 | public Rectangle Bounds;
11 | public IPathCollection Paths;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/lib/FontStashSharp.Rasterizers.SixLabors.Fonts/SixLaborsFontLoader.cs:
--------------------------------------------------------------------------------
1 | using FontStashSharp.Interfaces;
2 |
3 | namespace FontStashSharp.Rasterizers.SixLabors.Fonts
4 | {
5 | public class SixLaborsFontLoader: IFontLoader
6 | {
7 | public IFontSource Load(byte[] data)
8 | {
9 | return new SixLaborsFontSource(data);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/lib/FontStashSharp.Rasterizers.StbTrueTypeSharp/FontStashSharp.Rasterizers.StbTrueTypeSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 | net8.0
5 |
6 |
7 | true
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lib/FontStashSharp.Rasterizers.StbTrueTypeSharp/StbTrueTypeSharpLoader.cs:
--------------------------------------------------------------------------------
1 | using FontStashSharp.Interfaces;
2 |
3 | namespace FontStashSharp.Rasterizers.StbTrueTypeSharp
4 | {
5 | public class StbTrueTypeSharpLoader : IFontLoader
6 | {
7 | private readonly StbTrueTypeSharpSettings _settings;
8 |
9 | public StbTrueTypeSharpLoader(StbTrueTypeSharpSettings settings)
10 | {
11 | _settings = settings;
12 | }
13 |
14 | public IFontSource Load(byte[] data)
15 | {
16 | return new StbTrueTypeSharpSource(data, _settings);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lib/FontStashSharp.Rasterizers.StbTrueTypeSharp/StbTrueTypeSharpSettings.cs:
--------------------------------------------------------------------------------
1 | namespace FontStashSharp.Rasterizers.StbTrueTypeSharp
2 | {
3 | public struct StbTrueTypeSharpSettings
4 | {
5 | public int KernelWidth;
6 | public int KernelHeight;
7 | public bool UseOldRasterizer;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/Bounds.cs:
--------------------------------------------------------------------------------
1 | #if MONOGAME || FNA
2 | using Microsoft.Xna.Framework;
3 | #elif STRIDE
4 | using Stride.Core.Mathematics;
5 | #else
6 | using System.Numerics;
7 | #endif
8 |
9 | namespace FontStashSharp
10 | {
11 | public struct Bounds
12 | {
13 | public static readonly Bounds Empty = new Bounds
14 | {
15 | X = 0,
16 | Y = 0,
17 | X2 = 0,
18 | Y2 = 0,
19 | };
20 |
21 | public float X, Y, X2, Y2;
22 |
23 | public Bounds(float x, float y, float x2, float y2)
24 | {
25 | X = x;
26 | Y = y;
27 | X2 = x2;
28 | Y2 = y2;
29 | }
30 |
31 | public void ApplyScale(Vector2 scale)
32 | {
33 | X *= scale.X;
34 | Y *= scale.Y;
35 | X2 *= scale.X;
36 | Y2 *= scale.Y;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/FontAtlasNode.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace FontStashSharp
4 | {
5 | [StructLayout(LayoutKind.Sequential)]
6 | internal struct FontAtlasNode
7 | {
8 | public int X;
9 | public int Y;
10 | public int Width;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/FontGlyph.cs:
--------------------------------------------------------------------------------
1 | #if MONOGAME || FNA
2 | using Microsoft.Xna.Framework;
3 | using Microsoft.Xna.Framework.Graphics;
4 | #elif STRIDE
5 | using Stride.Core.Mathematics;
6 | using Texture2D = Stride.Graphics.Texture;
7 | #else
8 | using System.Drawing;
9 | using Texture2D = System.Object;
10 | #endif
11 |
12 | namespace FontStashSharp
13 | {
14 | public class FontGlyph
15 | {
16 | public int Codepoint;
17 | public int Id;
18 | public int XAdvance;
19 | public Texture2D Texture;
20 | public Point RenderOffset;
21 | public Point TextureOffset;
22 | public Point Size;
23 |
24 | public bool IsEmpty
25 | {
26 | get
27 | {
28 | return Size.X == 0 || Size.Y == 0;
29 | }
30 | }
31 |
32 | public Rectangle TextureRectangle => new Rectangle(TextureOffset.X, TextureOffset.Y, Size.X, Size.Y);
33 | public Rectangle RenderRectangle => new Rectangle(RenderOffset.X, RenderOffset.Y, Size.X, Size.Y);
34 | }
35 |
36 | public class DynamicFontGlyph : FontGlyph
37 | {
38 | public float FontSize;
39 | public int FontSourceIndex;
40 | public FontSystemEffect Effect;
41 | public int EffectAmount;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/FontMetrics.cs:
--------------------------------------------------------------------------------
1 | namespace FontStashSharp
2 | {
3 | internal struct FontMetrics
4 | {
5 | public int Ascent { get; private set; }
6 | public int Descent { get; private set; }
7 | public int LineHeight { get; private set; }
8 |
9 | public FontMetrics(int ascent, int descent, int lineHeight)
10 | {
11 | Ascent = ascent;
12 | Descent = descent;
13 | LineHeight = lineHeight;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/lib/FontStashSharp/FontStashSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | FontStashSharp
5 | FontStashSharp
6 | Platform-Agnostic Version of FontStashSharp
7 | $(DefineConstants);PLATFORM_AGNOSTIC
8 |
9 |
10 | true
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/Glyph.cs:
--------------------------------------------------------------------------------
1 | #if MONOGAME || FNA
2 | using Microsoft.Xna.Framework;
3 | #elif STRIDE
4 | using Stride.Core.Mathematics;
5 | #else
6 | using System.Drawing;
7 | #endif
8 |
9 | namespace FontStashSharp
10 | {
11 | public struct Glyph
12 | {
13 | public int Index;
14 | public int Codepoint;
15 | public Rectangle Bounds;
16 | public int XAdvance;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/Interfaces/IFontStashRenderer.cs:
--------------------------------------------------------------------------------
1 | #if MONOGAME || FNA
2 | using Microsoft.Xna.Framework;
3 | using Microsoft.Xna.Framework.Graphics;
4 | #elif STRIDE
5 | using Stride.Core.Mathematics;
6 | using Stride.Graphics;
7 | using Texture2D = Stride.Graphics.Texture;
8 | #else
9 | using System.Drawing;
10 | using System.Numerics;
11 | using Color = FontStashSharp.FSColor;
12 | using Texture2D = System.Object;
13 | #endif
14 |
15 | namespace FontStashSharp.Interfaces
16 | {
17 | public interface IFontStashRenderer
18 | {
19 | #if MONOGAME || FNA || STRIDE
20 | GraphicsDevice GraphicsDevice { get; }
21 | #else
22 | ITexture2DManager TextureManager { get; }
23 | #endif
24 |
25 | void Draw(Texture2D texture, Vector2 pos, ref Matrix4x4 worldMatrix, Rectangle? src, Color color, float rotation, Vector2 scale, float depth);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/Interfaces/IFontStashRenderer2.cs:
--------------------------------------------------------------------------------
1 | #if MONOGAME || FNA
2 | using Microsoft.Xna.Framework.Graphics;
3 | #elif STRIDE
4 | using Stride.Core.Mathematics;
5 | using Stride.Graphics;
6 | using Texture2D = Stride.Graphics.Texture;
7 | #else
8 | using System.Numerics;
9 | using Texture2D = System.Object;
10 | using System.Runtime.InteropServices;
11 | #endif
12 |
13 | namespace FontStashSharp.Interfaces
14 | {
15 | #if PLATFORM_AGNOSTIC
16 | [StructLayout(LayoutKind.Sequential, Pack = 1)]
17 | public struct VertexPositionColorTexture
18 | {
19 | ///
20 | /// Position
21 | ///
22 | public Vector3 Position;
23 |
24 | ///
25 | /// Color
26 | ///
27 | public FSColor Color;
28 |
29 | ///
30 | /// Texture Coordinate
31 | ///
32 | public Vector2 TextureCoordinate;
33 | }
34 | #endif
35 |
36 | public interface IFontStashRenderer2
37 | {
38 | #if MONOGAME || FNA || STRIDE
39 | GraphicsDevice GraphicsDevice { get; }
40 | #else
41 | ITexture2DManager TextureManager { get; }
42 | #endif
43 |
44 | void DrawQuad(Texture2D texture, ref VertexPositionColorTexture topLeft, ref VertexPositionColorTexture topRight, ref VertexPositionColorTexture bottomLeft, ref VertexPositionColorTexture bottomRight);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/Interfaces/ITexture2DManager.cs:
--------------------------------------------------------------------------------
1 | #if PLATFORM_AGNOSTIC
2 |
3 | using System.Drawing;
4 |
5 | namespace FontStashSharp.Interfaces
6 | {
7 | ///
8 | /// Texture Creation Service
9 | ///
10 | public interface ITexture2DManager
11 | {
12 | ///
13 | /// Creates a texture of the specified size
14 | ///
15 | ///
16 | ///
17 | ///
18 | object CreateTexture(int width, int height);
19 |
20 | ///
21 | /// Returns size of the specified texture
22 | ///
23 | ///
24 | ///
25 | Point GetTextureSize(object texture);
26 |
27 | ///
28 | /// Sets RGBA data at the specified bounds
29 | ///
30 | ///
31 | ///
32 | void SetTextureData(object texture, Rectangle bounds, byte[] data);
33 | }
34 | }
35 |
36 | #endif
--------------------------------------------------------------------------------
/lib/FontStashSharp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | [assembly: InternalsVisibleTo("FontStashSharp.Tests")]
4 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/AutoEllipsisMethod.cs:
--------------------------------------------------------------------------------
1 | namespace FontStashSharp.RichText
2 | {
3 | public enum AutoEllipsisMethod
4 | {
5 | ///
6 | /// Autoellipsis is disabled.
7 | ///
8 | None,
9 |
10 | ///
11 | /// The text can be cut at any character.
12 | ///
13 | Character,
14 |
15 | ///
16 | /// The text will be cut at spaces.
17 | ///
18 | Word
19 | }
20 | }
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/BaseChunk.cs:
--------------------------------------------------------------------------------
1 | #if MONOGAME || FNA
2 | using Microsoft.Xna.Framework;
3 | #elif STRIDE
4 | using Stride.Core.Mathematics;
5 | #else
6 | using System.Drawing;
7 | using Color = FontStashSharp.FSColor;
8 | using System.Numerics;
9 | #endif
10 |
11 | namespace FontStashSharp.RichText
12 | {
13 | public abstract class BaseChunk
14 | {
15 | public abstract Point Size { get; }
16 |
17 | public int LineIndex { get; internal set; }
18 | public int ChunkIndex { get; internal set; }
19 | public int VerticalOffset { get; internal set; }
20 | public Color? Color { get; set; }
21 |
22 | protected BaseChunk()
23 | {
24 | }
25 |
26 | public abstract void Draw(FSRenderContext context, Vector2 position, Color color);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/ChunkInfo.cs:
--------------------------------------------------------------------------------
1 | #if MONOGAME || FNA
2 | using Microsoft.Xna.Framework;
3 | using Microsoft.Xna.Framework.Graphics;
4 | #elif STRIDE
5 | using Stride.Core.Mathematics;
6 | #else
7 | using System.Drawing;
8 | #endif
9 |
10 | namespace FontStashSharp.RichText
11 | {
12 | internal enum ChunkInfoType
13 | {
14 | Text,
15 | Space,
16 | Image
17 | }
18 |
19 | internal struct ChunkInfo
20 | {
21 | public ChunkInfoType Type;
22 | public int X;
23 | public int Y;
24 | public bool LineEnd;
25 | public int StartIndex, EndIndex;
26 | public IRenderable Renderable;
27 |
28 | public int Width
29 | {
30 | get
31 | {
32 | if (Type == ChunkInfoType.Image)
33 | {
34 | return Renderable.Size.X;
35 | }
36 |
37 | return X;
38 | }
39 | }
40 |
41 | public int Height
42 | {
43 | get
44 | {
45 | if (Type == ChunkInfoType.Image)
46 | {
47 | return Renderable.Size.Y;
48 | }
49 |
50 | return Y;
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/IRenderable.cs:
--------------------------------------------------------------------------------
1 | using FontStashSharp.Interfaces;
2 |
3 | #if MONOGAME || FNA
4 | using Microsoft.Xna.Framework;
5 | #elif STRIDE
6 | using Stride.Core.Mathematics;
7 | #else
8 | using System.Drawing;
9 | using System.Numerics;
10 | using Color = FontStashSharp.FSColor;
11 | #endif
12 |
13 | namespace FontStashSharp.RichText
14 | {
15 | public interface IRenderable
16 | {
17 | Point Size { get; }
18 |
19 | void Draw(FSRenderContext context, Vector2 position, Color color);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/ImageChunk.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | #if MONOGAME || FNA
4 | using Microsoft.Xna.Framework;
5 | #elif STRIDE
6 | using Stride.Core.Mathematics;
7 | #else
8 | using System.Drawing;
9 | using System.Numerics;
10 | using Color = FontStashSharp.FSColor;
11 | #endif
12 |
13 | namespace FontStashSharp.RichText
14 | {
15 | public class ImageChunk : BaseChunk
16 | {
17 | private readonly IRenderable _renderable;
18 |
19 | public override Point Size => _renderable.Size;
20 |
21 | public ImageChunk(IRenderable renderable)
22 | {
23 | if (renderable == null)
24 | {
25 | throw new ArgumentNullException(nameof(renderable));
26 | }
27 |
28 | _renderable = renderable;
29 | }
30 |
31 | public override void Draw(FSRenderContext context, Vector2 position, Color color)
32 | {
33 | _renderable.Draw(context, position, color);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/RichTextDefaults.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FontStashSharp.RichText
4 | {
5 | public static class RichTextDefaults
6 | {
7 | public static Func FontResolver { get; set; }
8 | public static Func ImageResolver { get; set; }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/RichTextSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FontStashSharp.RichText
4 | {
5 | public class RichTextSettings
6 | {
7 | public Func FontResolver { get; set; }
8 | public Func ImageResolver { get; set; }
9 |
10 | public RichTextSettings()
11 | {
12 | FontResolver = RichTextDefaults.FontResolver;
13 | ImageResolver = RichTextDefaults.ImageResolver;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/SpaceChunk.cs:
--------------------------------------------------------------------------------
1 | #if MONOGAME || FNA
2 | using Microsoft.Xna.Framework;
3 | #elif STRIDE
4 | using Stride.Core.Mathematics;
5 | #else
6 | using System.Drawing;
7 | using System.Numerics;
8 | using Color = FontStashSharp.FSColor;
9 | #endif
10 |
11 | namespace FontStashSharp.RichText
12 | {
13 | public class SpaceChunk : BaseChunk
14 | {
15 | private readonly int _width;
16 |
17 | public override Point Size => new Point(_width, 0);
18 |
19 | public SpaceChunk(int width)
20 | {
21 | _width = width;
22 | }
23 |
24 | public override void Draw(FSRenderContext context, Vector2 position, Color color)
25 | {
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/TextChunkGlyph.cs:
--------------------------------------------------------------------------------
1 | #if MONOGAME || FNA
2 | using Microsoft.Xna.Framework;
3 | #elif STRIDE
4 | using Stride.Core.Mathematics;
5 | #else
6 | using System.Drawing;
7 | #endif
8 |
9 | namespace FontStashSharp.RichText
10 | {
11 | public struct TextChunkGlyph
12 | {
13 | public int Index;
14 | public int Codepoint;
15 | public Rectangle Bounds;
16 | public int XAdvance;
17 | public int LineTop;
18 | public TextChunk TextChunk;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/TextHorizontalAlignment.cs:
--------------------------------------------------------------------------------
1 | namespace FontStashSharp.RichText
2 | {
3 | public enum TextHorizontalAlignment
4 | {
5 | Left,
6 | Center,
7 | Right
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/TextLine.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | #if MONOGAME || FNA
4 | using Microsoft.Xna.Framework;
5 | #elif STRIDE
6 | using Stride.Core.Mathematics;
7 | #else
8 | using System.Drawing;
9 | #endif
10 |
11 | namespace FontStashSharp.RichText
12 | {
13 | public class TextLine
14 | {
15 | public int Count { get; internal set; }
16 |
17 | public Point Size;
18 |
19 | public int LineIndex { get; internal set; }
20 |
21 | public int TextStartIndex { get; internal set; }
22 |
23 | public List Chunks { get; } = new List();
24 |
25 | public TextChunkGlyph? GetGlyphInfoByIndex(int index)
26 | {
27 | foreach (var chunk in Chunks)
28 | {
29 | var textChunk = chunk as TextChunk;
30 | if (textChunk == null) continue;
31 |
32 | if (index >= textChunk.Count)
33 | {
34 | index -= textChunk.Count;
35 | }
36 | else
37 | {
38 | return textChunk.GetGlyphInfoByIndex(index);
39 | }
40 | }
41 |
42 | return null;
43 | }
44 |
45 | public int? GetGlyphIndexByX(int startX)
46 | {
47 | if (Chunks.Count == 0)
48 | {
49 | return null;
50 | }
51 |
52 | var x = startX;
53 | for (var i = 0; i < Chunks.Count; ++i)
54 | {
55 | var chunk = (TextChunk)Chunks[i];
56 |
57 | if (x >= chunk.Size.X)
58 | {
59 | x -= chunk.Size.X;
60 | }
61 | else
62 | {
63 | if (chunk.Glyphs.Count > 0 && x < chunk.Glyphs[0].Bounds.X)
64 | {
65 | // Before first glyph
66 | return 0;
67 | }
68 |
69 | return chunk.GetGlyphIndexByX(x);
70 | }
71 | }
72 |
73 | // Use last chunk
74 | x = startX;
75 | return ((TextChunk)Chunks[Chunks.Count - 1]).GetGlyphIndexByX(startX);
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/lib/FontStashSharp/RichText/TextureFragment.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | #if MONOGAME || FNA
4 | using Microsoft.Xna.Framework;
5 | using Microsoft.Xna.Framework.Graphics;
6 | #elif STRIDE
7 | using Stride.Core.Mathematics;
8 | using Stride.Graphics;
9 | using Texture2D = Stride.Graphics.Texture;
10 | #else
11 | using System.Numerics;
12 | using System.Drawing;
13 | using Texture2D = System.Object;
14 | using Color = FontStashSharp.FSColor;
15 | #endif
16 |
17 | namespace FontStashSharp.RichText
18 | {
19 | public class TextureFragment : IRenderable
20 | {
21 | public Texture2D Texture { get; private set; }
22 | public Rectangle Region { get; private set; }
23 |
24 | public Point Size
25 | {
26 | get
27 | {
28 | return new Point((int)(Region.Width * Scale.X + 0.5f), (int)(Region.Height * Scale.Y + 0.5f));
29 | }
30 | }
31 |
32 | public Vector2 Scale = Vector2.One;
33 |
34 | public TextureFragment(Texture2D texture, Rectangle region)
35 | {
36 | if (texture == null)
37 | {
38 | throw new ArgumentNullException(nameof(texture));
39 | }
40 |
41 | Texture = texture;
42 | Region = region;
43 | }
44 |
45 | #if MONOGAME || FNA || STRIDE
46 | public TextureFragment(Texture2D texture) :
47 | this(texture, new Rectangle(0, 0, texture.Width, texture.Height))
48 | {
49 | }
50 | #endif
51 |
52 | public void Draw(FSRenderContext context, Vector2 position, Color color)
53 | {
54 | context.DrawImage(Texture, Region, position, Scale, Color.White);
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/lib/FontStashSharp/StringSegment.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FontStashSharp
4 | {
5 | public readonly ref struct StringSegment
6 | {
7 | public readonly string String;
8 | public readonly int Offset;
9 | public readonly int Length;
10 |
11 | public char this[int index] => String[Offset + index];
12 |
13 | public bool IsNullOrEmpty
14 | {
15 | get
16 | {
17 | if (String == null) return true;
18 |
19 | return Offset >= String.Length;
20 | }
21 | }
22 |
23 | public StringSegment(string value)
24 | {
25 | String = value;
26 | Offset = 0;
27 | Length = value != null ? value.Length : 0;
28 | }
29 |
30 | public StringSegment(string value, int offset)
31 | {
32 | String = value;
33 | Offset = offset;
34 | Length = value != null ? value.Length - offset : 0;
35 | }
36 |
37 | public StringSegment(string value, int offset, int length)
38 | {
39 | String = value;
40 | Offset = offset;
41 | Length = length;
42 | }
43 |
44 | public bool Equals(StringSegment b) => String == b.String && Offset == b.Offset && Length == b.Length;
45 |
46 | public override bool Equals(object obj) => throw new NotSupportedException();
47 |
48 | public override int GetHashCode() => IsNullOrEmpty ? 0 : String.GetHashCode() ^ Offset ^ Length;
49 |
50 | public override string ToString() => IsNullOrEmpty ? string.Empty : String.Substring(Offset, Length);
51 |
52 | public static bool operator ==(StringSegment a, StringSegment b) => a.Equals(b);
53 |
54 | public static bool operator !=(StringSegment a, StringSegment b) => !a.Equals(b);
55 | }
56 | }
--------------------------------------------------------------------------------
/lib/FontStashSharp/TextStyle.cs:
--------------------------------------------------------------------------------
1 | namespace FontStashSharp
2 | {
3 | public enum TextStyle
4 | {
5 | None,
6 | Underline,
7 | Strikethrough
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Enums/CursorMode.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Silk.NET.Input
5 | {
6 | ///
7 | /// Mode used by a cursor.
8 | ///
9 | ///
10 | /// Not every backend supports every cursor mode. Check availability with
11 | /// before changing the cursor mode.
12 | ///
13 | public enum CursorMode
14 | {
15 | ///
16 | /// Cursor is visible and has no restrictions on mobility.
17 | ///
18 | Normal,
19 |
20 | ///
21 | /// Cursor is invisible, and has no restrictions on mobility.
22 | ///
23 | Hidden,
24 |
25 | ///
26 | /// Cursor is invisible, and is restricted to the center of the screen.
27 | ///
28 | ///
29 | /// Only supported by GLFW, throws on SDL if used.
30 | ///
31 | Disabled,
32 |
33 | ///
34 | /// Cursor is invisible, and is restricted to the center of the screen. Mouse motion is not scaled.
35 | ///
36 | Raw
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Enums/CursorType.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Silk.NET.Input
5 | {
6 | ///
7 | /// Type used by a cursor.
8 | ///
9 | public enum CursorType
10 | {
11 | ///
12 | /// One of the standard cursors.
13 | ///
14 | Standard,
15 |
16 | ///
17 | /// A custom cursor provided as image data.
18 | ///
19 | Custom
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Enums/DeadzoneMethod.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Silk.NET.Input
5 | {
6 | ///
7 | /// Available methods to control the deadzone of a control stick.
8 | ///
9 | public enum DeadzoneMethod
10 | {
11 | ///
12 | /// The traditional deadzone method, where the reported value is directly proportional with the actual value until the actual value is within the deadzone - the reported value will be 0 in this case.
13 | ///
14 | ///
15 | ///
16 | /// y = x except where |x| is between 0 and d
17 | ///
18 | ///
19 | /// y is the output, x is the raw value, and d is the deadzone value.
20 | ///
21 | ///
22 | Traditional,
23 |
24 | ///
25 | /// A deadzone method where the reported value adapts to the range of the deadzone. If the value is within the deadzone, the reported value is 0.
26 | /// After exiting the deadzone, the reported value increases from 0 (when the actual value first exits the deadzone) to 1 (when the actual value is 1).
27 | ///
28 | ///
29 | ///
30 | /// y = (1 - d)x + (d * sgn(x))
31 | ///
32 | ///
33 | /// y is the output, x is the raw value, and d is the deadzone value.
34 | ///
35 | ///
36 | AdaptiveGradient
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Enums/Position2D.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System;
5 |
6 | namespace Silk.NET.Input
7 | {
8 | ///
9 | /// Represents the position of a joystick
10 | ///
11 | [Flags]
12 | public enum Position2D
13 | {
14 | ///
15 | /// The hat is centered.
16 | ///
17 | Centered = 0,
18 |
19 | ///
20 | /// The hat is pressed up.
21 | ///
22 | Up = 1,
23 |
24 | ///
25 | /// The hat is pressed down.
26 | ///
27 | Down = 2,
28 |
29 | ///
30 | /// The hat is pressed left.
31 | ///
32 | Left = 4,
33 |
34 | ///
35 | /// The hat is pressed right.
36 | ///
37 | Right = 8,
38 |
39 | ///
40 | /// The hat is pressed up and to the left.
41 | ///
42 | UpLeft = Up | Left,
43 |
44 | ///
45 | /// The hat is pressed up and to the right.
46 | ///
47 | UpRight = Up | Right,
48 |
49 | ///
50 | /// The hat is pressed down and to the left.
51 | ///
52 | DownLeft = Down | Left,
53 |
54 | ///
55 | /// The hat is pressed down and to the right.
56 | ///
57 | DownRight = Down | Right
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/InputPlatformAttribute.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System;
5 | using System.ComponentModel;
6 |
7 | namespace Silk.NET.Input
8 | {
9 | ///
10 | /// An assembly attribute which points the registrar to a type that implements
11 | ///
12 | [AttributeUsage(AttributeTargets.Assembly)]
13 | [EditorBrowsable(EditorBrowsableState.Never)]
14 | public class InputPlatformAttribute : Attribute
15 | {
16 | ///
17 | /// Creates a using the given type.
18 | ///
19 | /// The type.
20 | public InputPlatformAttribute(Type type)
21 | {
22 | Type = type;
23 | }
24 |
25 | ///
26 | /// The type.
27 | ///
28 | public Type Type { get; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Interfaces/IInputDevice.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Silk.NET.Input
5 | {
6 | ///
7 | /// Generic interface representing an input device.
8 | ///
9 | public interface IInputDevice
10 | {
11 | ///
12 | /// The name of this device, as reported by the hardware.
13 | ///
14 | string Name { get; }
15 |
16 | ///
17 | /// The index of this device.
18 | ///
19 | int Index { get; }
20 |
21 | ///
22 | /// Whether or not this device is currently connected.
23 | ///
24 | bool IsConnected { get; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Interfaces/IInputPlatform.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using Silk.NET.Windowing;
5 |
6 | namespace Silk.NET.Input
7 | {
8 | ///
9 | /// An interface representing an input platform.
10 | ///
11 | public interface IInputPlatform
12 | {
13 | ///
14 | /// If this platform is applicable to this window.
15 | ///
16 | /// The window to check.
17 | /// Whether or not this platform is applicable.
18 | ///
19 | /// Generally, each Input package will also have a matching Windowing package,
20 | /// and the Input package will reference the Windowing package. IsApplicable works
21 | /// by checking that the given window is an instance created by the Windowing
22 | /// package the Input package references. For example, GlfwInputPlatform will only
23 | /// be applicable for a GlfwWindow.
24 | ///
25 | bool IsApplicable(IView view);
26 |
27 | ///
28 | /// Get an input context for this view.
29 | ///
30 | /// The view to get a context for.
31 | /// The context.
32 | IInputContext CreateInput(IView view);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Interfaces/IMotor.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Silk.NET.Input
5 | {
6 | ///
7 | /// A rumble motor inside of a gamepad.
8 | ///
9 | public interface IMotor
10 | {
11 | ///
12 | /// The index of this vibration motor.
13 | ///
14 | int Index { get; }
15 |
16 | ///
17 | /// The motor's vibration intensity, between 0f and 1f.
18 | ///
19 | ///
20 | /// Some backends may truncate this value if variable intensity is not supported.
21 | ///
22 | float Speed { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Internals/CastReadOnlyList.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System.Collections;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 |
8 | namespace Silk.NET.Input.Internals
9 | {
10 | internal readonly struct CastReadOnlyList : IReadOnlyList
11 | {
12 | private readonly IReadOnlyList _original;
13 |
14 | public CastReadOnlyList(IReadOnlyList original)
15 | {
16 | _original = original;
17 | }
18 |
19 | public IEnumerator GetEnumerator() => _original.Cast().GetEnumerator();
20 |
21 | IEnumerator IEnumerable.GetEnumerator()
22 | {
23 | return GetEnumerator();
24 | }
25 |
26 | public int Count => _original.Count;
27 |
28 | public TTo this[int index]
29 | {
30 | get
31 | {
32 | var ret = (object?) _original[index];
33 | if (ret is null)
34 | {
35 | return default!;
36 | }
37 |
38 | return (TTo) ret;
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Internals/InputContextImplementationBase.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using Silk.NET.Windowing;
7 | using Silk.NET.Windowing.Internals;
8 |
9 | namespace Silk.NET.Input.Internals;
10 |
11 | internal abstract class InputContextImplementationBase : IInputContext
12 | {
13 | protected InputContextImplementationBase(IView window)
14 | {
15 | Window = window;
16 | if (window is ViewImplementationBase view)
17 | {
18 | view.ProcessEvents += ProcessEvents;
19 | }
20 | else
21 | {
22 | window.Update += Update;
23 | }
24 | }
25 |
26 | private void Update(double delta) => ProcessEvents();
27 |
28 | public void Dispose()
29 | {
30 | if (Window is ViewImplementationBase view)
31 | {
32 | view.ProcessEvents -= ProcessEvents;
33 | }
34 | else
35 | {
36 | Window.Update -= Update;
37 | }
38 | CoreDispose();
39 | }
40 |
41 | public abstract void CoreDispose();
42 | public abstract void ProcessEvents();
43 | public IView Window { get; }
44 | public abstract nint Handle { get; }
45 | public abstract IReadOnlyList Gamepads { get; }
46 | public abstract IReadOnlyList Joysticks { get; }
47 | public abstract IReadOnlyList Keyboards { get; }
48 | public abstract IReadOnlyList Mice { get; }
49 | public abstract IReadOnlyList OtherDevices { get; }
50 | public abstract event Action? ConnectionChanged;
51 | }
52 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Internals/IsConnectedEnumerator.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System.Collections;
5 | using System.Collections.Generic;
6 |
7 | namespace Silk.NET.Input.Internals
8 | {
9 | internal struct IsConnectedEnumerator : IEnumerator
10 | where T : IInputDevice
11 | {
12 | private IEnumerator _base;
13 |
14 | public IsConnectedEnumerator(IEnumerator @base)
15 | {
16 | _base = @base;
17 | Current = default!;
18 | }
19 |
20 | public bool MoveNext()
21 | {
22 | while (_base.MoveNext())
23 | {
24 | if (_base.Current?.IsConnected ?? false)
25 | {
26 | Current = _base.Current;
27 | return true;
28 | }
29 | }
30 |
31 | return false;
32 | }
33 |
34 | public void Reset()
35 | {
36 | _base.Reset();
37 | }
38 |
39 | public T Current { get; private set; }
40 |
41 | object IEnumerator.Current => Current;
42 |
43 | public void Dispose()
44 | {
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Internals/IsConnectedWrapper.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System.Collections;
5 | using System.Collections.Generic;
6 |
7 | namespace Silk.NET.Input.Internals
8 | {
9 | internal struct IsConnectedWrapper : IReadOnlyList
10 | where T : IInputDevice
11 | {
12 | private readonly IReadOnlyList _list;
13 |
14 | public IsConnectedWrapper(IReadOnlyList list) => _list = list;
15 | public IEnumerator GetEnumerator() => new IsConnectedEnumerator(_list.GetEnumerator());
16 |
17 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
18 |
19 | public int Count => _list.Count;
20 |
21 | public T this[int index] => _list[index];
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Internals/ReadOnlyCollectionListAdapter.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System.Collections;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 |
8 | namespace Silk.NET.Input.Internals
9 | {
10 | internal struct ReadOnlyCollectionListAdapter : IReadOnlyList
11 | {
12 | private readonly IReadOnlyCollection _col;
13 |
14 | public ReadOnlyCollectionListAdapter(IReadOnlyCollection col)
15 | {
16 | _col = col;
17 | }
18 |
19 | public IEnumerator GetEnumerator() => _col.GetEnumerator();
20 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
21 | public int Count => _col.Count;
22 | public T this[int index] => _col.ElementAt(index);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/PublicAPI/net5.0/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | Silk.NET.Input.StandardCursor.ResizeAll = 9 -> Silk.NET.Input.StandardCursor
3 | Silk.NET.Input.StandardCursor.NeswResize = 8 -> Silk.NET.Input.StandardCursor
4 | Silk.NET.Input.StandardCursor.NotAllowed = 10 -> Silk.NET.Input.StandardCursor
5 | Silk.NET.Input.StandardCursor.NwseResize = 7 -> Silk.NET.Input.StandardCursor
6 | Silk.NET.Input.StandardCursor.Wait = 11 -> Silk.NET.Input.StandardCursor
7 | Silk.NET.Input.StandardCursor.WaitArrow = 12 -> Silk.NET.Input.StandardCursor
8 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/PublicAPI/netcoreapp3.1/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | Silk.NET.Input.StandardCursor.ResizeAll = 9 -> Silk.NET.Input.StandardCursor
3 | Silk.NET.Input.StandardCursor.NeswResize = 8 -> Silk.NET.Input.StandardCursor
4 | Silk.NET.Input.StandardCursor.NotAllowed = 10 -> Silk.NET.Input.StandardCursor
5 | Silk.NET.Input.StandardCursor.NwseResize = 7 -> Silk.NET.Input.StandardCursor
6 | Silk.NET.Input.StandardCursor.Wait = 11 -> Silk.NET.Input.StandardCursor
7 | Silk.NET.Input.StandardCursor.WaitArrow = 12 -> Silk.NET.Input.StandardCursor
8 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | Silk.NET.Input.StandardCursor.ResizeAll = 9 -> Silk.NET.Input.StandardCursor
3 | Silk.NET.Input.StandardCursor.NeswResize = 8 -> Silk.NET.Input.StandardCursor
4 | Silk.NET.Input.StandardCursor.NotAllowed = 10 -> Silk.NET.Input.StandardCursor
5 | Silk.NET.Input.StandardCursor.NwseResize = 7 -> Silk.NET.Input.StandardCursor
6 | Silk.NET.Input.StandardCursor.Wait = 11 -> Silk.NET.Input.StandardCursor
7 | Silk.NET.Input.StandardCursor.WaitArrow = 12 -> Silk.NET.Input.StandardCursor
8 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | Silk.NET.Input.StandardCursor.ResizeAll = 9 -> Silk.NET.Input.StandardCursor
3 | Silk.NET.Input.StandardCursor.NeswResize = 8 -> Silk.NET.Input.StandardCursor
4 | Silk.NET.Input.StandardCursor.NotAllowed = 10 -> Silk.NET.Input.StandardCursor
5 | Silk.NET.Input.StandardCursor.NwseResize = 7 -> Silk.NET.Input.StandardCursor
6 | Silk.NET.Input.StandardCursor.Wait = 11 -> Silk.NET.Input.StandardCursor
7 | Silk.NET.Input.StandardCursor.WaitArrow = 12 -> Silk.NET.Input.StandardCursor
8 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Silk.NET.Input.Common.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | Silk.NET.Input
6 | enable
7 |
8 |
9 |
10 |
11 | <_Parameter1>Silk.NET.Input.Glfw
12 |
13 |
14 | <_Parameter1>Silk.NET.Input.Sdl
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Silk.NET.Input.Common.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
3 | True
4 | True
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Structs/Axis.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Silk.NET.Input
5 | {
6 | ///
7 | /// Represents an axis on a joystick.
8 | ///
9 | public readonly struct Axis
10 | {
11 | ///
12 | /// The index of this axis, used to determine which axis it is.
13 | ///
14 | public int Index { get; }
15 |
16 | ///
17 | /// The position of this axis.
18 | ///
19 | public float Position { get; }
20 |
21 | ///
22 | /// Creates a new instance of the Axis struct.
23 | ///
24 | /// The index of the new axis.
25 | /// The position of the new axis.
26 | public Axis(int index, float position)
27 | {
28 | Index = index;
29 | Position = position;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Structs/Button.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Silk.NET.Input
5 | {
6 | ///
7 | /// Represents a joystick button.
8 | ///
9 | public struct Button
10 | {
11 | ///
12 | /// The name of this button. Only guaranteed to be valid if this comes from an .
13 | ///
14 | public ButtonName Name { get; }
15 |
16 | ///
17 | /// The index of this button. Use this if this button comes from an .
18 | ///
19 | public int Index { get; }
20 |
21 | ///
22 | /// Whether or not this button is currently pressed.
23 | ///
24 | public bool Pressed { get; }
25 |
26 | ///
27 | /// Creates a new instance of the Button struct.
28 | ///
29 | /// The name of this button.
30 | /// The index of this button.
31 | /// Whether or not this button is currently pressed.
32 | public Button(ButtonName name, int index, bool pressed)
33 | {
34 | Name = name;
35 | Index = index;
36 | Pressed = pressed;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Structs/Deadzone.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System;
5 |
6 | namespace Silk.NET.Input
7 | {
8 | ///
9 | /// The deadzone to use for a joystick/gamepad's sticks.
10 | ///
11 | public readonly struct Deadzone
12 | {
13 | ///
14 | /// The size of the deadzone to use.
15 | ///
16 | public float Value { get; }
17 |
18 | ///
19 | /// The deadzone method to use.
20 | ///
21 | public DeadzoneMethod Method { get; }
22 |
23 | ///
24 | /// Creates a new instance of the Deadzone struct.
25 | ///
26 | /// The deadzone size.
27 | /// The deadzone method.
28 | public Deadzone(float value, DeadzoneMethod method)
29 | {
30 | Value = value;
31 | Method = method;
32 | }
33 |
34 | ///
35 | /// Applies this deadzone to a raw input value.
36 | ///
37 | /// The raw input value to apply the deadzone to.
38 | /// The input with deadzone applied.
39 | /// If the deadzone method isn't part of
40 | ///
41 | public float Apply(float raw)
42 | {
43 | return Method switch
44 | {
45 | DeadzoneMethod.Traditional => (Math.Abs(raw) < Value ? 0 : raw),
46 | DeadzoneMethod.AdaptiveGradient => ((1 - Value) * raw + Value * Math.Sign(raw)),
47 | _ => throw new ArgumentOutOfRangeException()
48 | };
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Structs/Hat.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Silk.NET.Input
5 | {
6 | ///
7 | /// Represents a joystick hat.
8 | ///
9 | public struct Hat
10 | {
11 | ///
12 | /// The index of this hat.
13 | ///
14 | public int Index { get; }
15 |
16 | ///
17 | /// The position of this hat.
18 | ///
19 | public Position2D Position { get; }
20 |
21 | ///
22 | /// Creates a new instance of the Hat struct.
23 | ///
24 | /// The index of the hat.
25 | /// The position of the hat.
26 | public Hat(int index, Position2D position)
27 | {
28 | Index = index;
29 | Position = position;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Structs/Thumbstick.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System;
5 |
6 | namespace Silk.NET.Input
7 | {
8 | ///
9 | /// A thumbstick on an
10 | ///
11 | public struct Thumbstick
12 | {
13 | ///
14 | /// The index of this stick.
15 | ///
16 | public int Index { get; }
17 |
18 | ///
19 | /// The x-axis of the stick, from -1.0 to 1.0
20 | ///
21 | public float X { get; }
22 |
23 | ///
24 | /// The y-axis of the stick, from -1.0 to 1.0
25 | ///
26 | public float Y { get; }
27 |
28 | ///
29 | /// The current position of the stick, from 0.0 to 1.0.
30 | ///
31 | public float Position => (float) Math.Sqrt(X * X + Y * Y);
32 |
33 | ///
34 | /// The current direction of the stick, from -π to π.
35 | ///
36 | public float Direction => (float) Math.Atan2(Y, X);
37 |
38 | ///
39 | /// Creates a new instance of the Thumbstick struct.
40 | ///
41 | /// The index of the stick.
42 | /// The position of the stick.
43 | /// The direction of the stick.
44 | public Thumbstick(int index, float x, float y)
45 | {
46 | Index = index;
47 | X = x;
48 | Y = y;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Common/Structs/Trigger.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Silk.NET.Input
5 | {
6 | ///
7 | /// Represents a trigger.
8 | ///
9 | public struct Trigger
10 | {
11 | ///
12 | /// The index of this trigger.
13 | ///
14 | public int Index { get; }
15 |
16 | ///
17 | /// The position of this trigger; how far down it's currently pressed.
18 | ///
19 | public float Position { get; }
20 |
21 | ///
22 | /// Creates a new instance of the Trigger struct.
23 | ///
24 | /// The index of this trigger.
25 | /// The position of this trigger.
26 | public Trigger(int index, float position)
27 | {
28 | Index = index;
29 | Position = position;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Extensions/CaptureExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Buffers;
2 |
3 | namespace Silk.NET.Input.Extensions
4 | {
5 | public static class CaptureExtensions
6 | {
7 | public static InputSnapshot CaptureState(this IInputContext obj, MemoryPool? memoryPool = null)
8 | => new(obj, memoryPool ?? MemoryPool.Shared);
9 | public static GamepadState CaptureState(this IGamepad obj, MemoryPool? memoryPool = null)
10 | => new(obj, memoryPool ?? MemoryPool.Shared);
11 | public static JoystickState CaptureState(this IJoystick obj, MemoryPool? memoryPool = null)
12 | => new(obj, memoryPool ?? MemoryPool.Shared);
13 | public static KeyboardState CaptureState(this IKeyboard obj, MemoryPool? memoryPool = null)
14 | => new(obj, memoryPool ?? MemoryPool.Shared);
15 | public static MouseState CaptureState(this IMouse obj, MemoryPool? memoryPool = null)
16 | => new MouseState(obj, memoryPool ?? MemoryPool.Shared);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Extensions/PublicAPI/net5.0/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Extensions/PublicAPI/netcoreapp3.1/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Extensions/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Extensions/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Extensions/Silk.NET.Input.Extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | true
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/GlfwEvents.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System;
5 | using Silk.NET.GLFW;
6 |
7 | namespace Silk.NET.Input.Glfw
8 | {
9 | internal class GlfwEvents : IDisposable
10 | {
11 | public unsafe GlfwEvents(WindowHandle* handle)
12 | {
13 | Handle = handle;
14 | GlfwProvider.GLFW.Value.SetCharCallback(handle, (a, b) => Char?.Invoke(a, b));
15 | GlfwProvider.GLFW.Value.SetKeyCallback(handle, (a, b, c, d, e) => Key?.Invoke(a, b, c, d, e));
16 | GlfwProvider.GLFW.Value.SetMouseButtonCallback(handle, (a, b, c, d) => MouseButton?.Invoke(a, b, c, d));
17 | GlfwProvider.GLFW.Value.SetCursorEnterCallback(handle, (a, b) => CursorEnter?.Invoke(a, b));
18 | GlfwProvider.GLFW.Value.SetCursorPosCallback(handle, (a, b, c) => CursorPos?.Invoke(a, b, c));
19 | GlfwProvider.GLFW.Value.SetScrollCallback(handle, (a, b, c) => Scroll?.Invoke(a, b, c));
20 | }
21 |
22 | public unsafe WindowHandle* Handle { get; }
23 | public event GlfwCallbacks.KeyCallback Key;
24 | public event GlfwCallbacks.CharCallback Char;
25 | public event GlfwCallbacks.MouseButtonCallback MouseButton;
26 | public event GlfwCallbacks.CursorEnterCallback CursorEnter;
27 | public event GlfwCallbacks.CursorPosCallback CursorPos;
28 | public event GlfwCallbacks.ScrollCallback Scroll;
29 |
30 | public unsafe void Dispose()
31 | {
32 | GlfwProvider.GLFW.Value.SetCharCallback(Handle, null);
33 | GlfwProvider.GLFW.Value.SetKeyCallback(Handle, null);
34 | GlfwProvider.GLFW.Value.SetMouseButtonCallback(Handle, null);
35 | GlfwProvider.GLFW.Value.SetCursorEnterCallback(Handle, null);
36 | GlfwProvider.GLFW.Value.SetCursorPosCallback(Handle, null);
37 | GlfwProvider.GLFW.Value.SetScrollCallback(Handle, null);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/GlfwInput.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System.Linq;
5 | using Silk.NET.Windowing.Glfw;
6 |
7 | namespace Silk.NET.Input.Glfw
8 | {
9 | public static class GlfwInput
10 | {
11 | public static void RegisterPlatform()
12 | {
13 | GlfwWindowing.RegisterPlatform(); // just in case it's not already
14 | if (!InputWindowExtensions._platforms.OfType().Any())
15 | {
16 | InputWindowExtensions.Add(new GlfwInputPlatform());
17 | }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/GlfwInputPlatform.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using Silk.NET.GLFW;
7 | using Silk.NET.Input;
8 | using Silk.NET.Input.Glfw;
9 | using Silk.NET.Windowing;
10 | using Silk.NET.Windowing.Glfw;
11 |
12 | [assembly: InputPlatform(typeof(GlfwInputPlatform))]
13 |
14 | namespace Silk.NET.Input.Glfw
15 | {
16 | ///
17 | internal class GlfwInputPlatform : IInputPlatform
18 | {
19 | private static readonly Dictionary _subs = new Dictionary();
20 |
21 | ///
22 | public bool IsApplicable(IView window) => window is GlfwWindow;
23 |
24 | ///
25 | public IInputContext CreateInput(IView window) => new GlfwInputContext(window);
26 |
27 | internal static unsafe void RegisterWindow(WindowHandle* handle, IEnumerable subscribers)
28 | {
29 | if (_subs.ContainsKey((nint) handle))
30 | {
31 | throw new InvalidOperationException($"More than one input context for window {(nint) handle}.");
32 | }
33 | var events = _subs[(nint) handle] = new GlfwEvents(handle);
34 | foreach (var subscriber in subscribers)
35 | {
36 | subscriber.Subscribe(events);
37 | }
38 | }
39 |
40 | internal static unsafe void UnregisterWindow(WindowHandle* handle, IEnumerable subscribers)
41 | {
42 | if (_subs.TryGetValue((nint) handle, out var events))
43 | {
44 | foreach (var subscriber in subscribers)
45 | {
46 | subscriber.Unsubscribe(events);
47 | }
48 |
49 | events.Dispose();
50 | _subs.Remove((nint) handle);
51 | }
52 | else
53 | {
54 | throw new ObjectDisposedException($"Input context already disposed for window {(nint) handle}");
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/IGlfwSubscriber.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Silk.NET.Input.Glfw
5 | {
6 | internal interface IGlfwSubscriber
7 | {
8 | void Subscribe(GlfwEvents events);
9 | void Unsubscribe(GlfwEvents events);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/PublicAPI/net5.0/PublicAPI.Shipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | Silk.NET.Input.Glfw.GlfwInput
3 | static Silk.NET.Input.Glfw.GlfwInput.RegisterPlatform() -> void
4 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/PublicAPI/net5.0/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/PublicAPI/netcoreapp3.1/PublicAPI.Shipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | Silk.NET.Input.Glfw.GlfwInput
3 | static Silk.NET.Input.Glfw.GlfwInput.RegisterPlatform() -> void
4 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/PublicAPI/netcoreapp3.1/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | Silk.NET.Input.Glfw.GlfwInput
3 | static Silk.NET.Input.Glfw.GlfwInput.RegisterPlatform() -> void
4 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/PublicAPI/netstandard2.1/PublicAPI.Shipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | Silk.NET.Input.Glfw.GlfwInput
3 | static Silk.NET.Input.Glfw.GlfwInput.RegisterPlatform() -> void
4 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/Silk.NET.Input.Glfw.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | true
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/lib/Silk.NET.Input.Glfw/Silk.NET.Input.Glfw.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
--------------------------------------------------------------------------------
/lib/Silk.NET.Input/Silk.NET.Input.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/lib/TrippyGL.Fonts.Building/TrippyGL.Fonts.Building.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | https://github.com/SilkCommunity/TrippyGL
6 | MIT
7 | https://github.com/SilkCommunity/TrippyGL
8 | TrippyGL_logo.png
9 | 1.2.1
10 | ThomasMiz
11 | true
12 | TrippyGL is a highly versatile, yet lightweight and simple to use OpenGL graphics library that runs on .NET Core.
13 |
14 | This package provides integration with the SixLabors.Fonts library for the TrippyGL.Fonts package, allowing the creation of TrippyGL fonts from common font file formats, such as as TrueType.
15 | OpenGL;graphics;gamedev;desktopgl;fonts;text
16 | git
17 | enable
18 | Changelog from 1.2.0:
19 | - Upgraded all dependencies
20 | README.md
21 |
22 |
23 |
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | True
36 | \
37 |
38 |
39 | True
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/lib/TrippyGL.Fonts.Extensions/TrippyGL.Fonts.Extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | https://github.com/SilkCommunity/TrippyGL
6 | https://github.com/SilkCommunity/TrippyGL
7 | TrippyGL_logo.png
8 | MIT
9 | ThomasMiz
10 | 1.2.1
11 | true
12 | TrippyGL is a highly versatile, yet lightweight and simple to use OpenGL graphics library that runs on .NET Core.
13 |
14 | This package provides integration between TrippyGL.Fonts and the main TrippyGL package.
15 | OpenGL;graphics;gamedev;desktopgl;fonts;text
16 | git
17 | enable
18 | Changelog from 1.2.0:
19 | - Upgraded all dependencies
20 | README.md
21 |
22 |
23 |
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | True
37 | \
38 |
39 |
40 | True
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/lib/TrippyGL.Fonts/Exceptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TrippyGL.Fonts
4 | {
5 | public class FontLoadingException : Exception
6 | {
7 | public FontLoadingException() : base() { }
8 |
9 | public FontLoadingException(string? message) : base(message) { }
10 |
11 | public FontLoadingException(string? message, Exception? innerException) : base(message, innerException) { }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/lib/TrippyGL.Fonts/TrippyGL.Fonts.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | true
6 | 1.2.1
7 | ThomasMiz
8 | MIT
9 | https://github.com/SilkCommunity/TrippyGL
10 | https://github.com/SilkCommunity/TrippyGL
11 | TrippyGL_logo.png
12 | TrippyGL is a highly versatile, yet lightweight and simple to use OpenGL graphics library that runs on .NET Core.
13 |
14 | This package provides basic font creating/loading/saving functionality.
15 | OpenGL;graphics;gamedev;desktopgl;fonts;text
16 | Changelog from 1.2.0:
17 | - Upgraded all dependencies
18 | git
19 | enable
20 | README.md
21 |
22 |
23 |
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | True
35 | \
36 |
37 |
38 | True
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lib/TrippyGL.ImageSharp/ImageUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using SixLabors.ImageSharp.Formats;
3 |
4 | namespace TrippyGL.ImageSharp
5 | {
6 | ///
7 | /// Contains helper image-related methods used across the library.
8 | ///
9 | public static class ImageUtils
10 | {
11 | internal const string ImageSizeMustMatchTextureSizeError = "The size of the image must match the size of the texture";
12 |
13 | internal const string TextureFormatMustBeColor4bError = "The texture's format must be Color4b (RGBA)";
14 |
15 | ///
16 | /// Gets an appropiate for the given .
17 | ///
18 | public static IImageFormat GetFormatFor(SaveImageFormat imageFormat)
19 | {
20 | return imageFormat switch
21 | {
22 | SaveImageFormat.Png => SixLabors.ImageSharp.Formats.Png.PngFormat.Instance,
23 | SaveImageFormat.Jpeg => SixLabors.ImageSharp.Formats.Jpeg.JpegFormat.Instance,
24 | SaveImageFormat.Bmp => SixLabors.ImageSharp.Formats.Bmp.BmpFormat.Instance,
25 | SaveImageFormat.Gif => SixLabors.ImageSharp.Formats.Gif.GifFormat.Instance,
26 | _ => throw new ArgumentException("Invalid " + nameof(SaveImageFormat), nameof(imageFormat)),
27 | };
28 | }
29 | }
30 |
31 | ///
32 | /// Specifies image file formats.
33 | ///
34 | public enum SaveImageFormat
35 | {
36 | Png, Jpeg, Bmp, Gif
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lib/TrippyGL.ImageSharp/TrippyGL.ImageSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | 1.2.1
6 | true
7 | ThomasMiz
8 | MIT
9 | https://github.com/SilkCommunity/TrippyGL
10 | https://github.com/SilkCommunity/TrippyGL
11 | TrippyGL_logo.png
12 | TrippyGL is a highly versatile, yet lightweight and simple to use OpenGL graphics library that runs on .NET Core.
13 |
14 | This package provides integration with the ImageSharp library, allowing loading and saving textures from files or images.
15 | OpenGL;graphics;gamedev;desktopgl;images;ImageSharp;textures;
16 | git
17 | enable
18 | Changelog from 1.2.0:
19 | - Upgraded all dependencies
20 | README.md
21 |
22 |
23 |
24 |
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | True
39 | \
40 |
41 |
42 | True
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/AttributeBaseType.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the base data types a vertex attribute can be composed of.
5 | ///
6 | public enum AttributeBaseType
7 | {
8 | Byte = 5120,
9 | UnsignedByte = 5121,
10 | Short = 5122,
11 | UnsignedShort = 5123,
12 | Int = 5124,
13 | UnsignedInt = 5125,
14 | Float = 5126,
15 | Double = 5130,
16 | HalfFloat = 5131,
17 | Fixed = 5132,
18 | //Int64Arb = 5134,
19 | //UnsignedInt64Arb = 5135,
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/BlendingFactor.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the possible blending factors that can be used in a blending equation.
5 | ///
6 | public enum BlendingFactor
7 | {
8 | Zero = 0,
9 | One = 1,
10 | SrcColor = 768,
11 | OneMinusSrcColor = 769,
12 | SrcAlpha = 770,
13 | OneMinusSrcAlpha = 771,
14 | DstAlpha = 772,
15 | OneMinusDstAlpha = 773,
16 | DstColor = 774,
17 | OneMinusDstColor = 775,
18 | SrcAlphaSaturate = 776,
19 | ConstantColor = 32769,
20 | OneMinusConstantColor = 32770,
21 | ConstantAlpha = 32771,
22 | OneMinusConstantAlpha = 32772,
23 | Src1Alpha = 34185,
24 | Src1Color = 35065,
25 | OneMinusSrc1Color = 35066,
26 | OneMinusSrc1Alpha = 35067
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/BlendingMode.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the blending equation modes that can be used in a .
5 | ///
6 | public enum BlendingMode
7 | {
8 | FuncAdd = 32774,
9 | Min = 32775,
10 | Max = 32776,
11 | FuncSubtract = 32778,
12 | FuncReverseSubtract = 32779,
13 | AlphaMin = 33568,
14 | AlphaMax = 33569
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/BlitFramebufferFilter.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the interpolation filters that can be used when blitting framebuffers.
5 | ///
6 | public enum BlitFramebufferFilter
7 | {
8 | Nearest = 9728,
9 | Linear = 9729
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/BufferTarget.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the buffer binding points at which a can be bound.
5 | ///
6 | public enum BufferTarget
7 | {
8 | ParameterBuffer = 33006,
9 | ArrayBuffer = 34962,
10 | ElementArrayBuffer = 34963,
11 | PixelPackBuffer = 35051,
12 | PixelUnpackBuffer = 35052,
13 | UniformBuffer = 35345,
14 | TextureBuffer = 35882,
15 | TransformFeedbackBuffer = 35982,
16 | CopyReadBuffer = 36662,
17 | CopyWriteBuffer = 36663,
18 | DrawIndirectBuffer = 36671,
19 | ShaderStorageBuffer = 37074,
20 | DispatchIndirectBuffer = 37102,
21 | QueryBuffer = 37266,
22 | AtomicCounterBuffer = 37568
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/BufferUsage.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies values that hint on how a will be used.
5 | ///
6 | ///
7 | /// Explanations and descriptions for these can be found in the khronos OpenGL wiki:
8 | /// https://www.khronos.org/opengl/wiki/Buffer_Object#Buffer_Object_Usage
9 | ///
10 | public enum BufferUsage
11 | {
12 | ///
13 | /// Optimizes the buffer for it's data to be set every use, or almost every use, and used for drawing.
14 | ///
15 | StreamDraw = 35040,
16 |
17 | ///
18 | /// Optimizes the buffer for it's data to be set every use, or almost every use, and used for reading back.
19 | ///
20 | StreamRead = 35041,
21 |
22 | ///
23 | /// Optimizes the buffer for it's data to be set every use, or almost every use, and used for copying within GPU memory.
24 | ///
25 | StreamCopy = 35042,
26 |
27 | ///
28 | /// Optimizes the buffer for it's data to be set once and used for drawing.
29 | ///
30 | StaticDraw = 35044,
31 |
32 | ///
33 | /// Optimizes the buffer for it's data to be set once and used for reading back.
34 | ///
35 | StaticRead = 35045,
36 |
37 | ///
38 | /// Optimizes the buffer for it's data to be set once and used for copying within GPU memory.
39 | ///
40 | StaticCopy = 35046,
41 |
42 | ///
43 | /// Optimizes the buffer for it's data to be set often and used for drawing.
44 | ///
45 | DynamicDraw = 35048,
46 |
47 | ///
48 | /// Optimizes the buffer for it's data to be set often and used for reading back.
49 | ///
50 | DynamicRead = 35049,
51 |
52 | ///
53 | /// Optimizes the buffer for it's data to be set often and used for copying within GPU memory.
54 | ///
55 | DynamicCopy = 35050
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/ClearBuffers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TrippyGL
4 | {
5 | ///
6 | /// Specifies the buffers that can be targeted by a clear operation.
7 | ///
8 | [Flags]
9 | public enum ClearBuffers : uint
10 | {
11 | Depth = 256,
12 | Stencil = 1024,
13 | Color = 16384,
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/CubemapFace.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the faces of a .
5 | ///
6 | public enum CubemapFace
7 | {
8 | PositiveX = 34069,
9 | NegativeX = 34070,
10 | PositiveY = 34071,
11 | NegativeY = 34072,
12 | PositiveZ = 34073,
13 | NegativeZ = 34074
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/CullingMode.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the modes for which polygon culling can be enabled.
5 | ///
6 | public enum CullingMode
7 | {
8 | CullFront = 1028,
9 | CullBack = 1029,
10 | CullFrontAndBack = 1032
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/DebugSeverity.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | public enum DebugSeverity
4 | {
5 | DontCare = 4352,
6 | Notification = 33387,
7 | High = 37190,
8 | Medium = 37191,
9 | Low = 37192
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/DebugSource.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | public enum DebugSource
4 | {
5 | DontCare = 4352,
6 | Api = 33350,
7 | WindowSystem = 33351,
8 | ShaderCompiler = 33352,
9 | ThirdParty = 33353,
10 | Application = 33354,
11 | Other = 33355
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/DebugType.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | public enum DebugType
4 | {
5 | DontCare = 4352,
6 | Error = 33356,
7 | DeprecatedBehavior = 33357,
8 | UndefinedBehavior = 33358,
9 | Portability = 33359,
10 | Performance = 33360,
11 | Other = 33361,
12 | Marker = 33384,
13 | PushGroup = 33385,
14 | PopGroup = 33386
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/DepthFunction.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the functions that can be used to perform depth testing.
5 | ///
6 | public enum DepthFunction
7 | {
8 | Never = 512,
9 | Less = 513,
10 | Equal = 514,
11 | LessOrEqual = 515,
12 | Greater = 516,
13 | NotEqual = 517,
14 | GreaterOrEqual = 518,
15 | Always = 519
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/DepthStencilFormat.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies depth and/or stencil formats a can have.
5 | ///
6 | public enum DepthStencilFormat
7 | {
8 | None = 0,
9 | Depth24Stencil8 = 35056,
10 | Depth32fStencil8 = 36013,
11 | Depth16 = 33189,
12 | Depth24 = 33190,
13 | Depth32f = 36012,
14 | Stencil8 = 36168 //not a recommended format though, better to use Depth24Stencil8
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/ElementType.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the different types of elements that can be used for indexed drawing.
5 | ///
6 | public enum ElementType
7 | {
8 | UnsignedByte = 5121,
9 | UnsignedShort = 5123,
10 | UnsignedInt = 5125
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/FramebufferAttachmentPoint.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the attachment points on a .
5 | ///
6 | public enum FramebufferAttachmentPoint
7 | {
8 | Color0 = 36064,
9 | Color1 = 36065,
10 | Color2 = 36066,
11 | Color3 = 36067,
12 | Color4 = 36068,
13 | Color5 = 36069,
14 | Color6 = 36070,
15 | Color7 = 36071,
16 | Color8 = 36072,
17 | Color9 = 36073,
18 | Color10 = 36074,
19 | Color11 = 36075,
20 | Color12 = 36076,
21 | Color13 = 36077,
22 | Color14 = 36078,
23 | Color15 = 36079,
24 | Depth = 36096,
25 | Stencil = 36128,
26 | DepthStencil = 33306
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/PolygonFace.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the faces of a polygon.
5 | ///
6 | public enum PolygonFace
7 | {
8 | Clockwise = 2304,
9 | CounterClockwise = 2305
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/PrimitiveType.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the types of primitives that can be rendered.
5 | ///
6 | public enum PrimitiveType
7 | {
8 | Points = 0,
9 | Lines = 1,
10 | LineLoop = 2,
11 | LineStrip = 3,
12 | Triangles = 4,
13 | TriangleStrip = 5,
14 | TriangleFan = 6,
15 | Quads = 7,
16 | LinesAdjacency = 10,
17 | LineStripAdjacency = 11,
18 | TrianglesAdjacency = 12,
19 | TriangleStripAdjacency = 13,
20 | Patches = 14,
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/ReadPixelsFormat.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies formats for a read pixels operation on a .
5 | ///
6 | public enum ReadPixelsFormat
7 | {
8 | // Allowed values in glReadPixels:
9 | // GL_RED, GL_GREEN, GL_BLUE, GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL
10 | // Source: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glReadPixels.xhtml
11 |
12 | Red = 6403,
13 | Green = 6404,
14 | Blue = 6405,
15 | Rgb = 6407,
16 | Bgr = 32992,
17 | Rgba = 6408,
18 | Bgra = 32993,
19 | DepthComponent = 6402,
20 | StencilIndex = 6401,
21 | DepthStencil = 34041
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/RenderbufferFormat.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies formats a 's storage can have.
5 | ///
6 | public enum RenderbufferFormat
7 | {
8 | Color4b = 32856,
9 |
10 | Float = 33326,
11 | Float2 = 33328,
12 | Float4 = 34836,
13 |
14 | Int = 33333,
15 | Int2 = 33339,
16 | Int4 = 36226,
17 |
18 | UnsignedInt = 33334,
19 | UnsignedInt2 = 33340,
20 | UnsignedInt4 = 36208,
21 |
22 | Depth16 = 33189,
23 | Depth24 = 33190,
24 | Depth32f = 36012,
25 | Depth24Stencil8 = 35056,
26 | Depth32fStencil8 = 36013,
27 | Stencil8 = 36168,
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/StencilFunction.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the different comparisons that can be used in a stencil test.
5 | ///
6 | public enum StencilFunction
7 | {
8 | Never = 512,
9 | Less = 513,
10 | Equal = 514,
11 | LessOrEqual = 515,
12 | Greater = 516,
13 | NotEqual = 517,
14 | GreaterOrEqual = 518,
15 | Always = 519
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/StencilOperation.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the operations that can be performed after comparison during a stencil test.
5 | ///
6 | public enum StencilOperation
7 | {
8 | Zero = 0,
9 | Invert = 5386,
10 | Keep = 7680,
11 | Replace = 7681,
12 | Increment = 7682,
13 | Decrement = 7683,
14 | IncrementWrap = 34055,
15 | DecrementWrap = 34056
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/TextureImageFormat.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies formats a 's image can have.
5 | ///
6 | public enum TextureImageFormat
7 | {
8 | // These are organized in such away so the base type (float, int, uint)
9 | // is distinguisable by dividing by 32 and the remainder indicates the amount of components
10 | // (amount of components: Color4b has 4, Vector2 has 2, Vector3i has 3, etc)
11 | // This is done in TrippyUtils.GetTextureFormatEnums()
12 |
13 | Color4b = 5,
14 |
15 | Float = 33,
16 | Float2 = 34,
17 | Float3 = 35,
18 | Float4 = 36,
19 | Depth16 = 37,
20 | Depth24 = 38,
21 | Depth32f = 39,
22 |
23 | Int = 65,
24 | Int2 = 66,
25 | Int3 = 67,
26 | Int4 = 68,
27 |
28 | UnsignedInt = 97,
29 | UnsignedInt2 = 98,
30 | UnsignedInt3 = 99,
31 | UnsignedInt4 = 100,
32 |
33 | Depth24Stencil8 = 129,
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/TextureMagFilter.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the magnifying filters that can be used when sampling a texture.
5 | ///
6 | public enum TextureMagFilter
7 | {
8 | Nearest = 9728,
9 | Linear = 9729
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/TextureMinFilter.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the minifying filters that can be used when sampling a texture.
5 | ///
6 | public enum TextureMinFilter
7 | {
8 | Nearest = 9728,
9 | Linear = 9729,
10 | NearestMipmapNearest = 9984,
11 | LinearMipmapNearest = 9985,
12 | NearestMipmapLinear = 9986,
13 | LinearMipmapLinear = 9987
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/TextureType.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the types of textures.
5 | ///
6 | public enum TextureType
7 | {
8 | Texture1D = 3552,
9 | Texture2D = 3553,
10 | //ProxyTexture1D = 32867,
11 | //ProxyTexture2D = 32868,
12 | Texture3D = 32879,
13 | //ProxyTexture3D = 32880,
14 | //DetailTexture2DSgis = 32917,
15 | //Texture4DSgis = 33076,
16 | //ProxyTexture4DSgis = 33077,
17 | //TextureRectangle = 34037,
18 | //ProxyTextureRectangle = 34039,
19 | TextureCubeMap = 34067,
20 | //TextureCubeMapPositiveX = 34069,
21 | //TextureCubeMapNegativeX = 34070,
22 | //TextureCubeMapPositiveY = 34071,
23 | //TextureCubeMapNegativeY = 34072,
24 | //TextureCubeMapPositiveZ = 34073,
25 | //TextureCubeMapNegativeZ = 34074,
26 | //ProxyTextureCubeMap = 34075,
27 | Texture1DArray = 35864,
28 | //ProxyTexture1DArray = 35865,
29 | Texture2DArray = 35866,
30 | //ProxyTexture2DArray = 35867,
31 | TextureCubeMapArray = 36873,
32 | //ProxyTextureCubeMapArray = 36875,
33 | Texture2DMultisample = 37120,
34 | //ProxyTexture2DMultisample = 37121,
35 | Texture2DMultisampleArray = 37122,
36 | //ProxyTexture2DMultisampleArray = 37123
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lib/TrippyGL/Enums/TextureWrapMode.cs:
--------------------------------------------------------------------------------
1 | namespace TrippyGL
2 | {
3 | ///
4 | /// Specifies the modes in which texture coordinate wrapping can be handled.
5 | ///
6 | public enum TextureWrapMode
7 | {
8 | Repeat = 10497,
9 | ClampToEdge = 33071,
10 | MirroredRepeat = 33648
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/lib/TrippyGL/IVertex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TrippyGL
4 | {
5 | ///
6 | /// This interface is used by different classes that need vertex specification (such as
7 | /// , ) to be able to handle vertex specification
8 | /// work in a more convenient way.
9 | /// All vertex structs that properly implement this interface can be easily used with these classes.
10 | ///
11 | public interface IVertex
12 | {
13 | /// The amount of attribute descriptions this vertex type has.
14 | int AttribDescriptionCount { get; }
15 |
16 | ///
17 | /// Gets the vertex attrib descriptors by writting them into a .
18 | /// The must have a length of .
19 | ///
20 | void WriteAttribDescriptions(Span descriptions);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/lib/TrippyGL/TextureMultisamplable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TrippyGL
4 | {
5 | ///
6 | /// An abstract type that supports multisampling.
7 | ///
8 | public abstract class TextureMultisamplable : Texture
9 | {
10 | /// The amount of samples this has.
11 | public uint Samples { get; private set; }
12 |
13 | internal TextureMultisamplable(GraphicsDevice graphicsDevice, TextureType type, uint samples, TextureImageFormat imageFormat)
14 | : base(graphicsDevice, type, imageFormat)
15 | {
16 | ValidateSampleCount(samples);
17 | Samples = samples;
18 | }
19 |
20 | private void ValidateSampleCount(uint samples)
21 | {
22 | if (samples < 0 || samples > GraphicsDevice.MaxSamples)
23 | throw new ArgumentOutOfRangeException(nameof(samples), samples, nameof(samples) + " must be in the range [0, " + nameof(GraphicsDevice.MaxSamples) + "]");
24 | }
25 |
26 | protected void ValidateNotMultisampledPixelAccess()
27 | {
28 | if (Samples != 0)
29 | throw new InvalidOperationException("You can't read/write the pixels of a multisampled texture");
30 | }
31 |
32 | protected void ValidateNotMultisampledWrapStates()
33 | {
34 | if (Samples != 0)
35 | throw new InvalidOperationException("You can't change a multisampled texture's sampler states");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lib/TrippyTests/ComplexVertexFormats/ComplexVertexFormats.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | PreserveNewest
15 |
16 |
17 | PreserveNewest
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/lib/TrippyTests/ComplexVertexFormats/Program.cs:
--------------------------------------------------------------------------------
1 | namespace ComplexVertexFormats
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | new ComplexVertexFormats().Run();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/TrippyTests/ComplexVertexFormats/fs1.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | in vec4 fColor;
4 |
5 | out vec4 FragColor;
6 |
7 | void main() {
8 | FragColor = fColor;
9 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/ComplexVertexFormats/vs1.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | uniform mat4 Projection;
4 |
5 | in float X;
6 | in float Y;
7 | in float Z;
8 |
9 | in float colorR;
10 | in float colorG;
11 | in float colorB;
12 |
13 | in mat4 matrix1;
14 |
15 | in float nothing0;
16 | in float sixtyFour;
17 | in float sixtyThree;
18 | in vec4 oneTwoThreeFour;
19 | in int alwaysZero;
20 | in float alsoZero;
21 |
22 | out vec4 fColor;
23 |
24 | void main() {
25 | gl_Position = Projection * matrix1 * vec4(X + float(alwaysZero), Y + alsoZero, Z, oneTwoThreeFour.x);
26 | fColor = vec4(
27 | colorR * (nothing0 + 1.0),
28 | colorG / 2048.0 * (oneTwoThreeFour.z - oneTwoThreeFour.y),
29 | colorB * (sixtyFour - sixtyThree),
30 | oneTwoThreeFour.w - oneTwoThreeFour.z
31 | );
32 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/GameOfLifeSim/GameOfLifeSim.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | PreserveNewest
15 |
16 |
17 | PreserveNewest
18 |
19 |
20 | PreserveNewest
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/lib/TrippyTests/GameOfLifeSim/Program.cs:
--------------------------------------------------------------------------------
1 | namespace GameOfLifeSim
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | new GameOfLifeSim().Run();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/TrippyTests/GameOfLifeSim/sim_fs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | uniform sampler2D previous;
4 | uniform vec2 pixelDelta;
5 |
6 | in vec2 fTexCoords;
7 |
8 | out vec4 FragColor;
9 |
10 | void main() {
11 | vec4 prev = texture(previous, fTexCoords);
12 |
13 | vec4 sum = texture(previous, fTexCoords + vec2(-pixelDelta.x, -pixelDelta.y));
14 | sum += texture(previous, fTexCoords + vec2(0, -pixelDelta.y));
15 | sum += texture(previous, fTexCoords + vec2(pixelDelta.x, -pixelDelta.y));
16 | sum += texture(previous, fTexCoords + vec2(-pixelDelta.x, 0));
17 | sum += texture(previous, fTexCoords + vec2(pixelDelta.x, 0));
18 | sum += texture(previous, fTexCoords + vec2(-pixelDelta.x, pixelDelta.y));
19 | sum += texture(previous, fTexCoords + vec2(0, pixelDelta.y));
20 | sum += texture(previous, fTexCoords + vec2(pixelDelta.x, pixelDelta.y));
21 |
22 | // Single color mode
23 | /*vec3 next = mix(
24 | vec3(step(2.8, sum.x) * step(sum.x, 3.2)),
25 | vec3(step(1.9, sum.x) * step(sum.x, 3.1)),
26 | step(0.5, prev.x)
27 | );*/
28 |
29 | // Multi color mode
30 | vec3 next = mix(
31 | vec3(step(vec3(2.8), sum.xyz) * step(sum.xyz, vec3(3.2))),
32 | vec3(step(vec3(1.9), sum.xyz) * step(sum.xyz, vec3(3.1))),
33 | step(0.5, prev.xyz)
34 | );
35 |
36 | FragColor = vec4(next, 1.0);
37 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/GameOfLifeSim/sim_vs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | in vec3 vPosition;
4 | in vec2 vTexCoords;
5 |
6 | out vec2 fTexCoords;
7 |
8 | void main() {
9 | gl_Position = vec4(vPosition, 1.0);
10 | fTexCoords = vec2(vTexCoords.x, 1.0 - vTexCoords.y);
11 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/IndexedRendering/IndexedRendering.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | PreserveNewest
15 |
16 |
17 | PreserveNewest
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/lib/TrippyTests/IndexedRendering/Program.cs:
--------------------------------------------------------------------------------
1 | namespace IndexedRendering
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | new IndexedRendering().Run();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/TrippyTests/IndexedRendering/SimpleVertex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using TrippyGL;
4 |
5 | namespace IndexedRendering
6 | {
7 | ///
8 | /// A simple vertex type with only one vertex attribute, a float vec2.
9 | ///
10 | [StructLayout(LayoutKind.Sequential)]
11 | struct SimpleVertex : IVertex
12 | {
13 | public float X, Y;
14 |
15 | public SimpleVertex(float x, float y)
16 | {
17 | X = x;
18 | Y = y;
19 | }
20 |
21 | public int AttribDescriptionCount => 1;
22 |
23 | public void WriteAttribDescriptions(Span descriptions)
24 | {
25 | descriptions[0] = new VertexAttribDescription(AttributeType.FloatVec2);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/TrippyTests/IndexedRendering/fs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | uniform vec4 color;
4 |
5 | out vec4 FragColor;
6 |
7 | void main() {
8 | FragColor = color;
9 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/IndexedRendering/indices.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/IndexedRendering/indices.png
--------------------------------------------------------------------------------
/lib/TrippyTests/IndexedRendering/vs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | uniform mat4 Projection;
4 |
5 | in vec2 vPosition;
6 |
7 | void main() {
8 | gl_Position = Projection * vec4(vPosition, 0.0, 1.0);
9 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/InstancedCubes/InstancedCubes.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | PreserveNewest
15 |
16 |
17 | PreserveNewest
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/lib/TrippyTests/InstancedCubes/Program.cs:
--------------------------------------------------------------------------------
1 | namespace InstancedCubes
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | new InstancedCubes().Run();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/TrippyTests/InstancedCubes/fs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | in vec4 fColor;
4 |
5 | out vec4 FragColor;
6 |
7 | void main() {
8 | FragColor = fColor;
9 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/InstancedCubes/vs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | uniform mat4 World;
4 | uniform mat4 View;
5 | uniform mat4 Projection;
6 |
7 | in vec3 vPosition;
8 | in vec4 vColor;
9 | in vec4 vOffset;
10 |
11 | out vec4 fColor;
12 |
13 | void main() {
14 | fColor = vColor;
15 |
16 | vec4 worldPosition = World * vec4(vPosition * vOffset.w, 1.0);
17 | worldPosition.xyz += vOffset.xyz;
18 | gl_Position = Projection * View * worldPosition;
19 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/ShaderFractals/Program.cs:
--------------------------------------------------------------------------------
1 | namespace ShaderFractals
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | new ShaderFractals().Run();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/TrippyTests/ShaderFractals/ShaderFractals.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 | true
10 |
11 |
12 |
13 | true
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | PreserveNewest
24 |
25 |
26 | PreserveNewest
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/lib/TrippyTests/ShaderFractals/fs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 | const int loops = 300;
3 |
4 | uniform vec2 c;
5 |
6 | in vec2 fCoords;
7 |
8 | out vec4 FragColor;
9 |
10 | vec2 CMult(vec2 a, vec2 b) {
11 | return vec2(a.x*b.x - a.y*b.y, a.x*b.y + a.y*b.x);
12 | }
13 |
14 | vec3 Jul(vec2 v) {
15 | for (int i=0; i 2.0 || v.y > 2.0)
18 | return vec3(float(i)/100.0, float(i)/150.0, float(i)/50.0);
19 | }
20 |
21 | return vec3(0, 0, 0);
22 | }
23 |
24 | void main() {
25 | FragColor = vec4(Jul(fCoords), 1.0);
26 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/ShaderFractals/vs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | uniform mat3x2 Transform;
4 | uniform mat4 Projection;
5 |
6 | in vec3 vPosition;
7 |
8 | out vec2 fCoords;
9 |
10 | void main() {
11 | gl_Position = Projection * vec4(vPosition, 1.0);
12 | fCoords = (Transform * vec3(vPosition.xy, 1.0)).xy;
13 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCube/Program.cs:
--------------------------------------------------------------------------------
1 | namespace SimpleCube
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | new SimpleCube().Run();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCube/SimpleCube.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | PreserveNewest
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCubemap/Program.cs:
--------------------------------------------------------------------------------
1 | namespace SimpleCubemap
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | new SimpleCubemap().Run();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCubemap/SimpleCubemap.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | PreserveNewest
16 |
17 |
18 | PreserveNewest
19 |
20 |
21 | PreserveNewest
22 |
23 |
24 | PreserveNewest
25 |
26 |
27 | PreserveNewest
28 |
29 |
30 | PreserveNewest
31 |
32 |
33 | PreserveNewest
34 |
35 |
36 | PreserveNewest
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCubemap/cubemap/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/SimpleCubemap/cubemap/back.png
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCubemap/cubemap/bottom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/SimpleCubemap/cubemap/bottom.png
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCubemap/cubemap/front.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/SimpleCubemap/cubemap/front.png
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCubemap/cubemap/left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/SimpleCubemap/cubemap/left.png
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCubemap/cubemap/right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/SimpleCubemap/cubemap/right.png
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCubemap/cubemap/top.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/SimpleCubemap/cubemap/top.png
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCubemap/fs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | uniform samplerCube cubemap;
4 |
5 | in vec3 fPosition;
6 |
7 | out vec4 FragColor;
8 |
9 | void main() {
10 | FragColor = texture(cubemap, fPosition);
11 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleCubemap/vs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | uniform mat4 World;
4 | uniform mat4 View;
5 | uniform mat4 Projection;
6 |
7 | in vec3 vPosition;
8 |
9 | out vec3 fPosition;
10 |
11 | void main() {
12 | fPosition = vPosition;
13 | gl_Position = Projection * View * World * vec4(vPosition, 1.0);
14 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleShader3D/Program.cs:
--------------------------------------------------------------------------------
1 | namespace SimpleShader3D
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | new SimpleShader3D().Run();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleShader3D/SimpleShader3D.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | PreserveNewest
16 |
17 |
18 | PreserveNewest
19 |
20 |
21 | PreserveNewest
22 |
23 |
24 | PreserveNewest
25 |
26 |
27 | PreserveNewest
28 |
29 |
30 | PreserveNewest
31 |
32 |
33 | PreserveNewest
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleShader3D/lamp_texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/SimpleShader3D/lamp_texture.png
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleShader3D/skyFs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | uniform float time;
4 | uniform vec3 sunDirection;
5 | uniform vec3 sunColor;
6 |
7 | in vec3 fPosition;
8 |
9 | out vec4 FragColor;
10 |
11 | float rand(float x, float y) {
12 | return fract(sin(dot(vec2(x, y), vec2(46.49791, -77.58153))) * 839.441956);
13 | }
14 |
15 | float waves(float rx, float ry) {
16 | return (sin(rx*2.0 - ry + time*1.1 + 1.3) * 0.5 + 0.5)
17 | * (sin(ry*3.0 - rx + time*0.5 + 2.7) * 0.5 + 0.5);
18 | }
19 |
20 | void main() {
21 | vec3 norm = normalize(fPosition);
22 | float rotX = asin(norm.y);
23 | float rotY = acos(clamp(norm.x / cos(rotX), -1, 1));
24 | rotY *= sign(norm.z);
25 |
26 | float rx = rotX + sin(rotY*3.0 + time*4.4 - 0.7) * 0.2;
27 | float ry = rotY + sin(rotX*2.0 - time*2.3 + 1.5) * 0.2;
28 |
29 | float w = waves(rx, ry);
30 |
31 | float p = pow(min(w+0.3, 1), 3)*0.15;
32 | float s = sqrt(w);
33 | vec3 skyMix = vec3(p + s*0.2, p, p + s);
34 | skyMix.xyz += rand(rotX, rotY)*0.1;
35 |
36 | float sunStrenght = max(pow(dot(norm, sunDirection)+0.01, 64), 0);
37 |
38 | FragColor = vec4(skyMix * (1.0-clamp(sunStrenght, -0.2, 0.2)) + sunColor * sunStrenght, 1.0);
39 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleShader3D/skyVs.glsl:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | uniform mat4 View;
4 | uniform mat4 Projection;
5 |
6 | in vec3 vPosition;
7 |
8 | out vec3 fPosition;
9 |
10 | void main() {
11 | gl_Position = Projection * View * vec4(vPosition, 1.0);
12 | fPosition = vPosition;
13 | }
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleTriangle/Program.cs:
--------------------------------------------------------------------------------
1 | namespace SimpleTriangle
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | new SimpleTriangle().Run();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleTriangle/SimpleTriangle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Numerics;
3 | using Silk.NET.Maths;
4 | using TrippyGL;
5 | using TrippyTestBase;
6 |
7 | namespace SimpleTriangle
8 | {
9 | // A simple project that opens an OpenGL window and renders a centered colored triangle.
10 |
11 | class SimpleTriangle : TestBase
12 | {
13 | VertexBuffer vertexBuffer;
14 | SimpleShaderProgram shaderProgram;
15 |
16 | protected override void OnLoad()
17 | {
18 | Span vertexData = stackalloc VertexColor[]
19 | {
20 | new VertexColor(new Vector3(-0.5f, -0.5f, 0), new Color4b(255, 0, 0, 255)),
21 | new VertexColor(new Vector3(0, 0.5f, 0), new Color4b(0, 255, 0, 255)),
22 | new VertexColor(new Vector3(0.5f, -0.5f, 0), new Color4b(0, 0, 255, 255)),
23 | };
24 |
25 | vertexBuffer = new VertexBuffer(graphicsDevice, vertexData, BufferUsage.StaticDraw);
26 | shaderProgram = SimpleShaderProgram.Create(graphicsDevice);
27 |
28 | graphicsDevice.ClearColor = new Vector4(0, 0, 0, 1);
29 | graphicsDevice.BlendingEnabled = false;
30 | graphicsDevice.DepthTestingEnabled = false;
31 | }
32 |
33 | protected override void OnRender(double dt)
34 | {
35 | graphicsDevice.Clear(ClearBuffers.Color);
36 |
37 | graphicsDevice.VertexArray = vertexBuffer;
38 | graphicsDevice.ShaderProgram = shaderProgram;
39 | graphicsDevice.DrawArrays(PrimitiveType.Triangles, 0, 3);
40 | }
41 |
42 | protected override void OnResized(Vector2D size)
43 | {
44 | if (size.X == 0 || size.Y == 0)
45 | return;
46 |
47 | graphicsDevice.SetViewport(0, 0, (uint)size.X, (uint)size.Y);
48 | }
49 |
50 | protected override void OnUnload()
51 | {
52 | vertexBuffer.Dispose();
53 | shaderProgram.Dispose();
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/lib/TrippyTests/SimpleTriangle/SimpleTriangle.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | PreserveNewest
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lib/TrippyTests/TextureBatcherTest/Program.cs:
--------------------------------------------------------------------------------
1 | namespace TextureBatcherTest
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | new TextureBatcherTest().Run();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/TrippyTests/TextureBatcherTest/TextureBatcherTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | PreserveNewest
19 |
20 |
21 | PreserveNewest
22 |
23 |
24 | PreserveNewest
25 |
26 |
27 | PreserveNewest
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/lib/TrippyTests/TextureBatcherTest/ball.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/TextureBatcherTest/ball.png
--------------------------------------------------------------------------------
/lib/TrippyTests/TextureBatcherTest/diamond.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/TextureBatcherTest/diamond.png
--------------------------------------------------------------------------------
/lib/TrippyTests/TextureBatcherTest/particles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/TextureBatcherTest/particles.png
--------------------------------------------------------------------------------
/lib/TrippyTests/TextureBatcherTest/rectangle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/TextureBatcherTest/rectangle.png
--------------------------------------------------------------------------------
/lib/TrippyTests/TexturedTriangles/Program.cs:
--------------------------------------------------------------------------------
1 | namespace TexturedTriangles
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | new TexturedTriangles().Run();
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/TrippyTests/TexturedTriangles/TexturedTriangles.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | PreserveNewest
16 |
17 |
18 | PreserveNewest
19 |
20 |
21 | PreserveNewest
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/lib/TrippyTests/TexturedTriangles/satellite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/TexturedTriangles/satellite.png
--------------------------------------------------------------------------------
/lib/TrippyTests/TexturedTriangles/texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/lib/TrippyTests/TexturedTriangles/texture.png
--------------------------------------------------------------------------------
/lib/TrippyTests/TrippyTestBase/TrippyTestBase.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | annotations
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/logo.png
--------------------------------------------------------------------------------
/logo_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/logo_small.png
--------------------------------------------------------------------------------
/runtimes/linux-x64/native/libminiaudioex.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/runtimes/linux-x64/native/libminiaudioex.so
--------------------------------------------------------------------------------
/shaders/batch.frag:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | in vec4 vColor;
4 | in vec2 vTexCoords;
5 |
6 | layout(location = 0) out vec4 FragColor;
7 |
8 | uniform sampler2D tex;
9 |
10 | void main() {
11 | vec4 texColor = texture(tex, vTexCoords);
12 |
13 |
14 | // Discard fully transparent pixels
15 | if (vColor.a <= 0.0) {
16 | discard;
17 | }
18 | FragColor = texColor * vColor;
19 | }
--------------------------------------------------------------------------------
/shaders/batch.vert:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout (location = 0) in vec3 aPosition;
4 | layout (location = 1) in vec4 aColor;
5 | layout (location = 2) in vec2 aTexCoords;
6 |
7 | out vec4 vColor;
8 | out vec2 vTexCoords;
9 |
10 | uniform mat4 uMVP;
11 |
12 | void main() {
13 | gl_Position = uMVP * vec4(aPosition, 1.0);
14 | vColor = aColor;
15 | vTexCoords = aTexCoords;
16 | }
--------------------------------------------------------------------------------
/shaders/dummyShader.frag:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | // don't, glass will be fucked
4 | layout(early_fragment_tests) in;
5 | layout(location = 0) out vec4 color;
6 |
7 | in vec2 texCoords;
8 |
9 | uniform sampler2D blockTexture;
10 |
11 | void main() {
12 | color = texture(blockTexture, texCoords);
13 | }
--------------------------------------------------------------------------------
/shaders/dummyShader.vert:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout (location = 0) in uvec3 vPos;
4 | layout (location = 1) in uvec2 texCoord;
5 | layout (location = 2) in vec4 colour;
6 |
7 | uniform mat4 uMVP;
8 | uniform vec3 uChunkPos;
9 |
10 | out vec2 texCoords;
11 |
12 | void main() {
13 | gl_Position = uMVP * vec4(uChunkPos + vPos / 256. - 16, 1.0);
14 | texCoords = texCoord / 32768.;
15 | }
16 |
--------------------------------------------------------------------------------
/shaders/fxaa.vert:
--------------------------------------------------------------------------------
1 | #version 430 core
2 |
3 | out vec2 v_texCoord;
4 |
5 | void main(void)
6 | {
7 | vec4 vertices[4] = vec4[4](vec4(-1.0, -1.0, 0.0, 1.0), vec4(1.0, -1.0, 0.0, 1.0), vec4(-1.0, 1.0, 0.0, 1.0), vec4(1.0, 1.0, 0.0, 1.0));
8 | vec2 texCoord[4] = vec2[4](vec2(0.0, 0.0), vec2(1.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0));
9 |
10 | v_texCoord = texCoord[gl_VertexID];
11 |
12 | gl_Position = vertices[gl_VertexID];
13 | }
--------------------------------------------------------------------------------
/shaders/inc/fog.inc:
--------------------------------------------------------------------------------
1 |
2 | // Fog calculation function for consistent fog across all shaders
3 | // Supports linear, exponential and exp2 fog types
4 |
5 | // Define fog parameters needed by any shader using fog
6 | uniform float fogStart;
7 | uniform float fogEnd;
8 | uniform bool fogEnabled;
9 | uniform int fogType; // 0 = linear, 1 = exp, 2 = exp2
10 | uniform float fogDensity;
11 | uniform vec4 fogColour;
12 | uniform vec4 skyColour;
13 |
14 | // Standard fog calculation for all non-terrain shaders
15 | float getFog(float fogDepth) {
16 | // Calculate fog factor based on fog type
17 | float fogFactor = 1.0;
18 |
19 | if (fogType == 0) {
20 | // Linear fog
21 | fogFactor = (fogEnd - fogDepth) / (fogEnd - fogStart);
22 | } else if (fogType == 1) {
23 | // Exponential fog
24 | fogFactor = exp(-fogDensity * fogDepth);
25 | } else if (fogType == 2) {
26 | // Exponential squared fog
27 | fogFactor = exp(-fogDensity * fogDensity * fogDepth * fogDepth);
28 | }
29 |
30 | return clamp(fogFactor, 0.0, 1.0);
31 | }
32 |
33 | vec4 applyFog(vec4 color, float fogDepth) {
34 | if (!fogEnabled) {
35 | return color;
36 | }
37 |
38 | float fogFactor = getFog(fogDepth);
39 | return mix(fogColour, color, fogFactor);
40 | }
--------------------------------------------------------------------------------
/shaders/instantVertex.frag:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | // don't, glass will be fucked
4 | //layout(early_fragment_tests) in;
5 | layout(location = 0) out vec4 outColour;
6 |
7 | in vec2 texCoords;
8 | in vec4 colour;
9 | in vec4 viewPosition; // Changed from fogDepth to view position
10 |
11 | uniform vec4 fogColor;
12 | uniform float fogStart;
13 | uniform float fogEnd;
14 | uniform bool fogEnabled;
15 | uniform int fogType; // 0 = linear, 1 = exp, 2 = exp2
16 | uniform float fogDensity; // For exp and exp2 fog
17 |
18 | uniform sampler2D tex;
19 |
20 | void main() {
21 |
22 | vec4 texColour = texture(tex, texCoords);
23 | if (colour.a <= 0) {
24 | discard;
25 | }
26 | vec4 mixColour = texColour * colour;
27 | if (fogEnabled) {
28 | // Calculate fogDepth in the fragment shader
29 | float fogDepth = length(viewPosition.xyz); // Use distance from camera instead of just z
30 |
31 | // Calculate fog factor based on fog type
32 | float fogFactor = 1.0;
33 |
34 | if (fogType == 0) {
35 | // Linear fog
36 | fogFactor = (fogEnd - fogDepth) / (fogEnd - fogStart);
37 | } else if (fogType == 1) {
38 | // Exponential fog
39 | fogFactor = exp(-fogDensity * fogDepth);
40 | } else if (fogType == 2) {
41 | // Exponential squared fog
42 | fogFactor = exp(-fogDensity * fogDensity * fogDepth * fogDepth);
43 | }
44 |
45 | fogFactor = clamp(fogFactor, 0.0, 1.0);
46 |
47 | // Mix original color with fog color
48 | outColour = mix(fogColor, mixColour, fogFactor);
49 | } else {
50 | outColour = mixColour;
51 | }
52 | }
--------------------------------------------------------------------------------
/shaders/instantVertex.vert:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout (location = 0) in vec3 vPos;
4 | layout (location = 1) in vec2 texCoord;
5 | layout (location = 2) in vec4 color;
6 |
7 | uniform mat4 uMVP;
8 | uniform mat4 uModelView;
9 |
10 | out vec2 texCoords;
11 | out vec4 colour;
12 | out vec4 viewPosition; // Changed from fogDepth to full position
13 |
14 | void main() {
15 | gl_Position = uMVP * vec4(vPos, 1.0);
16 | viewPosition = uModelView * vec4(vPos, 1.0); // Pass the full view position
17 | texCoords = texCoord;
18 | colour = color;
19 | }
20 |
--------------------------------------------------------------------------------
/shaders/instantVertexColour.frag:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | // don't, glass will be fucked
4 | //layout(early_fragment_tests) in;
5 | layout(location = 0) out vec4 outColour;
6 |
7 | in vec4 colour;
8 | in vec4 viewPosition; // Changed from fogDepth to view position
9 |
10 | uniform vec4 fogColor;
11 | uniform float fogStart;
12 | uniform float fogEnd;
13 | uniform bool fogEnabled;
14 | uniform int fogType; // 0 = linear, 1 = exp, 2 = exp2
15 | uniform float fogDensity; // For exp and exp2 fog
16 |
17 | void main() {
18 | if (colour.a <= 0) {
19 | discard;
20 | }
21 |
22 | if (fogEnabled) {
23 | // Calculate fogDepth in the fragment shader
24 | float fogDepth = length(viewPosition.xyz); // Use distance from camera instead of just z
25 |
26 | // Calculate fog factor based on fog type
27 | float fogFactor = 1.0;
28 |
29 | if (fogType == 0) {
30 | // Linear fog
31 | fogFactor = (fogEnd - fogDepth) / (fogEnd - fogStart);
32 | } else if (fogType == 1) {
33 | // Exponential fog
34 | fogFactor = exp(-fogDensity * fogDepth);
35 | } else if (fogType == 2) {
36 | // Exponential squared fog
37 | fogFactor = exp(-fogDensity * fogDensity * fogDepth * fogDepth);
38 | }
39 |
40 | fogFactor = clamp(fogFactor, 0.0, 1.0);
41 |
42 | // Mix original color with fog color
43 | outColour = mix(fogColor, colour, fogFactor);
44 | } else {
45 | outColour = colour;
46 | }
47 | }
--------------------------------------------------------------------------------
/shaders/instantVertexColour.vert:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout (location = 0) in vec3 vPos;
4 | layout (location = 1) in vec4 color;
5 |
6 | uniform mat4 uMVP;
7 | uniform mat4 uModelView;
8 |
9 | out vec4 colour;
10 | out vec4 viewPosition; // Changed from fogDepth to full position
11 |
12 | void main() {
13 | viewPosition = uModelView * vec4(vPos, 1.0); // Pass the full view position
14 | gl_Position = uMVP * vec4(vPos, 1.0);
15 | colour = color;
16 | }
--------------------------------------------------------------------------------
/shaders/outline.frag:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout(location = 0) out vec4 color;
4 |
5 | //uniform vec4 uColor;
6 |
7 | void main() {
8 | color = vec4(0.1, 0.1, 0.1, 1);
9 | }
10 |
--------------------------------------------------------------------------------
/shaders/outline.vert:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout (location = 0) in vec3 vPos;
4 |
5 | uniform mat4 uView;
6 | uniform mat4 uProjection;
7 |
8 | void main() {
9 | gl_Position = uProjection * uView * vec4(vPos, 1.0);
10 | }
11 |
--------------------------------------------------------------------------------
/shaders/shader.frag:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | #include "inc/fog.inc"
4 |
5 | // don't, glass will be fucked
6 | //layout(early_fragment_tests) in;
7 | layout(location = 0) out vec4 colour;
8 |
9 | in vec2 texCoords;
10 | in vec4 tint;
11 | in float vertexDist;
12 |
13 | uniform sampler2D blockTexture;
14 |
15 | void main() {
16 |
17 | vec4 blockColour = texture(blockTexture, texCoords);
18 | float ratio = getFog(vertexDist);
19 | // extract skylight, 0 to 15
20 |
21 | colour = vec4(blockColour.rgb * tint.rgb, blockColour.a);
22 |
23 | if (colour.a <= 0) {
24 | discard;
25 | }
26 | // make it always opaque (for mipmapping)
27 | colour.a = max(colour.a, 1);
28 |
29 | // mix the fog colour between it and the sky
30 | vec4 mixedFogColour = mix(fogColour, skyColour, ratio);
31 | // mix fog
32 | colour = mix(colour, mixedFogColour, ratio);
33 | }
--------------------------------------------------------------------------------
/shaders/shader.vert:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout (location = 0) in uvec3 vPos;
4 | layout (location = 1) in uvec2 texCoord;
5 | layout (location = 2) in vec4 colour;
6 |
7 | uniform mat4 uMVP;
8 | uniform vec3 uChunkPos;
9 |
10 |
11 | out vec2 texCoords;
12 | out vec4 tint;
13 |
14 | out float vertexDist;
15 |
16 | uniform vec3 uCameraPos;
17 |
18 | const float m = 1 / 256.;
19 | const float n = 1 / 32768.;
20 |
21 | void main() {
22 | vec3 pos = uChunkPos + ((vPos * m) - 16);
23 | gl_Position = uMVP * vec4(pos, 1.0);
24 | texCoords = texCoord * n;
25 | tint = colour;
26 | vertexDist = length(pos - uCameraPos);
27 | }
28 |
--------------------------------------------------------------------------------
/shaders/simpleBlock.frag:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | // don't, glass will be fucked
4 | //layout(early_fragment_tests) in;
5 | layout(location = 0) out vec4 color;
6 |
7 | in vec2 texCoords;
8 | in vec4 tint;
9 |
10 | in vec3 vertexPos;
11 |
12 | uniform sampler2D blockTexture;
13 |
14 | void main() {
15 | vec4 blockColour = texture(blockTexture, texCoords);
16 | color = vec4(blockColour.rgb * tint.rgb, blockColour.a);
17 | if (color.a <= 0) {
18 | discard;
19 | }
20 | color.a = max(color.a, 1);
21 | }
--------------------------------------------------------------------------------
/shaders/simpleBlock.vert:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout (location = 0) in vec3 vPos;
4 | layout (location = 1) in vec2 texCoord;
5 | layout (location = 2) in vec4 tintValue;
6 |
7 | uniform mat4 uMVP;
8 |
9 |
10 | out vec2 texCoords;
11 | out vec4 tint;
12 |
13 | out vec3 vertexPos;
14 |
15 | void main() {
16 | gl_Position = uMVP * vec4(vPos, 1.0);
17 | texCoords = texCoord;
18 | tint = tintValue;
19 | vertexPos = vPos;
20 | }
21 |
--------------------------------------------------------------------------------
/shaders/waterShader.frag:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | #include "inc/fog.inc"
4 |
5 | layout(early_fragment_tests) in;
6 | layout(location = 0) out vec4 colour;
7 |
8 | in vec2 texCoords;
9 | in vec4 tint;
10 | in float vertexDist;
11 |
12 | uniform sampler2D blockTexture;
13 |
14 | void main() {
15 |
16 | vec4 blockColour = texture(blockTexture, texCoords);
17 | float ratio = getFog(vertexDist);
18 | // extract skylight, 0 to 15
19 |
20 | colour = vec4(blockColour.rgb * tint.rgb, blockColour.a);
21 |
22 | if (colour.a <= 0) {
23 | discard;
24 | }
25 | // mix the fog colour between it and the sky
26 | vec4 mixedFogColour = mix(fogColour, skyColour, ratio);
27 | // mix fog
28 | colour = mix(colour, mixedFogColour, ratio);
29 | }
--------------------------------------------------------------------------------
/shaders/waterShader.vert:
--------------------------------------------------------------------------------
1 | #version 440
2 |
3 | layout (location = 0) in uvec3 vPos;
4 | layout (location = 1) in uvec2 texCoord;
5 | layout (location = 2) in vec4 colour;
6 |
7 | uniform mat4 uMVP;
8 | uniform vec3 uChunkPos;
9 |
10 |
11 | out vec2 texCoords;
12 | out vec4 tint;
13 |
14 | out float vertexDist;
15 |
16 | uniform vec3 uCameraPos;
17 |
18 | void main() {
19 | vec3 pos = uChunkPos + vPos / 256. - 16;
20 | gl_Position = uMVP * vec4(pos, 1.0);
21 | texCoords = texCoord / 32768.;
22 | // compute tint (light * ao * direction)
23 | // per-face lighting
24 | // float lColor = a[direction]
25 | tint = colour;
26 | vertexDist = length(pos - uCameraPos);
27 | }
28 |
--------------------------------------------------------------------------------
/snd/hit/wood1.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/hit/wood1.wav
--------------------------------------------------------------------------------
/snd/hit/wood2.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/hit/wood2.wav
--------------------------------------------------------------------------------
/snd/hit/wood7.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/hit/wood7.wav
--------------------------------------------------------------------------------
/snd/steps/grass_step1.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/steps/grass_step1.wav
--------------------------------------------------------------------------------
/snd/steps/grass_step2.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/steps/grass_step2.wav
--------------------------------------------------------------------------------
/snd/steps/grass_step3.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/steps/grass_step3.wav
--------------------------------------------------------------------------------
/snd/stone1.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/stone1.wav
--------------------------------------------------------------------------------
/snd/stone2.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/stone2.wav
--------------------------------------------------------------------------------
/snd/stone3.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/stone3.wav
--------------------------------------------------------------------------------
/snd/stone4.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/stone4.wav
--------------------------------------------------------------------------------
/snd/stone5.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/stone5.wav
--------------------------------------------------------------------------------
/snd/tallgrass_step1.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/tallgrass_step1.wav
--------------------------------------------------------------------------------
/snd/tests.flac:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/tests.flac
--------------------------------------------------------------------------------
/snd/tests.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/snd/tests.ogg
--------------------------------------------------------------------------------
/src/GL/BlockVertexPacked.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 | using Molten;
3 |
4 | namespace BlockGame.GL;
5 |
6 | [StructLayout(LayoutKind.Explicit, Size = 14)]
7 | public struct BlockVertexPacked {
8 | [FieldOffset(0)] public ushort x;
9 | [FieldOffset(2)] public ushort y;
10 | [FieldOffset(4)] public ushort z;
11 | [FieldOffset(6)] public ushort u;
12 | [FieldOffset(8)] public ushort v;
13 | [FieldOffset(10)] public Color c;
14 | [FieldOffset(10)] public byte r;
15 | [FieldOffset(11)] public byte g;
16 | [FieldOffset(12)] public byte b;
17 | [FieldOffset(13)] public byte a;
18 |
19 | public BlockVertexPacked(float x, float y, float z, float u, float v, byte r, byte g, byte b, byte a) {
20 | this.x = (ushort)((x + 16) * 256);
21 | this.y = (ushort)((y + 16) * 256);
22 | this.z = (ushort)((z + 16) * 256);
23 | this.u = (ushort)(u * 32768);
24 | this.v = (ushort)(v * 32768);
25 | this.r = r;
26 | this.g = g;
27 | this.b = b;
28 | this.a = a;
29 | }
30 |
31 | public BlockVertexPacked(float x, float y, float z, float u, float v, Color c) {
32 | this.x = (ushort)((x + 16) * 256);
33 | this.y = (ushort)((y + 16) * 256);
34 | this.z = (ushort)((z + 16) * 256);
35 | this.u = (ushort)(u * 32768);
36 | this.v = (ushort)(v * 32768);
37 | r = c.R;
38 | g = c.G;
39 | b = c.B;
40 | a = c.A;
41 | }
42 |
43 | public BlockVertexPacked(ushort x, ushort y, ushort z, ushort u, ushort v, Color c) {
44 | this.x = x;
45 | this.y = y;
46 | this.z = z;
47 | this.u = u;
48 | this.v = v;
49 | this.c = c;
50 | }
51 | }
--------------------------------------------------------------------------------
/src/GL/FloatVAO.cs:
--------------------------------------------------------------------------------
1 | using Silk.NET.OpenGL;
2 |
3 | namespace BlockGame.GL;
4 |
5 | public class FloatVAO {
6 | public uint handle;
7 |
8 | public uint vbo;
9 |
10 | public uint count;
11 |
12 | public Silk.NET.OpenGL.GL GL;
13 |
14 | public FloatVAO() {
15 | GL = Game.GL;
16 | handle = GL.GenVertexArray();
17 | GL.BindVertexArray(handle);
18 | }
19 |
20 | public void upload(float[] data) {
21 | unsafe {
22 | vbo = GL.GenBuffer();
23 | GL.BindBuffer(BufferTargetARB.ArrayBuffer, vbo);
24 | count = (uint)data.Length;
25 | fixed (float* d = data) {
26 | GL.BufferData(BufferTargetARB.ArrayBuffer, (uint)(data.Length * sizeof(float)), d,
27 | BufferUsageARB.DynamicDraw);
28 | }
29 | }
30 |
31 | format();
32 | }
33 |
34 | public void upload(Span data) {
35 | unsafe {
36 | vbo = GL.GenBuffer();
37 | GL.BindBuffer(BufferTargetARB.ArrayBuffer, vbo);
38 | count = (uint)data.Length;
39 | fixed (float* d = data) {
40 | GL.BufferData(BufferTargetARB.ArrayBuffer, (uint)(data.Length * sizeof(float)), d,
41 | BufferUsageARB.DynamicDraw);
42 | }
43 | }
44 |
45 | format();
46 | }
47 |
48 | public void format() {
49 | unsafe {
50 | GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, (void*)0);
51 | GL.EnableVertexAttribArray(0);
52 | }
53 | }
54 |
55 | public void bind() {
56 | GL.BindVertexArray(handle);
57 | }
58 |
59 | public void render() {
60 | GL.DrawArrays(PrimitiveType.Triangles, 0, count);
61 | }
62 | }
--------------------------------------------------------------------------------
/src/GL/MatrixStack.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 |
3 | namespace BlockGame.GL;
4 |
5 | ///
6 | /// A MatrixStack class handling matrix operations.
7 | ///
8 | public class MatrixStack {
9 | ///
10 | /// The stack of matrices.
11 | ///
12 | public List stack;
13 |
14 | ///
15 | /// The current matrix.
16 | ///
17 | public Matrix4x4 top {
18 | get => stack[^1];
19 | set => stack[^1] = value;
20 | }
21 |
22 | ///
23 | /// Creates a new MatrixStack.
24 | ///
25 | public MatrixStack() {
26 | stack = new List();
27 | }
28 |
29 | ///
30 | /// Loads the identity matrix on top.
31 | ///
32 | public void loadIdentity() {
33 | top = Matrix4x4.Identity;
34 | }
35 |
36 | ///
37 | /// Pushes the current matrix to the stack.
38 | ///
39 | public void push() {
40 | stack.Add(top);
41 | }
42 |
43 | ///
44 | /// Pops the top matrix from the stack.
45 | ///
46 | public void pop() {
47 | stack.RemoveAt(stack.Count - 1);
48 | }
49 |
50 | ///
51 | /// Multiplies the current matrix by another matrix.
52 | ///
53 | public void multiply(Matrix4x4 matrix) {
54 | top *= matrix;
55 | }
56 |
57 | ///
58 | /// Sets the current matrix to another matrix.
59 | ///
60 | public void set(Matrix4x4 matrix) {
61 | top = matrix;
62 | }
63 | }
--------------------------------------------------------------------------------
/src/GL/VAO.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.GL;
2 |
3 | public interface VAO : IDisposable {
4 | public void upload(Span data, Span indices);
5 |
6 | public void format();
7 |
8 | public void bind();
9 |
10 | public uint render();
11 | }
--------------------------------------------------------------------------------
/src/GL/VertexTinted.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using System.Runtime.InteropServices;
3 | using Molten;
4 | using Color4b = BlockGame.GL.vertexformats.Color4b;
5 |
6 | namespace BlockGame.GL;
7 |
8 | [StructLayout(LayoutKind.Explicit, Size = 16)]
9 | public readonly struct VertexTinted {
10 | [FieldOffset(0)]
11 | public readonly float x;
12 | [FieldOffset(4)]
13 | public readonly float y;
14 | [FieldOffset(8)]
15 | public readonly float z;
16 | [FieldOffset(12)]
17 | public readonly byte r;
18 | [FieldOffset(13)]
19 | public readonly byte g;
20 | [FieldOffset(14)]
21 | public readonly byte b;
22 | [FieldOffset(15)]
23 | public readonly byte a;
24 | [FieldOffset(12)]
25 | public readonly Color c;
26 |
27 |
28 | public VertexTinted(float x, float y, float z, byte r, byte g, byte b, byte a) {
29 | this.x = x;
30 | this.y = y;
31 | this.z = z;
32 | this.r = r;
33 | this.g = g;
34 | this.b = b;
35 | this.a = a;
36 | }
37 |
38 | public VertexTinted(float x, float y, float z, Color c) {
39 | this.x = x;
40 | this.y = y;
41 | this.z = z;
42 | this.c = c;
43 | }
44 |
45 | public VertexTinted(ushort x, ushort y, ushort z, byte r, byte g, byte b, byte a) {
46 | this.x = x;
47 | this.y = y;
48 | this.z = z;
49 | this.r = r;
50 | this.g = g;
51 | this.b = b;
52 | this.a = a;
53 | }
54 |
55 | public VertexTinted(Vector3 pos, Color4b tint) {
56 | x = pos.X;
57 | y = pos.Y;
58 | z = pos.Z;
59 | r = tint.R;
60 | g = tint.G;
61 | b = tint.B;
62 | a = tint.A;
63 | }
64 | }
--------------------------------------------------------------------------------
/src/GL/vertexformats/BVertexColorTexture.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace BlockGame.GL.vertexformats;
5 |
6 | ///
7 | /// A vertex with position, color, and texture coordinates
8 | ///
9 | [StructLayout(LayoutKind.Sequential)]
10 | public struct BVertexColorTexture {
11 | /// The position of the vertex
12 | public Vector3 Position;
13 |
14 | /// The color of the vertex
15 | public Color4b Color;
16 |
17 | /// The texture coordinates of the vertex
18 | public Vector2 TexCoords;
19 |
20 | ///
21 | /// Creates a new BVertexColorTexture
22 | ///
23 | /// The position of the vertex
24 | /// The color of the vertex
25 | /// The texture coordinates of the vertex
26 | public BVertexColorTexture(Vector3 position, Color4b color, Vector2 texCoords) {
27 | Position = position;
28 | Color = color;
29 | TexCoords = texCoords;
30 | }
31 | }
--------------------------------------------------------------------------------
/src/render/model/Cube.cs:
--------------------------------------------------------------------------------
1 | using BlockGame.GL;
2 | using BlockGame.util;
3 | using Molten;
4 | using Molten.DoublePrecision;
5 |
6 | namespace BlockGame.model;
7 |
8 | ///
9 | /// A cube has 6 faces and 24 verts overall.
10 | /// It has a position, and vertices can be added to it.
11 | ///
12 | public class Cube {
13 | public readonly BlockVertexTinted[] vertices = new BlockVertexTinted[24];
14 |
15 | ///
16 | /// The position of the cube.
17 | ///
18 | public Vector3D position;
19 |
20 | ///
21 | /// The the relative position of the cube (from the base position)
22 | ///
23 | public Vector3D cubePos;
24 |
25 | ///
26 | /// The rotation of the cube (from the base position)
27 | ///
28 | public Vector3D rotation;
29 |
30 | ///
31 | /// The extents of the cube.
32 | ///
33 | public Vector3D ext;
34 |
35 | public Cube(Vector3D cubePos, Vector3D ext, double expand, UVPair[] uvs) {
36 | this.cubePos = cubePos - expand;
37 | this.ext = ext + expand * 2;
38 |
39 | if (uvs == null || uvs.Length != 6) {
40 | throw new ArgumentException("UVs must be of length 6");
41 | }
42 |
43 | var colour = Color.White;
44 | // generate vertices
45 | // west
46 |
47 | }
48 |
49 | public Cube pos(Vector3D pos) {
50 | position = pos;
51 | return this;
52 | }
53 |
54 | public Cube rot(Vector3D rot) {
55 | rotation = rot;
56 | return this;
57 | }
58 |
59 | public void render(double scale) {
60 |
61 | }
62 | }
--------------------------------------------------------------------------------
/src/ui/Settings.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.ui;
2 |
3 | public class Settings {
4 | public bool vSync = false;
5 | public int guiScale = 4;
6 | public bool AO = true;
7 | public bool smoothLighting = true;
8 | public int renderDistance = 8;
9 | public float FOV = 75;
10 | public int mipmapping = 0;
11 | //public int anisotropy = 8;
12 | public bool fxaa = false;
13 |
14 | public static readonly Settings instance = new();
15 |
16 | ///
17 | /// Whether to use framebuffer effects.
18 | ///
19 | public bool framebufferEffects => fxaa;
20 | }
--------------------------------------------------------------------------------
/src/ui/element/Image.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using BlockGame.GL;
3 | using Molten;
4 | using Rectangle = System.Drawing.Rectangle;
5 |
6 | namespace BlockGame.ui;
7 |
8 | public class Image : GUIElement {
9 |
10 | BTexture2D texture;
11 |
12 | public Image(Menu menu, string name, string path) : base(menu, name) {
13 | texture = Game.textureManager.get(path);
14 | guiPosition.Width = (int)texture.width;
15 | guiPosition.Height = (int)texture.height;
16 | }
17 |
18 | public void setPosition(Vector2I pos) {
19 | setPosition(new Rectangle(pos.X, pos.Y, guiPosition.Width, guiPosition.Height));
20 | }
21 |
22 | public override void draw() {
23 | Rectangle tex;
24 | Game.gui.draw(texture, new Vector2(bounds.X, bounds.Y));
25 | var centre = new Vector2(bounds.X + bounds.Width / 2f, bounds.Y + bounds.Height / 2f);
26 | }
27 | }
--------------------------------------------------------------------------------
/src/ui/element/LevelSelectButton.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.ui;
2 |
3 | public class LevelSelectButton : Button {
4 | public int levelIndex;
5 |
6 | public LevelSelectButton(Menu menu, string name, int index, string? text = default) : base(menu, name, true, text) {
7 | this.levelIndex = index;
8 | }
9 | }
--------------------------------------------------------------------------------
/src/ui/element/Text.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using Molten;
3 | using Rectangle = System.Drawing.Rectangle;
4 |
5 | namespace BlockGame.ui;
6 |
7 | public class Text : GUIElement {
8 |
9 | public bool shadowed = false;
10 |
11 | public Text(Menu menu, string name, string text) : base(menu, name) {
12 | this.text = text;
13 | unscaledSize = true;
14 | }
15 |
16 | public static Text createText(Menu menu, string name, Vector2I pos, string text) {
17 | var bounds = Game.gui.measureString(text);
18 | var guitext = new Text(menu, name, text);
19 | guitext.setPosition(new Rectangle(pos.X, pos.Y, (int)(pos.X + bounds.X), (int)(pos.Y + bounds.Y)));
20 | return guitext;
21 | }
22 |
23 |
24 | public override void draw() {
25 | if (shadowed) {
26 | Game.gui.drawStringShadowed(text, new Vector2(bounds.X, bounds.Y));
27 | }
28 | else {
29 | Game.gui.drawString(text, new Vector2(bounds.X, bounds.Y));
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/ui/element/TextBox.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 |
3 | namespace BlockGame.ui;
4 |
5 | public class TextBox : GUIElement {
6 |
7 | public string input;
8 |
9 | public static int padding => 2 * GUI.guiScale;
10 |
11 | public TextBox(Menu menu, string name) : base(menu, name) {
12 | }
13 |
14 |
15 | public override void draw() {
16 | Game.gui.draw(Game.gui.guiTexture, new Vector2(bounds.X, bounds.Y), Game.gui.grayButtonRect);
17 | Game.gui.drawString(input, new Vector2(bounds.X + padding, bounds.Y + padding));
18 | }
19 | }
--------------------------------------------------------------------------------
/src/ui/element/ToggleButton.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.ui;
2 |
3 | public class ToggleButton : Button {
4 |
5 | private List states;
6 | private int index;
7 |
8 | public ToggleButton(Menu menu, string name, bool wide, int initialState, params string[] states) : base(menu, name, wide) {
9 | index = initialState;
10 | this.states = new List(states);
11 | text = states[index];
12 | clicked += doClick;
13 | }
14 |
15 | public void doClick(GUIElement guiElement) {
16 | index++;
17 | index %= states.Count;
18 | text = states[index];
19 | }
20 |
21 | public string getState() {
22 | return states[index];
23 | }
24 |
25 | public int getIndex() {
26 | return index;
27 | }
28 | }
--------------------------------------------------------------------------------
/src/ui/menu/LoadingMenu.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 |
3 | namespace BlockGame.ui;
4 |
5 | public class LoadingMenu : Menu {
6 |
7 | public double counter;
8 | ///
9 | /// 0 - 3
10 | ///
11 | public int dots = 2;
12 |
13 | private Text text;
14 | private World world;
15 |
16 | public LoadingMenu() {
17 | text = new Text(this, "loadingText", "Loading world...");
18 | text.setPosition(new Rectangle(0, 0, 160, 40));
19 | text.centreContents();
20 | addElement(text);
21 |
22 | counter = 0;
23 | }
24 |
25 | public void load(World world) {
26 | this.world = world;
27 | Game.renderer.setWorld(world);
28 | Game.world.init();
29 | }
30 |
31 | public override void render(double dt, double interp) {
32 | base.render(dt, interp);
33 | counter += dt;
34 | if (counter > 0.5) {
35 | dots++;
36 | dots = dots % 3;
37 | counter = 0;
38 | text.text = "Loading fonts" + new string('.', dots + 1);
39 | }
40 |
41 | Game.instance.switchToScreen(Screen.GAME_SCREEN);
42 | world.loadAroundPlayer();
43 | Game.instance.lockMouse();
44 |
45 | }
46 |
47 | public void sleep() {
48 | Task.Delay(2000).Wait();
49 | }
50 | }
--------------------------------------------------------------------------------
/src/ui/menu/PauseMenu.cs:
--------------------------------------------------------------------------------
1 | using Molten;
2 |
3 | namespace BlockGame.ui {
4 | public class PauseMenu : Menu {
5 | public PauseMenu() {
6 | var backToGame = new Button(this, "backToGame", false, "Back to the game");
7 | backToGame.setPosition(new Vector2I(0, 0));
8 | backToGame.centreContents();
9 | backToGame.clicked += _ => { Screen.GAME_SCREEN.backToGame(); };
10 | var settings = new Button(this, "settings", false, "Settings");
11 | settings.setPosition(new Vector2I(0, 24));
12 | settings.centreContents();
13 | settings.clicked += _ => { Screen.GAME_SCREEN.openSettings(); };
14 | var mainMenu = new Button(this, "mainMenu", false, "Quit to Main Menu");
15 | mainMenu.setPosition(new Vector2I(0, 48));
16 | mainMenu.centreContents();
17 | mainMenu.clicked += returnToMainMenu;
18 | addElement(backToGame);
19 | addElement(settings);
20 | addElement(mainMenu);
21 | }
22 |
23 | public static void returnToMainMenu(GUIElement guiElement) {
24 | // save world
25 | Game.world.worldIO.save(Game.world, Game.world.name);
26 |
27 | Game.instance.executeOnMainThread(() => Game.instance.switchToScreen(Screen.MAIN_MENU_SCREEN));
28 | }
29 |
30 | public override void update(double dt) {
31 | base.update(dt);
32 | // update ingame too!
33 | if (!Game.world.paused) {
34 | Screen.GAME_SCREEN.INGAME_MENU.update(dt);
35 | }
36 | }
37 |
38 | public override void draw() {
39 | base.draw();
40 | Screen.GAME_SCREEN.INGAME_MENU.draw();
41 | }
42 |
43 | public override void postDraw() {
44 | base.postDraw();
45 | Screen.GAME_SCREEN.INGAME_MENU.postDraw();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/src/ui/screen/MainMenuScreen.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.ui;
2 |
3 | public class MainMenuScreen : Screen {
4 |
5 | public override void activate() {
6 | currentMenu = Menu.MAIN_MENU;
7 | }
8 | }
--------------------------------------------------------------------------------
/src/util/ClientOnly.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.util;
2 |
3 | [AttributeUsage(AttributeTargets.All)]
4 | public class ClientOnly : Attribute {
5 |
6 | }
--------------------------------------------------------------------------------
/src/util/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.util;
2 |
3 | public static class Constants {
4 | public const int crosshairSize = 10;
5 | public const int crosshairThickness = 2;
6 | public const long MEGABYTES = 1 * 1024 * 1024;
7 | public const float maxPitch = 89;
8 | public const int initialWidth = 1440;
9 | public const int initialHeight = 960;
10 | public const double gravity = 20;
11 | public const double maxAccel = 50;
12 | public const double jumpSpeed = 7;
13 | public const double liquidSwimUpSpeed = 0.6;
14 | public const double liquidSurfaceBoost = 0.2;
15 | public const double maxVSpeed = 200;
16 | public const double friction = 0.82;
17 | public const double airFriction = 0.82;
18 | public const double flyFriction = 0.89;
19 | public const double verticalFriction = 0.99;
20 | public const double liquidFriction = 0.86;
21 | public const double epsilon = 0.0001;
22 | public const double epsilonGroundCheck = 0.01;
23 | public static double moveSpeed = 1.25;
24 | public const double groundMoveSpeed = 1;
25 | public const double airMoveSpeed = 0.75;
26 | public const double airFlySpeed = 1.25;
27 | public const double liquidMoveSpeed = 0.45;
28 | public const double sneakFactor = 0.28;
29 | public const float RAYCASTSTEP = 1 / 32f;
30 | public const float RAYCASTDIST = 6f;
31 | public const double breakDelay = 16;
32 | public const double placeDelay = 16;
33 | public const double flyModeDelay = 0.4;
34 | }
--------------------------------------------------------------------------------
/src/util/FIFOStack.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.util;
2 |
3 | public class FIFOStack : LinkedList {
4 | public T pop() {
5 | T first = First.Value;
6 | RemoveFirst();
7 | return first;
8 | }
9 |
10 | public void push(T obj) {
11 | AddFirst(obj);
12 | }
13 |
14 | public T peek() {
15 | return First.Value;
16 | }
17 |
18 | public T peek(int index) {
19 | return this.ElementAt(index);
20 | }
21 |
22 | //Remove(T object) implemented in LinkedList
23 | }
--------------------------------------------------------------------------------
/src/util/FixedArrayPool.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Concurrent;
2 |
3 | namespace BlockGame.util;
4 |
5 | public class FixedArrayPool {
6 |
7 | // how many items the pool can hold before it gets trimmed
8 | private const int MAX_ITEMS_BEFORE_TRIM = 1024;
9 |
10 | private readonly ConcurrentBag _objects;
11 |
12 | public readonly int arrayLength;
13 |
14 | private int grabCtr;
15 | private int putBackCtr;
16 |
17 | public FixedArrayPool(int arrayLength) {
18 | this.arrayLength = arrayLength;
19 | _objects = new ConcurrentBag();
20 | }
21 |
22 | public T[] grab() {
23 | grabCtr++;
24 | //Console.Out.WriteLine("diff: " + (grabCtr - putBackCtr));
25 | return _objects.TryTake(out var item) ? item : new T[arrayLength];
26 | }
27 |
28 | public void putBack(T[] item) {
29 | putBackCtr++;
30 | _objects.Add(item);
31 | }
32 |
33 | public void trim() {
34 | if (_objects.Count > MAX_ITEMS_BEFORE_TRIM) {
35 | // nuke all the old objects
36 | _objects.Clear();
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/src/util/ItemSlot.cs:
--------------------------------------------------------------------------------
1 | using System.Numerics;
2 | using BlockGame.ui;
3 | using Molten;
4 | using Rectangle = System.Drawing.Rectangle;
5 |
6 | namespace BlockGame.util;
7 |
8 | ///
9 | /// Handles an ItemStack + item movement + gui-related code.
10 | ///
11 | public class ItemSlot {
12 |
13 | public const int SLOTSIZE = 20;
14 | public const int PADDING = 2;
15 | public const int ITEMSIZE = 16;
16 | public const int ITEMSIZEHALF = 8;
17 |
18 | public ItemStack stack;
19 |
20 | public Rectangle rect;
21 | public Vector2I itemPos;
22 |
23 | public ItemSlot(int x, int y) {
24 | rect = new Rectangle(x, y, SLOTSIZE, SLOTSIZE);
25 | itemPos = new Vector2I(x + PADDING, y + PADDING);
26 | }
27 | }
--------------------------------------------------------------------------------
/src/util/ItemStack.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.util;
2 |
3 | public class ItemStack {
4 | public ushort block;
5 | public int quantity;
6 |
7 | public ItemStack(ushort block, int quantity) {
8 | this.block = block;
9 | this.quantity = quantity;
10 | }
11 |
12 | public ItemStack copy() {
13 | return new ItemStack(block, quantity);
14 | }
15 | }
--------------------------------------------------------------------------------
/src/util/Metrics.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.util;
2 |
3 | public class Metrics {
4 | public int renderedVerts;
5 | public int renderedChunks;
6 | public int renderedSubChunks;
7 |
8 | public void clear() {
9 | renderedVerts = 0;
10 | renderedChunks = 0;
11 | renderedSubChunks = 0;
12 | }
13 | }
--------------------------------------------------------------------------------
/src/util/ProgressUpdater.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.util;
2 |
3 | public interface ProgressUpdater {
4 | public void start(string? stage);
5 | public void stage(string? stage);
6 | public void update(float progress);
7 | }
8 |
--------------------------------------------------------------------------------
/src/util/ServerOnly.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.util;
2 |
3 | [AttributeUsage(AttributeTargets.All)]
4 | public class ServerOnly : Attribute {
5 |
6 | }
--------------------------------------------------------------------------------
/src/util/TextureManager.cs:
--------------------------------------------------------------------------------
1 | using BlockGame.GL;
2 | using Silk.NET.OpenGL;
3 |
4 | namespace BlockGame.util;
5 |
6 | public class TextureManager {
7 |
8 | public Silk.NET.OpenGL.GL GL;
9 |
10 | public BTexture2D blockTextureGUI;
11 | public BTexture2D background;
12 | public BTextureAtlas blockTexture;
13 | public BTexture2D lightTexture;
14 |
15 | public Dictionary textures = new();
16 | public BTexture2D waterOverlay;
17 |
18 | public BTexture2D sunTexture;
19 |
20 | public TextureManager(Silk.NET.OpenGL.GL GL) {
21 | this.GL = GL;
22 |
23 | blockTextureGUI = new BTexture2D("textures/blocks.png");
24 | background = new BTexture2D("textures/bg.png");
25 | blockTexture = new BTextureAtlas("textures/blocks.png", 16);
26 | lightTexture = new BTexture2D("textures/lightmap.png");
27 | waterOverlay = new BTexture2D("textures/water.png");
28 | sunTexture = new BTexture2D("textures/sun_03.png");
29 | }
30 |
31 | public BTexture2D get(string path) {
32 | if (!textures.TryGetValue(path, out _)) {
33 | textures[path] = new BTexture2D(path);;
34 | }
35 | return textures[path];
36 | }
37 | }
--------------------------------------------------------------------------------
/src/util/TimerAction.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame.util;
2 |
3 | public sealed record TimerAction(Action action, double lastCalled, bool repeating, long interval) {
4 | public readonly Action action = action;
5 | public double lastCalled = lastCalled;
6 | public bool repeating = repeating;
7 | ///
8 | /// Interval (in milliseconds)
9 | ///
10 | public long interval = interval;
11 |
12 | ///
13 | /// Should this action happen or is it disabled? (disabled timers are scheduled for deletion in the queue)
14 | ///
15 | public bool enabled = true;
16 |
17 | public bool Equals(TimerAction? other) {
18 | return ReferenceEquals(this, other);
19 | }
20 |
21 | public override int GetHashCode() {
22 | return action.GetHashCode();
23 | }
24 | }
--------------------------------------------------------------------------------
/src/util/font/BDFLoader.cs:
--------------------------------------------------------------------------------
1 | using FontStashSharp.Interfaces;
2 |
3 | namespace BlockGame.util.font;
4 |
5 | public class BDFLoader : IFontLoader {
6 | public IFontSource Load(byte[] data) {
7 | return new BDFSource(data);
8 | }
9 | }
--------------------------------------------------------------------------------
/src/util/font/BdfChar.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace BlockGame.util.font;
4 |
5 | public class BdfChar
6 | {
7 | public int Encoding { get; set; }
8 | public int Width { get; set; }
9 | public int Height { get; set; }
10 | public int XOffset { get; set; }
11 | public int YOffset { get; set; }
12 | public int XAdvance { get; set; }
13 | public byte[,] Bitmap { get; set; }
14 |
15 | public string DebugPrint()
16 | {
17 | var sb = new StringBuilder();
18 | for (int row = 0; row < Height; row++)
19 | {
20 | for (int col = 0; col < Width; col++)
21 | {
22 | sb.Append(Bitmap[row, col] == 1 ? "*" : " ");
23 | }
24 | sb.AppendLine();
25 | }
26 | return sb.ToString();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/util/font/FontLoader.cs:
--------------------------------------------------------------------------------
1 | using FontStashSharp;
2 |
3 | namespace BlockGame.util.font;
4 |
5 | public class FontLoader {
6 | public TextRenderer renderer;
7 | public TextRenderer3D renderer3D;
8 | public FontSystem fontSystem;
9 | public FontSystem fontSystemThin;
10 |
11 | public FontLoader(string name, string name2) {
12 | var settings = new FontSystemSettings
13 | {
14 | FontLoader = new BDFLoader(),
15 | TextureWidth = 256,
16 | TextureHeight = 256
17 | };
18 | renderer = new TextRenderer();
19 | renderer3D = new TextRenderer3D();
20 |
21 | // todo hack something together in a better way
22 | fontSystem = new FontSystem(settings);
23 | fontSystem.AddFont(File.ReadAllBytes(name));
24 | fontSystemThin = new FontSystem(settings);
25 | fontSystemThin.AddFont(File.ReadAllBytes(name2));
26 | }
27 | }
--------------------------------------------------------------------------------
/src/util/font/TextRenderer.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 | using System.Numerics;
3 | using BlockGame.GL;
4 | using FontStashSharp;
5 | using FontStashSharp.Interfaces;
6 | using Color4b = BlockGame.GL.vertexformats.Color4b;
7 | using Rectangle = System.Drawing.Rectangle;
8 |
9 | namespace BlockGame.util.font;
10 |
11 | public class TextRenderer : IFontStashRenderer {
12 | private readonly SpriteBatch tb;
13 | private readonly BTexture2DManager _textureManager;
14 |
15 | public ITexture2DManager TextureManager => _textureManager;
16 |
17 | public TextRenderer() {
18 | _textureManager = new BTexture2DManager();
19 | tb = Game.graphics.mainBatch;
20 | }
21 |
22 | public void Draw(object texture, Vector2 pos, ref Matrix4x4 worldMatrix, Rectangle? src, FSColor color, float rotation, Vector2 scale, float depth) {
23 | var tex = (BTexture2D)texture;
24 | var intPos = new Vector2((int)pos.X, (int)pos.Y);
25 | // texture height
26 | tb.Draw(tex,
27 | intPos,
28 | src,
29 | new Color4b(color.R, color.G, color.B, color.A),
30 | scale,
31 | rotation,
32 | Vector2.Zero,
33 | depth);
34 | }
35 | }
36 |
37 | internal static class Utility {
38 | public static Vector2 ToSystemNumeric(Point p) {
39 | return new Vector2(p.X, p.Y);
40 | }
41 |
42 | public static Color4b ToTrippy(this FSColor c) {
43 | return new Color4b(c.R, c.G, c.B, c.A);
44 | }
45 |
46 | public static FSColor toFS(this Color4b c) {
47 | return new FSColor(c.R, c.G, c.B, c.A);
48 | }
49 | }
--------------------------------------------------------------------------------
/src/util/font/Texture2DManager.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 | using BlockGame.GL;
3 | using FontStashSharp.Interfaces;
4 | using Silk.NET.OpenGL;
5 |
6 | namespace BlockGame.util.font;
7 |
8 | public class BTexture2DManager : ITexture2DManager {
9 |
10 | public BTexture2DManager() {
11 |
12 | }
13 |
14 | public object CreateTexture(int width, int height) => new BTexture2D((uint)width, (uint)height);
15 |
16 | public Point GetTextureSize(object texture) {
17 | var xnaTexture = (BTexture2D)texture;
18 |
19 | return new Point((int)xnaTexture.width, (int)xnaTexture.height);
20 | }
21 |
22 | public void SetTextureData(object texture, Rectangle bounds, byte[] data) {
23 | var xnaTexture = (BTexture2D)texture;
24 |
25 | xnaTexture.SetData(data, bounds.X, bounds.Y, (uint)bounds.Width, (uint)bounds.Height);
26 | }
27 | }
--------------------------------------------------------------------------------
/src/util/math/ContainmentType.cs:
--------------------------------------------------------------------------------
1 | namespace System.Numerics
2 | {
3 | ///
4 | /// Defines how the bounding volumes intersects or contain one another.
5 | ///
6 | public enum ContainmentType
7 | {
8 | ///
9 | /// Indicates that there is no overlap between two bounding volumes.
10 | ///
11 | Disjoint,
12 | ///
13 | /// Indicates that one bounding volume completely contains another volume.
14 | ///
15 | Contains,
16 | ///
17 | /// Indicates that bounding volumes partially overlap one another.
18 | ///
19 | Intersects
20 | }
21 | }
--------------------------------------------------------------------------------
/src/util/math/PlaneIntersectionType.cs:
--------------------------------------------------------------------------------
1 | namespace System.Numerics
2 | {
3 | ///
4 | /// Defines the intersection between a and a bounding volume.
5 | ///
6 | public enum PlaneIntersectionType
7 | {
8 | ///
9 | /// There is no intersection, the bounding volume is in the negative half space of the plane.
10 | ///
11 | Front,
12 | ///
13 | /// There is no intersection, the bounding volume is in the positive half space of the plane.
14 | ///
15 | Back,
16 | ///
17 | /// The plane is intersected.
18 | ///
19 | Intersecting
20 | }
21 | }
--------------------------------------------------------------------------------
/src/util/xNBT/NBT.cs:
--------------------------------------------------------------------------------
1 | using K4os.Compression.LZ4.Streams;
2 |
3 | namespace BlockGame.util.xNBT;
4 |
5 | public static class NBT {
6 | public static NBTCompound readCompressed(Stream stream) {
7 | using var decompress = LZ4Stream.Decode(stream);
8 | using var reader = new BinaryReader(decompress);
9 | var nbt = NBTTag.read(reader);
10 | if (nbt is NBTCompound compound) {
11 | return compound;
12 | }
13 | throw new IOException("Root tag must be a compound!");
14 | }
15 |
16 | public static void writeCompressed(NBTCompound nbt, Stream stream) {
17 | using var compress = LZ4Stream.Encode(stream);
18 | using var writer = new BinaryWriter(compress);
19 | NBTTag.write(nbt, writer);
20 | }
21 |
22 | public static void writeFile(NBTCompound nbt, string name) {
23 | using var stream = new FileStream(name, FileMode.Create, FileAccess.Write);
24 | writeCompressed(nbt, stream);
25 | }
26 |
27 | public static NBTCompound readFile(string name) {
28 | using var stream = new FileStream(name, FileMode.Open, FileAccess.Read);
29 | return readCompressed(stream);
30 | }
31 | }
--------------------------------------------------------------------------------
/src/world/BlockUpdate.cs:
--------------------------------------------------------------------------------
1 | using Molten;
2 |
3 | namespace BlockGame;
4 |
5 | public readonly record struct BlockUpdate(Vector3I position, int tick) {
6 | public readonly Vector3I position = position;
7 | public readonly int tick = tick;
8 | };
--------------------------------------------------------------------------------
/src/world/HeightMap.cs:
--------------------------------------------------------------------------------
1 | using BlockGame.util;
2 |
3 | namespace BlockGame;
4 |
5 | public class HeightMap : IDisposable {
6 |
7 | private static FixedArrayPool heightPool = new(Chunk.CHUNKSIZE * Chunk.CHUNKSIZE);
8 |
9 | public byte[] height;
10 | public Chunk chunk;
11 |
12 | public HeightMap(Chunk chunk) {
13 | this.chunk = chunk;
14 | height = heightPool.grab();
15 | Array.Clear(height);
16 | }
17 |
18 | public byte get(int x, int z) {
19 | return height[x * Chunk.CHUNKSIZE + z];
20 | }
21 |
22 | public void set(int x, int z, byte val) {
23 | // pack it back inside
24 | height[x * Chunk.CHUNKSIZE + z] = val;
25 | }
26 | private void ReleaseUnmanagedResources() {
27 | heightPool.putBack(height);
28 | }
29 | public void Dispose() {
30 | ReleaseUnmanagedResources();
31 | GC.SuppressFinalize(this);
32 | }
33 | ~HeightMap() {
34 | ReleaseUnmanagedResources();
35 | }
36 | }
--------------------------------------------------------------------------------
/src/world/Humanoid.cs:
--------------------------------------------------------------------------------
1 | using Molten.DoublePrecision;
2 |
3 | namespace BlockGame;
4 |
5 | public class Humanoid : Entity {
6 | public Humanoid(World world) : base(world) {
7 | }
8 |
9 | public void update(double dt) {
10 | }
11 |
12 | public void render(double dt, double interp) {
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/src/world/Inventory.cs:
--------------------------------------------------------------------------------
1 | using BlockGame.util;
2 |
3 | namespace BlockGame;
4 |
5 | public class Inventory {
6 | public ItemStack[] slots = new ItemStack[10];
7 | ///
8 | /// Selected index
9 | ///
10 | public int selected;
11 |
12 | public Inventory() {
13 | for (int i = 0; i < slots.Length; i++) {
14 | slots[i] = new ItemStack((ushort)(i + 1), Random.Shared.Next(15));
15 | }
16 | // replace water with something useful
17 | //slots[Block.WATER.id - 1] = new ItemStack(Block.LEAVES.id, 1);
18 | }
19 |
20 | public ItemStack getSelected() {
21 | return slots[selected];
22 | }
23 | }
--------------------------------------------------------------------------------
/src/world/LightNode.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame;
2 |
3 | public readonly record struct LightNode(int x, int y, int z, Chunk chunk) {
4 | public readonly int x = x;
5 | public readonly int y = y;
6 | public readonly int z = z;
7 | public readonly Chunk chunk = chunk;
8 | }
9 |
10 | public readonly record struct LightRemovalNode(int x, int y, int z, byte value, Chunk chunk) {
11 | public readonly int x = x;
12 | public readonly int y = y;
13 | public readonly int z = z;
14 | public readonly byte value = value;
15 | public readonly Chunk chunk = chunk;
16 | }
--------------------------------------------------------------------------------
/src/world/Region.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame;
2 |
3 | public class Region {
4 | public RegionCoord coord;
5 |
6 | public Dictionary chunks = new();
7 | }
--------------------------------------------------------------------------------
/src/world/TickAction.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 | using Molten;
3 |
4 | namespace BlockGame;
5 |
6 | [StructLayout(LayoutKind.Auto)]
7 | public readonly record struct TickAction(Vector3I pos, Action action, int tick) {
8 | public readonly Vector3I pos = pos;
9 | public readonly Action action = action;
10 | public readonly int tick = tick;
11 |
12 |
13 | // two tickactions are equal if the positions are equal and the tick is equal
14 | public bool Equals(TickAction other) {
15 | return pos.Equals(other.pos) && tick == other.tick;
16 | }
17 | public override int GetHashCode() {
18 | unchecked {
19 | return pos.GetHashCode() * 397 ^ tick;
20 | }
21 | }
22 | };
--------------------------------------------------------------------------------
/src/world/chunk/BlockData.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame;
2 |
3 | public interface BlockData {
4 | public ushort this[int x, int y, int z] { get; set; }
5 |
6 | public byte getLight(int x, int y, int z);
7 |
8 | public byte skylight(int x, int y, int z);
9 |
10 | public byte blocklight(int x, int y, int z);
11 |
12 | public void setSkylight(int x, int y, int z, byte val);
13 |
14 | public void setBlocklight(int x, int y, int z, byte val);
15 | }
--------------------------------------------------------------------------------
/src/world/chunk/ChunkComparer.cs:
--------------------------------------------------------------------------------
1 | using Molten.DoublePrecision;
2 |
3 | namespace BlockGame;
4 |
5 | public class ChunkComparer : IComparer {
6 | public Player player;
7 |
8 | public ChunkComparer(Player player) {
9 | this.player = player;
10 | }
11 | public int Compare(Chunk x, Chunk y) {
12 | return (int)(Vector2D.Distance((Vector2D)x.worldPos, new Vector2D((int)player.position.X, (int)player.position.Z)) -
13 | Vector2D.Distance((Vector2D)y.worldPos, new Vector2D((int)player.position.X, (int)player.position.Z)));
14 | }
15 | }
--------------------------------------------------------------------------------
/src/world/chunk/ChunkLoadTicket.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame;
2 |
3 | public readonly record struct ChunkLoadTicket(ChunkCoord chunkCoord, ChunkStatus level) {
4 | public readonly ChunkCoord chunkCoord = chunkCoord;
5 | public readonly ChunkStatus level = level;
6 | }
--------------------------------------------------------------------------------
/src/world/chunk/EmptyBlockData.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | namespace BlockGame;
4 |
5 | public class EmptyBlockData : BlockData {
6 |
7 | public ushort this[int x, int y, int z] {
8 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
9 | get => 0;
10 | set { }
11 | }
12 |
13 | public byte getLight(int x, int y, int z) {
14 | // only skylight, zero blocklight
15 | return 15;
16 | }
17 |
18 | public byte skylight(int x, int y, int z) {
19 | return 15;
20 | }
21 |
22 | public byte blocklight(int x, int y, int z) {
23 | return 0;
24 | }
25 |
26 | public void setSkylight(int x, int y, int z, byte val) {
27 | }
28 |
29 | public void setBlocklight(int x, int y, int z, byte val) {
30 | }
31 | }
--------------------------------------------------------------------------------
/src/world/worldgen/WorldgenUtil.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame;
2 |
3 | public class WorldgenUtil {
4 |
5 | }
--------------------------------------------------------------------------------
/src/world/worldgen/feature/Feature.cs:
--------------------------------------------------------------------------------
1 | using BlockGame.util;
2 |
3 | namespace BlockGame;
4 |
5 | public abstract class Feature {
6 | public abstract void place(World world, XRandom random, int x, int y, int z);
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/world/worldgen/generator/SimpleWorldGenerator.cs:
--------------------------------------------------------------------------------
1 | using BlockGame.util;
2 |
3 | namespace BlockGame;
4 |
5 | public partial class SimpleWorldGenerator : WorldGenerator {
6 |
7 | public World world;
8 |
9 | public FastNoiseLite noise;
10 | public FastNoiseLite noise2;
11 | public FastNoiseLite treenoise;
12 |
13 | public XRandom random;
14 |
15 | public SimpleWorldGenerator(World world) {
16 | this.world = world;
17 | }
18 |
19 | public void setup(int seed) {
20 | random = new XRandom(seed);
21 | noise = new FastNoiseLite(seed);
22 | noise2 = new FastNoiseLite(random.Next(seed));
23 | treenoise = new FastNoiseLite(random.Next(seed));
24 | noise.SetFrequency(0.02f);
25 | noise2.SetFrequency(0.05f);
26 | treenoise.SetFrequency(1f);
27 | }
28 |
29 | public float getNoise(int x, int z) {
30 | // we want to have multiple octaves
31 | return (8f * noise.GetNoise(1 / 8f * x, 1 / 8f * z)
32 | + 4f * noise.GetNoise(1 / 4f * x, 1 / 4f * z)
33 | + 2f * noise.GetNoise(1 / 2f * x, 1 / 2f * z)
34 | + 1f * noise.GetNoise(1 * x, 1 * z)
35 | + 0.5f * noise.GetNoise(2 * x, 2 * z)
36 | + 1 / 4f * noise.GetNoise(4 * x, 4 * z)) / (8f + 4f + 2f + 1f + 0.5f + 1 / 4f);
37 | }
38 |
39 | // 3d noise!
40 | public float getNoise(int x, int y, int z) {
41 | // we want to have multiple octaves
42 | return (8f * noise.GetNoise(1 / 8f * x, 1 / 8f * y, 1 / 8f * z)
43 | + 4f * noise.GetNoise(1 / 4f * x, 1 / 4f * y, 1 / 4f * z)
44 | + 2f * noise.GetNoise(1 / 2f * x, 1 / 2f * y, 1 / 2f * z)
45 | + 1f * noise.GetNoise(1 * x, 1 * y, 1 * z)
46 | + 0.5f * noise.GetNoise(2 * x, 2 * y, 2 * z)
47 | + 1 / 4f * noise.GetNoise(4 * x, 4 * y, 4 * z)) / (8f + 4f + 2f + 1f + 0.5f + 1 / 4f);
48 | }
49 |
50 | public float getNoise2(int x, int z) {
51 | // we want to have multiple octaves
52 | return noise2.GetNoise(1 * x, 1 * z);
53 | }
54 |
55 | }
--------------------------------------------------------------------------------
/src/world/worldgen/generator/TechDemoChunkGenerator.cs:
--------------------------------------------------------------------------------
1 | using BlockGame.util;
2 |
3 | namespace BlockGame;
4 |
5 | public partial class TechDemoWorldGenerator {
6 | public void generate(ChunkCoord coord) {
7 | var chunk = world.getChunk(coord);
8 | for (int x = 0; x < Chunk.CHUNKSIZE; x++) {
9 | for (int z = 0; z < Chunk.CHUNKSIZE; z++) {
10 | var worldPos = World.toWorldPos(chunk.coord.x, chunk.coord.z, x, 0, z);
11 | // -1 to 1
12 | // transform to the range 10 - 30
13 | var height = noise.GetNoise(worldPos.X, worldPos.Z) * 20 + 20;
14 | for (int y = 0; y < height - 1; y++) {
15 | chunk.setBlock(x, y, z, Block.DIRT.id);
16 | }
17 | chunk.setBlock(x, (int)height, z, Block.GRASS.id);
18 | }
19 | }
20 | chunk.status = ChunkStatus.GENERATED;
21 | }
22 |
23 | public void populate(ChunkCoord coord) {
24 | var chunk = world.getChunk(coord);
25 | chunk.status = ChunkStatus.POPULATED;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/world/worldgen/generator/TechDemoWorldGenerator.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame;
2 |
3 | public partial class TechDemoWorldGenerator : WorldGenerator {
4 |
5 | public FastNoiseLite noise;
6 | public World world;
7 |
8 |
9 |
10 | public TechDemoWorldGenerator(World world) {
11 | this.world = world;
12 | }
13 |
14 | public void setup(int seed) {
15 | noise = new FastNoiseLite(seed);
16 | noise.SetFrequency(0.003f);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/world/worldgen/generator/WorldGenerator.cs:
--------------------------------------------------------------------------------
1 | namespace BlockGame;
2 |
3 | public interface WorldGenerator {
4 | public void setup(int seed);
5 |
6 | public void generate(ChunkCoord coord);
7 |
8 | public void populate(ChunkCoord coord);
9 | }
--------------------------------------------------------------------------------
/textures/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/bg.png
--------------------------------------------------------------------------------
/textures/blocks.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/blocks.png
--------------------------------------------------------------------------------
/textures/character.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/character.png
--------------------------------------------------------------------------------
/textures/creative_inventory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/creative_inventory.png
--------------------------------------------------------------------------------
/textures/debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/debug.png
--------------------------------------------------------------------------------
/textures/gui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/gui.png
--------------------------------------------------------------------------------
/textures/inventory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/inventory.png
--------------------------------------------------------------------------------
/textures/lightmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/lightmap.png
--------------------------------------------------------------------------------
/textures/sun_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/sun_01.png
--------------------------------------------------------------------------------
/textures/sun_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/sun_02.png
--------------------------------------------------------------------------------
/textures/sun_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/sun_03.png
--------------------------------------------------------------------------------
/textures/title.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/title.png
--------------------------------------------------------------------------------
/textures/water.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/textures/water.png
--------------------------------------------------------------------------------
/todolist.txt:
--------------------------------------------------------------------------------
1 | - add ores
2 | - running functionality for the character
3 |
4 | immediate todolist:
5 | - none for now! :P
6 |
7 | ötletek:
8 | -legyenek missziók
9 | -minden ore-nak legyen haszna
10 | -menüpontok elérési útvonala legyen rövid (old world-szeruen, sok opció legyen elérhető egyidejűleg a képernyőn)
11 | -mobok támadjanak gyakrabban és éjjel-nappal, legyen kihivás az életben maradás (a játék elején főleg)
12 | -NPC-ktol lehessen vasarolni, de ne tul sok mindent
13 | -accessories slot-t csinalni
14 | -nem kellenek nagy bosszok, hanem "apró" ellenségek helyettük: verem, szúrós virágok, harapós fák, véletlenszerűen megvaduló háziállatok, amik sebeznek
15 |
16 |
17 | Minimal Viable Prototype list:
18 | 1. Movement (water)
19 | 2. Character model
20 | 3. Multiplayer
21 | 4. World generation (more blocks, more variety, cliffs or something, flowers)
22 | 5. Reintroduce world saving/loading
23 |
24 | Follow-up:
25 | 1. Chat/commands
26 | 2. More blocks
27 | 3. Character customisation (change colours, hairstyle, etc.) by using a drawer block
--------------------------------------------------------------------------------
/wglinfo64.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pannoniae/BlockGame/94f6da2b5a1b6b9e25642f50d4c9ccd2cdb2c305/wglinfo64.exe
--------------------------------------------------------------------------------