Revision: 78267
          http://sourceforge.net/p/brlcad/code/78267
Author:   starseeker
Date:     2021-02-18 17:52:26 +0000 (Thu, 18 Feb 2021)
Log Message:
-----------
Cleanup, move logic to various ISSTGL methods.

Modified Paths:
--------------
    brlcad/trunk/src/isst/isstgl.cpp
    brlcad/trunk/src/isst/isstgl.h
    brlcad/trunk/src/isst/main.cpp

Modified: brlcad/trunk/src/isst/isstgl.cpp
===================================================================
--- brlcad/trunk/src/isst/isstgl.cpp    2021-02-18 16:17:02 UTC (rev 78266)
+++ brlcad/trunk/src/isst/isstgl.cpp    2021-02-18 17:52:26 UTC (rev 78267)
@@ -31,6 +31,7 @@
 isstGL::isstGL()
 {
     TIENET_BUFFER_INIT(buffer_image);
+    texdata = realloc(texdata, camera.w * camera.h * 3);
 
     tile.format = RENDER_CAMERA_BIT_DEPTH_24;
 
@@ -44,8 +45,15 @@
     camera.type = RENDER_CAMERA_PERSPECTIVE;
     camera.fov = 25;
     render_camera_init(&camera, bu_avail_cpus());
+    render_phong_init(&camera.render, NULL);
 }
 
+isstGL::~isstGL()
+{
+    TIENET_BUFFER_FREE(buffer_image);
+    free(texdata);
+}
+
 void
 isstGL::paintGL()
 {
@@ -78,8 +86,14 @@
     tile.size_x = camera.w;
     tile.size_y = camera.h;
 
+    // Set up the raytracing image buffer
     TIENET_BUFFER_SIZE(buffer_image, (uint32_t)(3 * camera.w * camera.h));
+
+    // Set up the corresponding texture memory in OpenGL.
     texdata = realloc(texdata, camera.w * camera.h * 3);
+    glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
     glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, camera.w, camera.h, 0, GL_RGB, 
GL_UNSIGNED_BYTE, texdata);
 }
 

Modified: brlcad/trunk/src/isst/isstgl.h
===================================================================
--- brlcad/trunk/src/isst/isstgl.h      2021-02-18 16:17:02 UTC (rev 78266)
+++ brlcad/trunk/src/isst/isstgl.h      2021-02-18 17:52:26 UTC (rev 78267)
@@ -43,6 +43,7 @@
 {
     public:
        isstGL();
+       ~isstGL();
 
        struct tie_s *tie = NULL; // From parent app
 
@@ -59,7 +60,7 @@
        struct camera_tile_s tile;
        tienet_buffer_t buffer_image;
        void *texdata = NULL;
-       GLuint texid;
+       GLuint texid = 0;
 };
 
 #endif /* ISSTGL_H */

Modified: brlcad/trunk/src/isst/main.cpp
===================================================================
--- brlcad/trunk/src/isst/main.cpp      2021-02-18 16:17:02 UTC (rev 78266)
+++ brlcad/trunk/src/isst/main.cpp      2021-02-18 17:52:26 UTC (rev 78267)
@@ -55,36 +55,18 @@
 
     // TODO - this needs to be a setting that is saved and restored
     mainWin.resize(1100, 800);
-    mainWin.canvas->camera.w = 1100;
-    mainWin.canvas->camera.h = 800;
-    mainWin.canvas->tile.size_x = 1100;
-    mainWin.canvas->tile.size_y = 800;
 
+    // The OpenGL widget manages the rendering, so let it know about the
+    // TIE data structure associated with the current model
     mainWin.canvas->tie = app.tie;
 
-    TIENET_BUFFER_SIZE(mainWin.canvas->buffer_image, (uint32_t)(3 * 
mainWin.canvas->camera.w * mainWin.canvas->camera.h));
-    mainWin.canvas->buffer_image.ind = 0;
-
+    // Initialize the camera position
     VSETALL(mainWin.canvas->camera.pos, app.tie->radius);
     VMOVE(mainWin.canvas->camera.focus, app.tie->mid);
 
-    render_phong_init(&mainWin.canvas->camera.render, NULL);
-
+    // Draw the window
     mainWin.show();
 
-    // Set up the texture data.  TODO - this seems to work on Linux, but may
-    // need to resize texdata in the resize callback...  not sure if we're
-    // "getting away" with this...  also not clear it should be needed with the
-    // painter approach to drawing the image, but without this resizing crashed
-    // fairly quickly...
-    glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
-    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-    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);
-
-    mainWin.canvas->update();
-
     return app.exec();
 }
 

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

Reply via email to