Ignore:
Timestamp:
Apr 8, 2009, 6:56:12 PM (15 years ago)
Author:
garnier
Message:

Improvments for print in pixmap. Not finish yet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/OpenGL/src/G4OpenGLXViewer.cc

    r959 r975  
    2525//
    2626//
    27 // $Id: G4OpenGLXViewer.cc,v 1.51 2009/03/05 16:36:13 lgarnier Exp $
     27// $Id: G4OpenGLXViewer.cc,v 1.52 2009/04/08 16:55:44 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    9292
    9393void G4OpenGLXViewer::SetView () {
    94   glXMakeCurrent (dpy, fGLXWin, cx);
     94  glXMakeCurrent (dpy, win, cx);
    9595  G4OpenGLViewer::SetView (); 
    9696}
     
    259259  class_hints -> res_class = NewString("G4OpenGL");
    260260
    261    fGLXWin = XCreateWindow (dpy, XRootWindow (dpy, vi -> screen), x_origin,
     261   win = XCreateWindow (dpy, XRootWindow (dpy, vi -> screen), x_origin,
    262262                        y_origin, fWinSize_x, fWinSize_y, 0, vi -> depth,
    263263                        InputOutput, vi -> visual, 
     
    266266                        &swa);
    267267 
    268    XSetWMProperties (dpy, fGLXWin, &windowName, &iconName, 0, 0,
     268   XSetWMProperties (dpy, win, &windowName, &iconName, 0, 0,
    269269                     size_hints, wm_hints, class_hints);
    270270 
    271271// request X to Draw window on screen.
    272   XMapWindow (dpy, fGLXWin);
     272  XMapWindow (dpy, win);
    273273
    274274// Wait for window to appear (wait for an "expose" event).
    275   XIfEvent (dpy, &event, G4OpenGLXViewerWaitForNotify, (char*) fGLXWin);
     275  XIfEvent (dpy, &event, G4OpenGLXViewerWaitForNotify, (char*) win);
    276276
    277277// connect the context to a window
    278   Bool success = glXMakeCurrent (dpy, fGLXWin, cx);
     278  Bool success = glXMakeCurrent (dpy, win, cx);
    279279  if (!success) {
    280280    fViewId = -1;  // This flags an error.
     
    405405    glXMakeCurrent (dpy, None, NULL);
    406406    glXDestroyContext (dpy, cx);
    407     if (fGLXWin) XDestroyWindow (dpy, fGLXWin); // ...if already deleted in
     407    if (win) XDestroyWindow (dpy, win); // ...if already deleted in
    408408    // sub-class G4OpenGLXmViewer.
    409409    XFlush (dpy);
     
    451451
    452452#ifdef G4DEBUG_VIS_OGL
    453     printf("G4OpenGLXViewer::print Create pixmap old context:%d new context %d old winGL:%d  Size :%d %d\n",cx,pcx,fGLXWin,fWinSize_x, fWinSize_y);
     453    printf("G4OpenGLXViewer::print Create pixmap  Size :%d %d\n",fWinSize_x, fWinSize_y);
    454454#endif
    455455    cx=pcx;
     
    478478
    479479    GLXDrawable tmp_win;
    480     tmp_win=fGLXWin;
    481     fGLXWin=glxpmap;
    482    
    483     int winX=fWinSize_x;
    484     int winY=fWinSize_y;
     480    tmp_win=win;
     481    win=glxpmap;
     482   
     483//     int winX=fWinSize_x;
     484//     int winY=fWinSize_y;
    485485
    486486    //#define CHECK_MULTIPLE_PRINT 1
     
    504504
    505505#ifdef G4DEBUG_VIS_OGL
    506     printf("G4OpenGLXViewer::print Call DrawView context:%d old winGL:%d \n",cx,fGLXWin);
     506    printf("G4OpenGLXViewer::print Call DrawView \n");
    507507#endif
    508508
     
    537537    fWinSize_x = winX;
    538538#endif
    539     fGLXWin=tmp_win;
     539    win=tmp_win;
    540540    cx=tmp_cx;
    541541   
    542542//     bool er2 = glXMakeCurrent (dpy,
    543 //                  fGLXWin,
     543//                  win,
    544544//                  cx);
    545545#ifdef G4DEBUG_VIS_OGL
    546     printf("G4OpenGLXViewer::print Restored context:%d old winGL:%d \n",cx,fGLXWin);
     546    printf("G4OpenGLXViewer::print Restored \n");
    547547#endif
    548548    //    printf("Error 1:%d 2:%d\n",er1,er2);
     
    593593
    594594 
    595 #ifdef G4DEBUG_VIS_OGL
    596   printf("------%d------\n",tmp_cx);
    597 #endif
    598595  return glXCreateContext (dpy,
    599596                           pvi,
     
    623620  if (lineBuffer == NULL)
    624621    return false;
    625   for (int y = 0; y<lineSize; y++) {
     622  for (unsigned int y = 0; y<lineSize; y++) {
    626623    lineBuffer[y] = 0;
    627624  }
     
    662659
    663660
    664   for (int i=0;i<height;i++) {
     661  for (unsigned int i=0;i<height;i++) {
    665662    glReadPixels (0, i, (GLsizei)width, 1, format, GL_UNSIGNED_BYTE, (GLvoid*) lineBuffer);
    666663    glXWaitGL (); //Wait for effects of all previous OpenGL commands to
    667664    //    printf("\n%d ",i);
    668     for (int j=0;j<lineSize;j++) {
     665    for (unsigned int j=0;j<lineSize;j++) {
    669666      buffer[j+i*lineSize] = lineBuffer[j];
    670667      //      printf("%d ",buffer[j]);
     
    699696  GLubyte* pixels;
    700697  GLubyte* curpix;
    701   int components, pos, i;
     698  int components;
    702699
    703700  GLenum format;
     
    777774         
    778775  curpix = (GLubyte*) pixels;
    779   pos = 0;
    780   for (i = width*height*components; i>0; i--) {
     776  unsigned int pos = 0;
     777  for (unsigned int i = width*height*components; i>0; i--) {
    781778    fprintf (fp, "%02hx ", *(curpix++));
    782779    if (++pos >= width) {
Note: See TracChangeset for help on using the changeset viewer.