Skip to content

Commit

Permalink
Merge pull request #5381 from frenzibyte/opengl-prefix
Browse files Browse the repository at this point in the history
Prefix all remaining OpenGL-specific classes with "GL" in name
  • Loading branch information
smoogipoo authored Aug 26, 2022
2 parents ecdec63 + 69ef974 commit a961c2e
Show file tree
Hide file tree
Showing 27 changed files with 149 additions and 151 deletions.
1 change: 1 addition & 0 deletions osu-framework.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IL/@EntryIndexedValue">IL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IOS/@EntryIndexedValue">IOS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IOSGL/@EntryIndexedValue">IOSGL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IPC/@EntryIndexedValue">IPC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=JIT/@EntryIndexedValue">JIT</s:String>
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework.Tests/Graphics/ShaderRegexTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace osu.Framework.Tests.Graphics
[TestFixture]
public class ShaderRegexTest
{
private readonly Regex shaderAttributeRegex = new Regex(OpenGLShaderPart.SHADER_ATTRIBUTE_PATTERN);
private readonly Regex shaderAttributeRegex = new Regex(GLShaderPart.SHADER_ATTRIBUTE_PATTERN);

[Test]
public void TestComment()
Expand Down
12 changes: 6 additions & 6 deletions osu.Framework.Tests/Shaders/TestSceneShaderDisposal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace osu.Framework.Tests.Shaders
public class TestSceneShaderDisposal : FrameworkTestScene
{
private ShaderManager manager;
private OpenGLShader shader;
private GLShader shader;

private WeakReference<IShader> shaderRef;

Expand All @@ -30,7 +30,7 @@ public void SetUpSteps()
AddStep("setup manager", () =>
{
manager = new TestShaderManager(new NamespacedResourceStore<byte[]>(new DllResourceStore(typeof(Game).Assembly), @"Resources/Shaders"));
shader = (OpenGLShader)manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE);
shader = (GLShader)manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE);
shaderRef = new WeakReference<IShader>(shader);
shader.EnsureShaderCompiled();
Expand Down Expand Up @@ -61,18 +61,18 @@ public void TestShadersLoseReferencesOnManagerDisposal()
private class TestShaderManager : ShaderManager
{
public TestShaderManager(IResourceStore<byte[]> store)
: base(new OpenGLRenderer(), store)
: base(new GLRenderer(), store)
{
}

internal override IShader CreateShader(IRenderer renderer, string name, params IShaderPart[] parts)
=> new TestOpenGLShader(renderer, name, parts.Cast<OpenGLShaderPart>().ToArray());
=> new TestGLShader(renderer, name, parts.Cast<GLShaderPart>().ToArray());

private class TestOpenGLShader : OpenGLShader
private class TestGLShader : GLShader
{
private readonly IRenderer renderer;

internal TestOpenGLShader(IRenderer renderer, string name, OpenGLShaderPart[] parts)
internal TestGLShader(IRenderer renderer, string name, GLShaderPart[] parts)
: base(renderer, name, parts)
{
this.renderer = renderer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.iOS;
using osu.Framework.Graphics.OpenGL;

namespace osu.Framework.iOS.Graphics
namespace osu.Framework.iOS.Graphics.OpenGL
{
internal class IOSOpenGLRenderer : OpenGLRenderer
internal class IOSGLRenderer : GLRenderer
{
private readonly IOSGameView gameView;

public IOSOpenGLRenderer(IOSGameView gameView)
public IOSGLRenderer(IOSGameView gameView)
{
this.gameView = gameView;
}
Expand Down
4 changes: 2 additions & 2 deletions osu.Framework.iOS/IOSGameHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using osu.Framework.Input.Handlers;
using osu.Framework.Input.Handlers.Midi;
using osu.Framework.IO.Stores;
using osu.Framework.iOS.Graphics;
using osu.Framework.iOS.Graphics.OpenGL;
using osu.Framework.iOS.Graphics.Textures;
using osu.Framework.iOS.Graphics.Video;
using osu.Framework.iOS.Input;
Expand All @@ -36,7 +36,7 @@ public IOSGameHost(IOSGameView gameView)
this.gameView = gameView;
}

protected override IRenderer CreateRenderer() => new IOSOpenGLRenderer(gameView);
protected override IRenderer CreateRenderer() => new IOSGLRenderer(gameView);

protected override void SetupForRun()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

namespace osu.Framework.Graphics.OpenGL.Batches
{
internal class LinearBatch<T> : VertexBatch<T>
internal class GLLinearBatch<T> : GLVertexBatch<T>
where T : struct, IEquatable<T>, IVertex
{
private readonly PrimitiveType type;

public LinearBatch(OpenGLRenderer renderer, int size, int maxBuffers, PrimitiveType type)
public GLLinearBatch(GLRenderer renderer, int size, int maxBuffers, PrimitiveType type)
: base(renderer, size, maxBuffers)
{
this.type = type;
}

protected override VertexBuffer<T> CreateVertexBuffer(OpenGLRenderer renderer) => new LinearVertexBuffer<T>(renderer, Size, type, BufferUsageHint.DynamicDraw);
protected override GLVertexBuffer<T> CreateVertexBuffer(GLRenderer renderer) => new GLLinearBuffer<T>(renderer, Size, type, BufferUsageHint.DynamicDraw);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

namespace osu.Framework.Graphics.OpenGL.Batches
{
internal class QuadBatch<T> : VertexBatch<T>
internal class GLQuadBatch<T> : GLVertexBatch<T>
where T : struct, IEquatable<T>, IVertex
{
public QuadBatch(OpenGLRenderer renderer, int size, int maxBuffers)
public GLQuadBatch(GLRenderer renderer, int size, int maxBuffers)
: base(renderer, size, maxBuffers)
{
}

protected override VertexBuffer<T> CreateVertexBuffer(OpenGLRenderer renderer) => new QuadVertexBuffer<T>(renderer, Size, BufferUsageHint.DynamicDraw);
protected override GLVertexBuffer<T> CreateVertexBuffer(GLRenderer renderer) => new GLQuadBuffer<T>(renderer, Size, BufferUsageHint.DynamicDraw);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

namespace osu.Framework.Graphics.OpenGL.Batches
{
internal abstract class VertexBatch<T> : IVertexBatch<T>
internal abstract class GLVertexBatch<T> : IVertexBatch<T>
where T : struct, IEquatable<T>, IVertex
{
public List<VertexBuffer<T>> VertexBuffers = new List<VertexBuffer<T>>();
public List<GLVertexBuffer<T>> VertexBuffers = new List<GLVertexBuffer<T>>();

/// <summary>
/// The number of vertices in each VertexBuffer.
Expand All @@ -28,12 +28,12 @@ internal abstract class VertexBatch<T> : IVertexBatch<T>
private int currentBufferIndex;
private int currentVertexIndex;

private readonly OpenGLRenderer renderer;
private readonly GLRenderer renderer;
private readonly int maxBuffers;

private VertexBuffer<T> currentVertexBuffer => VertexBuffers[currentBufferIndex];
private GLVertexBuffer<T> currentVertexBuffer => VertexBuffers[currentBufferIndex];

protected VertexBatch(OpenGLRenderer renderer, int bufferSize, int maxBuffers)
protected GLVertexBatch(GLRenderer renderer, int bufferSize, int maxBuffers)
{
Size = bufferSize;
this.renderer = renderer;
Expand All @@ -54,7 +54,7 @@ protected void Dispose(bool disposing)
{
if (disposing)
{
foreach (VertexBuffer<T> vbo in VertexBuffers)
foreach (GLVertexBuffer<T> vbo in VertexBuffers)
vbo.Dispose();
}
}
Expand All @@ -68,10 +68,10 @@ void IVertexBatch.ResetCounters()
currentVertexIndex = 0;
}

protected abstract VertexBuffer<T> CreateVertexBuffer(OpenGLRenderer renderer);
protected abstract GLVertexBuffer<T> CreateVertexBuffer(GLRenderer renderer);

/// <summary>
/// Adds a vertex to this <see cref="VertexBatch{T}"/>.
/// Adds a vertex to this <see cref="GLVertexBatch{T}"/>.
/// </summary>
/// <param name="v">The vertex to add.</param>
public void Add(T v)
Expand Down Expand Up @@ -100,7 +100,7 @@ public void Add(T v)
}

/// <summary>
/// Adds a vertex to this <see cref="VertexBatch{T}"/>.
/// Adds a vertex to this <see cref="GLVertexBatch{T}"/>.
/// This is a cached delegate of <see cref="Add"/> that should be used in memory-critical locations such as <see cref="DrawNode"/>s.
/// </summary>
public Action<T> AddAction { get; private set; }
Expand All @@ -110,7 +110,7 @@ public int Draw()
if (currentVertexIndex == 0)
return 0;

VertexBuffer<T> vertexBuffer = currentVertexBuffer;
GLVertexBuffer<T> vertexBuffer = currentVertexBuffer;
if (changeBeginIndex >= 0)
vertexBuffer.UpdateRange(changeBeginIndex, changeEndIndex);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace osu.Framework.Graphics.OpenGL.Buffers
{
public static class BufferFormatExtensions
public static class GLBufferFormatExtensions
{
public static FramebufferAttachment GetAttachmentType(this RenderbufferInternalFormat format)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@

namespace osu.Framework.Graphics.OpenGL.Buffers
{
internal class FrameBuffer : IFrameBuffer
internal class GLFrameBuffer : IFrameBuffer
{
public Texture Texture { get; }

private readonly List<RenderBuffer> attachedRenderBuffers = new List<RenderBuffer>();
private readonly OpenGLRenderer renderer;
private readonly TextureGL textureGL;
private readonly List<GLRenderBuffer> attachedRenderBuffers = new List<GLRenderBuffer>();
private readonly GLRenderer renderer;
private readonly GLTexture glTexture;
private readonly int frameBuffer;

public FrameBuffer(OpenGLRenderer renderer, RenderbufferInternalFormat[]? renderBufferFormats = null, All filteringMode = All.Linear)
public GLFrameBuffer(GLRenderer renderer, RenderbufferInternalFormat[]? renderBufferFormats = null, All filteringMode = All.Linear)
{
this.renderer = renderer;
frameBuffer = GL.GenFramebuffer();
Texture = renderer.CreateTexture(textureGL = new FrameBufferTexture(renderer, filteringMode), WrapMode.None, WrapMode.None);
Texture = renderer.CreateTexture(glTexture = new FrameBufferTexture(renderer, filteringMode), WrapMode.None, WrapMode.None);

renderer.BindFrameBuffer(frameBuffer);

GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget2d.Texture2D, textureGL.TextureId, 0);
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget2d.Texture2D, glTexture.TextureId, 0);
renderer.BindTexture(0);

if (renderBufferFormats != null)
{
foreach (var format in renderBufferFormats)
attachedRenderBuffers.Add(new RenderBuffer(renderer, format));
attachedRenderBuffers.Add(new GLRenderBuffer(renderer, format));
}

renderer.UnbindFrameBuffer(frameBuffer);
Expand All @@ -55,10 +55,10 @@ public Vector2 Size

size = value;

textureGL.Width = (int)Math.Ceiling(size.X);
textureGL.Height = (int)Math.Ceiling(size.Y);
textureGL.SetData(new TextureUpload());
textureGL.Upload();
glTexture.Width = (int)Math.Ceiling(size.X);
glTexture.Height = (int)Math.Ceiling(size.Y);
glTexture.SetData(new TextureUpload());
glTexture.Upload();
}
}

Expand Down Expand Up @@ -90,7 +90,7 @@ public void Unbind()

#region Disposal

~FrameBuffer()
~GLFrameBuffer()
{
renderer.ScheduleDisposal(b => b.Dispose(false), this);
}
Expand All @@ -108,7 +108,7 @@ protected virtual void Dispose(bool disposing)
if (isDisposed)
return;

textureGL.Dispose();
glTexture.Dispose();
renderer.DeleteFrameBuffer(frameBuffer);

foreach (var buffer in attachedRenderBuffers)
Expand All @@ -119,9 +119,9 @@ protected virtual void Dispose(bool disposing)

#endregion

private class FrameBufferTexture : TextureGL
private class FrameBufferTexture : GLTexture
{
public FrameBufferTexture(OpenGLRenderer renderer, All filteringMode = All.Linear)
public FrameBufferTexture(GLRenderer renderer, All filteringMode = All.Linear)
: base(renderer, 1, 1, true, filteringMode)
{
BypassTextureUploadQueueing = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace osu.Framework.Graphics.OpenGL.Buffers
{
internal static class LinearIndexData
internal static class GLLinearIndexData
{
static LinearIndexData()
static GLLinearIndexData()
{
GL.GenBuffers(1, out EBO_ID);
}
Expand All @@ -24,12 +24,12 @@ static LinearIndexData()
/// <summary>
/// This type of vertex buffer lets the ith vertex be referenced by the ith index.
/// </summary>
internal class LinearVertexBuffer<T> : VertexBuffer<T>
internal class GLLinearBuffer<T> : GLVertexBuffer<T>
where T : struct, IEquatable<T>, IVertex
{
private readonly int amountVertices;

public LinearVertexBuffer(OpenGLRenderer renderer, int amountVertices, PrimitiveType type, BufferUsageHint usage)
public GLLinearBuffer(GLRenderer renderer, int amountVertices, PrimitiveType type, BufferUsageHint usage)
: base(renderer, amountVertices, usage)
{
this.amountVertices = amountVertices;
Expand All @@ -42,17 +42,17 @@ protected override void Initialise()
{
base.Initialise();

if (amountVertices > LinearIndexData.MaxAmountIndices)
if (amountVertices > GLLinearIndexData.MaxAmountIndices)
{
ushort[] indices = new ushort[amountVertices];

for (int i = 0; i < amountVertices; i++)
indices[i] = (ushort)i;

Renderer.BindBuffer(BufferTarget.ElementArrayBuffer, LinearIndexData.EBO_ID);
Renderer.BindBuffer(BufferTarget.ElementArrayBuffer, GLLinearIndexData.EBO_ID);
GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(amountVertices * sizeof(ushort)), indices, BufferUsageHint.StaticDraw);

LinearIndexData.MaxAmountIndices = amountVertices;
GLLinearIndexData.MaxAmountIndices = amountVertices;
}
}

Expand All @@ -61,7 +61,7 @@ public override void Bind(bool forRendering)
base.Bind(forRendering);

if (forRendering)
Renderer.BindBuffer(BufferTarget.ElementArrayBuffer, LinearIndexData.EBO_ID);
Renderer.BindBuffer(BufferTarget.ElementArrayBuffer, GLLinearIndexData.EBO_ID);
}

protected override PrimitiveType Type { get; }
Expand Down
Loading

0 comments on commit a961c2e

Please sign in to comment.