Exemplo n.º 1
0
void NcursesEditorView::refresh()
{
    EditorAreas areas = determineEditorAreas(model.lineCount());

    forceCursorVisible(areas.editorArea, model, topVisibleLine, leftVisibleColumn);
    placeText(areas.editorArea, model, topVisibleLine, leftVisibleColumn);
    redrawLineNumberArea(areas.lineNumberArea, model, topVisibleLine);
    redrawStatusBar(areas.statusBarArea, model);
    redrawScrollArea(areas.scrollArea, leftVisibleColumn);
    placeCursor(areas.editorArea, model, topVisibleLine, leftVisibleColumn);

    ::refresh();
}
Exemplo n.º 2
0
/* OpenGL callbacks */
void redrawScene () {
	pScene sc;
	pTransform view;
	pPersp p;
	pCamera c;

	sc = cv.scene[currentScene()];
	view = sc->view;
	p = sc->persp;
	c = sc->camera;

	if (stereoMode == MONO || !hasStereo) {
		glDrawBuffer(GL_BACK_LEFT);
		glClearColor(sc->par.back[0], sc->par.back[1],
		             sc->par.back[2], sc->par.back[3]);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		gluLookAt(0., 0., -p->depth, 0., 0., 0., 0.0, 1.0, 0.0);

		setupView(sc);
		glMultMatrixf(view->matrix);
		glTranslatef(sc->cx, sc->cy, sc->cz);
		drawModel(sc);
		if (sc->type & S_DECO) redrawStatusBar(sc);
	} else {
		double ndfl, ratio, top, bottom;
		double left, right, nnear, ffar;

		nnear = -p->depth - 0.5 * sc->dmax;
		if (nnear < 0.1) nnear = 0.1;

		ffar = -p->depth + 0.5 * sc->dmax;
		ratio = sc->par.xs / (double)sc->par.ys;
		top = nnear * tan(DTOR * 0.5 * p->fovy);
		ndfl = nnear / p->depth;
		if (sc->par.eyesep < 0.0)
			sc->par.eyesep = fabs(p->depth / 20.0);

		/* left view */
		glDrawBuffer(GL_BACK_LEFT);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		left = -ratio * top + 0.5 * sc->par.eyesep * ndfl;
		right = ratio * top + 0.5 * sc->par.eyesep * ndfl;
		bottom = -top;

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glFrustum(left, right, top, bottom, nnear, ffar);
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		gluLookAt(-sc->par.eyesep, 0., -p->depth,
		          sc->par.eyesep / 3.0, 0., 0.,
		          0.0, 1.0, 0.0);

		setupView(sc);
		glMultMatrixf(view->matrix);
		glTranslatef(sc->cx, sc->cy, sc->cz);
		drawModel(sc);
		if (sc->type & S_DECO) redrawStatusBar(sc);

		/* right view */
		glDrawBuffer(GL_BACK_RIGHT);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		left = -ratio * top - 0.5 * sc->par.eyesep * ndfl;
		right = ratio * top - 0.5 * sc->par.eyesep * ndfl;

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glFrustum(left, right, top, bottom, nnear, ffar);
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		gluLookAt(sc->par.eyesep, 0., -p->depth,
		          sc->par.eyesep / 3.0, 0., 0.,
		          0.0, 1.0, 0.0);

		setupView(sc);
		glMultMatrixf(view->matrix);
		glTranslatef(sc->cx, sc->cy, sc->cz);
		drawModel(sc);
		if (sc->type & S_DECO) redrawStatusBar(sc);
	}

	/* refresh screen */
	if (saveimg && animate)
		glFlush();
	else
		glutSwapBuffers();

	if (ddebug) checkErrors();

	if (saveimg && !(sc->type & S_SCISSOR)) keyFile('H', 0, 0);

	/* redraw linked scene */
	if (!animate && sc->slave > -1) {
		pScene slave;

		slave = cv.scene[sc->slave];
		glutSetWindow(slave->idwin);
		redrawScene();
	}
}
Exemplo n.º 3
0
int sftcpy(pScene sc,pMesh mesh) {
    FILE     *file;
    GLfloat  *fbbuffer;
    GLint     nvalues;
    GLsizei   size;
    char     *ptr,data[128];
    static int nfree=0;

    /* default */
    if ( ddebug ) printf("soft copy\n");

//#ifdef IGL
//#define SFT_EXT "ps"
//#define GL2PS_EXT GL2PS_EPS
//#else
#define SFT_EXT "ps"
//#endif
    /* get file name */
    strcpy(data,mesh->name);
    ptr = (char*)strstr(data,".mesh");
    if ( ptr ) *ptr = '\0';
    nfree = filnum(data,nfree,SFT_EXT);
    if ( nfree == -1 )  return(0);

    /* open PS file */
    sprintf(data,"%s.%.3d." SFT_EXT,data,nfree);
    file = fopen(data,"w");
    if ( !file ) {
        fprintf(stdout,"  Unable to open %s\n",data);
        return(0);
    }

//#ifdef IGL
//  // http://www.geuz.org/gl2ps/#tth_sEc3
//  GLint buffsize = 0, state = GL2PS_OVERFLOW;
//  GLint viewport[4];
//
//  glGetIntegerv(GL_VIEWPORT, viewport);
//
//  while( state == GL2PS_OVERFLOW ){
//    buffsize += 1024*1024;
//    gl2psBeginPage (mesh->name, "medit", viewport,
//        GL2PS_EXT, GL2PS_BSP_SORT, GL2PS_SILENT |
//        GL2PS_OCCLUSION_CULL | GL2PS_BEST_ROOT,
//        GL_RGBA, 0, NULL, 0, 0, 0, buffsize,
//        file, data );
//    drawModel(sc);
//    if ( sc->type & S_DECO )  redrawStatusBar(sc);
//    state = gl2psEndPage();
//  }
//
//  fclose(file);
//
//#else

    /* size for feedback buffer */
    size    =  0;
    nvalues = -1;
    do {
        size += 1024*1024;
        fbbuffer = (GLfloat *)calloc(1+size,sizeof(GLfloat));
        if ( !fbbuffer ) {
            return(0);
        }
        if ( ddebug ) printf("feedback pointer = %p\n",fbbuffer);

        /* draw scene in back buffer */
        glFeedbackBuffer(size,GL_3D_COLOR,fbbuffer);
        (void)glRenderMode(GL_FEEDBACK);
        /*
            glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();
            gluLookAt(0.,0.,-sc->persp->depth, 0.,0.,0., 0.0,1.0,0.0);

            setupView(sc);
            glMultMatrixf(sc->view->matrix);
            glTranslatef(sc->cx,sc->cy,sc->cz);
        */
        drawModel(sc);
        if ( sc->type & S_DECO )  redrawStatusBar(sc);

        /*drawModel(sc);*/
        nvalues = (GLint)glRenderMode(GL_RENDER);
        if ( nvalues < 0 )
            free(fbbuffer);
    }
    while ( nvalues < 0 );

    if ( nvalues < 1 ) {
        return(0);
    }
    else if ( ddebug )  printf("nvalues = %d  size = %d\n",nvalues,size);

    /* write EPS file */
    glutSetCursor(GLUT_CURSOR_WAIT);

    headps(file);
    coreps(file,size,fbbuffer);
    tailps(file);

    if ( ddebug ) fprintf(stdout,"%s written\n",data);
    glutSetCursor(GLUT_CURSOR_INHERIT);
//#endif

    return(1);
}
Exemplo n.º 4
0
void scissorScene() {
  pScene      sc;
  pMesh       mesh;
  pPersp      p;
  pTransform  view;
  int         width,height;

  /* default */
  if ( ddebug ) printf("enable scissoring\n");
  sc   = cv.scene[currentScene()];
  mesh = cv.mesh[sc->idmesh];
  view = sc->view;
  p    = sc->persp; 

  /* subdivide main window */
  glViewport(0,0,sc->par.xs,sc->par.ys);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluOrtho2D(0,sc->par.xs,0,sc->par.ys);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glClearColor(sc->par.back[0],sc->par.back[1],sc->par.back[2],sc->par.back[3]);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  /* split window */
  glDisable(GL_LIGHTING);
  glColor4fv(sc->par.line);
  glBegin(GL_LINES);
  glVertex2i(sc->par.xs/2,0);
  glVertex2i(sc->par.xs/2,sc->par.ys);
  glVertex2i(0,sc->par.ys/2);
  glVertex2i(sc->par.xs,sc->par.ys/2);
  glEnd();
  glEnable(GL_LIGHTING);

  width  = (sc->par.xs + 1)/2;
  height = (sc->par.ys + 1)/2;

  glDisable(GL_LIGHTING);
  glColor4fv(sc->par.line);
  output2(5,sc->par.ys/2+5,"Top");
  output2(5,5,"Front");
  output2(sc->par.xs/2+5,5,"Right");

  glEnable(GL_SCISSOR_TEST);

  /* draw top right : normal */
  glViewport(width,height,width,height);
  glScissor(width,height,width,height);
  farclip(1);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt(0.,0.,-p->depth, 0.,0.,0., 0.0,1.0,0.0);
  setupView(sc);
  glMultMatrixf(view->matrix);
  glTranslatef(sc->cx,sc->cy,sc->cz);
  drawModel(sc);
  if ( sc->type & S_DECO )  redrawStatusBar(sc);

  /* draw top left : top view */
  glViewport(0,height,width,height);
  glScissor(0,height,width,height);
  farclip(1);  

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt(0.,0.,-p->depth, 0.,0.,0., 0.0,1.0,0.0);
  setupView(sc);
  glTranslatef(sc->cx,sc->cy,sc->cz);
  glRotatef(-90,0.0,0.0,1.0);
  glTranslatef(view->opanx,0.,0.);
  drawModel(sc);

  /* draw bottom left : front */
  glViewport(0,0,width,height);
  glScissor(0,0,width,height);
  farclip(1);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt(0.,0.,-p->depth, 0.,0.,0., 0.0,1.0,0.0);
  setupView(sc);
  glTranslatef(sc->cx,sc->cy,sc->cz);
  glRotatef(-90.0,1.0,0.0,0.0);
  glTranslatef(view->opanx,0.,0.);
  drawModel(sc);

  /* draw bottom right : right */
  glViewport(width,0,width,height);
  glScissor(width,0,width,height);
  farclip(1);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt(0.,0.,-p->depth, 0.,0.,0., 0.0,1.0,0.0);
  setupView(sc);
  glRotatef(-90.0,1.0,0.0,0.0);
  glRotatef(-90.0,0.0,0.0,1.0);
  glTranslatef(0.,view->opany,0.);
  drawModel(sc);

  glutSwapBuffers();
  glDisable(GL_SCISSOR_TEST);
  glViewport(0,0,sc->par.xs,sc->par.ys);
 
  if ( saveimg ) keyFile('H',0,0);
}