コード例 #1
0
//ENTRY POINT FOR APPLICATION
//CALL WINDOW CREATION ROUTINE, DEAL WITH MESSAGES, WATCH FOR INTERACTION
int main(int argc, char **argv) {
	Util::log("%s" , "TEST");
	View * v = new View(&argc, argv);
	// Open a window
	v->createWindow("bumpmapping", 640, 480);

	//init variables etc, then GL
	if(!DemoInit())
	{
		Util::log("Demo Initiation failed");
		return 0;
	}
	else
		Util::log("Demo Initiation Successful");

	if(!GLInit())
	{
		Util::log("OpenGL Initiation failed");
		return 0;
	}
	else
		Util::log("OpenGL Initiation Successful");

	v->onKeyboard(&UpdateFrame);
	v->onDraw(&RenderFrame);
	v->start();
	DemoShutdown();
	
	Util::log("Exiting...");
	return 0;								//Exit The Program
}
コード例 #2
0
int main(int argc, char **argv) {
	View * v = new View(&argc, argv);
	v->createWindow("q3bsp", 640, 480);

	//init variables etc, then GL
	if (!DemoInit()) {
		Util::log("Demo Initiation failed");
		return 0;
	} else
		Util::log("Demo Initiation Successful");

	if (!GLInit()) {
		Util::log("OpenGL Initiation failed");
		return 0;
	} else
		Util::log("OpenGL Initiation Successful");

	// Register the callback function to do the drawing.
	v->onDraw(&RenderFrame);

	// If there's nothing to do, draw.
//	v->onIdle(&RenderFrame);
	v->onKeyboard(&UpdateFrame);
	v->setSpecialHandler(&cbSpecial);
	v->onMouse(&OnMouse);
	v->onMouseMove(&OnMouseMove);
	v->start();

	DemoShutdown();

	Util::log("Exiting...");
	return 0;								//Exit The Program
}
コード例 #3
0
ファイル: main.cpp プロジェクト: jinshizi/rushcodes
//--------------------------------------------------------------
// Name:			WinMain - global
// Description:		The equivalant to Main( ) in console apps
// Arguments:		Just some default arguments that windows requires
// Return Value:	An integer variable
//--------------------------------------------------------------
int WINAPI WinMain( HINSTANCE hInstance, 
				    HINSTANCE hPrevInstance, 
				    LPSTR	 lpCmdLine, 
				    int		 nCmdShow ) 
{
	char szBuffer[256];

	//Do all of the Initiation stuff
	if( !DemoInit( ) )
		return false;

	while( true )
	{
		if( !g_glApp.HandleMessages( ) )
			break;

		if( g_glApp.MenuDown( ID_DEMO_EXIT ) )
			PostQuitMessage( 0 );

		//save the current height map
		else if( g_glApp.MenuDown( ID_DEMO_SAVEMAP ) )
		{
			sprintf( szBuffer, "height%d_%d.RAW", g_bruteForce.m_iSize, g_iCurrentHeightmap );

			g_bruteForce.SaveHeightMap( szBuffer );

			g_iCurrentHeightmap++;
		}

		//generate a new height map using fault formation
		else if( g_glApp.MenuDown( ID_DEMO_FF ) )
		{
			g_iFractalAlgo= FAULT_FORMATION;
			g_glApp.CreateDialogBox( IDD_ROUGHNESS, IDD_ROUGHNESSProc );
		}

		//generate a new height map using midpoint displacement
		else if( g_glApp.MenuDown( ID_DEMO_MD ) )
		{
			g_iFractalAlgo= MIDPOINT_DISPLACEMENT;
			g_glApp.CreateDialogBox( IDD_ROUGHNESS, IDD_ROUGHNESSProc );
		}

		if( g_glApp.IsActive( )==APP_ACTIVE )
		{
			//check input
			if( !DemoInput( ) )
				break;

			//rendering loop
			DemoRender( );
		}
	} 

	//Shut the game down
	DemoShutdown( );
	return false;
}
コード例 #4
0
/**
 * Called when the position, the size, or the clip rect of the element in the
 * browser that corresponds to this NaCl module has changed.
 * @param[in] instance The identifier of the instance representing this NaCl
 *     module.
 * @param[in] position The location on the page of this NaCl module. This is
 *     relative to the top left corner of the viewport, which changes as the
 *     page is scrolled.
 * @param[in] clip The visible region of the NaCl module. This is relative to
 *     the top left of the plugin's coordinate system (not the page).  If the
 *     plugin is invisible, @a clip will be (0, 0, 0, 0).
 */
