Revision: 78252
http://sourceforge.net/p/brlcad/code/78252
Author: starseeker
Date: 2021-02-17 02:49:29 +0000 (Wed, 17 Feb 2021)
Log Message:
-----------
Trying to move the drawing code to a function is changing the results. Might
be a different issue - even from the main function results aren't consistent
run to run.
Modified Paths:
--------------
brlcad/trunk/src/isst/CMakeLists.txt
brlcad/trunk/src/isst/isstapp.cpp
brlcad/trunk/src/isst/isstapp.h
brlcad/trunk/src/isst/main.cpp
brlcad/trunk/src/isst/main_window.cpp
brlcad/trunk/src/isst/main_window.h
Added Paths:
-----------
brlcad/trunk/src/isst/isstgl.cpp
brlcad/trunk/src/isst/isstgl.h
Modified: brlcad/trunk/src/isst/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/isst/CMakeLists.txt 2021-02-16 23:01:51 UTC (rev
78251)
+++ brlcad/trunk/src/isst/CMakeLists.txt 2021-02-17 02:49:29 UTC (rev
78252)
@@ -20,11 +20,13 @@
main.cpp
main_window.cpp
isstapp.cpp
+ isstgl.cpp
)
set(moc_headers
main_window.h
isstapp.h
+ isstgl.h
)
if(BRLCAD_ENABLE_QT)
Modified: brlcad/trunk/src/isst/isstapp.cpp
===================================================================
--- brlcad/trunk/src/isst/isstapp.cpp 2021-02-16 23:01:51 UTC (rev 78251)
+++ brlcad/trunk/src/isst/isstapp.cpp 2021-02-17 02:49:29 UTC (rev 78252)
@@ -285,11 +285,8 @@
d.dbip = dbip;
BU_ALLOC(tie, struct tie_s);
- TIENET_BUFFER_INIT(buffer_image);
- render_camera_init(&camera, bu_avail_cpus());
d.cur_tie = this->tie;
-
BN_CK_TOL(tree_state.ts_tol);
BG_CK_TESS_TOL(tree_state.ts_ttol);
Modified: brlcad/trunk/src/isst/isstapp.h
===================================================================
--- brlcad/trunk/src/isst/isstapp.h 2021-02-16 23:01:51 UTC (rev 78251)
+++ brlcad/trunk/src/isst/isstapp.h 2021-02-17 02:49:29 UTC (rev 78252)
@@ -54,10 +54,6 @@
struct tie_s *tie;
struct adrt_mesh_s *meshes;
- struct render_camera_s camera;
- tienet_buffer_t buffer_image;
- void *texdata;
- int texid;
struct tie_s *cur_tie;
struct db_i *dbip;
Added: brlcad/trunk/src/isst/isstgl.cpp
===================================================================
--- brlcad/trunk/src/isst/isstgl.cpp (rev 0)
+++ brlcad/trunk/src/isst/isstgl.cpp 2021-02-17 02:49:29 UTC (rev 78252)
@@ -0,0 +1,105 @@
+/* I S S T G L . C P P
+ * BRL-CAD
+ *
+ * Copyright (c) 2021 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file isstgl.cpp
+ *
+ * Brief description
+ *
+ */
+
+#include <QOpenGLWidget>
+
+#include "bu/parallel.h"
+#include "isstgl.h"
+
+isstGL::isstGL()
+{
+ TIENET_BUFFER_INIT(buffer_image);
+
+ tile.format = RENDER_CAMERA_BIT_DEPTH_24;
+
+ camera.type = RENDER_CAMERA_PERSPECTIVE;
+ camera.fov = 25;
+ render_camera_init(&camera, bu_avail_cpus());
+}
+
+void
+isstGL::render()
+{
+ TIENET_BUFFER_SIZE(buffer_image, (uint32_t)(3 * camera.w * camera.h));
+ texid = 0;
+ if (texdata)
+ free(texdata);
+ makeCurrent();
+ glGenTextures(1, &texid);
+
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ texdata = malloc(camera.w * camera.h * 3);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, camera.w, camera.h, 0, GL_RGB,
GL_UNSIGNED_BYTE, texdata);
+ glDisable(GL_LIGHTING);
+ glViewport(0,0, camera.w, camera.h);
+ glMatrixMode (GL_PROJECTION);
+ glLoadIdentity ();
+ glOrtho(0, camera.w, camera.h, 0, -1, 1);
+ glMatrixMode (GL_MODELVIEW);
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ buffer_image.ind = 0;
+
+ VSETALL(camera.pos, tie->radius);
+ VMOVE(camera.focus, tie->mid);
+
+ render_phong_init(&camera.render, NULL);
+
+ render_camera_prep(&camera);
+ render_camera_render(&camera, tie, &tile, &buffer_image);
+
+ glClear(GL_DEPTH_BUFFER_BIT);
+ glLoadIdentity();
+ glColor3f(1,1,1);
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, texid);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, camera.w, camera.h, GL_RGB,
GL_UNSIGNED_BYTE, buffer_image.data + sizeof(camera_tile_t));
+ glBegin(GL_TRIANGLE_STRIP);
+
+ glTexCoord2d(0, 0); glVertex3f(0, 0, 0);
+ glTexCoord2d(0, 1); glVertex3f(0, camera.h, 0);
+ glTexCoord2d(1, 0); glVertex3f(camera.w, 0, 0);
+ glTexCoord2d(1, 1); glVertex3f(camera.w, camera.h, 0);
+
+ glEnd();
+ glFlush();
+ doneCurrent();
+
+}
+
+// Local Variables:
+// tab-width: 8
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// c-file-style: "stroustrup"
+// End:
+// ex: shiftwidth=4 tabstop=8
+
Property changes on: brlcad/trunk/src/isst/isstgl.cpp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: brlcad/trunk/src/isst/isstgl.h
===================================================================
--- brlcad/trunk/src/isst/isstgl.h (rev 0)
+++ brlcad/trunk/src/isst/isstgl.h 2021-02-17 02:49:29 UTC (rev 78252)
@@ -0,0 +1,73 @@
+/* I S S T G L . H
+ * BRL-CAD
+ *
+ * Copyright (c) 2021 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file isstgl.h
+ *
+ * Brief description
+ *
+ */
+
+#ifndef ISSTGL_H
+#define ISSTGL_H
+
+#include <QOpenGLWidget>
+#include <QOpenGLFunctions>
+extern "C" {
+#include "rt/tie.h"
+#include "adrt.h"
+#include "adrt_struct.h"
+#include "librender/camera.h"
+}
+
+// Use QOpenGLFunctions so we don't have to prefix all OpenGL calls with "f->"
+class isstGL : public QOpenGLWidget
+{
+ public:
+ isstGL();
+
+ struct tie_s *tie = NULL; // From parent app
+
+ void render();
+
+#if 0
+ protected:
+ void resizeGL(int w, int h) override;
+ void paintGL() override;
+#endif
+
+
+ public:
+ struct render_camera_s camera;
+ struct camera_tile_s tile;
+ tienet_buffer_t buffer_image;
+ void *texdata = NULL;
+ GLuint texid;
+};
+
+#endif /* ISSTGL_H */
+
+// Local Variables:
+// tab-width: 8
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// c-file-style: "stroustrup"
+// End:
+// ex: shiftwidth=4 tabstop=8
+
Property changes on: brlcad/trunk/src/isst/isstgl.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: brlcad/trunk/src/isst/main.cpp
===================================================================
--- brlcad/trunk/src/isst/main.cpp 2021-02-16 23:01:51 UTC (rev 78251)
+++ brlcad/trunk/src/isst/main.cpp 2021-02-17 02:49:29 UTC (rev 78252)
@@ -55,64 +55,62 @@
// TODO - this needs to be a setting that is saved and restored
mainWin.resize(1100, 800);
- app.camera.w = 1100;
- app.camera.h = 800;
+ mainWin.canvas->camera.w = 1100;
+ mainWin.canvas->camera.h = 800;
+ mainWin.canvas->tie = app.tie;
mainWin.show();
- app.camera.type = RENDER_CAMERA_PERSPECTIVE;
- app.camera.fov = 25;
- struct camera_tile_s tile;
- tile.format = RENDER_CAMERA_BIT_DEPTH_24;
- tile.size_x = 1100;
- tile.size_y = 800;
+ mainWin.canvas->tile.size_x = 1100;
+ mainWin.canvas->tile.size_y = 800;
- TIENET_BUFFER_SIZE(app.buffer_image, (uint32_t)(3 * app.camera.w *
app.camera.h));
- app.texid = 0;
- mainWin.canvas->makeCurrent();
- glClearColor (0.0, 0, 0.0, 1);
- glBindTexture (GL_TEXTURE_2D, app.texid);
+ //mainWin.canvas->makeCurrent();
+
+ QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
+ if (!f)
+ bu_log("no current functions\n");
+
+ TIENET_BUFFER_SIZE(mainWin.canvas->buffer_image, (uint32_t)(3 *
mainWin.canvas->camera.w * mainWin.canvas->camera.h));
+
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- app.texdata = malloc(app.camera.w * app.camera.h * 3);
- glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, app.camera.w, app.camera.h, 0,
GL_RGB, GL_UNSIGNED_BYTE, app.texdata);
+ mainWin.canvas->texdata = malloc(mainWin.canvas->camera.w *
mainWin.canvas->camera.h * 3);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, mainWin.canvas->camera.w,
mainWin.canvas->camera.h, 0, GL_RGB, GL_UNSIGNED_BYTE, mainWin.canvas->texdata);
glDisable(GL_LIGHTING);
-
- glViewport(0,0, app.camera.w, app.camera.h);
+ glViewport(0,0, mainWin.canvas->camera.w, mainWin.canvas->camera.h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
- glOrtho(0, app.camera.w, app.camera.h, 0, -1, 1);
+ glOrtho(0, mainWin.canvas->camera.w, mainWin.canvas->camera.h, 0, -1, 1);
glMatrixMode (GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT);
- app.buffer_image.ind = 0;
+ mainWin.canvas->buffer_image.ind = 0;
- VSETALL(app.camera.pos, app.tie->radius);
- VMOVE(app.camera.focus, app.tie->mid);
+ VSETALL(mainWin.canvas->camera.pos, app.tie->radius);
+ VMOVE(mainWin.canvas->camera.focus, app.tie->mid);
- render_phong_init(&app.camera.render, NULL);
+ render_phong_init(&mainWin.canvas->camera.render, NULL);
- render_camera_prep(&app.camera);
- render_camera_render(&app.camera, app.tie, &tile, &app.buffer_image);
+ render_camera_prep(&mainWin.canvas->camera);
+ render_camera_render(&mainWin.canvas->camera, app.tie,
&mainWin.canvas->tile, &mainWin.canvas->buffer_image);
glClear(GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glColor3f(1,1,1);
glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, app.texid);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, app.camera.w, app.camera.h,
GL_RGB, GL_UNSIGNED_BYTE, app.buffer_image.data + sizeof(camera_tile_t));
+ glBindTexture(GL_TEXTURE_2D, mainWin.canvas->texid);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mainWin.canvas->camera.w,
mainWin.canvas->camera.h, GL_RGB, GL_UNSIGNED_BYTE,
mainWin.canvas->buffer_image.data + sizeof(camera_tile_t));
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2d(0, 0); glVertex3f(0, 0, 0);
- glTexCoord2d(0, 1); glVertex3f(0, app.camera.h, 0);
- glTexCoord2d(1, 0); glVertex3f(app.camera.w, 0, 0);
- glTexCoord2d(1, 1); glVertex3f(app.camera.w, app.camera.h, 0);
+ glTexCoord2d(0, 1); glVertex3f(0, mainWin.canvas->camera.h, 0);
+ glTexCoord2d(1, 0); glVertex3f(mainWin.canvas->camera.w, 0, 0);
+ glTexCoord2d(1, 1); glVertex3f(mainWin.canvas->camera.w,
mainWin.canvas->camera.h, 0);
glEnd();
glFlush();
Modified: brlcad/trunk/src/isst/main_window.cpp
===================================================================
--- brlcad/trunk/src/isst/main_window.cpp 2021-02-16 23:01:51 UTC (rev
78251)
+++ brlcad/trunk/src/isst/main_window.cpp 2021-02-17 02:49:29 UTC (rev
78252)
@@ -43,7 +43,8 @@
file_menu->addAction(isst_exit);
// Set up Display canvas
- canvas = new QOpenGLWidget();
+ //canvas = new QOpenGLWidget();
+ canvas = new isstGL();
canvas->setMinimumSize(512,512);
setCentralWidget(canvas);
Modified: brlcad/trunk/src/isst/main_window.h
===================================================================
--- brlcad/trunk/src/isst/main_window.h 2021-02-16 23:01:51 UTC (rev 78251)
+++ brlcad/trunk/src/isst/main_window.h 2021-02-17 02:49:29 UTC (rev 78252)
@@ -35,6 +35,7 @@
#include <QAction>
#include <QStatusBar>
#include <QFileDialog>
+#include "isstgl.h"
class ISST_MainWindow : public QMainWindow
{
@@ -42,7 +43,7 @@
public:
ISST_MainWindow();
- QOpenGLWidget *canvas;
+ isstGL *canvas;
private slots:
void open_file();
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits