Fix for Nvidia driver being exceedingly picky.
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 5m24s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 5m24s
This commit is contained in:
5
main.cpp
5
main.cpp
@@ -126,8 +126,8 @@ public:
|
|||||||
image2_render_target = new RenderTarget(image2);
|
image2_render_target = new RenderTarget(image2);
|
||||||
|
|
||||||
J2D::Begin(image2_render_target);
|
J2D::Begin(image2_render_target);
|
||||||
J2D::FillRect(Colors::Red, {0,0}, {4,4});
|
|
||||||
J2D::DrawString(Colors::Red, "TEST", 0, 16, 1, 16, FreeSans);
|
J2D::DrawString(Colors::Red, "TEST", 0, 16, 1, 16, FreeSans);
|
||||||
|
J2D::FillRect(Colors::Blue, {0,0}, {4,4});
|
||||||
J2D::End();
|
J2D::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,10 +165,9 @@ public:
|
|||||||
J3D::DrawString(Colors::Red, "JGL Sample Text", {-0.33, -0.1, 1.0f}, 1.f, 32, FreeSans, textAngle, true);
|
J3D::DrawString(Colors::Red, "JGL Sample Text", {-0.33, -0.1, 1.0f}, 1.f, 32, FreeSans, textAngle, true);
|
||||||
J3D::End();
|
J3D::End();
|
||||||
|
|
||||||
|
|
||||||
J2D::Begin(j2d_render_target, true);
|
J2D::Begin(j2d_render_target, true);
|
||||||
J2D::FillRect(Colors::Blue, {0,52}, {100,100});
|
J2D::FillRect(Colors::Blue, {0,52}, {100,100});
|
||||||
J2D::DrawSprite(*image2, {300, 300}, 0, {0.5,0.5}, {1, 1}, Colors::White);
|
J2D::DrawSprite(*image2, {300, 400}, sprite_radians * 0.10, {0.5,0.5}, {1, 1}, Colors::White);
|
||||||
J2D::DrawMirrorSprite(*image, {400, 300}, Direction::Horizontal | Direction::Vertical, sprite_radians, {0.5,0.5}, {1, 1}, Colors::White);
|
J2D::DrawMirrorSprite(*image, {400, 300}, Direction::Horizontal | Direction::Vertical, sprite_radians, {0.5,0.5}, {1, 1}, Colors::White);
|
||||||
J2D::DrawPartialSprite(*image, {225, 300}, image->GetDimensions() * 0.25, image->GetDimensions() * 0.75, sprite_radians, {0.5, 0.5}, {1,1}, Colors::White);
|
J2D::DrawPartialSprite(*image, {225, 300}, image->GetDimensions() * 0.25, image->GetDimensions() * 0.75, sprite_radians, {0.5, 0.5}, {1,1}, Colors::White);
|
||||||
J2D::FillRect(Colors::Pinks::HotPink, {68, 120}, {32, 32});
|
J2D::FillRect(Colors::Pinks::HotPink, {68, 120}, {32, 32});
|
||||||
|
121
src/JGL.cpp
121
src/JGL.cpp
@@ -18,6 +18,7 @@ bool inJ2D = false;
|
|||||||
bool inJ3D = false;
|
bool inJ3D = false;
|
||||||
bool wasTexture2DEnabled = false;
|
bool wasTexture2DEnabled = false;
|
||||||
bool wasTextureCoordArrayEnabled = false;
|
bool wasTextureCoordArrayEnabled = false;
|
||||||
|
|
||||||
bool wasDepthTestEnabled = false;
|
bool wasDepthTestEnabled = false;
|
||||||
bool wasVertexArraysEnabled = false;
|
bool wasVertexArraysEnabled = false;
|
||||||
bool wasCullFaceEnabled = false;
|
bool wasCullFaceEnabled = false;
|
||||||
@@ -105,17 +106,13 @@ namespace JGL {
|
|||||||
else
|
else
|
||||||
wasBlendEnabled = true;
|
wasBlendEnabled = true;
|
||||||
|
|
||||||
if (!glIsEnabled(GL_TEXTURE_2D))
|
if (glIsEnabled(GL_TEXTURE_2D))
|
||||||
wasTexture2DEnabled = false,
|
wasTexture2DEnabled = true,
|
||||||
glEnable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
else
|
|
||||||
wasTexture2DEnabled = true;
|
|
||||||
|
|
||||||
if (!glIsEnabled(GL_TEXTURE_COORD_ARRAY))
|
if (glIsEnabled(GL_TEXTURE_COORD_ARRAY))
|
||||||
wasTextureCoordArrayEnabled = false,
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
else
|
|
||||||
wasTextureCoordArrayEnabled = true;
|
wasTextureCoordArrayEnabled = true;
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
if (glIsEnabled(GL_COLOR_ARRAY))
|
if (glIsEnabled(GL_COLOR_ARRAY))
|
||||||
wasColorArrayEnabled = true,
|
wasColorArrayEnabled = true,
|
||||||
@@ -152,11 +149,11 @@ namespace JGL {
|
|||||||
if (!wasBlendEnabled)
|
if (!wasBlendEnabled)
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
if (!wasTexture2DEnabled)
|
if (wasTexture2DEnabled)
|
||||||
glDisable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
if (!wasTextureCoordArrayEnabled)
|
if (wasTextureCoordArrayEnabled)
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
if (wasColorArrayEnabled)
|
if (wasColorArrayEnabled)
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
@@ -373,13 +370,17 @@ namespace JGL {
|
|||||||
std::swap(textureCoordinates[0], textureCoordinates[3]),
|
std::swap(textureCoordinates[0], textureCoordinates[3]),
|
||||||
std::swap(textureCoordinates[1], textureCoordinates[2]);
|
std::swap(textureCoordinates[1], textureCoordinates[2]);
|
||||||
|
|
||||||
glColor4ubv(color.ptr());
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture.GetGLTextureHandle());
|
glEnable(GL_TEXTURE_2D);
|
||||||
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), vertices.data());
|
glColor4ubv(color.ptr());
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vector2), textureCoordinates.data());
|
glBindTexture(GL_TEXTURE_2D, texture.GetGLTextureHandle());
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), vertices.data());
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glTexCoordPointer(2, GL_FLOAT, sizeof(Vector2), textureCoordinates.data());
|
||||||
glColor4fv(baseColor);
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
glColor4fv(baseColor);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -458,17 +459,20 @@ namespace JGL {
|
|||||||
(v.x - pos2.x - offset.x * scale.x) * sin_theta + (v.y - pos2.y - offset.y * scale.y) * cos_theta +
|
(v.x - pos2.x - offset.x * scale.x) * sin_theta + (v.y - pos2.y - offset.y * scale.y) * cos_theta +
|
||||||
pos2.y + offset.y * scale.y};
|
pos2.y + offset.y * scale.y};
|
||||||
|
|
||||||
glColor4ubv(color.ptr());
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture.GetGLTextureHandle());
|
glEnable(GL_TEXTURE_2D);
|
||||||
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), vertices.data());
|
glColor4ubv(color.ptr());
|
||||||
glTexCoordPointer(2, GL_FLOAT, 0, textureCoordinates.data());
|
glBindTexture(GL_TEXTURE_2D, texture.GetGLTextureHandle());
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), vertices.data());
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glTexCoordPointer(2, GL_FLOAT, 0, textureCoordinates.data());
|
||||||
glColor4fv(baseColor);
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
glColor4fv(baseColor);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void J2D::DrawPartialSprite(const JGL::Texture& texture, float positionX, float positionY, float sub_texture_positionX,
|
||||||
J2D::DrawPartialSprite(const JGL::Texture& texture, float positionX, float positionY, float sub_texture_positionX,
|
|
||||||
float sub_texture_positionY, unsigned int sub_texture_sizeX,
|
float sub_texture_positionY, unsigned int sub_texture_sizeX,
|
||||||
unsigned int sub_texture_sizeY, float originX, float originY, float rad_rotation,
|
unsigned int sub_texture_sizeY, float originX, float originY, float rad_rotation,
|
||||||
float scaleX, float scaleY, const Color4& color, JGL::Direction inversion) {
|
float scaleX, float scaleY, const Color4& color, JGL::Direction inversion) {
|
||||||
@@ -538,24 +542,27 @@ namespace JGL {
|
|||||||
(v.x - pos2.x - offset.x * scale.x) * sin_theta + (v.y - pos2.y - offset.y * scale.y) * cos_theta + pos2.y + offset.y * scale.y
|
(v.x - pos2.x - offset.x * scale.x) * sin_theta + (v.y - pos2.y - offset.y * scale.y) * cos_theta + pos2.y + offset.y * scale.y
|
||||||
};
|
};
|
||||||
|
|
||||||
glColor4ubv(color.ptr());
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), vertices.data());
|
glEnable(GL_TEXTURE_2D);
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vector2), textureCoordinates.data());
|
glColor4ubv(color.ptr());
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), vertices.data());
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, sizeof(Vector2), textureCoordinates.data());
|
||||||
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
|
|
||||||
//Reset the wrapping mode.
|
//Reset the wrapping mode.
|
||||||
if (texture.GetWrappingMode() == TextureWrappingMode::CLAMP_TO_EDGE)
|
if (texture.GetWrappingMode() == TextureWrappingMode::CLAMP_TO_EDGE)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE),
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE),
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
else if (texture.GetWrappingMode() == TextureWrappingMode::REPEAT)
|
else if (texture.GetWrappingMode() == TextureWrappingMode::REPEAT)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT),
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT),
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
else if (texture.GetWrappingMode() == TextureWrappingMode::CLAMP_TO_BORDER)
|
else if (texture.GetWrappingMode() == TextureWrappingMode::CLAMP_TO_BORDER)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER),
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER),
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glColor4fv(baseColor);
|
||||||
glColor4fv(baseColor);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
void J2D::OutlineCircle(const Color4& color, const Vector2& center, float radius, unsigned int subdivisions, float thickness) {
|
void J2D::OutlineCircle(const Color4& color, const Vector2& center, float radius, unsigned int subdivisions, float thickness) {
|
||||||
@@ -873,17 +880,13 @@ namespace JGL {
|
|||||||
wasVertexArraysEnabled = false,
|
wasVertexArraysEnabled = false,
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
if (!glIsEnabled(GL_TEXTURE_COORD_ARRAY))
|
if (glIsEnabled(GL_TEXTURE_COORD_ARRAY))
|
||||||
wasTextureCoordArrayEnabled = false,
|
wasTextureCoordArrayEnabled = true,
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
else
|
|
||||||
wasTextureCoordArrayEnabled = true;
|
|
||||||
|
|
||||||
|
if (glIsEnabled(GL_TEXTURE_2D))
|
||||||
wasTexture2DEnabled = true;
|
wasTexture2DEnabled = true,
|
||||||
if (!glIsEnabled(GL_TEXTURE_2D))
|
glDisable(GL_TEXTURE_2D);
|
||||||
wasTexture2DEnabled = false,
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
wasCullFaceEnabled = false;
|
wasCullFaceEnabled = false;
|
||||||
if (glIsEnabled(GL_CULL_FACE))
|
if (glIsEnabled(GL_CULL_FACE))
|
||||||
@@ -911,7 +914,7 @@ namespace JGL {
|
|||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
if (wasTexture2DEnabled)
|
if (wasTexture2DEnabled)
|
||||||
glDisable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
if (!wasBlendEnabled)
|
if (!wasBlendEnabled)
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
@@ -919,8 +922,8 @@ namespace JGL {
|
|||||||
if (wasCullFaceEnabled)
|
if (wasCullFaceEnabled)
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
if (!wasTextureCoordArrayEnabled)
|
if (wasTextureCoordArrayEnabled)
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
//Put the draw color back how it was before.
|
//Put the draw color back how it was before.
|
||||||
glColor4fv(oldColor);
|
glColor4fv(oldColor);
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
namespace JGL {
|
namespace JGL {
|
||||||
CachedFont* CacheFont(const Font& font, u32 size) {
|
CachedFont* CacheFont(const Font& font, u32 size) {
|
||||||
|
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
CachedFont* cachedFont;
|
CachedFont* cachedFont;
|
||||||
FT_Set_Pixel_Sizes(font.face, 0, size);
|
FT_Set_Pixel_Sizes(font.face, 0, size);
|
||||||
Logger::Debug("Caching font data...");
|
Logger::Debug("Caching font data...");
|
||||||
@@ -88,6 +90,7 @@ namespace JGL {
|
|||||||
xoffset += g->bitmap.width;
|
xoffset += g->bitmap.width;
|
||||||
charcode = FT_Get_Next_Char(font.face, charcode, &gindex);
|
charcode = FT_Get_Next_Char(font.face, charcode, &gindex);
|
||||||
}
|
}
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
return cachedFont;
|
return cachedFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,13 +110,16 @@ namespace JGL {
|
|||||||
CachedFont* cachedFont = fontCache.getFont(size, font.index);
|
CachedFont* cachedFont = fontCache.getFont(size, font.index);
|
||||||
|
|
||||||
if (font.face == nullptr)
|
if (font.face == nullptr)
|
||||||
jlog::Fatal("Drawing a string with an uninitialized font?");
|
Logger::Fatal("Drawing a string with an uninitialized font?");
|
||||||
|
|
||||||
//If the font doesn't exist in the cache yet.
|
//If the font doesn't exist in the cache yet.
|
||||||
if (!cachedFont)
|
if (!cachedFont)
|
||||||
cachedFont = CacheFont(font, size);
|
cachedFont = CacheFont(font, size);
|
||||||
|
|
||||||
glColor4ubv(color.ptr());
|
glColor4ubv(color.ptr());
|
||||||
|
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
//Texture parameters are restored when the texture_handle is bound
|
//Texture parameters are restored when the texture_handle is bound
|
||||||
glBindTexture(GL_TEXTURE_2D, *cachedFont->getTexture());
|
glBindTexture(GL_TEXTURE_2D, *cachedFont->getTexture());
|
||||||
|
|
||||||
@@ -152,6 +158,8 @@ namespace JGL {
|
|||||||
glDrawArrays(GL_TRIANGLES, 0, (int) vertices.size() * 6);
|
glDrawArrays(GL_TRIANGLES, 0, (int) vertices.size() * 6);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glColor4f(1, 1, 1, 1);
|
glColor4f(1, 1, 1, 1);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
void J3D::DrawString(const Color4& color, const std::string& text, const Vector3& pos, float scale, u32 size, const Font& font, const EulerAngle& angle, bool draw_back_face) {
|
void J3D::DrawString(const Color4& color, const std::string& text, const Vector3& pos, float scale, u32 size, const Font& font, const EulerAngle& angle, bool draw_back_face) {
|
||||||
@@ -183,6 +191,8 @@ namespace JGL {
|
|||||||
if (!cachedFont)
|
if (!cachedFont)
|
||||||
cachedFont = CacheFont(font, size);
|
cachedFont = CacheFont(font, size);
|
||||||
|
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
glColor4ubv(color.ptr());
|
glColor4ubv(color.ptr());
|
||||||
glBindTexture(GL_TEXTURE_2D, *cachedFont->getTexture());
|
glBindTexture(GL_TEXTURE_2D, *cachedFont->getTexture());
|
||||||
|
|
||||||
@@ -234,6 +244,8 @@ namespace JGL {
|
|||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glColor4f(1, 1, 1, 1);
|
glColor4f(1, 1, 1, 1);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user