mirror of https://github.com/auygun/kaliber.git
Fix for opengl renderer
This commit is contained in:
parent
392c4eaf8f
commit
0398903585
|
@ -40,12 +40,6 @@ RendererOpenGL::~RendererOpenGL() {
|
||||||
OnDestroy();
|
OnDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererOpenGL::Shutdown() {
|
|
||||||
LOG(0) << "Shutting down renderer.";
|
|
||||||
is_initialized_ = false;
|
|
||||||
ShutdownInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RendererOpenGL::OnWindowResized(int width, int height) {
|
void RendererOpenGL::OnWindowResized(int width, int height) {
|
||||||
screen_width_ = width;
|
screen_width_ = width;
|
||||||
screen_height_ = height;
|
screen_height_ = height;
|
||||||
|
@ -68,15 +62,6 @@ uint64_t RendererOpenGL::CreateGeometry(std::unique_ptr<Mesh> mesh) {
|
||||||
return 0;
|
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;
|
GLuint vertex_array_id = 0;
|
||||||
if (vertex_array_objects_) {
|
if (vertex_array_objects_) {
|
||||||
glGenVertexArrays(1, &vertex_array_id);
|
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,
|
glBufferData(GL_ARRAY_BUFFER, mesh->num_vertices() * vertex_size,
|
||||||
mesh->GetVertices(), GL_STATIC_DRAW);
|
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.
|
// Create the index buffer and upload the data.
|
||||||
GLuint index_buffer_id = 0;
|
GLuint index_buffer_id = 0;
|
||||||
if (mesh->GetIndices()) {
|
if (mesh->GetIndices()) {
|
||||||
|
|
|
@ -44,7 +44,9 @@ void RendererOpenGL::OnDestroy() {
|
||||||
ndk_helper::GLContext::GetInstance()->Invalidate();
|
ndk_helper::GLContext::GetInstance()->Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererOpenGL::ShutdownInternal() {
|
void RendererOpenGL::Shutdown() {
|
||||||
|
LOG(0) << "Shutting down renderer.";
|
||||||
|
is_initialized_ = false;
|
||||||
ndk_helper::GLContext::GetInstance()->Suspend();
|
ndk_helper::GLContext::GetInstance()->Suspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,9 @@ bool RendererOpenGL::Initialize(Platform* platform) {
|
||||||
|
|
||||||
void RendererOpenGL::OnDestroy() {}
|
void RendererOpenGL::OnDestroy() {}
|
||||||
|
|
||||||
void RendererOpenGL::ShutdownInternal() {
|
void RendererOpenGL::Shutdown() {
|
||||||
|
LOG(0) << "Shutting down renderer.";
|
||||||
|
is_initialized_ = false;
|
||||||
if (display_ && glx_context_) {
|
if (display_ && glx_context_) {
|
||||||
glXMakeCurrent(display_, None, NULL);
|
glXMakeCurrent(display_, None, NULL);
|
||||||
glXDestroyContext(display_, glx_context_);
|
glXDestroyContext(display_, glx_context_);
|
||||||
|
|
Loading…
Reference in New Issue