static void Instance_DidChangeView(PP_Instance instance,
                                   PP_Resource view_resource) {
	struct PP_Rect pos;
    int bFirstCall = 0;

	psNaCLContext->psView->GetRect(view_resource, &pos);

	if (pos.size.width == 0 || pos.size.height == 0)
	{
		return;
	}

	psNaCLContext->i32PluginWidth = pos.size.width;
	psNaCLContext->i32PluginHeight = pos.size.height;

    if(psNaCLContext->hRenderContext == 0)
    {
        bFirstCall = 1;
    }

    if(psNaCLContext->hRenderContext == 0)
    {
	    int32_t attribs[] = {
	    PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
	    PP_GRAPHICS3DATTRIB_BLUE_SIZE, 8,
	    PP_GRAPHICS3DATTRIB_GREEN_SIZE, 8,
	    PP_GRAPHICS3DATTRIB_RED_SIZE, 8,
	    PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 16,
	    PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 0,
	    PP_GRAPHICS3DATTRIB_SAMPLES, 4,
	    PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 1,
	    PP_GRAPHICS3DATTRIB_WIDTH, psNaCLContext->i32PluginWidth,
	    PP_GRAPHICS3DATTRIB_HEIGHT, psNaCLContext->i32PluginHeight,
	    PP_GRAPHICS3DATTRIB_NONE,
	    };

	    psNaCLContext->hRenderContext = psNaCLContext->psG3D->Create(psNaCLContext->hModule, NULL, attribs);
	    psNaCLContext->psInstanceInterface->BindGraphics(psNaCLContext->hModule, psNaCLContext->hRenderContext);

        if(bFirstCall)
        {
	        DemoInit(psNaCLContext, psNaCLContext->i32PluginWidth, psNaCLContext->i32PluginHeight);
        }

        PP_CompletionCallback cc = PP_MakeCompletionCallback(DrawFrame, 0);
        psNaCLContext->psCore->CallOnMainThread(0, cc, PP_OK);
    }
    else
    {
        psNaCLContext->psG3D->ResizeBuffers(psNaCLContext->hRenderContext,
            psNaCLContext->i32PluginWidth,
            psNaCLContext->i32PluginHeight);

    }
}
コード例 #5
0
// Entry point
int main(int argc, char *argv[])
{
	DemoInit();
	int res = DemoEntry(argc, argv);
	if (res != 0)
		return res;
#ifdef __EMSCRIPTEN__
	emscripten_set_main_loop(DemoMainloop, 60, 0);
#else
	while (1)
	{
		if (ImGui::IsKeyPressed(SDLK_ESCAPE) && !ImGui::GetIO().WantCaptureKeyboard)
			break;

		DemoMainloop();
	}
#endif
	return 0;
}
コード例 #6
0
//WinMain
int WINAPI WinMain(	HINSTANCE	hInstance,			//Instance
					HINSTANCE	hPrevInstance,		//Previous Instance
					LPSTR		lpCmdLine,			//Command line params
					int			nShowCmd)			//Window show state
{
	//Save hInstance
	WINDOW::Instance()->hInstance=hInstance;

	//Init GL and variables
	if(!GLInit())
	{
		LOG::Instance()->OutputError("OpenGL Initiation Failed");
		return false;
	}
	else
		LOG::Instance()->OutputSuccess("OpenGL Initiation Successful");

	if(!DemoInit())
	{
		LOG::Instance()->OutputError("Demo Initiation Failed");
		return false;
	}
	else
		LOG::Instance()->OutputSuccess("Demo Initiation Successful");

	//Main Loop
	for(;;)
	{
		if(!(WINDOW::Instance()->HandleMessages()))	//quit if HandleMessages returns false
			break;

		UpdateFrame();
	}

	//Shutdown
	DemoShutdown();

	//Exit program
	LOG::Instance()->OutputSuccess("Exiting...");
	return 0;
}
コード例 #7
0
ファイル: main_wnd.cpp プロジェクト: atyuwen/aegis4k
int EntryPoint()
{
	IDirect3D9* d3d = Direct3DCreate9(D3D_SDK_VERSION);
	if (d3d == NULL)
	{
		return 0;
	}

	g_dev_params.hDeviceWindow = InitWindow();
	IDirect3DDevice9* device = NULL;
	if (d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_dev_params.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_dev_params, &device) != S_OK)
	{
		return 0;
	}

	DemoInit(device);

	MSG msg;
	while (GetCurrentSample() < MAX_SAMPLES)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT) break;
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		DemoUpdate(device, GetTickCount());
		Sleep(10);
	}

