Skip to content
Merged
Changes from all 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
18 changes: 16 additions & 2 deletions src/base/URenderer_OpenGL.pas
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ TRenderer_OpenGLBase = class(TRenderer)
SupportsVAO: boolean;
SupportsFBO: boolean;
SupportsMappedBuffer: boolean;
GlyphTextureFormat: GLint;

MappedBuffer: PGLfloat; // OpenGL 2.0 doesn't support mapped buffers, so we manage it ourself.

Expand Down Expand Up @@ -284,6 +285,7 @@ implementation
MAX_QUADS = (VBO_SIZE div QUAD_STRIDE_BYTES); // Number of quads that can be stored in the VBO
EBO_INDICES = MAX_QUADS * 6; // 2 triangles, 6 total vertices per quad
EBO_SIZE = EBO_INDICES * SizeOf(GLuint);
GL_LUMINANCE = $1909;

type
TTexture_OpenGL = class(TTexture)
Expand Down Expand Up @@ -1523,7 +1525,7 @@ function TRenderer_OpenGLBase.LoadTexture(Data: PByte; W, H: integer; const Iden
// store this in the red channel, and later assign it to alpha in the fragment shader
function TRenderer_OpenGLBase.LoadGlyph(Data: PByte; W, H: integer): TTexture;
begin
Result := TTexture_OpenGL.Create(Data, W, H, PATH_NONE, GL_RED, 1, GL_CLAMP_TO_EDGE);
Result := TTexture_OpenGL.Create(Data, W, H, PATH_NONE, GlyphTextureFormat, 1, GL_CLAMP_TO_EDGE);
{$IFDEF DEBUG_MODE}
RaiseExceptionIfError;
{$ENDIF};
Expand Down Expand Up @@ -1768,6 +1770,7 @@ procedure TRenderer_OpenGL3.CheckVersion();
SupportsVAO := true;
SupportsFBO := true;
SupportsMappedBuffer := true;
GlyphTextureFormat := GL_RED;
if ((MajorVersion > 3) or ((MajorVersion = 3) and (MinorVersion >= 3))) then
fSupportsProjectM := true;
end;
Expand Down Expand Up @@ -1818,6 +1821,8 @@ procedure TRenderer_OpenGLES.CheckVersion();
var
Extensions: string;
GL_OES_vertex_array_object: boolean;
GL_OES_element_index_uint: boolean;
GL_EXT_texture_rg: boolean;
begin
if (MajorVersion < 2) then
raise Exception.Create('Could not initialize OpenGL ES 2.0 or later');
Expand All @@ -1827,14 +1832,22 @@ procedure TRenderer_OpenGLES.CheckVersion();
SupportsVAO := true;
fSupportsProjectM := true;
SupportsMappedBuffer := true;
GlyphTextureFormat := GL_RED;
end
else
begin
Extensions := Int_GetExtensionString;
GL_OES_element_index_uint := Int_CheckExtension(Extensions, 'GL_OES_element_index_uint');
if (not GL_OES_element_index_uint) then
Comment thread
complexlogic marked this conversation as resolved.
raise Exception.Create('OpenGL ES driver does not support the required GL_OES_element_index_uint extension');
GL_OES_vertex_array_object := Int_CheckExtension(Extensions, 'GL_OES_vertex_array_object');
if (GL_OES_vertex_array_object) then
SupportsVAO := true;

GL_EXT_texture_rg := Int_CheckExtension(Extensions, 'GL_EXT_texture_rg');
if (GL_EXT_texture_rg) then
GlyphTextureFormat := GL_RED
else
GlyphTextureFormat := GL_LUMINANCE;
end;
SupportsFBO := true;
end;
Expand Down Expand Up @@ -1887,6 +1900,7 @@ procedure TRenderer_OpenGL2.CheckVersion();
SupportsMappedBuffer := true;
fSupportsProjectM := false;
SupportsFBO := false;
GlyphTextureFormat := GL_LUMINANCE;
end;

procedure TRenderer_OpenGL2.GetShaderSource(out MainVertex, MainFragment, TextFragment, LineStripVertex, LineStripFragment: string);
Expand Down
Loading