Neler Yeni

Glfw Ve Glad Çizim Yapmıyor

Katılım
3 Aralık 2023
Mesajlar
1
Dahası  
Reaksiyon skoru
0
İsim
Yavuz Durmuş
#include "HuskyWindow.h"

#include "../event/input.h"

#include "../core/Log.h"



#include <glad/glad.h>

#include <GLFW/glfw3.h>





#include <iostream>



namespace Husky

{

HuskyWindow::HuskyWindow(int width, int height, const char* title)

{

glfwInit();

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);

glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);



window = glfwCreateWindow(width, height, title, glfwGetPrimaryMonitor(), NULL);

if (window == NULL)

{

glfwTerminate();

throw std::runtime_error("Failed to create window");

}

glfwMakeContextCurrent(window);

glfwSwapInterval(1);



// loading glad

if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))

{

throw std::runtime_error("Failed to init glad");

}

//glClearColor(1.0f, 0.2f, 0.0f, 1.0f);

glfwSetKeyCallback(window, key_callback);

glfwSetMouseButtonCallback(window, mouse_callback);

}

HuskyWindow::~HuskyWindow()

{

glfwDestroyWindow(window);

glfwTerminate();

}

int HuskyWindow::GetHeight() const

{

return height;

}

int HuskyWindow::GetWidth() const

{

return width;

}

const char* HuskyWindow::GetTitle() const

{

return title;

}

void HuskyWindow::Update()

{

// Clear the screen

glClearColor(1.0f, 1.0f, 0.0f, 1.0f);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);



// Draw the triangle

glBegin(GL_TRIANGLES);

glVertex2d(-0.5, -0.5);

glVertex2d(0.5, -0.5);

glVertex2d(0, 0.5);

glEnd();



// Swap buffers to display the rendered content

glfwSwapBuffers(window);



// Poll events

glfwPollEvents();



}

void HuskyWindow::Close()

{

glfwSetWindowShouldClose(window, true);

}

bool HuskyWindow::ShouldClose()

{

return glfwWindowShouldClose(window);

}

void HuskyWindow::key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)

{

// key input alanı

if (key == Key::Escape && action == Key::KeyRelease)

{

HUSKY_CLIENT_INFO("Exiting...");

glfwSetWindowShouldClose(window, GLFW_TRUE);

}

}

void HuskyWindow::mouse_callback(GLFWwindow* window, int button, int action, int mods)

{

// mouse input alanı

}

} bu render sınıfı kodum ancak bir sorun var glClearColor fonksiyonu çalışıyor ve arka plan değişiyor ancak glBegin(GL_TRIANGLES);

glVertex2d(-0.5, -0.5);

glVertex2d(0.5, -0.5);

glVertex2d(0, 0.5);

glEnd(); satırlarındaki çizim kodu çalışmıyor boş ekran geliyor 1 gündür uğraşıyorum nasıl çözerim lütfen yardım edin
 
Top Bottom