#ifndef RELEASE
	DemoDestroy(device);
	device->Release();
	d3d->Release();
	DestroyWindow(g_dev_params.hDeviceWindow);
	return 0;
#else
	ExitProcess(0);
#endif
}
コード例 #8
0
//ENTRY POINT FOR APPLICATION
//CALL WINDOW CREATION ROUTINE, DEAL WITH MESSAGES, WATCH FOR INTERACTION
int WINAPI WinMain(	HINSTANCE	hInstance,				//instance
					HINSTANCE	hPrevInstance,			//Previous Instance
					LPSTR		lpCmdLine,				//command line parameters
					int			nCmdShow)				//Window show state
{
	//Initiation
	errorLog.Init("Error Log.txt");

	//init variables etc, then GL
	if(!DemoInit())
	{
		errorLog.OutputError("Demo Initiation failed");
		return 0;
	}
	else
		errorLog.OutputSuccess("Demo Initiation Successful");

	if(!GLInit())
	{
		errorLog.OutputError("OpenGL Initiation failed");
		return 0;
	}
	else
		errorLog.OutputSuccess("OpenGL Initiation Successful");

	//Main Loop
	for(;;)
	{
		if(!(window.HandleMessages())) break;//handle windows messages, quit if returns false
		UpdateFrame();
		RenderFrame();
	}

	DemoShutdown();
	
	errorLog.OutputSuccess("Exiting...");
	return (window.msg.wParam);								//Exit The Program
}
コード例 #9
0
ファイル: main.cpp プロジェクト: jinshizi/rushcodes
//--------------------------------------------------------------
// Name:			WinMain - global
// Description:		The equivalant to Main( ) in console apps
// Arguments:		Just some default arguments that windows requires
// Return Value:	An integer variable
//--------------------------------------------------------------
int WINAPI WinMain( HINSTANCE hInstance, 
				    HINSTANCE hPrevInstance, 
				    LPSTR	 lpCmdLine, 
				    int		 nCmdShow ) 
{
	//Do all of the Initiation stuff
	if( !DemoInit( ) )
		return false;

	while( true )
	{
		if( !g_glApp.HandleMessages( ) )
			break;

		//exit the demo
		if( g_glApp.MenuDown( ID_DEMO_EXIT ) )
			PostQuitMessage( 0 );

		//take a screenshot
		else if( g_glApp.MenuDown( ID_DEMO_SCREENSHOT ) )
			g_glApp.TakeScreenshot( "screenshot.bmp" );

		if( g_glApp.IsActive( )==APP_ACTIVE )
		{
			//check input
			if( !DemoInput( ) )
				break;

			//rendering loop
			DemoRender( );
		}
	} 

	//Shut the game down
	DemoShutdown( );
	return false;
}
コード例 #10
0
ファイル: main.cpp プロジェクト: ivan33609/A2300
void main(int argc, char *argv[])
{
    printf("InvenSense Tea Pot App %s %s %s\r\n", VERSION, __DATE__, __TIME__);

    if (ASR2300SensorProcessStart()!= 0)
    {
        MessageBox(NULL, TEXT("Unable to start ASR 2300 processing. Check connection."),
            TEXT("Error"), MB_OK);
    }
    else
    {
#ifndef DISABLE_TEAPOT
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

        glutInitWindowSize(480,480);
        glutInitWindowPosition (500, 0);
        glutCreateWindow("InvenSense Tea Pot Demo");

        DemoInit();
#endif
        //IMUquaternionInit(&qData);
#ifndef DISABLE_TEAPOT
        glutDisplayFunc(DemoDisplayMain);
        glutKeyboardUpFunc(DemoKeyboardUpFunc);
        glutReshapeFunc(ReshapeWindowSize);
        glutIdleFunc(DemoDisplayIdle);
        glEnable(GL_BLEND);
        glutMainLoop();
#else
        while(1)
        Sleep(4);
        
#endif
    }

}   // end of main()
コード例 #11
0
ファイル: main.cpp プロジェクト: nugyflex/C--Project
// Entry point
int main(int argc, char *argv[])
{
	DemoInit();

	gMusic.load("audio/Jakim - Aboriginal Derivatives.mon");
	gMusic.setParams(10);

	gEcho.setParams(0.2f, 0.5f, 0.05f);
	gBiquad.setParams(SoLoud::BiquadResonantFilter::LOWPASS, 44100, 4000, 2);

	gMusic.setLooping(1);	
	gMusic.setFilter(0, &gBiquad);
	gMusic.setFilter(1, &gLofi);
	gMusic.setFilter(2, &gEcho);
	gMusic.setFilter(3, &gDCRemoval);

	gSoloud.init(SoLoud::Soloud::CLIP_ROUNDOFF | SoLoud::Soloud::ENABLE_VISUALIZATION);

	gMusichandle = gSoloud.play(gMusic);


	float filter_param0[4] = { 0, 0, 0, 0 };
	float filter_param1[4] = { 1000, 8000, 0, 0 };
	float filter_param2[4] = { 2, 3,  0, 0 };
	
	int hwchannels = 4;
	int waveform = 0;

	// Main loop: loop forever.
	while (1)
	{
		gSoloud.setFilterParameter(gMusichandle, 0, 0, filter_param0[0]);
		gSoloud.setFilterParameter(gMusichandle, 1, 0, filter_param0[1]);
		gSoloud.setFilterParameter(gMusichandle, 2, 0, filter_param0[2]);
		gSoloud.setFilterParameter(gMusichandle, 3, 0, filter_param0[3]);

		gSoloud.setFilterParameter(gMusichandle, 0, 2, filter_param1[0]);
		gSoloud.setFilterParameter(gMusichandle, 0, 3, filter_param2[0]);
		gSoloud.setFilterParameter(gMusichandle, 1, 1, filter_param1[1]);
		gSoloud.setFilterParameter(gMusichandle, 1, 2, filter_param2[1]);

		DemoUpdateStart();

		float *buf = gSoloud.getWave();
		float *fft = gSoloud.calcFFT();

		ONCE(ImGui::SetNextWindowPos(ImVec2(500, 20)));
		ImGui::Begin("Output");
		ImGui::PlotLines("##Wave", buf, 256, 0, "Wave", -1, 1, ImVec2(264, 80));
		ImGui::PlotHistogram("##FFT", fft, 256/2, 0, "FFT", 0, 10, ImVec2(264,80),8);
		ImGui::Text("Music volume     : %d%%", (int)floor(gSoloud.getVolume(gMusichandle) * 100));
		ImGui::Text("Active voices    : %d", gSoloud.getActiveVoiceCount());
		ImGui::End();

		ONCE(ImGui::SetNextWindowPos(ImVec2(20, 20)));
		
		ImGui::Begin("Control");
		if (ImGui::SliderInt("Channels", &hwchannels, 1, 4))
		{
			gMusic.setParams(hwchannels, waveform);
		}
		if (ImGui::CollapsingHeader("Waveform", (const char*)0, true, false))
		{
			if (ImGui::RadioButton("Square", waveform == SoLoud::Monotone::SQUARE))
			{
				waveform = SoLoud::Monotone::SQUARE;
				gMusic.setParams(hwchannels, waveform);
			}
			if (ImGui::RadioButton("Saw", waveform == SoLoud::Monotone::SAW))
			{
				waveform = SoLoud::Monotone::SAW;
				gMusic.setParams(hwchannels, waveform);
			}
			if (ImGui::RadioButton("Sin", waveform == SoLoud::Monotone::SIN))
			{
				waveform = SoLoud::Monotone::SIN;
				gMusic.setParams(hwchannels, waveform);
			}
			if (ImGui::RadioButton("SawSin", waveform == SoLoud::Monotone::SAWSIN))
			{
				waveform = SoLoud::Monotone::SAWSIN;
				gMusic.setParams(hwchannels, waveform);
			}
		}
		ImGui::Separator();
		ImGui::Text("Biquad filter (lowpass)");
		ImGui::SliderFloat("Wet##4", &filter_param0[0], 0, 1);
		ImGui::SliderFloat("Frequency##4", &filter_param1[0], 0, 8000);
		ImGui::SliderFloat("Resonance##4", &filter_param2[0], 1, 20);
		ImGui::Separator();
		ImGui::Text("Lofi filter");
		ImGui::SliderFloat("Wet##2", &filter_param0[1], 0, 1);
		ImGui::SliderFloat("Rate##2", &filter_param1[1], 1000, 8000);
		ImGui::SliderFloat("Bit depth##2", &filter_param2[1], 0, 8);
		ImGui::Separator();
		ImGui::Text("Echo filter");
		ImGui::SliderFloat("Wet##3", &filter_param0[2], 0, 1);
		ImGui::Separator();
		ImGui::Text("DC removal filter");
		ImGui::SliderFloat("Wet##1", &filter_param0[3], 0, 1);
		ImGui::End();
		DemoUpdateEnd();
	}
	return 0;
}
コード例 #12
0
ファイル: main.cpp プロジェクト: jinshizi/rushcodes
//--------------------------------------------------------------
// Name:			WinMain - global
// Description:		The equivalant to Main( ) in console apps
// Arguments:		Just some default arguments that windows requires
// Return Value:	An integer variable
//--------------------------------------------------------------
int WINAPI WinMain( HINSTANCE hInstance, 
				    HINSTANCE hPrevInstance, 
				    LPSTR	 lpCmdLine, 
				    int		 nCmdShow ) 
{
	char szBuffer[256];

	//Do all of the Initiation stuff
	if( !DemoInit( ) )
		return false;

	while( true )
	{
		if( !g_glApp.HandleMessages( ) )
			break;

		//exit the demo
		if( g_glApp.MenuDown( ID_DEMO_EXIT ) )
			PostQuitMessage( 0 );

		//take a screenshot
		else if( g_glApp.MenuDown( ID_DEMO_SCREENSHOT ) )
			g_glApp.TakeScreenshot( "screenshot.bmp" );

		//save the current height map
		else if( g_glApp.MenuDown( ID_DEMO_SAVEMAP ) )
		{
			sprintf( szBuffer, "height%d_%d.RAW", g_bruteForce.m_iSize, g_iCurrentHeightmap );

			g_bruteForce.SaveHeightMap( szBuffer );

			g_iCurrentHeightmap++;
		}

		//save the current texture map
		else if( g_glApp.MenuDown( ID_DEMO_SAVE_TEXTUREMAP ) )
			g_bruteForce.SaveTextureMap( "texturemap.bmp" );

		//generate a texture map (with the size provided)
		else if( g_glApp.MenuDown( ID_DEMO_GENERATE_TEXTURE_MAP ) )
			g_glApp.CreateDialogBox( IDD_TEXTURESIZE, IDD_TEXTUREProc );

		//generate a new height map using fault formation
		else if( g_glApp.MenuDown( ID_DEMO_FF ) )
		{
			g_iFractalAlgo= FAULT_FORMATION;
			g_glApp.CreateDialogBox( IDD_ROUGHNESS, IDD_ROUGHNESSProc );
		}

		//generate a new height map using midpoint displacement
		else if( g_glApp.MenuDown( ID_DEMO_MD ) )
		{
			g_iFractalAlgo= MIDPOINT_DISPLACEMENT;
			g_glApp.CreateDialogBox( IDD_ROUGHNESS, IDD_ROUGHNESSProc );
		}

		//save the current light map to a file
		else if( g_glApp.MenuDown( ID_DEMO_SAVELIGHTMAP ) )
			g_bruteForce.SaveLightMap( "lightmap.raw" );

		//customize slope lighting parameters using a dialog box
		else if( g_glApp.MenuDown( ID_DEMO_CUSTOMIZE_SLOPE ) )
			g_glApp.CreateDialogBox( IDD_CUSTOMIZE_SLOPE, IDD_CUSTOMIZE_SLOPEProc );

		if( g_glApp.IsActive( )==APP_ACTIVE )
		{
			//check input
			if( !DemoInput( ) )
				break;

			//rendering loop
			DemoRender( );
		}
	} 

	//Shut the game down
	DemoShutdown( );
	return false;
}
コード例 #13
0
ファイル: framework.c プロジェクト: icebreaker/LDPrototype
int main(int argc, char *argv[])
#endif
{
	UNUSED(argc);
	UNUSED(argv);

	TUpdate lUpdate = {0,};
	TConfig lConfig = 
	{
		800 /* width */, 
		600 /* height */, 
		16 /* bpp */,
		false /* fullscreen */,
		"LDPrototype", /* title */
		16, /* Hz */
		1, /* VSync */
		0, /* Multisampling (0 == disabled) */
		false, /* Grab Input */
		false, /* Hide Cursor */
		false, /* Center Cursor */
		false   /* Audio */
	};
	
	DemoConfig(&lConfig);
		
	if(SDL_Init(SDL_INIT_EVERYTHING)<0)
	{
		printf("SDL_init: %s\n", SDL_GetError());
		return -1;
	}
	
	/*! Initialize random seed */
    srand(time(NULL));
	
	if(lConfig.mAudio)
	{
	    if(Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 1024) < 0)
	    {
	        printf("Mix_OpenAudio: %s\n", Mix_GetError());
	        return -2;
	    }
	}
	
    /* Input */
	uint32 lCenterX = lConfig.mWidth / 2;
	uint32 lCenterY = lConfig.mHeight/ 2;

	if(lConfig.mGrabInput)
    	SDL_WM_GrabInput(SDL_GRAB_ON);

    if(lConfig.mHideCursor)
        SDL_ShowCursor(SDL_DISABLE);

    SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL );

	/* OpenGL */
    SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, lConfig.mVSync );

    if(lConfig.mMultiSampling)
    {
	    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, lConfig.mMultiSampling);
    }

    /* Window */
    uint32 lFlags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_OPENGL;	
	if(lConfig.mFullScreen)	lFlags |= SDL_FULLSCREEN;
	
	SDL_Surface *lScreen = SDL_SetVideoMode(lConfig.mWidth, lConfig.mHeight, lConfig.mBpp, lFlags);
	if(lScreen == NULL)
	{
		printf("SDL_SetVideoMode: %s\n", SDL_GetError());
		return -3;
	}

	if(lConfig.mTitle!=NULL)
		SDL_WM_SetCaption(lConfig.mTitle, lConfig.mTitle);
    
    /* OpenGL Again */
    uint32 lError = 0;
    if((lError=glewInit()) != GLEW_OK)
    {
        printf("glewInit: %s\n", glewGetErrorString(lError));
        goto exit;
    }

    if(!GLEW_VERSION_2_0)
    {
        printf("OpenGL 2.0 is not available.\n");
        goto exit;
    }
    
    {
        int lTexImageUnits = 0;
        int lTexUnits = 0;

        glGetIntegerv(GL_MAX_TEXTURE_UNITS,&lTexUnits);
		glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&lTexImageUnits);

		printf("%d Texture and %d Image Units ...\n",lTexUnits, lTexImageUnits);
		if(lTexUnits<4)
		{
		    printf(" => WARNING: You don't seem to have at least 4 Texture Units ...\n");
		    goto exit;
		}
	}

    if(!GLEW_EXT_framebuffer_object)
    {
        printf(" => WARNING: GL_EXT_framebuffer_object is not supported ...\n");
        goto exit;
    }
    if(!GLEW_EXT_framebuffer_multisample)
    {
        printf(" => WARNING: GL_EXT_framebuffer_multisample is not supported ...\n");
        goto exit;
    }
    if(!GLEW_EXT_framebuffer_blit)
    {
        printf(" => WARNING: GL_EXT_framebuffer_blit is not supported ...\n");
        goto exit;
    }

    printf("Non Power Of Two Textures: %s\n", (GLEW_ARB_texture_non_power_of_two)?"yes":"no");
	
	/* Init the demo */
	if(!DemoInit(&lConfig))
		goto demo_exit;
		
    lUpdate.mStartTime = SDL_GetTicks();		
		
	/* Event Loop */
	while(1)
	{	
		SDL_Event lEvent;
		while (SDL_PollEvent(&lEvent))
		{
			switch(lEvent.type)
			{
				case SDL_QUIT:
				{
					lUpdate.mKeys[SDLK_ESCAPE] = true;
				}
				break;
			 	case SDL_KEYDOWN:
			 	{
			 		lUpdate.mKeys[lEvent.key.keysym.sym] = true;
        		}
      			break;
      			case SDL_KEYUP:
			 	{
			 		lUpdate.mKeys[lEvent.key.keysym.sym] = false;
        		}
      			break;
      			case SDL_MOUSEMOTION:
      			{
      			    lUpdate.mMouseX = lEvent.motion.x;
      			    lUpdate.mMouseY = lEvent.motion.y;
      			    lUpdate.mMouseDeltaX = lEvent.motion.xrel;
      			    lUpdate.mMouseDeltaY = lEvent.motion.yrel;
      			}
      			break;
			}
		}

		if(lUpdate.mKeys[SDLK_ESCAPE])
		{
		    lUpdate.mKeys[SDLK_ESCAPE] = false;
			goto demo_exit;
		}

		if(lConfig.mCenterCursor)
		    SDL_WarpMouse( lCenterX, lCenterY );

		if(!DemoUpdate(&lConfig, &lUpdate))
		    break;
		    
		DemoRender(&lConfig, &lUpdate);

		lUpdate.mLastTime = lUpdate.mTime;
		lUpdate.mTime = SDL_GetTicks();
		lUpdate.mElapsedTime = lUpdate.mTime - lUpdate.mStartTime;

		lUpdate.mDeltaTime = (lUpdate.mTime - lUpdate.mLastTime);		
		if(lUpdate.mDeltaTime < lConfig.mHz)
			SDL_Delay( lConfig.mHz - lUpdate.mDeltaTime );
	}

