Exemplo n.º 1
0
/////////////////////////////////////////////////////////////////////////
// Main initialization point
//
int sample_main(int argc, const char** argv)
{
    NVPWindow::ContextFlags context(
    3,      //major;
    3,      //minor;
    false,   //core;
    1,      //MSAA;
    true,   //debug;
    false,  //robust;
    false,  //forward;
    NULL   //share;
    );

    g_myWindow.argc = argc;
    g_myWindow.argv = argv;

    if(!g_myWindow.create("bk3d viewer", &context))
        return false;

    g_myWindow.makeContextCurrent();
    g_myWindow.swapInterval(0);

    while(MyWindow::sysPollEvents(false) )
    {
        idle();
    }
    return true;
}
int main()
{
	MyWindow w;
	w.create();		// 이 순간 윈도우가 만들어져야 합니다.
					// 왼쪽 버튼을 누르면 "LButton" 이라고 출력되어야 합니다.
	IoProcessMessage();
}
Exemplo n.º 3
0
int utIOWindowGL(){

	MyWindow win;
	MyWindow win2;
	
	
//	struct Func:TimedFunction{
//		void onExecute(){ printf("hello\n"); }
//	};
//
//	Func tf;
//	tf(1000);

	win.create(Window::Dim(100,0, 200,200), "Window 1", 40);
	win2.create(Window::Dim(300,0, 200,200), "Window 2", 40);
//	win2.create(Window::Dim(200,200,300), "Window 2", 40, SingleBuf);

	win.freqs(1,2);
	win2.freqs(3,4);

//win.cursorHide(true);

	Window::startLoop();
	return 0;
}
Exemplo n.º 4
0
int main(){

	for(int i=0; i<800; ++i){
		int Nv = rnd::prob(0.5)
					? (rnd::prob(0.5) ? addCube(shapes) : addDodecahedron(shapes))
					: addIcosahedron(shapes);
		
		Mat4f xfm;
		xfm.setIdentity();
		xfm.scale(Vec3f(rnd::uniform(1.,0.1), rnd::uniform(1.,0.1), rnd::uniform(1.,0.1)));
		xfm.translate(Vec3f(rnd::uniformS(8.), rnd::uniformS(8.), rnd::uniformS(8.)));
		//xfm.rotate(rnd::uniform(), rnd::uniform(), rnd::uniform());
		
		shapes.transform(xfm, shapes.vertices().size()-Nv);

		for(int i=0; i<Nv; ++i){
			float f = float(i)/Nv;
			shapes.color(HSV(f*0.1+0.2,1,1));
		}
	}

	shapes.primitive(Graphics::TRIANGLES);
	shapes.decompress();
	shapes.generateNormals();


	win1.add(new StandardWindowKeyControls);

	win1.create(Window::Dim(800, 600));

	MainLoop::start();
	return 0;
}
Exemplo n.º 5
0
int main() {
    win1.add(new StandardWindowKeyControls);
    win1.create(Window::Dim(800, 600));

    MainLoop::start();
    return 0;
}
int main(){
	MyWindow win;
	GLVDetachable gui;
	glv::Table layout("><");

	// Create some random widgets for testing
	glv::Button btn;
	glv::Sliders sld(glv::Rect(100,10*4), 1,4);
	glv::Slider2D sld2;

	btn.colors().set(glv::Color(1,0,0));
	layout.enable(glv::DrawBack);
	//layout.enable(glv::Controllable | glv::HitTest);
	//layout.addHandler(glv::Event::MouseDrag, glv::Behavior::mouseMove);

	layout
		<< gui.detachedButton() << new glv::Label("detach")
		<< btn << new glv::Label("param 1")
		<< sld << new glv::Label("param 2")
		<< sld2<< new glv::Label("param 3")
	;

	gui << layout;
	layout.arrange();

	// We must assign a parent window to the GUI
	gui.parentWindow(win);

	win.append(*new StandardWindowKeyControls);
	win.create();

	MainLoop::start();
}
Exemplo n.º 7
0
int main(){
	iso.primitive(Graphics::TRIANGLES);

	win.create(Window::Dim(800,600), "Rob's Game of Life", 140);
	win.add(new StandardWindowKeyControls);
	win.add(new NavInputControl(nav));
	Window::startLoop();
}
Exemplo n.º 8
0
int main(){    
    win1.create(Window::Dim(800, 600), "Allocore Example: MsgTube");
	
	audio.append(win1);
	audio.start();

	MainLoop::start();
	return 0;
}
int main(){

	double world_radius = 50;

	nav.smooth(0.8);
	lens.near(1).far(world_radius);

	// set up mesh:
	mesh.primitive(Graphics::TRIANGLES);
	double tri_size = 2;
	int count = 4000;
	for (int i=0; i<count; i++) {
		double x = rnd::uniformS(world_radius);
		double y = rnd::uniformS(world_radius);
		double z = rnd::uniformS(world_radius);
		for (int v=0; v<3; v++) {
			mesh.color(HSV(float(i)/count, v!=2, 1));
			mesh.vertex(x+rnd::uniformS(tri_size), y+rnd::uniformS(tri_size), z+rnd::uniformS(tri_size));
		}
	}

	// set up grid:
	grid.primitive(Graphics::LINES);
	double stepsize = 1./2;
	for (double x=-1; x<=1; x+= stepsize) {
	for (double y=-1; y<=1; y+= stepsize) {
		grid.vertex(x, y, 1);
		grid.vertex(x, y, -1);
	}}
	for (double x=-1; x<=1; x+= stepsize) {
	for (double z=-1; z<=1; z+= stepsize) {
		grid.vertex(x, 1, z);
		grid.vertex(x, -1, z);
	}}
	for (double y=-1; y<=1; y+= stepsize) {
	for (double z=-1; z<=1; z+= stepsize) {
		grid.vertex(1, y, z);
		grid.vertex(-1, y, z);
	}}
	grid.scale(world_radius);

	// set up cube:
	cube.color(1,1,1,1);
	cube.primitive(Graphics::TRIANGLES);
	addCube(cube);
	cube.generateNormals();

	win.create(Window::Dim(100, 0, 640, 480), "Cube Map FBO Example", 60);
	win.displayMode(win.displayMode() | Window::STEREO_BUF);
	win.add(new StandardWindowKeyControls);
	win.add(new NavInputControl(nav));

	MainLoop::start();

    return 0;
}
int main (int argc, char * const argv[]) {
	searchpaths.addAppPaths(argc, argv);
	searchpaths.addSearchPath(searchpaths.appPath() + "../../share");
	searchpaths.print();

	// load in a "scene"
	FilePath path = searchpaths.find("ducky.obj");
	printf("reading %s\n", path.filepath().c_str());

	ascene = Scene::import(path.filepath());
	if (ascene==0) {
		printf("error reading %s\n", path.filepath().c_str());
		return -1;
	} else {
		ascene->getBounds(scene_min,scene_max);
		scene_center = (scene_min + scene_max) / 2.f;
		ascene->dump();
	}
	File frag_file(searchpaths.find("basicFragment.glsl"), "r", true);
	File vert_file(searchpaths.find("basicVertex.glsl"), "r", true);

	printf("frag_file %s\n", frag_file.path().c_str());
	printf("vert_file %s\n", vert_file.path().c_str());

	frag.source(frag_file.readAll(), Shader::FRAGMENT);
	vert.source(vert_file.readAll(), Shader::VERTEX);

	win1.add(new StandardWindowKeyControls);
	win1.create(Window::Dim(640, 480));

	Image img(searchpaths.find("hubble.jpg").filepath());
	tex.allocate(img.array());

	MainLoop::start();

	return 0;
}
Exemplo n.º 11
0
int main(){

	{
		int Nv = addTetrahedron(solids[0]);

		solids[0].primitive(Graphics::TRIANGLES);

		for(int i=0; i<Nv; ++i){
			float f = float(i)/Nv;
			solids[0].color(HSV(f*0.2+0.4,1,1));
		}

		solids[0].decompress();
		solids[0].generateNormals();
	}

	{
		int Nv = addCube(solids[1]);

		solids[1].primitive(Graphics::TRIANGLES);

		for(int i=0; i<Nv; ++i){
			float f = float(i)/Nv;
			solids[1].color(HSV(f*0.1+0.2,1,1));
		}

		solids[1].decompress();
		solids[1].generateNormals();
	}

	{
		int Nv = addOctahedron(solids[2]);
		solids[2].primitive(Graphics::TRIANGLES);

		for(int i=0; i<Nv; ++i){
			float f = float(i)/Nv;
			solids[2].color(HSV(f*0.1+0.1,1,1));
		}

		solids[2].decompress();
		solids[2].generateNormals();
	}

	{
		int Nv = addDodecahedron(solids[3]);
		solids[3].primitive(Graphics::TRIANGLES);

		for(int i=0; i<Nv; ++i){
			float f = float(i)/Nv;
			solids[3].color(HSV(f*0.1,1,1));
		}

		solids[3].decompress();
		solids[3].generateNormals();
	}

	{
		int Nv = addIcosahedron(solids[4]);
		solids[4].primitive(Graphics::TRIANGLES);

		for(int i=0; i<Nv; ++i){
			float f = float(i)/Nv;
			solids[4].color(HSV(f*0.1 + 0.7,1,1));
		}

		solids[4].decompress();
		solids[4].generateNormals();
	}

	win.add(new StandardWindowKeyControls);
	win.create();
	MainLoop::start();
}
Exemplo n.º 12
0
//------------------------------------------------------------------------------
// Main initialization point
//------------------------------------------------------------------------------
int sample_main(int argc, const char** argv)
{
    // you can create more than only one
    static MyWindow myWindow;
    // -------------------------------
    // Basic OpenGL settings
    //
    NVPWindow::ContextFlags context(
    4,      //major;
    3,      //minor;
    false,   //core;
    1,      //MSAA;
    24,     //depth bits
    8,      //stencil bits
    false,   //debug;
    false,  //robust;
    false,  //forward;
    NULL   //share;
    );

    // -------------------------------
    // Create the window
    //
    if(!myWindow.create("gl_vk_supersampled", &context, 1280,720))
    {
        LOGE("Failed to initialize the sample\n");
        return false;
    }

    // -------------------------------
    // Parse arguments/options
    //
    for(int i=1; i<argc; i++)
    {
        if(strlen(argv[i]) <= 1)
            continue;
        switch(argv[i][1])
        {
        case 's':
            s_bStats = atoi(argv[++i]) ? true : false;
            LOGI("s_bStats set to %s\n", s_bStats ? "true":"false");
            break;
        case 'q':
            g_MSAA = atoi(argv[++i]);
            #ifdef USESVCUI
            if(g_pWinHandler) g_pWinHandler->GetCombo("MSAA")->SetSelectedByData(g_MSAA);
            #endif
            LOGI("g_MSAA set to %d\n", g_MSAA);
            break;
        case 'r':
            g_Supersampling = atof(argv[++i]);
            #ifdef USESVCUI
            if(g_pWinHandler) g_pWinHandler->GetCombo("SS")->SetSelectedByData(g_Supersampling*10);
            #endif
            LOGI("g_Supersampling set to %.2f\n", g_Supersampling);
            break;
        case 'd':
            #ifdef USESVCUI
            if(g_pTweakContainer) g_pTweakContainer->SetVisible(atoi(argv[++i]) ? 1 : 0);
            #endif
            break;
        default:
            LOGE("Wrong command-line\n");
        case 'h':
            LOGI(s_sampleHelpCmdLine);
            break;
        }
    }
	s_pCurRenderer = g_renderers[s_curRenderer];
	s_pCurRenderer->initGraphics(myWindow.getWidth(), myWindow.getHeight(), g_Supersampling, g_MSAA);
    g_profiler.init();
    g_profiler.setDefaultGPUInterface(s_pCurRenderer->getTimerInterface());
    s_pCurRenderer->setDownSamplingMode(g_downSamplingMode);

    // -------------------------------
    // Message pump loop
    //
    myWindow.makeContextCurrent();
    myWindow.swapInterval(0);
    myWindow.reshape();

    while(MyWindow::sysPollEvents(false) )
    {
        myWindow.idle();
    }
    return true;
}
Exemplo n.º 13
0
int main(){    
    win.create(Window::Dim(800, 600), "Allocore Example: Camera");

	MainLoop::start();
	return 0;
}