Skip to content

Commit

Permalink
fix movie.produce
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettSJohnson committed Jan 10, 2025
1 parent 0b74ba6 commit 15cb785
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 38 deletions.
25 changes: 14 additions & 11 deletions layer0/GenericBuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include <iostream>
#include "GenericBuffer.h"

#include "GraphicsUtil.h"

#include <iostream>

VertexFormatBaseType GetVertexFormatBaseType(VertexFormat format)
{
switch (format) {
Expand Down Expand Up @@ -369,13 +372,13 @@ bool GenericBuffer::interleaveBufferData()
bool GenericBuffer::genBuffer(GLuint& id, size_t size, const void* ptr)
{
glGenBuffers(1, &id);
if (!glCheckOkay())
if (!CheckGLErrorOK(nullptr, "GenericBuffer::genBuffer failed\n"))
return false;
glBindBuffer(bufferType(), id);
if (!glCheckOkay())
if (!CheckGLErrorOK(nullptr, "GenericBuffer::bindBuffer failed\n"))
return false;
glBufferData(bufferType(), size, ptr, GL_STATIC_DRAW);
if (!glCheckOkay())
if (!CheckGLErrorOK(nullptr, "GenericBuffer::bufferData failed\n"))
return false;
return true;
}
Expand Down Expand Up @@ -487,7 +490,7 @@ void renderBuffer_t::genBuffer() {
glRenderbufferStorage(GL_RENDERBUFFER, rbo_lut[(int)_storage],
_width,
_height);
glCheckOkay();
CheckGLErrorOK(nullptr, "GLRenderBuffer::genBuffer failed");
}

void renderBuffer_t::freeBuffer() { glDeleteRenderbuffers(1, &_id); }
Expand Down Expand Up @@ -653,7 +656,7 @@ void textureBuffer_t::genBuffer() {
glTexParameteri(dim, GL_TEXTURE_WRAP_R, tex_tab(_sampling[4]));
#endif

glCheckOkay();
CheckGLErrorOK(nullptr, "GLTextureBuffer::genBuffer failed");
}

void textureBuffer_t::freeBuffer() { glDeleteTextures(1, &_id); }
Expand Down Expand Up @@ -682,7 +685,7 @@ void textureBuffer_t::texture_data_1D(int width, const void *data) {
default:
break;
};
glCheckOkay();
CheckGLErrorOK(nullptr, "GLTextureBuffer::texture_data_1D failed");
#endif
}

Expand All @@ -707,7 +710,7 @@ void textureBuffer_t::texture_data_2D(int width, int height, const void *data) {
default:
break;
}
glCheckOkay();
CheckGLErrorOK(nullptr, "GLTextureBuffer::texture_data_2D failed");
}

void textureBuffer_t::texture_subdata_2D(
Expand All @@ -726,7 +729,7 @@ void textureBuffer_t::texture_subdata_2D(
tex_tab(_format), tex_tab(_type), data);
break;
}
glCheckOkay();
CheckGLErrorOK(nullptr, "GLTextureBuffer::texture_subdata_2D failed");
}

void textureBuffer_t::texture_data_3D(int width, int height, int depth,
Expand Down Expand Up @@ -757,7 +760,7 @@ void textureBuffer_t::texture_data_3D(int width, int height, int depth,
}
#endif

glCheckOkay();
CheckGLErrorOK(nullptr, "GLTextureBuffer::texture_data_3D failed");
}

void textureBuffer_t::bind() const { glBindTexture(tex_tab(_dim), _id); }
Expand Down Expand Up @@ -929,7 +932,7 @@ void renderTarget_t::layout(std::vector<rt_layout_t> &&desc,
}
_fbo->attach_renderbuffer(_rbo, fbo::attachment::DEPTH);
_desc = std::move(desc);
glCheckOkay();
CheckGLErrorOK(nullptr, "GLRenderBuffer::layout failed\n");
}

