Beispiel #1
0
void reshape(int w, int h)
{
    height = h;
    width = w;
    if(height==0) height=1;       //Prevent a divide by zero if window's height is too small

    float ratio = 1.0*width/height;

    // set subwindow 1 as the active window
	glutSetWindow(subWindow1);
	// resize and reposition the sub window
	glutPositionWindow(border,border);
	glutReshapeWindow(w-2*border, h/2 - border*3/2);
	setProjection(w-2*border, h/2 - border*3/2);

	// set subwindow 2 as the active window
	glutSetWindow(subWindow2);
	// resize and reposition the sub window
	glutPositionWindow(border,(h+border)/2);
	glutReshapeWindow(w/2-border*3/2, h/2 - border*3/2);
	setProjection(w/2-border*3/2,h/2 - border*3/2);

	// set subwindow 3 as the active window
	glutSetWindow(subWindow3);
	// resize and reposition the sub window
	glutPositionWindow((w+border)/2,(h+border)/2);
	glutReshapeWindow(w/2-border*3/2,h/2 - border*3/2);
	setProjection(w/2-border*3/2,h/2 - border*3/2);
}
void changeSize(int w1,int h1) {

	if(h1 == 0)
		h1 = 1;

	// we're keeping these values cause we'll need them latter
	w = w1;
	h = h1;

	// set subwindow 1 as the active window
	glutSetWindow(subWindow1);
	// resize and reposition the sub window
	glutPositionWindow(border, border);
	glutReshapeWindow(w-2*border, h/2 - border*3/2);
	setProjection(w-2*border, h/2 - border*3/2);

	// set subwindow 2 as the active window
	glutSetWindow(subWindow2);
	// resize and reposition the sub window
	glutPositionWindow(border,(h+border)/2);
	glutReshapeWindow(w/2-border*3/2, h/2 - border*3/2);
	setProjection(w/2-border*3/2,h/2 - border*3/2);

	// set subwindow 3 as the active window
	glutSetWindow(subWindow3);
	// resize and reposition the sub window
	glutPositionWindow((w+border)/2, (h+border)/2);
	glutReshapeWindow(w/2-border*3/2, h/2 - border*3/2);
	setProjection(w/2-border*3/2, h/2 - border*3/2);
}
Beispiel #3
0
void Osg3dView::buildPopupMenu()
{
    QAction *a;
    QMenu *sub = m_popupMenu.addMenu("MouseMode...");

    a = sub->addAction("Orbit", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_O));
    a->setData(QVariant(MM_ORBIT));
    a = sub->addAction("Pan", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_P));
    a->setData(QVariant(MM_PAN));
    a = sub->addAction("Rotate", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_R));
    a->setData(QVariant(MM_ROTATE));
    a = sub->addAction("Zoom", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_Z));
    a->setData(QVariant(MM_ZOOM));
    a = sub->addAction("Pick Center", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_C));
    a->setData(QVariant(MM_PICK_CENTER));
    a = sub->addAction("Select Object", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_S));
    a->setData(QVariant(MM_SELECT));

    sub = m_popupMenu.addMenu("Std View...");
    a = sub->addAction("Top", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_T));
    a->setData(V_TOP);
    a = sub->addAction("Underside", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_U));
    a->setData(V_BOTTOM);
    a = sub->addAction("Front", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_F));
    a->setData(V_FRONT);
    a = sub->addAction("Back", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_B));
    a->setData(V_BACK);
    a = sub->addAction("Right", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_R));
    a->setData(V_RIGHT);
    a = sub->addAction("Left", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_L));
    a->setData(V_LEFT);

    sub = m_popupMenu.addMenu("Projection...");
    a = sub->addAction("Orthographic", this, SLOT(setProjection()));
    a->setData(P_ORTHO);
    a = sub->addAction("Perspective", this, SLOT(setProjection()));
    a->setData(P_PERSP);

    sub = m_popupMenu.addMenu("DrawMode...");
    a = sub->addAction("Facets", this, SLOT(setDrawMode()), QKeySequence(Qt::Key_F));
    a->setData(osg::PolygonMode::FILL);
    a = sub->addAction("Wireframe", this, SLOT(setDrawMode()), QKeySequence(Qt::Key_W));
    a->setData(osg::PolygonMode::LINE);
    a = sub->addAction("Verticies", this, SLOT(setDrawMode()), QKeySequence(Qt::Key_V));
    a->setData(osg::PolygonMode::POINT);

    sub = m_popupMenu.addMenu("Toggle...");
    a = sub->addAction("MenuBar", this, SIGNAL(toggleMenuBar()), QKeySequence(Qt::CTRL+ Qt::Key_M));
    a = sub->addAction("ToolBar", this, SIGNAL(toggleToolBar()), QKeySequence(Qt::CTRL+ Qt::Key_T));
}
void TCompCamera::renderInMenu() {
	float fov_in_rad = getFov();
	float znear = getZNear();
	float zfar = getZFar();
	float ar = getAspectRatio();

	bool changed = false;
	//float fov_in_deg = rad2deg(fov_in_rad);
	//if (ImGui::SliderFloat("Fov", &fov_in_deg, 30.f, 110.f)) {
	//	changed = true;
	//	fov_in_rad = deg2rad(fov_in_deg);
	//}
	if (!isOrtho()) {
		float fov_in_deg = rad2deg(fov_in_rad);
		if (ImGui::DragFloat("Fov", &fov_in_deg, 0.1f, 1.f, 120.f)) {
			changed = true;
			fov_in_rad = deg2rad(clamp(fov_in_deg, 1.f, 120.f));
		}
	}
	changed |= ImGui::DragFloat("ZNear", &znear, 0.01f, 0.01f);
	changed |= ImGui::DragFloat("ZFar", &zfar, 0.01f, 1.f, 1000.f);
	if (changed)
		setProjection(fov_in_rad, znear, zfar);

	if (ImGui::SliderFloat("a/r", &ar, 0.f, 10.f)) {
		//setAspectRatio(ar);
	}
}
Beispiel #5
0
void
Lpanel::doPickProjection(void)
{
//  glOrtho(bbox.xyz_min[0], bbox.xyz_max[0], bbox.xyz_min[1], bbox.xyz_max[1], .1, 1000.);
  setProjection(1);

}
Beispiel #6
0
GlobeGPS::GlobeGPS(QWidget *parent) : MarbleWidget(parent),
    loadedDives(0),
    messageWidget(new KMessageWidget(this)),
    fixZoomTimer(new QTimer(this)),
    currentZoomLevel(0),
    needResetZoom(false),
    editingDiveLocation(false)
{
    // check if Google Sat Maps are installed
    // if not, check if they are in a known location
    MapThemeManager mtm;
    QStringList list = mtm.mapThemeIds();
    QString subsurfaceDataPath;
    QDir marble;
    if (!list.contains("earth/googlesat/googlesat.dgml")) {
        subsurfaceDataPath = getSubsurfaceDataPath("marbledata");
        if (subsurfaceDataPath.size()) {
            MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
        } else {
            subsurfaceDataPath = getSubsurfaceDataPath("data");
            if (subsurfaceDataPath.size())
                MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
        }
    }
    messageWidget->setCloseButtonVisible(false);
    messageWidget->setHidden(true);

    setMapThemeId("earth/googlesat/googlesat.dgml");
    //setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
    setProjection(Marble::Spherical);

    setAnimationsEnabled(true);
    Q_FOREACH (AbstractFloatItem *i, floatItems()) {
        i->setVisible(false);
    }
Beispiel #7
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLView::create("My Game");
        director->setOpenGLView(glview);
    }

    director->setProjection(cocos2d::Director::Projection::_2D);
    director->setDepthTest(false);
    // turn on display FPS
    director->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);

    // create a scene. it's an autorelease object
    auto scene = HelloWorld::createScene();

    // run
    director->runWithScene(scene);

    return true;
}
Beispiel #8
0
void
init(void)
{
    GLfloat matDiff[4] = { 0.65F, 0.05F, 0.20F, 0.60F };
    GLfloat matSpec[4] = { 0.50F, 0.50F, 0.50F, 1.00F };
    GLfloat matShine = 20.00F;
    GLint indexes[3];
    GLfloat light0Pos[4] = { 0.70F, 0.70F, 1.25F, 0.00F };

    glClearColor(colors[2].diff[0], colors[2].diff[1], colors[2].diff[2], 1.0F);
    glClearIndex((GLfloat) colors[2].indexes[1]);

    setProjection();
    glTranslatef(0.0F, 0.0F, -2.0F);

    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiff);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matSpec);
    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, matShine);

    indexes[0] = 0;
    indexes[1] = colors[0].indexes[1] - colors[0].indexes[0];
    indexes[2] = colors[0].indexes[2] - colors[0].indexes[0];
    glMaterialiv(GL_FRONT_AND_BACK, GL_COLOR_INDEXES, indexes);
    glLightfv(GL_LIGHT0, GL_POSITION, light0Pos);
    glEnable(GL_LIGHT0);

    glEnable(GL_LIGHTING);
    glEnable(GL_DEPTH_TEST);

    setCheckTexture();
    glEnable(GL_TEXTURE_2D);

    glEnable(GL_CULL_FACE);
}
Beispiel #9
0
 void VisorOpenGL::resizeGL(int width, int height)
 {
     //int side = qMin(width, height);
     //glViewport((width - side) / 2, (height - side) / 2, width,width);//side, side);
     glViewport(0,0,width,height);
     setProjection();
}
Beispiel #10
0
CFirstPersonCamera::CFirstPersonCamera(const glm::vec3& position, const glm::vec3& target,
                                       const glm::vec3& up, float fieldOfView, float aspectRatio,
                                       float zNear, float zFar)
{
    lookAt(position, target, up);
    setProjection(fieldOfView, aspectRatio, zNear, zFar);
}
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
		glview = GLViewImpl::create("My Game");	//for cocos2d-x ver3.3