demo_exit:
	DemoShutdown();

exit:
    if(lConfig.mAudio)
    {
        Mix_CloseAudio();
    }
    
	SDL_Quit();

	printf("Sayonara ...\n");
	return 0;
}
コード例 #14
0
ファイル: main.cpp プロジェクト: kubikle/rev2014
//--------------------------------------------------------------------------------------
// Entry point to the program. Initializes everything and goes into a message processing 
// loop. Idle time is used to render the scene.
//--------------------------------------------------------------------------------------
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{
    UNREFERENCED_PARAMETER( hPrevInstance );
    UNREFERENCED_PARAMETER( lpCmdLine );

	g_options.bpp = 32;
	g_options.dWidth = 1280;
	g_options.dHeight = 1280/16*9;
	g_options.iWidth = 1280/4*2;
	g_options.iHeight = 720/4*2;
	g_options.offsetX = 0;
	g_options.offsetY = 0;
	g_options.sWidth = 0;
	g_options.sHeight = 0;
	g_options.aspectRatio = 4/3;
#ifdef SYNC_PLAYER
	g_options.fullscreen = true;
#else
	g_options.fullscreen = false;
#endif
	g_options.saveImages = false;
	g_options.saveFrameRate = 60.0;
		
    if( FAILED( InitWindow( hInstance, nCmdShow ) ) ) {
		Quit("Failed to initialize window");
	}

#ifdef SYNC_PLAYER
	InitOptions();
#endif

	CalculateScreenSize();

	SetWindowPos(g_hWnd, NULL, 0, 0, g_options.dWidth, g_options.dHeight, NULL);
	ShowWindow( g_hWnd, nCmdShow );

    if( FAILED( InitDevice() ) )
    {
		Quit("Failed to initialize device");
    }
	
	BOOL *fullscreen = new BOOL;

	g_pSwapChain->GetFullscreenState(fullscreen,NULL);
	while(*fullscreen != g_options.fullscreen) {
		g_pSwapChain->GetFullscreenState(fullscreen,NULL);
		Sleep(1000);
	}

#ifdef SYNC_PLAYER
	ShowCursor(FALSE);
#endif

	InitAudio();
	LoadShaders();
	DemoInit();

	PlayMusic();
    // Main message loop
    MSG msg = {0};
#ifndef SYNC_PLAYER
	double lastRow = -1;
#endif
    while( true)
    {
		if(WM_QUIT == msg.message) break;
#ifdef SYNC_PLAYER
		if(GetAsyncKeyState(VK_ESCAPE)) break;
#endif
		
        if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
        {
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
        else
        {
			double row = GetAudioRow();
			double delta = row - lastRow;
			if(row > 3504) break;
#ifndef SYNC_PLAYER
			
			if(row == lastRow) {
				// Turha syödä kaikki resursseja, jos pause päällä.
				Sleep(100);
			}
#endif
			
			lastRow = row;
            Render(row, delta);
        }
    }

    CleanupDevice();

    return ( int )msg.wParam;
}
コード例 #15
0
ファイル: mainloop.c プロジェクト: dervish77/adgf
/*  main	- main program
 *
 *  Parameters:
 *	argc	- number of command line arguments
 *	argv	- pointer to command line argument array
 *
 *  Returns:
 *	none
 */
int 
mainloop(void)
{
   DATABASE_S_T		mdata;


   printf("\nMain Loop Demo - version %d.%d\n", VERSION_MAJOR, VERSION_MINOR);


   printf("--initializing demo...\n");
   DemoInit(&mdata);
   data = &mdata;

#if 0
   /*  parse command line args
    */
   switch (argc)
   {
      case 1:
            printf("--running demo...\n");
            DemoRun(&mdata);
         break;

      case 2:
         if ( (argv[1][0] EQ '-') AND (argv[1][1] EQ 'i') )
         {
            printf("--starting up interactive demo...\n");
            DemoInteractive(&mdata);
         }
         else if ( (argv[1][0] EQ '-') AND (argv[1][1] EQ 'h') )
         {
            DemoHelp();
         }
         else
         {
            ErrorUsage();
         }
         break;

      default:
         ErrorUsage();
         break;
   }
#endif

#if 0
   printf("--running demo...\n");
   DemoRun(&mdata);
   DemoRun(&mdata);
   DemoRun(&mdata);
#endif

#if 1
   printf("--starting up interactive demo...\n");
   DemoInteractive(&mdata);
#endif

   printf("--closing demo...\n");
   DemoClose(&mdata);

//   exit(0);
}