int main(int argc, char* argv[])
{
	try
	{
		char* testname_args1[] = {"program.exe","antialias_amount=8 width=1280 height=720 window_name", " =multisampled is_antialiased=true"};
		char* testname_args2[] = {"program.exe","width=1280 height=720", ""};

		GLWindow glWindow = GLWindow(GLWindow::Settings(3, testname_args1));
		GLWindow glWindow2 = GLWindow(GLWindow::Settings(3, testname_args2));


		PCInputBinding b;
		PCInputBinding b2;

		b2.bindButtonDown('a', print);
		b.bindButtonDown('a', playBeep);

		b.bindButtonDown(PCInputBinding::MOUSE_BUTTON_4, button4);
		b.bindButtonDown(PCInputBinding::MOUSE_BUTTON_5, button5);

		std::function< void () > quit = std::bind(&GLWindow::close, &glWindow);

		b.bindWindowClose( quit);
		b.bindButtonDown(PCInputBinding::ESCAPE, quit);
		//b.bindPowerStatusChange(powerTest);

		b2.bindPowerStatusChange(powerTest);

		quit = std::bind(&GLWindow::close, &glWindow2);

		b2.bindButtonDown(PCInputBinding::ESCAPE, quit);


		glWindow.use_binding(b);
		glWindow2.use_binding(b2);

		glWindow.bindContext();
		glClearColor(1.0,0.0,0.0,1.0);

		float dt=0.0;

		bool once =false;

		glWindow2.setTitle("Non-multisampled window test");


		glWindow.setWindowLocation(100,100);

		glWindow2.setWindowLocation(128,128);

		while(glWindow.isValid() || glWindow2.isValid()  )
		{
			dt += .001;

		//	std::cout<<dt<<std::endl;
			std::stringstream sstr;
			sstr<<"NON-MULTISAMPLED TEST:: BKGR COLOR INTERPOLATOR IS "<<(fabs(sin(dt)))<<std::endl;
			std::string abc = sstr.str();

				if(glWindow.bindContext()){
//			 		glEnable(GL_MULTISAMPLE_ARB);
				//the fact that we dont need the call to clear color here shows how	the gl state is maintained separately between different rendering contexts
				//glClearColor(1.0,0.0,0.0,1.0);

					glClear(GL_COLOR_BUFFER_BIT);
					glBegin(GL_TRIANGLES);

					//glClearColor(1.0,0.0,0.0,1.0);
					//glClear(GL_COLOR_BUFFER_BIT);

					glColor3f(1.0,0.0,0.0);
					glVertex3f(-1.0,1.0,0.0);

					glColor3f(0.0,1.0,0.0);
					glVertex3f(-1.0,-1.0,0.0);

					glColor3f(0.0,0.0,1.0);
					glVertex3f(1.0,-1.0,0.0);
					glEnd();

				glWindow.update();
				glWindow.flush();

				}

				if(glWindow2.bindContext()){

					glWindow2.setTitle(abc.c_str());



				glClearColor(fabs(sin(dt)),1.0,0.0,1.0);
				glClear(GL_COLOR_BUFFER_BIT);
					glBegin(GL_TRIANGLES);

					//glClearColor(1.0,0.0,0.0,1.0);
					//glClear(GL_COLOR_BUFFER_BIT);

					glColor3f(1.0,0.0,0.0);
					glVertex3f(-1.0,1.0,0.0);

					glColor3f(0.0,1.0,0.0);
					glVertex3f(-1.0,-1.0,0.0);

					glColor3f(0.0,0.0,1.0);
					glVertex3f(1.0,-1.0,0.0);
					glEnd();





		 		glWindow2.update();
				glWindow2.flush();





				}






		}
	}
	catch(std::exception& e)
	{
		std::cerr << e.what() << std::endl;
	}

	std::cout<<"made it to end of test program "<<std::endl;
	system("pause");

	return 0;
}
示例#2
0
int main(int argc, char* argv[])
{
	try
	{
		char* testname_args[] = {"program.exe","width=640 height=480 window_name", " =GL WINDOW TEST 1 is_fullscreen=false"};
		GLWindow::Settings setts(3, testname_args)  ;

		GLWindow glWindow = GLWindow(setts);


	 	setts.width=1280;
		setts.height=720;
		setts.is_fullscreen=true;
		setts.is_antialiased = true;
		setts.antialias_amount = 8;

		//setts.match_resolution_exactly=true;
		PCInputBinding b;

		b.bindButtonDown('a', playBeep);

		std::function< void () > quit = std::bind(&GLWindow::close, &glWindow);

		b.bindButtonDown(PCInputBinding::ESCAPE, quit);

		glWindow.use_binding(b);


		std::cout<<"Supported resolutions "<<std::endl;
		std::set<std::pair<int,int>> resolutions = glWindow.getResolutions();
		for(std::set<std::pair<int,int>>::const_iterator it = resolutions.begin(); it != resolutions.end(); it++){
			std::cout<<it->first<<"::"<<it->second<<std::endl;
		}


		glWindow.recreate(setts);


		glClearColor(0,1,0,1);
		std::cout<<"Recreated window width is "<<glWindow.getWidth()<<":::"<<glWindow.getHeight()<<std::endl;
		while(glWindow.isValid())
		{

		//	glViewport(0,0,glWindow.getWidth(),glWindow.getHeight());
			//glWindow.bind();
			glClear(GL_COLOR_BUFFER_BIT);

			glBegin(GL_TRIANGLES);

			glClearColor(1.0,0.0,0.0,1.0);
			glClear(GL_COLOR_BUFFER_BIT);

			glColor3f(1.0,0.0,0.0);
			glVertex3f(-1.0,1.0,0.0);

			glColor3f(0.0,1.0,0.0);
			glVertex3f(-1.0,-1.0,0.0);

			glColor3f(0.0,0.0,1.0);
			glVertex3f(1.0,-1.0,0.0);
			glEnd();

			glWindow.update();
			glWindow.flush();
		//
		}

	}
	catch(std::exception& e)
	{
		std::cerr << e.what() << std::endl;
	}


	system("pause");
	return 0;
}