diff --git a/qad/FindQAD.cmake b/qad/FindQAD.cmake index 4937148..32afe8c 100644 --- a/qad/FindQAD.cmake +++ b/qad/FindQAD.cmake @@ -33,6 +33,12 @@ foreach(_Q ${_QAD_LIBS}) #message(STATUS "Library ${_Q} (${_QU}) -> ${QAD_${_QU}_LIBRARY} found in ${_SEARCH_DIR}") list(APPEND QT_MULTILIB_LIST qad_${_Q}) endforeach() +list(APPEND QT_MULTILIB_LIST qglview) +foreach(_v ${_QT_VERSIONS_}) + find_library(QGLVIEW${_v}_LIBRARY qglview${_v} ${_SEARCH_DIR}) + set(MULTILIB_qglview_SUFFIX_Qt${_v} ${_v}) + set(MULTILIB_qglview_SUFFIX_Qt${_v} ${_v} PARENT_SCOPE) +endforeach() set(QT_MULTILIB_LIST ${QT_MULTILIB_LIST} PARENT_SCOPE) if(NOT LIBPROJECT) if (NOT _QAD_MSG) diff --git a/qad/graphic/graphic.ui b/qad/graphic/graphic.ui index b86c538..ee68f6b 100644 --- a/qad/graphic/graphic.ui +++ b/qad/graphic/graphic.ui @@ -17,7 +17,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -30,8 +39,8 @@ -10 0 - 28 - 361 + 33 + 420 @@ -47,12 +56,6 @@ :/icons/zoom-fit-best.png:/icons/zoom-fit-best.png - - - 16 - 16 - - @@ -64,12 +67,6 @@ :/icons/view-grid.png:/icons/view-grid.png - - - 16 - 16 - - true @@ -87,12 +84,6 @@ :/icons/edit-guides.png:/icons/edit-guides.png - - - 16 - 16 - - true @@ -107,12 +98,6 @@ :/icons/expand_s_y.png:/icons/expand_s_y.png - - - 16 - 16 - - true @@ -127,12 +112,6 @@ :/icons/expand_s_x.png:/icons/expand_s_x.png - - - 16 - 16 - - true @@ -147,12 +126,6 @@ :/icons/view-fullscreen.png:/icons/view-fullscreen.png - - - 16 - 16 - - @@ -164,12 +137,6 @@ :/icons/border-line.png:/icons/border-line.png - - - 16 - 16 - - true @@ -187,12 +154,6 @@ :/icons/legend.png:/icons/legend.png - - - 16 - 16 - - true @@ -210,12 +171,6 @@ :/icons/media-playback-pause.png:/icons/media-playback-pause.png - - - 16 - 16 - - true @@ -230,12 +185,6 @@ :/icons/configure.png:/icons/configure.png - - - 16 - 16 - - @@ -247,12 +196,6 @@ :/icons/document-save.png:/icons/document-save.png - - - 16 - 16 - - @@ -280,12 +223,6 @@ :/icons/edit-clear.png:/icons/edit-clear.png - - - 16 - 16 - - @@ -297,12 +234,6 @@ :/icons/dialog-close.png:/icons/dialog-close.png - - - 16 - 16 - - @@ -350,7 +281,16 @@ QFrame::Sunken - + + 0 + + + 0 + + + 0 + + 0 @@ -365,7 +305,16 @@ 0 - + + 2 + + + 2 + + + 2 + + 2 @@ -417,7 +366,16 @@ 0 - + + 2 + + + 2 + + + 2 + + 2 @@ -455,12 +413,21 @@ + + 1 + + + 1 + + + 1 + + + 1 + 4 - - 1 - diff --git a/qad/graphic/graphic_conf.ui b/qad/graphic/graphic_conf.ui index de95034..4f7ebf5 100644 --- a/qad/graphic/graphic_conf.ui +++ b/qad/graphic/graphic_conf.ui @@ -9,8 +9,8 @@ 0 0 - 448 - 513 + 492 + 585 @@ -20,7 +20,16 @@ true - + + 2 + + + 2 + + + 2 + + 2 @@ -35,7 +44,16 @@ 2 - + + 2 + + + 2 + + + 2 + + 2 @@ -142,7 +160,16 @@ 2 - + + 2 + + + 2 + + + 2 + + 2 @@ -254,7 +281,16 @@ 2 - + + 2 + + + 2 + + + 2 + + 2 @@ -390,7 +426,16 @@ Margins - + + 2 + + + 2 + + + 2 + + 2 diff --git a/qglview/CMakeLists.txt b/qglview/CMakeLists.txt index 1041028..9243844 100644 --- a/qglview/CMakeLists.txt +++ b/qglview/CMakeLists.txt @@ -25,7 +25,7 @@ qt_add_library(${PROJECT_NAME} SHARED out_CPP) qt_target_link_libraries(${PROJECT_NAME} qad_utils qad_widgets ${OPENGL_LIBRARIES}) message(STATUS "Building ${PROJECT_NAME}") if (LIBPROJECT) - sdk_install("qad" "${PROJECT_NAME}" "${H}") + sdk_install("qad" "${PROJECT_NAME}" "${out_HDR}") else() if (LIB) if (WIN32) diff --git a/qglview/glmaterial.cpp b/qglview/glmaterial.cpp index 891e999..9fd8efa 100644 --- a/qglview/glmaterial.cpp +++ b/qglview/glmaterial.cpp @@ -83,6 +83,7 @@ void GLCubeTexture::loadPathesFromDirectory(const QString & dir) { GLuint GLTextureManagerBase::loadTexture(const QString & path, bool ownership, bool bump) { + if (!currentGLTextureManager) return 0; QString p = findFile(path, search_pathes); if (p.isEmpty()) return 0; int tid = ((GLTextureManagerBase*)currentGLTextureManager)->textureID(p, bump); @@ -225,7 +226,8 @@ void Material::apply(__GLShaderProgram__ * prog) { void Material::loadTextures(GLTextureManagerBase * tm) { //qDebug() << "load textures"; - if (tm == 0) tm = (GLTextureManagerBase*)currentGLTextureManager; + if (!tm) tm = (GLTextureManagerBase*)currentGLTextureManager; + if (!tm) return; if (!map_diffuse.bitmap_path.isEmpty()) map_diffuse.bitmap_id = tm->loadTexture(map_diffuse.bitmap_path); if (!map_normal.bitmap_path.isEmpty()) map_normal.bitmap_id = tm->loadTexture(map_normal.bitmap_path, true, true); if (!map_relief.bitmap_path.isEmpty()) map_relief.bitmap_id = tm->loadTexture(map_relief.bitmap_path); diff --git a/qglview/gltypes.h b/qglview/gltypes.h index 1879ed9..220a75e 100644 --- a/qglview/gltypes.h +++ b/qglview/gltypes.h @@ -185,7 +185,7 @@ QMatrix4x4 getGLMatrix(GLenum matrix); void setGLMatrix(QMatrix4x4 matrix); inline void deleteGLTexture(GLuint & tex) {if (tex != 0) glDeleteTextures(1, &tex); tex = 0;} #if QT_VERSION >= 0x050600 -# define QGLCI QOpenGLExtraFunctions gf(QOpenGLContext::currentContext()); +# define QGLCI if (!QOpenGLContext::currentContext()) return; QOpenGLExtraFunctions gf(QOpenGLContext::currentContext()); # define QGLC gf. inline void glActiveTextureChannel(int channel) {QGLCI gf.glActiveTexture(GL_TEXTURE0 + channel);} inline void glDisableTextures(int channels = 8) {QGLCI for (int i = channels - 1; i >= 0; --i) {glActiveTextureChannel(i); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_CUBE_MAP);}} diff --git a/qglview/qglview.cpp b/qglview/qglview.cpp index 3a0a892..5c5fdbc 100644 --- a/qglview/qglview.cpp +++ b/qglview/qglview.cpp @@ -39,6 +39,7 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) { setFocusPolicy(Qt::WheelFocus); setScene(new QGraphicsScene()); setInteractive(true); + need_init_ = true; objects_.is_root = true; painter_ = 0; backColor_ = Qt::black; @@ -108,8 +109,11 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) { QGLView::~QGLView() { + stop(); if (shader_select != 0) delete shader_select; if (shader_halo != 0) delete shader_halo; + currentQGLView = 0; + currentGLTextureManager = 0; //if (shader_rope != 0) delete shader_rope; } @@ -159,12 +163,13 @@ void QGLView::drawBackground(QPainter * painter, const QRectF & rect) { glDisable(GL_CULL_FACE); glReleaseTextures(); QGraphicsView::drawBackground(painter_, rect); + painter_ = 0; } void QGLView::initializeGL() { //qDebug() << "init glview"; - makeCurrent(); + //makeCurrent(); #if QT_VERSION >= 0x050600 initializeOpenGLFunctions(); #endif @@ -216,11 +221,18 @@ void QGLView::initializeGL() { //createGLTexture(t, QImage("e/bottom.jpg")); //qDebug() << bindTexture(QImage("e/bottom.jpg")); + need_init_ = false; emit glInitializeDone(); } void QGLView::paintGL() { +#if QT_VERSION >= 0x050600 + //initializeOpenGLFunctions(); + if (need_init_) + initializeGL(); +#endif + //qDebug() << "paintGL"; //QMutexLocker ml_v(&v_mutex); glEnable(GL_CULL_FACE); //glDisable(GL_CULL_FACE); @@ -308,6 +320,7 @@ void QGLView::paintGL() { renderer_->prepareScene(); renderer_->renderScene(); } + emit glPainting(); if (selectionHalo_ || hoverHalo_) { glReleaseTextures(); glReleaseShaders(); @@ -342,7 +355,7 @@ void QGLView::paintGL() { glResetAllTransforms(); glReleaseFramebuffer(); - emit glPainting(); + emit glEndPaint(); /*releaseShaders(); glActiveTextureChannel(0); diff --git a/qglview/qglview.h b/qglview/qglview.h index a26cba7..f383da9 100644 --- a/qglview/qglview.h +++ b/qglview/qglview.h @@ -269,7 +269,7 @@ private: double fogDensity_, fogStart_, fogEnd_, fps_, fps_tm, hoverHaloFill_, selectionHaloFill_, m_motionBlurFactor; int timer, fps_cnt, sh_id_loc; bool is_init, fogEnabled_, lightEnabled_, grabMouse_, mouse_first, mouseRotate_, mouseSelect_, customMouseMove_; - bool shaders_supported, changed_, cameraOrbit_; + bool shaders_supported, changed_, cameraOrbit_, need_init_; bool hoverHalo_, selectionHalo_, mouseThis_, shaders_bind, selecting_; public slots: @@ -305,6 +305,7 @@ public slots: signals: void glBeginPaint(); void glPainting(); + void glEndPaint(); void glKeyPressEvent(QKeyEvent * e); void glKeyReleaseEvent(QKeyEvent * e); void glMousePressEvent(QMouseEvent * e); diff --git a/qglview/renderer_deferred_shading.cpp b/qglview/renderer_deferred_shading.cpp index d6a9496..1df6c89 100644 --- a/qglview/renderer_deferred_shading.cpp +++ b/qglview/renderer_deferred_shading.cpp @@ -88,13 +88,13 @@ void RendererDeferredShading::renderScene() { fbo_g.bind(); int buffs[] = {0, 1, 2, 3, 4}; fbo_g.setWriteBuffers(buffs, 5); - if (white_image_id == 0) { + if (white_image_id == 0 && currentGLTextureManager) { glActiveTextureChannel(6); white_image_id = ((GLTextureManagerBase*)currentGLTextureManager)->loadTexture(white_image, false); glBindTexture(GL_TEXTURE_2D, white_image_id); glActiveTextureChannel(0); } - if (violent_image_id == 0) { + if (violent_image_id == 0 && currentGLTextureManager) { glActiveTextureChannel(7); violent_image_id = ((GLTextureManagerBase*)currentGLTextureManager)->loadTexture(violent_image, false); glBindTexture(GL_TEXTURE_2D, violent_image_id);