void renderTarget_t::resize(shape_type size) {
Expand Down
1 change: 0 additions & 1 deletion layer0/GenericBuffer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once
// -----------------------------------------------------------------------------
#include "GraphicsUtil.h"
#include "Vector.h"
#include <vector>
#include <tuple>
Expand Down
27 changes: 26 additions & 1 deletion layer0/GraphicsUtil.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#include "GraphicsUtil.h"

#include "PyMOLGlobals.h"
#include "Feedback.h"

#include <stdlib.h>
#ifdef _WEBGL
#include <emscripten.h>
#endif

#include <iostream>
#include "GraphicsUtil.h"
// -----------------------------------------------------------------------------
// UTIL
// Prints a backtrace during runtime of the last ^ stack frames
Expand All @@ -26,6 +32,25 @@ bool glCheckOkay() {
return true;
}

bool CheckGLErrorOK(PyMOLGlobals* G, std::string_view errString)
{
GLenum err;
if ((err = glGetError()) != 0) {
#ifdef _WEBGL
print_trace();
#else
if (G) {
PRINTFB(G, FB_CGO, FB_Errors)
"GL_Error: 0x%04x @ %s\n", err, errString.data() ENDFB(G);
} else {
printf("GL_ERROR : 0x%04x %s\n", err, errString.data());
}
std::terminate();
#endif
}
return err == 0;
}

/**
* GL debugging callback - enable with "pymol --gldebug"
*
Expand Down
7 changes: 5 additions & 2 deletions layer0/GraphicsUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

#include "os_gl.h"

// Generic Error Handing
bool glCheckOkay();
#include <string_view>

struct PyMOLGlobals;

bool CheckGLErrorOK(PyMOLGlobals* G, std::string_view errString);

void GLAPIENTRY gl_debug_proc(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *);
// userParam is qualified as const in OpenGL 4.4 spec but non-const in OpenGL 4.3 spec
Expand Down
1 change: 1 addition & 0 deletions layer1/CGO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Z* -------------------------------------------------------------------
#include "Util.h"
#include "VFont.h"
#include "Vector.h"
#include "GraphicsUtil.h"

#include "pymol/algorithm.h"

Expand Down
12 changes: 1 addition & 11 deletions layer1/CGOGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "CGORenderer.h"
#include "CoordSet.h"
#include "Feedback.h"
#include "GraphicsUtil.h"
#include "Scene.h"
#include "SceneDef.h"
#include "ShaderMgr.h"
Expand Down Expand Up @@ -56,17 +57,6 @@ static int CGOConvertDebugMode(int debug, int modeArg)
return mode;
}

#define CHECK_GL_ERROR_OK(printstr) \
if ((err = glGetError()) != 0) { \
PRINTFB(G, FB_CGO, FB_Errors) printstr, err ENDFB(G); \
}

void CheckGLErrorOK(PyMOLGlobals* G, pymol::zstring_view errString)
{
GLenum err;
CHECK_GL_ERROR_OK(errString.c_str());
}

static void CGO_gl_begin(CCGORenderer* I, CGO_op_data pc)
{
#ifndef PURE_OPENGL_ES_2
Expand Down
2 changes: 0 additions & 2 deletions layer1/CGOGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ struct CSetting;
struct Rep;
struct PickContext;

void CheckGLErrorOK(PyMOLGlobals* G, pymol::zstring_view errString);

void CGORenderGLPicking(CGO * I, RenderInfo *info,
PickContext * context, CSetting * set1, CSetting * set2, Rep *rep);
void CGORenderGL(CGO * I, const float *color, CSetting * set1, CSetting * set2,
Expand Down
1 change: 0 additions & 1 deletion layer1/Ortho.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3122,7 +3122,6 @@ static pymol::Result<pymol::Image> OrthoMakeSizedImage(
OrthoSetExtent(G, extent);
G->ShaderMgr->bindOffscreenOrtho(extent, true);

auto drawBuffer = SceneDrawBothGetConfig(G);
pymol::Image final_image(extent.width, extent.height);

// Save before we change scene extents in OrthoDrawSizedTile
Expand Down
15 changes: 6 additions & 9 deletions layer1/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1512,10 +1512,12 @@ float *SceneGetPmvMatrix(PyMOLGlobals * G)

GLFramebufferConfig SceneDrawBothGetConfig(PyMOLGlobals* G)
{
if (SceneMustDrawBoth(G)) {
return { CShaderMgr::OpenGLDefaultFramebufferID, GL_BACK_LEFT };
}
return { CShaderMgr::OpenGLDefaultFramebufferID, GL_BACK };
GLFramebufferConfig config;
config.framebuffer = G->ShaderMgr->defaultBackbuffer.framebuffer;
config.drawBuffer = SceneMustDrawBoth(G)
? GL_BACK_LEFT
: G->ShaderMgr->defaultBackbuffer.drawBuffer;
return config;
}

int SceneCaptureWindow(PyMOLGlobals * G)
Expand Down Expand Up @@ -1792,7 +1794,6 @@ pymol::Result<> SceneMakeSizedImage(PyMOLGlobals* G, Extent2D extent,

int nXStep = (extent.width / (I->Width + 1)) + 1;
int nYStep = (extent.height / (I->Height + 1)) + 1;
auto drawBuffer = SceneDrawBothGetConfig(G);

pymol::Image final_image(extent.width, extent.height);

Expand Down Expand Up @@ -4557,10 +4558,6 @@ void SceneCopy(PyMOLGlobals * G, GLFramebufferConfig config, int force, int enti
{
CScene *I = G->Scene;

if (config.drawBuffer == GL_BACK) {
config.drawBuffer = G->ShaderMgr->defaultBackbuffer.drawBuffer;
}

if(force || (!(I->StereoMode ||
SettingGetGlobal_b(G, cSetting_stereo_double_pump_mono) || I->ButtonsShown))) {
/* no copies while in stereo mode */
Expand Down

0 comments on commit 15cb785

Please sign in to comment.