Texture setup

This commit is contained in:
Matt Thorson 2020-08-08 14:39:08 -07:00
parent 7329e98beb
commit 5cef6c2b26
4 changed files with 33 additions and 5 deletions

View File

@ -95,7 +95,7 @@ namespace Strawberry
if (PlatformLayer.Closed())
return;
uint32 tick = PlatformLayer.Tick;
uint32 tick = PlatformLayer.Ticks;
msCounter += (tick - prevTick);
prevTick = tick;

View File

@ -1,7 +1,29 @@
using System;
namespace Strawberry {
class GL {
namespace Strawberry
{
class GLTexture : Texture
{
private uint32 handle;
public this(int width, int height, void* pixels)
{
Width = width;
Height = height;
GL.glGenTextures(1, &handle);
GL.glBindTexture(GL.GL_TEXTURE_2D, handle);
GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, width, height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixels);
}
public ~this()
{
GL.glDeleteTextures(1, &handle);
}
}
class GL
{
public function void* GetProcAddressFunc(StringView procname);
public const uint GL_DEPTH_BUFFER_BIT = 0x00000100;

View File

@ -11,7 +11,7 @@ namespace Strawberry
public abstract void RenderEnd();
//Update
public abstract uint32 Tick { get; } // Milliseconds since game launched
public abstract uint32 Ticks { get; } // Milliseconds since game launched
//Input
public abstract void UpdateInput();
@ -21,4 +21,10 @@ namespace Strawberry
public abstract bool PollGamepadButton(int gamepadID, Buttons button);
public abstract float PollGamepadAxis(int gamepadID, Axes axis);
}
public abstract class Texture
{
public int Width { get; protected set; }
public int Height { get; protected set; }
}
}

View File

@ -89,7 +89,7 @@ namespace Strawberry
return (SDL.PollEvent(out event) != 0 && event.type == .Quit);
}
public override uint32 Tick => SDL.GetTicks();
public override uint32 Ticks => SDL.GetTicks();
public override void RenderBegin()
{