Fix Implementation of J2D::DrawLine2D & J3D::DrawLine3D
This commit is contained in:
@@ -56,14 +56,16 @@ namespace JGL
|
||||
std::cout << "Error::FREETYPE: Failed to load font!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
FT_Set_Pixel_Sizes(face, 0, default_font_size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderText(std::string text, float x, float y, float scale) {
|
||||
void RenderText(std::string text, float x, float y, float scale, u32 text_size) {
|
||||
glUseProgram(0); // Fixed-function pipeline.
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
|
||||
FT_Set_Pixel_Sizes(face, 0, text_size);
|
||||
|
||||
const char* c;
|
||||
for (c = text.c_str(); *c; c++)
|
||||
{
|
||||
@@ -145,10 +147,10 @@ namespace JGL
|
||||
}
|
||||
|
||||
void DrawLine2D(const Color3 &color, const Vector2 &A, const Vector2 &B, float thickness) {
|
||||
auto vp_a = ScreenToViewport(A);
|
||||
auto vp_b = ScreenToViewport(B);
|
||||
auto vp_a = A;//ScreenToViewport(A);
|
||||
auto vp_b = B;//ScreenToViewport(B);
|
||||
|
||||
glBegin(GL_LINE);
|
||||
glBegin(GL_LINES);
|
||||
glLineWidth(thickness);
|
||||
glColor3f(color.r, color.g, color.b);
|
||||
glVertex2f(vp_a.x, vp_a.y);
|
||||
@@ -222,12 +224,14 @@ namespace JGL
|
||||
{
|
||||
void DrawLine3D(const Color3& color, const Vector3& A, const Vector3& B, float thickness)
|
||||
{
|
||||
glBegin(GL_LINE);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glLineWidth(thickness);
|
||||
glColor3f(color.r, color.g, color.b);
|
||||
glColor3f(color.r/255.f, color.g/255.f, color.b/255.f);
|
||||
glVertex3f(A.x, A.y, A.z);
|
||||
glVertex3f(B.x, B.y, B.z);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
29
src/LearnOpenGL/Texture2D.cpp
Normal file
29
src/LearnOpenGL/Texture2D.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <LearnOpenGL/Texture2D.h>
|
||||
#include <glad/glad.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
Texture2D::Texture2D()
|
||||
: Width(0), Height(0), InternalFormat(GL_RGB), ImageFormat(GL_RGB), WrapS(GL_REPEAT), WrapT(GL_REPEAT),
|
||||
Filter_Min(GL_LINEAR), Filter_Max(GL_LINEAR) {
|
||||
glGenTextures(1, &this->ID);
|
||||
}
|
||||
|
||||
void Texture2D::Generate(unsigned int width, unsigned int height, unsigned char *data) {
|
||||
this->Width = width;
|
||||
this->Height = height;
|
||||
glBindTexture(GL_TEXTURE_2D, this->ID);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, this->InternalFormat, width, height, 0, this->ImageFormat, GL_UNSIGNED_BYTE,
|
||||
data);
|
||||
// set Texture wrap and filter modes
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, this->WrapS);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, this->WrapT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, this->Filter_Min);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, this->Filter_Max);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
void Texture2D::Bind() const
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, this->ID);
|
||||
}
|
Reference in New Issue
Block a user