Fix windows being picky.
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m28s
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m28s
This commit is contained in:
11
main.cpp
11
main.cpp
@@ -24,13 +24,13 @@ public:
|
||||
Vector3 position = {0,0,0};
|
||||
Vector3 angle = {0,0,0};
|
||||
|
||||
std::array<GLfloat, 16> lookAt(const Vector3& eye, const Vector3& center, const Vector3& up) {
|
||||
std::vector<GLfloat> lookAt(const Vector3& eye, const Vector3& center, const Vector3& up) {
|
||||
Vector3 f = Vector3::Normalized((center - eye));
|
||||
Vector3 upN = Vector3::Normalized(up);
|
||||
Vector3 s = Vector3::Normalized(f.Cross(upN));
|
||||
Vector3 u = Vector3::Normalized(s.Cross(f));
|
||||
|
||||
std::array<GLfloat, 16> result = {
|
||||
std::vector<GLfloat> result = {
|
||||
s.x, u.x, -f.x, 0.0f,
|
||||
s.y, u.y, -f.y, 0.0f,
|
||||
s.z, u.z, -f.z, 0.0f,
|
||||
@@ -96,12 +96,14 @@ public:
|
||||
camera->render();
|
||||
|
||||
///All 3D elements of the scene and JGL elements *must* be rendered before the 2d stuff.
|
||||
|
||||
J3D::Begin();
|
||||
J3D::DrawLine(JGL::Colors::Red, {-0.33,-0.125,1}, {-1,-0.125,1});
|
||||
J3D::DrawLine(JGL::Colors::Red, {-0.33,-0.125,1}, {-0.33,0.25,1});
|
||||
J3D::DrawString(JGL::Colors::Red, "JGL Sample Text", {-0.33, -0.1, 1.0f},textAngle, 1.f, 32, FreeSans);
|
||||
J3D::End();
|
||||
|
||||
|
||||
J2D::Begin();
|
||||
J2D::FillRect(Colors::Blue, {0,52}, {100,100});
|
||||
J2D::FillRect(Color4::FromColor3(Colors::Pinks::HotPink), {68, 120}, {32, 32});
|
||||
@@ -124,8 +126,9 @@ public:
|
||||
|
||||
void OnRefresh(float elapsed) override {
|
||||
display();
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
exit(1);
|
||||
int glError = glGetError();
|
||||
if (glError != GL_NO_ERROR)
|
||||
std::cout << glError << std::endl;
|
||||
glSwapBuffers();
|
||||
}
|
||||
|
||||
|
26
src/JGL.cpp
26
src/JGL.cpp
@@ -50,7 +50,7 @@ namespace JGL {
|
||||
wasVertexArraysEnabled = true;
|
||||
if (!glIsEnabled(GL_VERTEX_ARRAY))
|
||||
wasVertexArraysEnabled = false,
|
||||
glEnable(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
wasCullFaceEnabled = true;
|
||||
if (!glIsEnabled(GL_CULL_FACE))
|
||||
@@ -72,12 +72,12 @@ namespace JGL {
|
||||
wasTextureCoordArrayEnabled = true;
|
||||
if (!glIsEnabled(GL_TEXTURE_COORD_ARRAY))
|
||||
wasTextureCoordArrayEnabled = false,
|
||||
glEnable(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
wasColorArrayEnabled = false;
|
||||
if (glIsEnabled(GL_COLOR_ARRAY))
|
||||
wasColorArrayEnabled = true,
|
||||
glDisable(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
if (!inJ3D)
|
||||
inJ2D = true;
|
||||
@@ -95,7 +95,7 @@ namespace JGL {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
if (!wasVertexArraysEnabled)
|
||||
glDisable(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
if (!wasCullFaceEnabled)
|
||||
glDisable(GL_CULL_FACE);
|
||||
@@ -107,13 +107,15 @@ namespace JGL {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
if (!wasTextureCoordArrayEnabled)
|
||||
glDisable(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
if (wasColorArrayEnabled)
|
||||
glEnable(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
/*
|
||||
//Select whatever texture unit was selected before.
|
||||
glActiveTexture(GL_TEXTURE0 + activeTextureUnit);
|
||||
*/
|
||||
|
||||
//Put the draw color back how it was before.
|
||||
glColor4f(oldColor[0], oldColor[1], oldColor[2], oldColor[3]);
|
||||
@@ -160,11 +162,11 @@ namespace JGL {
|
||||
(color1.b + color2.b) / 2.f / 255.f, (color1.a + color2.a) / 2.f / 255.f,color2.r / 255.f, color2.g / 255.f, color2.b / 255.f, color2.a / 255.f,
|
||||
(color1.r + color2.r) / 2.f / 255.f, (color1.g + color2.g) / 2.f / 255.f, (color1.b + color2.b) / 2.f / 255.f,(color1.a + color2.a) / 2.f / 255.f};
|
||||
|
||||
glEnable(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), vertices);
|
||||
glColorPointer(4, GL_FLOAT, 0, colors.data());
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
glDisable(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
void J2D::FillGradientRect(const Color3& color1, const Color3& color2, const Gradient& gradient, const Vector2& pos, const Vector2& size) {
|
||||
@@ -236,12 +238,12 @@ namespace JGL {
|
||||
GLfloat colors[8] = {color1.r / 255.f, color1.g / 255.f, color1.b / 255.f, color1.a / 255.f,
|
||||
color2.r / 255.f, color2.g / 255.f, color2.b / 255.f, color2.a / 255.f};
|
||||
|
||||
glEnable(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glLineWidth(thickness);
|
||||
glColorPointer(4,GL_FLOAT,sizeof(GL_FLOAT) * 4, colors);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), vertices);
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
glDisable(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
void J2D::DrawGradientLine(const Color3& color1, const Color3& color2, const Vector2& A, const Vector2& B, float thickness) {
|
||||
@@ -368,7 +370,7 @@ namespace JGL {
|
||||
wasVertexArraysEnabled = false;
|
||||
if (!glIsEnabled(GL_VERTEX_ARRAY))
|
||||
wasVertexArraysEnabled = false,
|
||||
glEnable(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
wasTexture2DEnabled = true;
|
||||
if (!glIsEnabled(GL_TEXTURE_2D))
|
||||
@@ -401,7 +403,7 @@ namespace JGL {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
if (!wasVertexArraysEnabled)
|
||||
glDisable(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
if (wasTexture2DEnabled)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
Reference in New Issue
Block a user