コード例 #1
0
/**
 * Method is call on press special key
 */
void Visualizer::onSpecial(int key, int, int)
{
        switch(key)
        {
                case GLUT_KEY_UP:
                        if (yshift>-50) yshift--;                       /* shift up */
                        onReshape(WindowWidth, WindowHeight);
                        glutPostRedisplay();
                        break;
                case GLUT_KEY_DOWN:
                        if (yshift<50) yshift++;                       /* shift down */
                        onReshape(WindowWidth, WindowHeight);
                        glutPostRedisplay();
                        break;
                case GLUT_KEY_LEFT:
                        if (xshift<50) xshift++;                       /* shift left */
                        onReshape(WindowWidth, WindowHeight);
                        glutPostRedisplay();
                        break;
                case GLUT_KEY_RIGHT:
                        if (xshift>-50) xshift--;                       /* shift right */
                        onReshape(WindowWidth, WindowHeight);
                        glutPostRedisplay();
                        break;
        }	
}
コード例 #2
0
ファイル: DrawingWindow.cpp プロジェクト: Avaesia/Projects
void DrawingWindow::reshapeFunction(int _width, int _height)
{
	#ifdef GLUT_Y_AXIS_BUG
	// GLUT BUG - se ia in considerare si dimensiunea marginii ferestrei pe Y
	if(glutBorderOffset == 0)
	{
		glutBorderOffset = height - _height;
	}
	// GLUT BUG - atunci cand se maximizeaza fereastra folosind butonul de MAXIMIZE, se calculeaza CORECT dimensiunea ferestrei pe Y tinand cont si de margine (BORDER)
	// Ignora in acest caz dimensiunea marginii
	if(glutGet(GLUT_WINDOW_HEIGHT) != _height)
	{
		actualBorderOffset = 0;
	}
	else
		actualBorderOffset = glutBorderOffset;
	#endif
	
	onReshape(_width,_height);
	
	width = _width;
	height = _height; 

	//glViewport stabileste transformarea in poarta de vizualizare
	glViewport(0,0,width,height);
		
	//se stabileste transformarea de proiectie
	glMatrixMode(GL_PROJECTION);
	//se porneste de la matricea identitate
	glLoadIdentity();
	//glOrtho este o proiectie ortografica - ea stabileste volumul de vizualizares
	//in cazul nostru, stabileste fereastra de vizualizare
	glOrtho(0,200,0,200,1,300);
	//ne intoarcem la matricea de modelare vizualizare
	
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	
	//gluLookAt(0.0, 0.0, 20.0,0.0, 0.0, 0.0,	0.0, 1.0, 0.0);  

	gluLookAt(45, 45, 45,0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
}
コード例 #3
0
// This file is part of CGLib.
//
// CGLib is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// CGLib 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with CGLib; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//
// Copyright 2007 Carlos Martinho

#include "ReshapeEventNotifier.h"

namespace cg {

	SINGLETON_IMPLEMENTATION(ReshapeEventNotifier)

    void ReshapeEventNotifier::handleReshape(int width, int height) {
		FOR_EACH_LISTENER(onReshape(width,height))
    }
}
コード例 #4
0
/**
 * This method is call on press of key
 */
void Visualizer::onKeyboard(unsigned char key, int, int)
{
  	if (key>='A' && key<='Z') key+='a'-'A';       /* convert upper char on lower */

  	switch (key) {                                /* press key */
    		case '1' :                                  	/* show vertex */
      			glPolygonMode(GL_FRONT, GL_POINT);
      			glPolygonMode(GL_BACK, GL_POINT);
      			glutPostRedisplay();
      			break;
    		case '2' :                                  	/* show wireframe */
      			glPolygonMode(GL_FRONT, GL_LINE);
      			glPolygonMode(GL_BACK, GL_LINE);
      			glutPostRedisplay();
     			break;
    		case '3' :                                  	/* show fill polygons */
      			glPolygonMode(GL_FRONT, GL_FILL);
      			glPolygonMode(GL_BACK, GL_FILL);
      			glutPostRedisplay();
      			break;
    		case '5' :                                  	/* decrease vision angle */
      			if (fov>0) fov--;
      			onReshape(WindowWidth, WindowHeight);
      			glutPostRedisplay();
     			break;
    		case '6' :
      			if (fov<180) fov++;                     /* increase vision angle */
      			onReshape(WindowWidth, WindowHeight);
      			glutPostRedisplay();
      			break;
    		case '7' :                                  	/* zoom in trim plain */
      			if (line_width > 0) line_width -= 0.5;	
		  	glLineWidth(line_width);                
		  	glPointSize(line_width);                
      			onReshape(WindowWidth, WindowHeight);
      			glutPostRedisplay();
      			break;
    		case '8' :                                  	/* zoom out trim plain */
      			if (line_width < 10) line_width += 0.5;
		  	glLineWidth(line_width);                
		  	glPointSize(line_width);                
      			onReshape(WindowWidth, WindowHeight);
      			glutPostRedisplay();
      			break;
		case 's' :				    	/* print to bitmap - screenshot */
			saveScreenshot(screenshotFileName);
			break;
    		case 27 :                                   	/* Escape */
    		case 'q' :
      			exit(0);                                /* exit */
      			break;
    		case 'm' :
			colorInput = INTERPOLATE_RADIOSITY;	/* interpolate radiosity */
			createCallList();
			glutPostRedisplay();
			break;
    		case 'b' :
			colorInput = INTERPOLATE_RADIOSITY_RAW;	/* interpolate radiosity */
			createCallList();
			glutPostRedisplay();
			break;
    		case 'v' :
			colorInput = RADIOSITY;	/* radiosity */
			createCallList();
			glutPostRedisplay();
			break;
    		case 'n' :
			colorInput = RADIOSITY_LAST;	/* radiosity */
			createCallList();
			glutPostRedisplay();
			break;
		case 'z' :
			colorInput = REFLECTIVITY;	/* reflectivity + emission */
			createCallList();
			glutPostRedisplay();
			break;
		case 'x' :
			colorInput = EMISSION;	/* reflectivity */
			createCallList();
			glutPostRedisplay();
			break;
		case 'c' :
			colorInput = REFLECT_EMISS;	/* emission */
			createCallList();
			glutPostRedisplay();
			break;
   		case 'f' :
      			glutFullScreen();                      	/* fullscrean */
      			break;
    		case 'w' :
      			glutReshapeWindow(WindowWidth, WindowHeight);              /* go back to window */
      			break;
    		default:
      			break;
  	}
}