Esempio n. 1
0
/*
 * Just in case the initial loading takes a while on the target machine. The rest of the loading a pretty quick by comparison.
 */
static void showLoadingStep(float step, float maxSteps)
{
	SDL_Rect r;

	prepareScene();

	r.w = SCREEN_WIDTH - 400;
	r.h = 14;
	r.x = (SCREEN_WIDTH / 2) - r.w / 2;
	r.y = (SCREEN_HEIGHT / 2) - r.h / 2;

	SDL_SetRenderDrawColor(app.renderer, 128, 128, 128, 255);
	SDL_RenderDrawRect(app.renderer, &r);

	r.w *= (step / maxSteps);
	r.x += 2;
	r.y += 2;
	r.w -= 4;
	r.h -= 4;

	SDL_SetRenderDrawColor(app.renderer, 128, 196, 255, 255);
	SDL_RenderFillRect(app.renderer, &r);

	presentScene();

	SDL_Delay(1);
}
Esempio n. 2
0
void idle()
{
	if(glutGetWindow() != mainWindow)
	{
		glutSetWindow(mainWindow);
	}
	prepareScene();
	glutPostRedisplay();
}
Esempio n. 3
0
void startSectionTransition(void)
{
	transitionStartTime = SDL_GetTicks();

	prepareScene();
	
	presentScene();
	
	expireTexts();
}
Esempio n. 4
0
UIGDetailsModel::UIGDetailsModel(QObject *pParent)
    : QObject(pParent)
    , m_pScene(0)
    , m_pRoot(0)
{
    /* Prepare scene: */
    prepareScene();

    /* Prepare root: */
    prepareRoot();
}
Esempio n. 5
0
//=========================================================================
void BubbleChartView::fromJson(QJsonObject &json)
{
    try
    {
        QJsonObject jDp = json["Dp"].toObject();
        dataProvider()->fromJson(jDp);
        QJsonObject jConfig = json["Config"].toObject();
        getConfig()->fromJson(jConfig);
        prepareScene();
        header->setPlainText(json["Header"].toString());
        showChart();
    }
    catch (...)
    {
        QMessageBox::warning(this, "Error occured", "Cannot restore Bubble Chart from project configuration");
    }
}
Esempio n. 6
0
void MapExporter::construct()
{
	if (_totalNodeCount > 0 && GlobalMainFrame().isActiveApp())
	{
		enableProgressDialog();
	}

	// Prepare the output stream
	game::IGamePtr curGame = GlobalGameManager().currentGame();
	assert(curGame != NULL);

	xml::NodeList nodes = curGame->getLocalXPath(RKEY_FLOAT_PRECISION);
	assert(!nodes.empty());

	int precision = string::convert<int>(nodes[0].getAttributeValue("value"));
	_mapStream.precision(precision);

	// Add origin to func_* children before writing
	prepareScene();
}
Esempio n. 7
0
//=========================================================================
BubbleChartView::BubbleChartView(BlastTaxDataProviders *_dataProviders, QWidget *parent, bool setRank)
    : DataGraphicsView(NULL, parent)
{
    flags |= DGF_BUBBLES | DGF_RANKS;
    config = new BubbleChartParameters();

    if ( setRank && mainWindow->getRank() == TR_NORANK )
        mainWindow->setRank(TR_SPECIES);

    if ( _dataProviders == NULL )
        _dataProviders = new BlastTaxDataProviders();

    taxDataProvider = new ChartDataProvider(_dataProviders, this);

    connect((ChartDataProvider *)taxDataProvider, SIGNAL(taxVisibilityChanged(quint32)), this, SLOT(onTaxVisibilityChanged(quint32)));
    connect((ChartDataProvider *)taxDataProvider, SIGNAL(cacheUpdated()), this, SLOT(onDataChanged()));

    QGraphicsScene *s = new QGraphicsScene(this);
    s->setItemIndexMethod(QGraphicsScene::NoIndex);
    setCacheMode(CacheBackground);
    setViewportUpdateMode(BoundingRectViewportUpdate);
    setRenderHint(QPainter::Antialiasing);
    setTransformationAnchor(AnchorUnderMouse);
    setMinimumSize(400, 200);
    setAlignment(Qt::AlignCenter);
    setScene(s);

    setChartRectSize(800, 800);

    propertiesAction = popupMenu.addAction("Properties...");
    connect(propertiesAction, SIGNAL(triggered(bool)), this, SLOT(showPropertiesDialog()));

    if ( _dataProviders->size() > 0 )
    {
        prepareScene();
        showChart();
    }
    onTaxRankChanged(mainWindow->getRank());
}
Esempio n. 8
0
void init(int* argc, char** argv)
{
	glutInit(argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize(800, 600);
	mainWindow = glutCreateWindow("Qix");

	const Qix::Color FrameColor = 0xff999999;
	const Qix::Color PlayerColor = 0xffff0000;

	sceneTransform = Qix::Transformation(
		Qix::Vector3(0, 0, -2),
		Qix::Vector3(0.1, 0.1, 0.1),
		Qix::Vector3(0, 0, 0)
	);

	light = Qix::Light(Qix::Vector4(6, 8, 0, 0));
	light.ambient = 0xff333333;

	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(0, -6, 0),
				Qix::Vector3(18, 1, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(-8.5, 0, 0),
				Qix::Vector3(1, 11, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(8.5, 0, 0),
				Qix::Vector3(1, 11, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(0, 6, 0),
				Qix::Vector3(18, 1, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	);
	renderItems.push_back(new Qix::Sphere(
			Qix::Transformation(
				Qix::Vector3(-5, 3, 0),
				Qix::Vector3(0.4, 0.4, 0.4),
				Qix::Vector3(0, 0, 0)
			),
			PlayerColor
		)
	);

	prepareScene();

	// Enable depth checking.
	glEnable(GL_DEPTH_TEST);

	//glutIdleFunc(idle);
	glutTimerFunc(10, animate, 1);
	glutReshapeFunc(reshape);
	glutDisplayFunc(display);

	GLUI* glui = GLUI_Master.create_glui("Light Controls", 0, 800, 50);
    GLUI_Panel* mainPan = new GLUI_Panel(glui, "", GLUI_PANEL_NONE);
    
    
    GLUI_Panel* pan;
    pan = new GLUI_Panel(mainPan, "Ambient");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.ambient.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.ambient.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.ambient.data[Qix::Color::BlueChannel]));
    
    pan = new GLUI_Panel(mainPan, "Diffuse");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.diffuse.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.diffuse.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.diffuse.data[Qix::Color::BlueChannel]));    
    
    pan = new GLUI_Panel(mainPan, "Specular");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.specular.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.specular.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.specular.data[Qix::Color::BlueChannel]));
    
    createExitButton(glui, "Exit");
	

	glui->set_main_gfx_window(mainWindow);
	GLUI_Master.set_glutIdleFunc(idle); 

	glutMainLoop();
}
Esempio n. 9
0
void init(int* argc, char** argv)
{
	glutInit(argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize(800, 600);
	mainWindow = glutCreateWindow("Qix");

	const Qix::Color FrameColor = 0xff999999;
	const Qix::Color PlayerColor = 0xffff0000;
    
    

	sceneTransform = Qix::Transformation(
		Qix::Vector3(0, 0, -2),
		Qix::Vector3(0.1, 0.1, 0.1),
		Qix::Vector3(0, 0, 0)
	);

	light = Qix::Light(Qix::Vector4(6, 8, 0, 0));
	light.ambient = 0xff333333;

	walls.push_back(Qix::Wall(Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(0, -6, 0),
				Qix::Vector3(18, 1, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	));
	walls.push_back(Qix::Wall(Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(-8.5, 0, 0),
				Qix::Vector3(1, 11, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	));
	walls.push_back(Qix::Wall(Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(8.5, 0, 0),
				Qix::Vector3(1, 11, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	));
	walls.push_back(Qix::Wall(Qix::Cube(
			Qix::Transformation(
				Qix::Vector3(0, 6, 0),
				Qix::Vector3(18, 1, 1),
				Qix::Vector3(0, 0, 0)
			),
			FrameColor
		)
	));
	bouncy = Qix::Bouncy(Qix::Sphere(
			Qix::Transformation(
				Qix::Vector3(0, 0, 0),
				Qix::Vector3(0.4, 0.4, 0.4),
				Qix::Vector3(0, 0, 0)
			),
			PlayerColor
		)
	);
    bouncy.angle = (double) rand() / ((double) RAND_MAX + 1.0) * M_PI * 2;

	prepareScene();

	// Enable depth checking.
	glEnable(GL_DEPTH_TEST);

	//glutIdleFunc(idle);
	glutTimerFunc(10, animate, 1);
	glutReshapeFunc(reshape);
	glutDisplayFunc(display);

	GLUI* glui = GLUI_Master.create_glui("Controller", 0, 800, 50);
    GLUI_Panel* mainPan = new GLUI_Panel(glui, "Light Settings");
    
    GLUI_Panel* pan;
    

    pan = new GLUI_Panel(mainPan, "Ambient");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.ambient.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.ambient.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.ambient.data[Qix::Color::BlueChannel]));
    
    pan = new GLUI_Panel(mainPan, "Diffuse");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.diffuse.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.diffuse.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.diffuse.data[Qix::Color::BlueChannel]));    
    
    pan = new GLUI_Panel(mainPan, "Specular");
    new GLUI_Column(mainPan, false);
	createColorSpinner(pan, "R", &(light.specular.data[Qix::Color::RedChannel]));
	createColorSpinner(pan, "G", &(light.specular.data[Qix::Color::GreenChannel]));
	createColorSpinner(pan, "B", &(light.specular.data[Qix::Color::BlueChannel]));
    
    mainPan = new GLUI_Panel(glui, "", GLUI_PANEL_NONE);
    pan = new GLUI_Panel(mainPan, "Sphere Settings");
    pan->set_alignment(GLUI_ALIGN_LEFT);
    mainPan->set_w(500);
    new GLUI_Column(mainPan, false);
    createAngleSelector(pan, "Initial Angle", &ballAngle);
    createResetButton(pan, "Reset");

    pan = new GLUI_Panel(mainPan, "", GLUI_PANEL_NONE);
    new GLUI_StaticText(pan, "                                                ");
    new GLUI_Column(mainPan, false);

    pan = new GLUI_Panel(mainPan, "Other");
    new GLUI_Column(mainPan, false);
    pan->set_alignment(GLUI_ALIGN_RIGHT);
    createExitButton(pan, "Exit");
	

	glui->set_main_gfx_window(mainWindow);
	GLUI_Master.set_glutIdleFunc(idle); 

	glutMainLoop();
}
Esempio n. 10
0
int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize(800, 600);
	mainWindow = glutCreateWindow("Heightmaps");

    

    /*std::cout << "P2" << std::endl;
    std::cout << map->width << std::endl;
    std::cout << map->height << std::endl;
    std::cout << map->depth << std::endl;
    for(int i = 0; i < map->width * map->height; i++)
    {
        std::cout << map->data[i] << std::endl;
    }*/
    
	sceneTransform = Transformation(
		Vector3(0, 0, -100),
		Vector3(0.3, 0.3, 0.3),
		Vector3(0, 0, 0)
	);
	light = Light(Vector4(10, 10, -10, 0));
	prepareScene();    
	sceneTransform.rotation.data[0] = -35;
    
	// Enable depth checking.
	glEnable(GL_DEPTH_TEST);

    glutIdleFunc(idle);
	glutTimerFunc(10, animate, 1);
	glutReshapeFunc(reshape);
	glutDisplayFunc(display);
	glutKeyboardFunc(keyboard);

	glui = GLUI_Master.create_glui("Heightmap Controls", 0, 800, 50);
    GLUI_Panel* mainPan = new GLUI_Panel(glui, "", GLUI_PANEL_NONE);
    
    
    GLUI_Panel* pan;
    createStaticText(mainPan, "Heightmap Utility");
    createStaticText(mainPan, "by Andrew Crowell");
    createStaticText(mainPan, "for CIS*4800 A4, 2010");
    createStaticText(mainPan, "");
    createStaticText(mainPan, "The W and A keys rotate the map.");
    pan = new GLUI_Panel(mainPan, "Heightmap");
    
    createTextField(pan, "Filename", mapFilename, loadMap);
	createFloatSpinner(pan, "R", &mapColor.data[Color::RedChannel], refreshGeometry)->set_float_limits(0, 1);
	createFloatSpinner(pan, "G", &mapColor.data[Color::GreenChannel], refreshGeometry)->set_float_limits(0, 1);
	createFloatSpinner(pan, "B", &mapColor.data[Color::BlueChannel], refreshGeometry)->set_float_limits(0, 1);
	createFloatSpinner(pan, "Z Scale", &mapScaleZ, refreshGeometry);
	createCheckbox(pan, "Randomize", &mapRandomize, refreshGeometry);
	
    pan = new GLUI_Panel(mainPan, "Message");
    errorMessageLabel = createStaticText(pan, "                                                ");
        
    createExitButton(glui, "Exit");
    
	glui->set_main_gfx_window(mainWindow);
	GLUI_Master.set_glutIdleFunc(idle); 

	loadMap(0);
	glutMainLoop();
	
    return 0;
}
Esempio n. 11
0
int main(int argc, char *argv[])
{
	float td;
	long then, lastFrameTime, frames;
	long expireTextTimer;
	SDL_Event event;
	
	memset(&app, 0, sizeof(App));
	memset(&dev, 0, sizeof(Dev));
	
	handleLoggingArgs(argc, argv);
	
	atexit(cleanup);

	srand(time(NULL));
	
	init18N(argc, argv);
	
	initLookups();

	initSDL();
	
	initGameSystem();
	
	createScreenshotFolder();
	
	if (fileExists(getSaveFilePath(SAVE_FILENAME)))
	{
		loadGame();
	}
	
	handleMissionArgs(argc, argv);
	
	dev.fps = frames = td = 0;
	then = SDL_GetTicks();
	lastFrameTime = SDL_GetTicks() + 1000;
	expireTextTimer = SDL_GetTicks() + (1000 * 10);
	
	while (1)
	{
		td += (SDL_GetTicks() - then);
		
		then = SDL_GetTicks();
		
		while (SDL_PollEvent(&event))
		{
			switch (event.type)
			{
				case SDL_MOUSEMOTION:
					doMouseMotion(&event.motion);
					break;
				
				case SDL_MOUSEWHEEL:
					doMouseWheel(&event.wheel);
					break;
				
				case SDL_MOUSEBUTTONDOWN:
					doMouseDown(&event.button);
					break;

				case SDL_MOUSEBUTTONUP:
					doMouseUp(&event.button);
					break;
				
				case SDL_KEYDOWN:
					doKeyDown(&event.key);
					break;
					
				case SDL_KEYUP:
					doKeyUp(&event.key);
					break;

				case SDL_QUIT:
					exit(0);
					break;
			}
		}
		
		if (app.modalDialog.type != MD_NONE)
		{
			doModalDialog();
		}
		
		while (td >= LOGIC_RATE)
		{
			/* let the delegate decide during logic() */
			app.doTrophyAlerts = 0;
			
			app.delegate.logic();
			
			td -= LOGIC_RATE;
			
			if (app.doTrophyAlerts)
			{
				doTrophyAlerts();
			}
			
			if (app.resetTimeDelta)
			{
				td = 0;
				then = SDL_GetTicks();
				app.resetTimeDelta = 0;
			}
			
			game.stats[STAT_TIME]++;
		}
		
		prepareScene();

		app.delegate.draw();
		
		if (app.doTrophyAlerts)
		{
			drawTrophyAlert();
		}
		
		if (app.modalDialog.type != MD_NONE)
		{
			drawModalDialog();
		}
		
		presentScene();
		
		doDevKeys();
		
		frames++;
		
		if (SDL_GetTicks() > lastFrameTime)
		{
			dev.fps = frames;
			frames = 0;
			lastFrameTime = SDL_GetTicks() + 1000;
			
			if (dev.takeScreenshots)
			{
				saveScreenshot();
			}
		}
		
		if (isControl(CONTROL_SCREENSHOT))
		{
			saveScreenshot();
			
			clearControl(CONTROL_SCREENSHOT);
		}
		
		if (SDL_GetTicks() > expireTextTimer)
		{
			expireTexts(0);
			
			expireTextTimer = SDL_GetTicks() + (1000 * 10);
		}
		
		/* don't save more than once per request, and not in the middle of battle */
		if (app.saveGame && battle.status != MS_IN_PROGRESS)
		{
			saveGame();
			app.saveGame = 0;
		}
		
		/* always zero the mouse motion */
		app.mouse.dx = app.mouse.dy = 0;

		SDL_Delay(1);
	}

	return 0;
}
Esempio n. 12
0
void init(int* argc, char** argv)
{
    memset(keys, 0, sizeof(keys));

    glutInit(argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    glutInitWindowSize(800, 600);
    mainWindow = glutCreateWindow("Qix");

    const Qix::Color FrameColor = 0xff999999;
    const Qix::Color BouncyColor = 0xffff0000;


    frameTexture = Qix::Texture::loadImage("grasstiles.dat");

    sceneTransform = Qix::Transformation(
                         Qix::Vector3(0, 0, -2),
                         Qix::Vector3(0.1, 0.1, 0.1),
                         Qix::Vector3(0, 0, 0)
                     );

    light = Qix::Light(Qix::Vector4(6, 8, 0, 4));
    light.ambient = 0xff666666;

    map.init(frameTexture);
    bouncy = Qix::Bouncy(Qix::Sphere(
                             Qix::Transformation(
                                 Qix::Vector3(0, 0, 0),
                                 Qix::Vector3(0.2, 0.2, 0.2),
                                 Qix::Vector3(0, 0, 0)
                             ),
                             BouncyColor
                         )
                        );
    bouncy.angle = (double) rand() / ((double) RAND_MAX + 1.0) * M_PI * 2;

    player.init();

    prepareScene();

    // Enable depth checking.
    glEnable(GL_DEPTH_TEST);

    //glutIdleFunc(idle);
    glutTimerFunc(10, animate, 1);
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);

    GLUI* glui = GLUI_Master.create_glui("Controller", 0, 800, 50);
    GLUI_Panel* mainPan = new GLUI_Panel(glui, "Light Settings");

    GLUI_Panel* pan;


    pan = new GLUI_Panel(mainPan, "Ambient");
    new GLUI_Column(mainPan, false);
    createColorSpinner(pan, "R", &(light.ambient.data[Qix::Color::RedChannel]));
    createColorSpinner(pan, "G", &(light.ambient.data[Qix::Color::GreenChannel]));
    createColorSpinner(pan, "B", &(light.ambient.data[Qix::Color::BlueChannel]));

    pan = new GLUI_Panel(mainPan, "Diffuse");
    new GLUI_Column(mainPan, false);
    createColorSpinner(pan, "R", &(light.diffuse.data[Qix::Color::RedChannel]));
    createColorSpinner(pan, "G", &(light.diffuse.data[Qix::Color::GreenChannel]));
    createColorSpinner(pan, "B", &(light.diffuse.data[Qix::Color::BlueChannel]));

    pan = new GLUI_Panel(mainPan, "Specular");
    new GLUI_Column(mainPan, false);
    createColorSpinner(pan, "R", &(light.specular.data[Qix::Color::RedChannel]));
    createColorSpinner(pan, "G", &(light.specular.data[Qix::Color::GreenChannel]));
    createColorSpinner(pan, "B", &(light.specular.data[Qix::Color::BlueChannel]));

    mainPan = new GLUI_Panel(glui, "", GLUI_PANEL_NONE);
    pan = new GLUI_Panel(mainPan, "Sphere Settings");
    pan->set_alignment(GLUI_ALIGN_LEFT);
    mainPan->set_w(500);
    new GLUI_Column(mainPan, false);
    createAngleSelector(pan, "Initial Angle", &ballAngle);
    createResetButton(pan, "Reset");

    pan = new GLUI_Panel(mainPan, "", GLUI_PANEL_NONE);
    new GLUI_StaticText(pan, "                                                ");
    new GLUI_Column(mainPan, false);

    pan = new GLUI_Panel(mainPan, "Other");
    new GLUI_Column(mainPan, false);
    pan->set_alignment(GLUI_ALIGN_RIGHT);
    createExitButton(pan, "Exit");


    glutIgnoreKeyRepeat(true);
    glutKeyboardFunc(keyboard);
    glutKeyboardUpFunc(release);

    glui->set_main_gfx_window(mainWindow);
    GLUI_Master.set_glutIdleFunc(idle);

    glutMainLoop();
}