Fix for opengl renderer

This commit is contained in:
Attila Uygun 2023-07-04 22:41:57 +02:00
parent 392c4eaf8f
commit 0398903585
3 changed files with 15 additions and 17 deletions

View File

@ -40,12 +40,6 @@ RendererOpenGL::~RendererOpenGL() {
OnDestroy();
}
void RendererOpenGL::Shutdown() {
LOG(0) << "Shutting down renderer.";
is_initialized_ = false;
ShutdownInternal();
}
void RendererOpenGL::OnWindowResized(int width, int height) {
screen_width_ = width;
screen_height_ = height;
@ -68,15 +62,6 @@ uint64_t RendererOpenGL::CreateGeometry(std::unique_ptr<Mesh> mesh) {
return 0;
}
// Make sure the vertex format is understood and the attribute pointers are
// set up.
std::vector<GeometryOpenGL::Element> vertex_layout;
if (!SetupVertexLayout(mesh->vertex_description(), vertex_size,
vertex_array_objects_, vertex_layout)) {
LOG(0) << "Invalid vertex layout";
return 0;
}
GLuint vertex_array_id = 0;
if (vertex_array_objects_) {
glGenVertexArrays(1, &vertex_array_id);
@ -90,6 +75,15 @@ uint64_t RendererOpenGL::CreateGeometry(std::unique_ptr<Mesh> mesh) {
glBufferData(GL_ARRAY_BUFFER, mesh->num_vertices() * vertex_size,
mesh->GetVertices(), GL_STATIC_DRAW);
// Make sure the vertex format is understood and the attribute pointers are
// set up.
std::vector<GeometryOpenGL::Element> vertex_layout;
if (!SetupVertexLayout(mesh->vertex_description(), vertex_size,
vertex_array_objects_, vertex_layout)) {
LOG(0) << "Invalid vertex layout";
return 0;
}
// Create the index buffer and upload the data.
GLuint index_buffer_id = 0;
if (mesh->GetIndices()) {

View File

@ -44,7 +44,9 @@ void RendererOpenGL::OnDestroy() {
ndk_helper::GLContext::GetInstance()->Invalidate();
}
void RendererOpenGL::ShutdownInternal() {
void RendererOpenGL::Shutdown() {
LOG(0) << "Shutting down renderer.";
is_initialized_ = false;
ndk_helper::GLContext::GetInstance()->Suspend();
}

View File

@ -36,7 +36,9 @@ bool RendererOpenGL::Initialize(Platform* platform) {
void RendererOpenGL::OnDestroy() {}
void RendererOpenGL::ShutdownInternal() {
void RendererOpenGL::Shutdown() {
LOG(0) << "Shutting down renderer.";
is_initialized_ = false;
if (display_ && glx_context_) {
glXMakeCurrent(display_, None, NULL);
glXDestroyContext(display_, glx_context_);