//        glview = GLView::create("My Game");	//for cocos2d-x ver3.2
        director->setOpenGLView(glview);
    }
	int h = 1024;
	int w = 1024;
	glview->setFrameSize(h, w);
	glview->setDesignResolutionSize(h, w, ResolutionPolicy::NO_BORDER);
	//���s���e
	director->setProjection(kCCDirectorProjection2D);

    // turn on display FPS
    director->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);

    // create a scene. it's an autorelease object
    auto scene = HelloWorld::createScene();

    // run
    director->runWithScene(scene);

    return true;
}
Beispiel #12
0
void VisorOpenGL::paintGL() {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glLoadIdentity();
     setProjection();
     setCamara();
     dibujarEscena();
 }
/**
 * Renders a scene not to the screen but into a texture
 */
void drawSceneToSpecificFramebuffer(GLuint fbo, int renderToTexture) {
    /**
     * Drawing into the given framebuffer-object
     */
    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    if (renderToTexture) {
        glClearColor(0.0, 0.8, 0.8, 0.0);
    } else {
        glClearColor(0.0, 1.0, 1.0, 0.0);
    }
    glClearDepth(1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glDisable(GL_CULL_FACE);
    glViewport (0, 0, G_Width, G_Height);
    setProjection ((double)G_Width/G_Height);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt (getCameraPosition(0), getCameraPosition(1), getCameraPosition(2),
         0.0, 0.0, 0.0,
         0.0, 1.0, 0.0);

    glDisable(GL_TEXTURE_2D);
    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
        printf ("Framebuffer is not correct!\n");
    }

    drawDemo(renderToTexture);

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
Beispiel #14
0
void
Camera::set(CoordinateFrame3 const & frame_, ProjectionType projection_type_, Real left_, Real right_, Real bottom_,
            Real top_, Real near_dist_, Real far_dist_, ProjectedYDirection proj_y_dir_)
{
  setFrame(frame_);
  setProjection(projection_type_, left_, right_, bottom_, top_, near_dist_, far_dist_, proj_y_dir_);
}
Beispiel #15
0
	CameraOld::CameraOld(Scene* scene) :
		mScene(scene)
	{
		setProjection();
		setPosition(glm::vec3(10,10,10));
		lookAt(glm::vec3(0,0,0));
	}
Beispiel #16
0
void RuedaRaton(int rueda, int sentido, int x, int y) {

	gl_fovy -= gl_fovy_paso*(float)sentido;
	if (gl_fovy < gl_fovy_min) gl_fovy = gl_fovy_min;
	if (gl_fovy > gl_fovy_max) gl_fovy = gl_fovy_max;
	setProjection();
	glutPostRedisplay();
}
Beispiel #17
0
//---------------------------------------------------------
void Terrain::zoomOnZone (double x0, double y0, double x1, double y1)
{
	double mh, mv;
	mh = fabs(x0-x1)*0.05;
	mv = fabs(y0-y1)*0.05;
	proj->setVisibleArea (x0-mh,y0-mv, x1+mh,y1+mv);
	setProjection (proj);
}
/**
 * Callback for changes in the window-size.
 * Initiate the change of the projection-matrix to the windowsize.
 * @param w screen-width
 * @param h screen-height.
 */
void cbReshape (int w, int h)
{
  /* Whole screen is relevant. */
  glViewport (0, 0, (GLsizei) w, (GLsizei) h);

  /* Adjust of the projection-matrix to the new aspect-ratio */
  setProjection ((GLdouble) w / (GLdouble) h);
}
Beispiel #19
0
	void CameraComponent::init()
	{
		auto scene = entity->getScene();
		//_key = AGE::GetPrepareThread()->addCamera();
		//entity->getLink().registerOctreeObject(_key);
		auto screenSize = entity->getScene()->getInstance<IRenderContext>()->getScreenSize();
		setProjection(glm::perspective(glm::radians(60.0f), (float)screenSize.x / (float)screenSize.y, 0.1f, 2000.0f));
	}
Beispiel #20
0
/**
 * Convenience overload.
 * 
 * @param minBounds :: Near-bottom-left corner of the scene.
 * @param maxBounds :: Far-top-right corner of the scene.
 * @param type :: Projection type: ORTHO or PERSPECTIVE. PERSPECTIVE isn't fully implemented
 */
void Viewport::setProjection(const Mantid::Kernel::V3D& minBounds, const Mantid::Kernel::V3D& maxBounds, ProjectionType type)
{
  double radius = minBounds.norm();
  double tmp = maxBounds.norm();
  if (tmp > radius) radius = tmp;

  setProjection( minBounds.X(), maxBounds.X(), minBounds.Y(), maxBounds.Y(), -radius, radius, type );
}
Beispiel #21
0
void CCDirector::reshapeProjection(CCSize newWindowSize)
{
    m_obWinSizeInPoints = m_pobOpenGLView->getSize();
	m_obWinSizeInPixels = CCSizeMake(m_obWinSizeInPoints.width * m_fContentScaleFactor,
		                             m_obWinSizeInPoints.height * m_fContentScaleFactor);

	setProjection(m_eProjection);
}
Beispiel #22
0
//---------------------------------------------------------
void Terrain::slotTimerZoomWheel () {
    if (deltaZoomWheel != 1) {
		//printf("slotTimerZoomWheel\n");
		proj->zoom(deltaZoomWheel);
		deltaZoomWheel = 1;
		setProjection(proj);
		//DBGN(proj->getScale());
    }
}
Beispiel #23
0
//-----------------------------------------------------------------------------------------
Projection_libproj::Projection_libproj(int code, int w, int h, double cx, double cy, double scale)
	: Projection(w,h, cx,cy, scale)
{
	setProjection(code);
	CX = cx;
	CY = cy;
    Projection_libproj::setScale(scale); // virtual function call in CTOR
//    setCenterPosition(cx, cy);
}
Beispiel #24
0
//-----------------------------------------------------------------------------------------
Projection_libproj::Projection_libproj(const Projection_libproj &model)
	: Projection(model.getW(),model.getH(), model.getCX(),model.getCY(),model.getScale())
{
	setProjection(model.currentProj);
	CX = model.getCX();
	CY = model.getCY();
    Projection_libproj::setScale(model.getScale());
//    setCenterPosition(model.getCX(),model.getCY());
}
/**
 * Callback fuer Aenderungen der Fenstergroesse.
 * Initiiert Anpassung der Projektionsmatrix an veraenderte Fenstergroesse.
 * @param w Fensterbreite (In).
 * @param h Fensterhoehe (In).
 */
static void
cbReshape (int w, int h)
{
  /* Das ganze Fenster ist GL-Anzeigebereich */
  glViewport (0, 0, (GLsizei) w, (GLsizei) h);

  /* Anpassen der Projektionsmatrix an das Seitenverhaeltnis des Fensters */
  setProjection ((GLdouble) w / (GLdouble) h);
}
Beispiel #26
0
//==========================================================================
void MyGlWindow::draw()
//==========================================================================
{

  glViewport(0,0,w(),h());

    // clear the window, be sure to clear the Z-Buffer too
  glClearColor(0.2f,0.2f,.2f,0);		// background should be blue


  glClearStencil(0);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
  glEnable(GL_DEPTH);
  glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
  
  // now draw the ground plane
  setProjection();
  setupFloor();

  glPushMatrix();
  drawFloor(50,32);
  glPopMatrix();

  // now to draw the shadows



  setupLight();


  // Add a sphere to the scene.
  glBegin(GL_LINES);
  glColor3f(1,0,0);
  glVertex3f(0,0,0);
  glVertex3f(0,100,0);
  glColor3f(0,1,0);
  glVertex3f(0,0,0);
  glVertex3f(100,0,0);
  glColor3f(0,0,1);
  glVertex3f(0,0,0);
  glVertex3f(0,0,100);
  glEnd();
  

  setupShadows();
  drawStuff();
  unsetupShadows();

  // Enable blending
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  drawStuff();


}
Beispiel #27
0
void GLApp::resize(int w, int h)
{
	width = w;
	height = h;
	if (height==0)										
	{
		height=1;										
	}
	setProjection(width, height);
}
Beispiel #28
0
void SkyBoxSurface::onStart(){
    FileLog::getInstance()->init();
        // 加载纹理
    lpSkyBox = new SkyBox(SkyBox::TYPE_BOX);
    lpSkyBox->loadBmp(0, "/Users/lichsword/Documents/workspace_apple/others/nehe-tuts/Data/redsky/redsky_down.bmp");
    lpSkyBox->loadBmp(1, "/Users/lichsword/Documents/workspace_apple/others/nehe-tuts/Data/redsky/redsky_up.bmp");
    lpSkyBox->loadBmp(2, "/Users/lichsword/Documents/workspace_apple/others/nehe-tuts/Data/redsky/redsky_east.bmp");
    lpSkyBox->loadBmp(3, "/Users/lichsword/Documents/workspace_apple/others/nehe-tuts/Data/redsky/redsky_west.bmp");
    lpSkyBox->loadBmp(4, "/Users/lichsword/Documents/workspace_apple/others/nehe-tuts/Data/redsky/redsky_north.bmp");
    lpSkyBox->loadBmp(5, "/Users/lichsword/Documents/workspace_apple/others/nehe-tuts/Data/redsky/redsky_south.bmp");
        // 绑定纹理
    int size = SkyBox::SIZE_BOX;
        //
    lpTextures = new GLuint[size];
    glGenTextures(size, lpTextures);
    
    ErrorReport::getInstance()->print("");
    
    Image * lpImages = lpSkyBox->getImageRef();
    for(int i=0; i<size; i++){
        loadTexture2D(&lpTextures[i], lpImages[i]);
    }
    
        // 使用2D纹理
    glEnable(GL_TEXTURE_2D);
        // 使用平滑着色
	glShadeModel(GL_SMOOTH);
        // 设置黑色背景
	glClearColor(0.1f, 0.1f, 0.1f, 0.1f);
        // 设置深度缓存
	glClearDepth(1.0f);
        // 使用深度缓存
	glEnable(GL_DEPTH_TEST);
        // 设置深度方程
	glDepthFunc(GL_LEQUAL);
    
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    
    /**
     * func: 设置纹理的环境参数
     * use GL_MODULATE instead of GL_REPLACE if lighting is being used GL_REPLACE
     */
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    
    setProjection();
    
        // 设置环境光
    glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
        // 设置光源位置
    glLightfv(GL_LIGHT0, GL_POSITION,LightPosition);
        // 启用0号光源
    glEnable(GL_LIGHT0);
    
    glBindTexture(GL_TEXTURE_2D, lpTextures[0]);
}
Beispiel #29
0
void Window::resizeEvent(QResizeEvent *event) {
  SceneGraph::Window::resizeEvent(event);

  QMatrix4x4 matrix;
  matrix.ortho(0, width(), height(), 0, -1, 1);

  setProjection(matrix);

  m_game.setSize(size());
  m_game.resetTransform();
}
Beispiel #30
0
void handleHead() {
    setProjection(getCoordinateSystem());
    
    long lines = getSOSILinesLength();
    for (int i = 0; i < lines; i++) {
        char* line = getSOSILine(i);
        if (line != NULL && strncmp(line, "..TEGNSETT ", 11) == 0) {
            setEncoding(line+11);
        }
    }
}