Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix all remaining OpenGL-specific classes with "GL" in name #5381

Merged
merged 4 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,16 +11,16 @@

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 List<GLRenderBuffer> attachedRenderBuffers = new List<GLRenderBuffer>();
private readonly GLRenderer renderer;
private readonly TextureGL textureGL;
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();
Expand All @@ -34,7 +34,7 @@ public FrameBuffer(OpenGLRenderer renderer, RenderbufferInternalFormat[]? render
if (renderBufferFormats != null)
{
foreach (var format in renderBufferFormats)
attachedRenderBuffers.Add(new RenderBuffer(renderer, format));
attachedRenderBuffers.Add(new GLRenderBuffer(renderer, format));
}

renderer.UnbindFrameBuffer(frameBuffer);
Expand Down Expand Up @@ -90,7 +90,7 @@ public void Unbind()

#region Disposal

~FrameBuffer()
~GLFrameBuffer()
{
renderer.ScheduleDisposal(b => b.Dispose(false), this);
}
Expand Down Expand Up @@ -121,7 +121,7 @@ protected virtual void Dispose(bool disposing)

private class FrameBufferTexture : TextureGL
{
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 OpenGLLinearIndexData
smoogipoo marked this conversation as resolved.
Show resolved Hide resolved
{
static LinearIndexData()
static OpenGLLinearIndexData()
{
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 > OpenGLLinearIndexData.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, OpenGLLinearIndexData.EBO_ID);
GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(amountVertices * sizeof(ushort)), indices, BufferUsageHint.StaticDraw);

LinearIndexData.MaxAmountIndices = amountVertices;
OpenGLLinearIndexData.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, OpenGLLinearIndexData.EBO_ID);
}

protected override PrimitiveType Type { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace osu.Framework.Graphics.OpenGL.Buffers
{
internal static class QuadIndexData
internal static class OpenGLQuadIndexData
smoogipoo marked this conversation as resolved.
Show resolved Hide resolved
{
static QuadIndexData()
static OpenGLQuadIndexData()
{
GL.GenBuffers(1, out EBO_ID);
}
Expand All @@ -22,7 +22,7 @@ static QuadIndexData()
public static int MaxAmountIndices;
}

internal class QuadVertexBuffer<T> : VertexBuffer<T>
internal class GLQuadBuffer<T> : GLVertexBuffer<T>
where T : struct, IEquatable<T>, IVertex
{
private readonly int amountIndices;
Expand All @@ -34,7 +34,7 @@ internal class QuadVertexBuffer<T> : VertexBuffer<T>
/// </summary>
public const int MAX_QUADS = ushort.MaxValue / indices_per_quad;

public QuadVertexBuffer(OpenGLRenderer renderer, int amountQuads, BufferUsageHint usage)
public GLQuadBuffer(GLRenderer renderer, int amountQuads, BufferUsageHint usage)
: base(renderer, amountQuads * IRenderer.VERTICES_PER_QUAD, usage)
{
amountIndices = amountQuads * indices_per_quad;
Expand All @@ -45,7 +45,7 @@ protected override void Initialise()
{
base.Initialise();

if (amountIndices > QuadIndexData.MaxAmountIndices)
if (amountIndices > OpenGLQuadIndexData.MaxAmountIndices)
{
ushort[] indices = new ushort[amountIndices];

Expand All @@ -59,10 +59,10 @@ protected override void Initialise()
indices[j + 5] = (ushort)(i + 1);
}

Renderer.BindBuffer(BufferTarget.ElementArrayBuffer, QuadIndexData.EBO_ID);
Renderer.BindBuffer(BufferTarget.ElementArrayBuffer, OpenGLQuadIndexData.EBO_ID);
GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(amountIndices * sizeof(ushort)), indices, BufferUsageHint.StaticDraw);

QuadIndexData.MaxAmountIndices = amountIndices;
OpenGLQuadIndexData.MaxAmountIndices = amountIndices;
}
}

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

if (forRendering)
Renderer.BindBuffer(BufferTarget.ElementArrayBuffer, QuadIndexData.EBO_ID);
Renderer.BindBuffer(BufferTarget.ElementArrayBuffer, OpenGLQuadIndexData.EBO_ID);
}

protected override int ToElements(int vertices) => 3 * vertices / 2;
Expand Down
Loading