Ignore:
Timestamp:
03/30/07 11:38:28 (17 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/global.h

    r2194 r2300  
    142142extern char filename[MAX_CHAR]; 
    143143 
    144 extern void init(void); 
     144extern int      init(void); 
    145145 
    146146extern void resetProjectedAreas(int **histogram, int numCameras); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/vmi_simplifier.h

    r2127 r2300  
    22#include <stdlib.h> 
    33#include <time.h> 
    4  
    54#include "GL/glew.h" 
    65#ifdef _WIN32 
     
    1514#include "buffers.h" 
    1615 
     16#define NO_GL_ERROR                                             0x00 
     17#define FRAMEBUFFER_ERROR                       0x01 
     18#define VERTEX_BUFFER_ERROR             0x02 
     19#define OCCLUSION_QUERY_ERROR   0x04 
     20#define IMAGING_ERROR                                   0x08 
     21#define MULTITEXTURE_ERROR              0x10 
     22#define SWAP_CONTROL_ERROR              0x20 
     23 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/main.cpp

    r2194 r2300  
    33namespace VMI  
    44{ 
    5 GLMmodel *pmodel = NULL; // The .obj model 
    6  
    7 GLubyte *pixels = NULL; 
    8  
    9 Camera *cameras = NULL; 
    10 int numCameras = 0; 
    11  
    12 Color *colors = NULL; 
    13  
    14 int **histogram = NULL; 
    15 GLuint *queries = NULL; 
    16  
    17 Mesh *mesh = NULL; 
    18  
    19 GLdouble *initialIs = NULL; 
    20  
    21 GLsizei width  = 256, 
    22         height = 256; 
    23  
    24 GLboolean bEnableOffScreen = GL_TRUE, 
    25           bBeQuiet         = GL_FALSE, 
    26           bSaveLog         = GL_FALSE, 
    27           bLoadCamerasFromFile = GL_FALSE, 
    28           bRemoveRedundantVertices = GL_TRUE; 
    29  
    30 int cameraType = 0, 
    31        numDemandedTriangles = 0; 
    32  
    33 GLdouble radius = 1.3, fov = 60.0; 
    34  
    35 char filename[MAX_CHAR] = {'\0'}; 
    36  
    37 GLuint fb, depth_rb, color_tex; 
     5        GLMmodel *pmodel = NULL; // The .obj model 
     6 
     7        GLubyte *pixels = NULL; 
     8 
     9        Camera *cameras = NULL; 
     10        int numCameras = 0; 
     11 
     12        Color *colors = NULL; 
     13 
     14        int **histogram = NULL; 
     15        GLuint *queries = NULL; 
     16 
     17        Mesh *mesh = NULL; 
     18 
     19        GLdouble *initialIs = NULL; 
     20 
     21        GLsizei width  = 256, 
     22                                        height = 256; 
     23 
     24        GLboolean bEnableOffScreen = GL_TRUE, 
     25                                                bBeQuiet         = GL_FALSE, 
     26                                                bSaveLog         = GL_FALSE, 
     27                                                bLoadCamerasFromFile = GL_FALSE, 
     28                                                bRemoveRedundantVertices = GL_TRUE; 
     29 
     30        int cameraType = 0, 
     31                        numDemandedTriangles = 0; 
     32 
     33        GLdouble radius = 1.3, fov = 60.0; 
     34 
     35        char filename[MAX_CHAR] = {'\0'}; 
     36 
     37        GLuint fb, depth_rb, color_tex; 
    3838 
    3939#ifdef VERTEX_ARRAY_INTERLEAVE 
    40 VertexIL *interleave = NULL; 
    41 #endif 
    42  
    43 GLuint vertex_buf = 0, 
    44       color_buf = 0; 
    45  
    46 Vertex_ *buf_vertices = NULL; 
    47 Color   *buf_colors = NULL; 
    48  
    49 int vmiWin = 0; 
    50  
    51 //      For progress update. 
    52 Geometry::TIPOFUNC      mUPB; 
     40        VertexIL *interleave = NULL; 
     41#endif 
     42 
     43        GLuint vertex_buf = 0, 
     44                                color_buf = 0; 
     45 
     46        Vertex_ *buf_vertices = NULL; 
     47        Color   *buf_colors = NULL; 
     48 
     49        int vmiWin = 0; 
     50 
     51        //      For progress update. 
     52        Geometry::TIPOFUNC      mUPB; 
    5353 
    5454} 
     
    5656using namespace VMI; 
    5757 
    58 void VMI::init(void) 
    59 { 
     58int     VMI::init(void) 
     59{ 
     60        //      Initialize error status. 
     61        int     error   =       NO_GL_ERROR; 
     62 
    6063        // Clear color 
    6164        glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 
     
    8184                fprintf(stderr, 
    8285                                                "GL_EXT_framebuffer_object extension is not available!\n"); 
    83                 exit(1); 
     86                 
     87                error   =       error | FRAMEBUFFER_ERROR; 
    8488        } 
    8589        else 
     
    131135                fprintf(stderr, 
    132136                                "GL_ARB_vertex_buffer_object extension is not available!\n"); 
     137 
     138                error   =       error | VERTEX_BUFFER_ERROR; 
    133139        } 
    134140        else 
     
    144150        { 
    145151                fprintf(stderr, 
    146                                 "GL_ARB_occlusion_query extension is not available!\n"); 
     152                                                "GL_ARB_occlusion_query extension is not available!\n"); 
     153 
     154                error   =       error | OCCLUSION_QUERY_ERROR; 
    147155        } 
    148156        else 
     
    158166        { 
    159167                fprintf(stderr,"GL_ARB_imaging extension is not available!\n"); 
     168 
     169                error   =       error | IMAGING_ERROR; 
    160170        } 
    161171 
     
    163173        { 
    164174                fprintf(stderr,"GL_ARB_multitexture extension is not available!\n"); 
     175 
     176                error   =       error | MULTITEXTURE_ERROR; 
    165177        } 
    166178 
     
    169181        { 
    170182                fprintf(stderr,"WGL_EXT_swap_control extension is not available!\n"); 
     183 
     184                error   =       error | SWAP_CONTROL_ERROR; 
    171185        } 
    172186#endif 
     
    180194        // Set a different color for every triangle. 
    181195        setColors4(colors, mesh->currentNumTriangles); 
     196 
     197        return error; 
    182198} 
    183199 
    184200void VMI::applyHWAcceleration(void) { 
    185      
     201 
    186202#ifdef VERTEX_ARRAY_INTERLEAVE 
    187     setupInterleave(mesh, colors); 
     203        setupInterleave(mesh, colors); 
    188204#endif 
    189205#ifdef VERTEX_ARRAY 
    190     setupVertexArray(mesh, colors); 
     206        setupVertexArray(mesh, colors); 
    191207#endif 
    192208#ifdef VERTEX_BUFFER_OBJECTS 
    193     setupVertexBufferObjects(mesh, colors); 
     209        setupVertexBufferObjects(mesh, colors); 
    194210#endif 
    195211 
     
    197213 
    198214void VMI::updateHWAcceleration(Change *c) { 
    199     
     215 
    200216#ifdef VERTEX_ARRAY_INTERLEAVE 
    201     if (interleave != NULL) free(interleave); 
    202     interleave = setupInterleave(mesh, colors); 
     217        if (interleave != NULL) free(interleave); 
     218        interleave = setupInterleave(mesh, colors); 
    203219#endif 
    204220#ifdef VERTEX_ARRAY 
    205     updateVertexArray(mesh, c); 
     221        updateVertexArray(mesh, c); 
    206222#endif 
    207223#ifdef VERTEX_BUFFER_OBJECTS 
    208     updateVertexBufferObjects(mesh, c); 
     224        updateVertexBufferObjects(mesh, c); 
    209225#endif 
    210226 
     
    212228 
    213229void VMI::setOrthographicProjection(void) { 
    214     // Switch to projection mode 
    215     glMatrixMode(GL_PROJECTION); 
    216     // Save previous matrix which contains the  
    217     // settings for the perspective projection 
    218     glPushMatrix(); 
    219     // Reset matrix 
    220     glLoadIdentity(); 
    221     glOrtho(0.0, (GLdouble)HISTOGRAM_SIZE, 0.0, (GLdouble)height, -1.0, 1.0); 
    222     glMatrixMode(GL_MODELVIEW); 
    223     glLoadIdentity(); 
     230        // Switch to projection mode 
     231        glMatrixMode(GL_PROJECTION); 
     232        // Save previous matrix which contains the  
     233        // settings for the perspective projection 
     234        glPushMatrix(); 
     235        // Reset matrix 
     236        glLoadIdentity(); 
     237        glOrtho(0.0, (GLdouble)HISTOGRAM_SIZE, 0.0, (GLdouble)height, -1.0, 1.0); 
     238        glMatrixMode(GL_MODELVIEW); 
     239        glLoadIdentity(); 
    224240} 
    225241 
    226242void VMI::resetPerspectiveProjection(void) { 
    227     // Set the current matrix to GL_PROJECTION 
    228     glMatrixMode(GL_PROJECTION); 
    229     // Restore previous settings 
    230     glPopMatrix(); 
    231     // Get back to GL_MODELVIEW matrix 
    232     glMatrixMode(GL_MODELVIEW); 
    233     glLoadIdentity(); 
     243        // Set the current matrix to GL_PROJECTION 
     244        glMatrixMode(GL_PROJECTION); 
     245        // Restore previous settings 
     246        glPopMatrix(); 
     247        // Get back to GL_MODELVIEW matrix 
     248        glMatrixMode(GL_MODELVIEW); 
     249        glLoadIdentity(); 
    234250} 
    235251 
    236252void VMI::renderBitmapString(float x, float y, void *font, char *string) { 
    237     char *c; 
    238     // Set position to start drawing fonts 
    239     glRasterPos2f(x, y); 
    240     // Loop all the characters in the string 
    241     for (c=string; *c != '\0'; c++) 
    242         glutBitmapCharacter(font, *c); 
     253        char *c; 
     254        // Set position to start drawing fonts 
     255        glRasterPos2f(x, y); 
     256        // Loop all the characters in the string 
     257        for (c=string; *c != '\0'; c++) 
     258                glutBitmapCharacter(font, *c); 
    243259} 
    244260 
    245261void VMI::renderGeometry(void) { 
    246262#ifdef IMMEDIATE_MODE 
    247     int i, v1, v2, v3; 
    248  
    249     // Immediate mode 
    250     glBegin (GL_TRIANGLES); 
    251     for (i=0; i<mesh->numTriangles; i++) { 
    252         if (mesh->triangles[i].enable == TRUE) { 
    253              
    254             v1= mesh->triangles[i].indices[0]; 
    255             v2= mesh->triangles[i].indices[1]; 
    256             v3= mesh->triangles[i].indices[2]; 
    257              
    258             glColor4ub(colors[i].r, colors[i].g, colors[i].b, colors[i].a); 
    259             glVertex3f(mesh->vertices[v1].x, mesh->vertices[v1].y, mesh->vertices[v1].z); 
    260             glVertex3f(mesh->vertices[v2].x, mesh->vertices[v2].y, mesh->vertices[v2].z); 
    261             glVertex3f(mesh->vertices[v3].x, mesh->vertices[v3].y, mesh->vertices[v3].z); 
    262         } 
    263     } 
    264     glEnd(); 
     263        int i, v1, v2, v3; 
     264 
     265        // Immediate mode 
     266        glBegin (GL_TRIANGLES); 
     267        for (i=0; i<mesh->numTriangles; i++) { 
     268                if (mesh->triangles[i].enable == TRUE) { 
     269 
     270                        v1= mesh->triangles[i].indices[0]; 
     271                        v2= mesh->triangles[i].indices[1]; 
     272                        v3= mesh->triangles[i].indices[2]; 
     273 
     274                        glColor4ub(colors[i].r, colors[i].g, colors[i].b, colors[i].a); 
     275                        glVertex3f(mesh->vertices[v1].x, mesh->vertices[v1].y, mesh->vertices[v1].z); 
     276                        glVertex3f(mesh->vertices[v2].x, mesh->vertices[v2].y, mesh->vertices[v2].z); 
     277                        glVertex3f(mesh->vertices[v3].x, mesh->vertices[v3].y, mesh->vertices[v3].z); 
     278                } 
     279        } 
     280        glEnd(); 
    265281#else 
    266282#ifdef VERTEX_ARRAY 
    267     glDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3); 
     283        glDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3); 
    268284#endif 
    269285#ifdef VERTEX_ARRAY_INTERLEAVE 
    270     glInterleavedArrays (GL_T2F_C4UB_V3F, 0, interleave); 
    271     glDrawArrays(GL_TRIANGLES, 0, mesh->currentNumTriangles * 3); 
     286        glInterleavedArrays (GL_T2F_C4UB_V3F, 0, interleave); 
     287        glDrawArrays(GL_TRIANGLES, 0, mesh->currentNumTriangles * 3); 
    272288#endif 
    273289#ifdef VERTEX_BUFFER_OBJECTS 
    274     glDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3); 
    275 #endif 
    276  
    277 #endif 
    278 } 
     290        glDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3); 
     291#endif 
     292 
     293#endif 
     294} 
     295 
    279296void VMI::drawTexture(void) { 
    280297 
    281     // Clear color and depth buffers 
    282     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    283  
    284     setOrthographicProjection(); 
    285  
    286     glEnable(GL_TEXTURE_2D); 
    287     glBindTexture(GL_TEXTURE_2D, color_tex); 
    288     glBegin(GL_QUADS); 
    289      
    290     glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); 
    291     glTexCoord2f(1.0f, 0.0f); glVertex2f(width, 0.0f);  
    292     glTexCoord2f(1.0f, 1.0f); glVertex2f(width, height); 
    293     glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, height); 
    294  
    295     glEnd(); 
    296     glFlush(); 
    297     glDisable(GL_TEXTURE_2D); 
    298  
    299     resetPerspectiveProjection(); 
    300  
    301     glutSwapBuffers(); 
     298        // Clear color and depth buffers 
     299        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     300 
     301        setOrthographicProjection(); 
     302 
     303        glEnable(GL_TEXTURE_2D); 
     304        glBindTexture(GL_TEXTURE_2D, color_tex); 
     305        glBegin(GL_QUADS); 
     306 
     307        glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); 
     308        glTexCoord2f(1.0f, 0.0f); glVertex2f(width, 0.0f);  
     309        glTexCoord2f(1.0f, 1.0f); glVertex2f(width, height); 
     310        glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, height); 
     311 
     312        glEnd(); 
     313        glFlush(); 
     314        glDisable(GL_TEXTURE_2D); 
     315 
     316        resetPerspectiveProjection(); 
     317 
     318        glutSwapBuffers(); 
    302319} 
    303320 
    304321void VMI::resetProjectedAreas(int **histogram, int numCameras) { 
    305     int i = 0; 
    306  
    307     // Reset the projected areas for all cameras 
    308     for (i=0; i<numCameras; i++) 
    309         resetSWHistogram(histogram[i], mesh->numTriangles); 
     322        int i = 0; 
     323 
     324        // Reset the projected areas for all cameras 
     325        for (i=0; i<numCameras; i++) 
     326                resetSWHistogram(histogram[i], mesh->numTriangles); 
    310327} 
    311328 
    312329void VMI::getProjectedAreas(int **histogram, int numCameras) 
    313330{ 
    314     int i; 
    315  
    316     // draw to the frame buffer 
    317     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); 
    318  
    319     //glDrawBuffer(GL_BACK); 
    320     //glReadBuffer(GL_BACK); 
    321  
    322     // Get the projected areas for all cameras 
    323     for (i=0; i<numCameras; i++) { 
    324          
    325         // Clear color and depth buffers 
    326         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    327          
    328         glMatrixMode(GL_MODELVIEW); 
    329         glLoadIdentity(); 
    330          
    331         // Camera  i 
    332         gluLookAt(cameras[i].eyeX, cameras[i].eyeY, cameras[i].eyeZ, 
    333                   cameras[i].centerX, cameras[i].centerY, cameras[i].centerZ, 
    334                   cameras[i].upX, cameras[i].upY, cameras[i].upZ); 
    335          
    336         renderGeometry(); 
    337         glFlush(); 
    338          
    339         /////////////////////////////////////////////////////////////////////////// 
    340          
    341         resetSWHistogram(histogram[i], mesh->numTriangles); 
    342          
     331        int i; 
     332 
     333        // draw to the frame buffer 
     334        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); 
     335 
     336        //glDrawBuffer(GL_BACK); 
     337        //glReadBuffer(GL_BACK); 
     338 
     339        // Get the projected areas for all cameras 
     340        for (i=0; i<numCameras; i++) { 
     341 
     342                // Clear color and depth buffers 
     343                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     344 
     345                glMatrixMode(GL_MODELVIEW); 
     346                glLoadIdentity(); 
     347 
     348                // Camera  i 
     349                gluLookAt(cameras[i].eyeX, cameras[i].eyeY, cameras[i].eyeZ, 
     350                                cameras[i].centerX, cameras[i].centerY, cameras[i].centerZ, 
     351                                cameras[i].upX, cameras[i].upY, cameras[i].upZ); 
     352 
     353                renderGeometry(); 
     354                glFlush(); 
     355 
     356                /////////////////////////////////////////////////////////////////////// 
     357 
     358                resetSWHistogram(histogram[i], mesh->numTriangles); 
     359 
    343360#ifdef USE_OCCLUSION_QUERY 
    344         getSWHistoByOcclusionQuery(mesh, colors, histogram[i]); 
     361                getSWHistoByOcclusionQuery(mesh, colors, histogram[i]); 
    345362#else // HYBRID_HW_SW_HISTOGRAM 
    346         getSWHistogram(histogram[i], pixels); 
    347 #endif 
    348     } 
    349  
    350     // draw to the window, reading from the color texture 
    351     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
    352  
    353     if (!bEnableOffScreen) drawTexture(); 
    354      
    355     /////////////////////////////////////////////////////////////////////////// 
     363                getSWHistogram(histogram[i], pixels); 
     364#endif 
     365        } 
     366 
     367        // draw to the window, reading from the color texture 
     368        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
     369 
     370        if (!bEnableOffScreen) drawTexture(); 
     371 
     372        ///////////////////////////////////////////////////////////////////////// 
    356373} 
    357374void VMI::getProjectedAreasWin(int **histogram, int numCameras, Change *c) 
    358375{ 
    359     int i, j, t, background; 
    360     int del_area, mod_area; 
    361     GLfloat min[3], max[3]; 
    362  
    363     // draw to the frame buffer 
    364     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); 
    365  
    366     //printChange(c); 
    367     getBoundingBox(c, min, max); 
    368     //printf("\n(%f,%f,%f)-(%f,%f,%f)\n", min[0], min[1], min[2], max[0], max[1], max[2]); 
    369      
    370     // Update HW acceleration OpenGL Technique 
    371     updateHWAcceleration(c); 
    372  
    373     //glDrawBuffer(GL_BACK); 
    374     //glReadBuffer(GL_BACK); 
    375  
    376     // Get the projected areas for all cameras 
    377     for (i=0; i<numCameras; i++) { 
    378          
    379         // Clear color and depth buffers 
    380         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    381          
    382         glMatrixMode(GL_MODELVIEW); 
    383         glLoadIdentity(); 
    384          
    385         // Camera  i 
    386         gluLookAt(cameras[i].eyeX, cameras[i].eyeY, cameras[i].eyeZ, 
    387                   cameras[i].centerX, cameras[i].centerY, cameras[i].centerZ, 
    388                   cameras[i].upX, cameras[i].upY, cameras[i].upZ); 
    389          
    390         renderGeometry(); 
    391         glFlush(); 
    392          
    393         /////////////////////////////////////////////////////////////////////////// 
    394         background = histogram[i][0]; 
    395         //printf("b: %d\n", histogram[i][0]); 
    396  
    397         del_area = 0; 
    398         mod_area = 0; 
    399  
    400         for (j=0; j<c->numDel; j++) { 
    401             t = c->deleted[j].id; 
    402             del_area += histogram[i][t + 1]; 
    403  
    404             histogram[i][t + 1] = 0; 
    405         } 
    406  
    407         for (j=0; j<c->numMod; j++) { 
    408             t = c->modified[j].id; 
    409             del_area += histogram[i][t + 1]; 
    410  
    411             histogram[i][t + 1] = 0; 
    412         } 
    413          
    414         getSWHistogramWin(histogram[i], pixels, min, max, c);  
    415  
    416         for (j=0; j<c->numMod; j++) { 
    417             t = c->modified[j].id; 
    418             mod_area += histogram[i][t + 1]; 
    419  
    420             //printf("t%d: %d\n",t, histogram[i][t + 1]); 
    421         } 
    422         histogram[i][0] = background + (del_area - mod_area); 
    423         //printf("b: %d\n", histogram[i][0]); 
    424     } 
    425     //getchar(); 
    426  
    427     // draw to the window, reading from the color texture 
    428     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
    429  
    430     if (!bEnableOffScreen) drawTexture(); 
    431      
    432     /////////////////////////////////////////////////////////////////////////// 
     376        int i, j, t, background; 
     377        int del_area, mod_area; 
     378        GLfloat min[3], max[3]; 
     379 
     380        // draw to the frame buffer 
     381        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); 
     382 
     383        //printChange(c); 
     384        getBoundingBox(c, min, max); 
     385        //printf("\n(%f,%f,%f)-(%f,%f,%f)\n", min[0], min[1], min[2], max[0], max[1], max[2]); 
     386 
     387        // Update HW acceleration OpenGL Technique 
     388        updateHWAcceleration(c); 
     389 
     390        //glDrawBuffer(GL_BACK); 
     391        //glReadBuffer(GL_BACK); 
     392 
     393        // Get the projected areas for all cameras 
     394        for (i=0; i<numCameras; i++) { 
     395 
     396                // Clear color and depth buffers 
     397                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     398 
     399                glMatrixMode(GL_MODELVIEW); 
     400                glLoadIdentity(); 
     401 
     402                // Camera  i 
     403                gluLookAt(cameras[i].eyeX, cameras[i].eyeY, cameras[i].eyeZ, 
     404                                cameras[i].centerX, cameras[i].centerY, cameras[i].centerZ, 
     405                                cameras[i].upX, cameras[i].upY, cameras[i].upZ); 
     406 
     407                renderGeometry(); 
     408                glFlush(); 
     409 
     410                //////////////////////////////////////////////////////////////////////// 
     411                background = histogram[i][0]; 
     412                //printf("b: %d\n", histogram[i][0]); 
     413 
     414                del_area = 0; 
     415                mod_area = 0; 
     416 
     417                for (j=0; j<c->numDel; j++) { 
     418                        t = c->deleted[j].id; 
     419                        del_area += histogram[i][t + 1]; 
     420 
     421                        histogram[i][t + 1] = 0; 
     422                } 
     423 
     424                for (j=0; j<c->numMod; j++) { 
     425                        t = c->modified[j].id; 
     426                        del_area += histogram[i][t + 1]; 
     427 
     428                        histogram[i][t + 1] = 0; 
     429                } 
     430 
     431                getSWHistogramWin(histogram[i], pixels, min, max, c);  
     432 
     433                for (j=0; j<c->numMod; j++) { 
     434                        t = c->modified[j].id; 
     435                        mod_area += histogram[i][t + 1]; 
     436 
     437                        //printf("t%d: %d\n",t, histogram[i][t + 1]); 
     438                } 
     439                histogram[i][0] = background + (del_area - mod_area); 
     440                //printf("b: %d\n", histogram[i][0]); 
     441        } 
     442        //getchar(); 
     443 
     444        // draw to the window, reading from the color texture 
     445        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
     446 
     447        if (!bEnableOffScreen) drawTexture(); 
     448 
     449        //////////////////////////////////////////////////////////////////////// 
    433450} 
    434451 
    435452void VMI::freeMemory(void) { 
    436453 
    437           // Free memory 
    438     deleteMesh(mesh); 
    439  
    440     //glmDelete(pmodel); 
    441  
    442     free(pixels); 
    443  
    444     free(cameras); 
    445  
    446     free(colors); 
    447      
    448     deleteHistogram(histogram, numCameras); 
    449  
    450     free(initialIs); 
    451      
    452     glDeleteRenderbuffersEXT(1, &depth_rb); 
    453      
    454     glDeleteRenderbuffersEXT(1, &color_tex); 
    455      
    456     glDeleteFramebuffersEXT(1, &fb); 
     454        // Free memory 
     455        deleteMesh(mesh); 
     456 
     457        //glmDelete(pmodel); 
     458 
     459        free(pixels); 
     460 
     461        free(cameras); 
     462 
     463        free(colors); 
     464 
     465        deleteHistogram(histogram, numCameras); 
     466 
     467        free(initialIs); 
     468 
     469        glDeleteRenderbuffersEXT(1, &depth_rb); 
     470 
     471        glDeleteRenderbuffersEXT(1, &color_tex); 
     472 
     473        glDeleteFramebuffersEXT(1, &fb); 
    457474#ifdef USE_OCCLUSION_QUERY 
    458     glDeleteQueriesARB(mesh->currentNumTriangles, queries); 
    459 #endif 
    460  
    461                 if (vmiWin != 0) 
    462                 { 
    463                         glutDestroyWindow(vmiWin); 
    464                 } 
     475        glDeleteQueriesARB(mesh->currentNumTriangles, queries); 
     476#endif 
     477 
     478        if (vmiWin != 0) 
     479        { 
     480                glutDestroyWindow(vmiWin); 
     481        } 
    465482 
    466483#ifdef VERTEX_BUFFER_OBJECTS 
    467     glDeleteBuffersARB(1, &vertex_buf); 
    468     glDeleteBuffersARB(1, &color_buf); 
    469  
    470                 buf_vertices = NULL; 
    471     buf_colors = NULL; 
     484        glDeleteBuffersARB(1, &vertex_buf); 
     485        glDeleteBuffersARB(1, &color_buf); 
     486 
     487        buf_vertices = NULL; 
     488        buf_colors = NULL; 
    472489 
    473490#endif 
    474491#ifdef VERTEX_ARRAY 
    475     free(buf_vertices); 
    476     free(buf_colors); 
    477  
    478                 buf_vertices = NULL; 
    479     buf_colors = NULL; 
     492        free(buf_vertices); 
     493        free(buf_colors); 
     494 
     495        buf_vertices = NULL; 
     496        buf_colors = NULL; 
    480497#endif 
    481498#ifdef VERTEX_ARRAY_INTERLEAVE 
    482                 free(interleave); 
    483                 interleave = NULL; 
     499        free(interleave); 
     500        interleave = NULL; 
    484501#endif 
    485502 
     
    494511 
    495512        histogram = NULL; 
    496   queries = NULL; 
     513        queries = NULL; 
    497514 
    498515        mesh = NULL; 
     
    516533 
    517534        // Apply HW acceleration OpenGL Technique 
    518   applyHWAcceleration(); 
     535        applyHWAcceleration(); 
    519536 
    520537        getProjectedAreas(histogram, numCameras); 
     
    555572 
    556573#ifdef SALIENCY 
    557     sprintf(s,"%s_%d_%d_%s_S.obj", filename, numCameras, mesh->currentNumTriangles, EXT); 
     574        sprintf(s,"%s_%d_%d_%s_S.obj", filename, numCameras, mesh->currentNumTriangles, EXT); 
    558575#else 
    559     sprintf(s,"%s_%d_%d_%s.obj", filename, numCameras, mesh->currentNumTriangles, EXT); 
     576        sprintf(s,"%s_%d_%d_%s.obj", filename, numCameras, mesh->currentNumTriangles, EXT); 
    560577#endif 
    561578 
Note: See TracChangeset for help on using the changeset viewer.