コード例 #1
0
ファイル: gemglfw2window.cpp プロジェクト: avilleret/Gem
void gemglfw2window :: destroyMess(void)
{
  if(makeCurrent()) {
    glfwCloseWindow();
  }
  destroy();
}
コード例 #2
0
ファイル: clipboard.c プロジェクト: AMD-FirePro/SDK
static void key_callback(GLFWwindow window, int key, int action)
{
    if (action != GLFW_PRESS)
        return;

    switch (key)
    {
        case GLFW_KEY_ESCAPE:
            glfwCloseWindow(window);
            break;

        case GLFW_KEY_V:
            if (control_is_down(window))
            {
                const char* string;

                string = glfwGetClipboardString(window);
                if (string)
                    printf("Clipboard contains \"%s\"\n", string);
                else
                    printf("Clipboard does not contain a string\n");
            }
            break;

        case GLFW_KEY_C:
            if (control_is_down(window))
            {
                const char* string = "Hello GLFW World!";
                glfwSetClipboardString(window, string);
                printf("Setting clipboard to \"%s\"\n", string);
            }
            break;
    }
}
コード例 #3
0
int _glfwPlatformTerminate( void )
{
    // Only the main thread is allowed to do this...
    if( GetCurrentThreadId() != _glfwThrd.First.WinID )
    {
        return GL_FALSE;
    }

    // Close OpenGL window
    glfwCloseWindow();

    // Kill thread package
    _glfwTerminateThreads();

    // Enable system keys again (if they were disabled)
    glfwEnable( GLFW_SYSTEM_KEYS );

    // Unload libraries (DLLs)
    _glfwFreeLibraries();

    // Restore FOREGROUNDLOCKTIMEOUT system setting
    SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
                          (LPVOID) _glfwLibrary.Sys.foregroundLockTimeout,
                          SPIF_SENDCHANGE );

    return GL_TRUE;
}
コード例 #4
0
ファイル: x11_init.c プロジェクト: nbeams/kiss
int _glfwPlatformTerminate( void )
{
#ifdef _GLFW_HAS_PTHREAD
    // Only the main thread is allowed to do this...
    if( pthread_self() != _glfwThrd.First.PosixID )
    {
        return GL_FALSE;
    }
#endif // _GLFW_HAS_PTHREAD

    // Close OpenGL window
    glfwCloseWindow();

    // Kill thread package
    _glfwTerminateThreads();

    // Terminate display
    _glfwTerminateDisplay();

    // Terminate joysticks
    _glfwTerminateJoysticks();

    // Unload libGL.so if necessary
#ifdef _GLFW_DLOPEN_LIBGL
    if( _glfwLibrary.Libs.libGL != NULL )
    {
        dlclose( _glfwLibrary.Libs.libGL );
        _glfwLibrary.Libs.libGL = NULL;
    }
#endif

    return GL_TRUE;
}
コード例 #5
0
void OptionsDialog2::Click(void) {
	switch(fActiveElement) {
	case ActiveElement::NONE:
		break;
	case ActiveElement::MUSIC:
		Options::fgOptions.fMusicOn = !Options::fgOptions.fMusicOn;
		gSoundControl.SwitchMusicStatus();
		break;
	case ActiveElement::PREVIOUS:
		dialog::Pop();
		break;
	case ActiveElement::ADVANCED:
		this->Push(new AdvancedOptions);
		break;
	case ActiveElement::SAVEANDQUIT:
		Options::fgOptions.fNewPerformance = fNewPerfLevel;
		Options::fgOptions.fFullScreen = fNewFullScreen;
		glfwCloseWindow();
		break;
	case ActiveElement::PING:
		gShowPing = !gShowPing;
		break;
	case ActiveElement::FULLSCREEN:
		fNewFullScreen = !fNewFullScreen;
		break;
	case ActiveElement::P1:
		fNewPerfLevel = 1; break;
	case ActiveElement::P2:
		fNewPerfLevel = 2; break;
	case ActiveElement::P3:
		fNewPerfLevel = 3; break;
	case ActiveElement::P4:
		fNewPerfLevel = 4; break;
	}
}
コード例 #6
0
ファイル: Visualization.cpp プロジェクト: fairlight1337/ego
Visualization::~Visualization() {
  if(m_bInitialized) {
    glDeleteTextures(1, &m_unTexture);
    glfwCloseWindow();
    glfwTerminate();
  }
}
コード例 #7
0
ファイル: game.c プロジェクト: xymostech/FPSGame
int main(int argc, char const **argv) {
	glfwInit();

	glfwOpenWindow(800, 600, 8, 8, 8, 8, 16, 0, GLFW_WINDOW);

	glfwSetWindowSizeCallback(set_window_size);
	glfwSetKeyCallback(set_key);

	init();

	int running = 1;

	while(running) {
		update();
		update_keys();

		draw();

		glfwSwapBuffers();

		running = !glfwGetKey(GLFW_KEY_ESC) &&
		          glfwGetWindowParam(GLFW_OPENED);
		
		glfwSleep(0.01);
	}

	terminate();

	glfwCloseWindow();
	glfwTerminate();

	return 0;
}
コード例 #8
0
static void close_window(void)
{
    double base = glfwGetTime();

    glfwCloseWindow();

    printf("Closing window took %0.3f seconds\n", glfwGetTime() - base);
}
コード例 #9
0
ファイル: Controller.c プロジェクト: Durza007/cen64-video
/* ============================================================================
 *  DestroyVIF: Releases any resources allocated for an VIF instance.
 * ========================================================================= */
void
DestroyVIF(struct VIFController *controller) {
  glDeleteTextures(1, &controller->frameTexture);

  glfwCloseWindow();
  glfwTerminate();
  free(controller);
}
コード例 #10
0
int main( int argc, char** argv )
{
	// Initialize GLFW
	glfwInit();
	if( !setupWindow( appWidth, appHeight, fullScreen ) ) return -1;
	
	// Initalize application and engine
	app = new Application( generatePath( argv[0], "../Content" ) );
	if ( !app->init() )
	{
		// Fake message box
		glfwCloseWindow();
		glfwOpenWindow( 800, 16, 8, 8, 8, 8, 24, 8, GLFW_WINDOW );
		glfwSetWindowTitle( "Unable to initalize engine - Make sure you have an OpenGL 2.0 compatible graphics card" );
		glfwSleep( 5 );
		
		std::cout << "Unable to initalize engine" << std::endl;
		std::cout << "Make sure you have an OpenGL 2.0 compatible graphics card";
		glfwTerminate();
		return -1;
	}
	app->resize( appWidth, appHeight );
	TwWindowSize( appWidth, appHeight );
	//glfwDisable( GLFW_MOUSE_CURSOR );

	int frames = 0;
	float fps = 30.0f;
	t0 = glfwGetTime();
	running = true;

	// Game loop
	while( running )
	{
		// Calc FPS
		++frames;
		if( frames >= 3 )
		{
			double t = glfwGetTime();
			fps = frames / (float)(t - t0);
			frames = 0;
			t0 = t;
		}

		// Render
		app->mainLoop( fps );
		TwDraw();
		glfwSwapBuffers();
	}

	glfwEnable( GLFW_MOUSE_CURSOR );

	// Quit
	app->release();
	delete app;
	glfwTerminate();

	return 0;
}
コード例 #11
0
ファイル: Application.cpp プロジェクト: tomaszr123/2DEngine
// closes th window and shuts down the full framework 
void Application::Shutdown()
{
	m_spriteBatch->End();
	glfwCloseWindow();
	glfwTerminate();
	
	//delete m_font;
	//m_font = nullptr;
}
コード例 #12
0
ファイル: GLFWWindow.cpp プロジェクト: Funto/Tohoku-Engine
void GLFWWindow::close()
{
	if(!opened)
		return;

	glfwCloseWindow();
	glfwTerminate();
	opened = false;
}
コード例 #13
0
ファイル: glus_glfw.c プロジェクト: bagobor/GLUS
GLUSvoid GLUSAPIENTRY glusDestroyWindow(GLUSvoid)
{
    glfwCloseWindow();

    g_windowCreated = GLUS_FALSE;

    glfwTerminate();

    g_initdone = GLUS_FALSE;
}
コード例 #14
0
ファイル: macosx_window.c プロジェクト: x-y-z/SteerSuite-CUDA
OSStatus _glfwCommandHandler( EventHandlerCallRef handlerCallRef,
                                 EventRef event,
                                 void *userData )
{
    if( _glfwWin.SysKeysDisabled )
    {
        // TO DO: give adequate UI feedback that this is the case
        return eventNotHandledErr;
    }

    HICommand command;
    if( GetEventParameter( event,
                           kEventParamDirectObject,
                           typeHICommand,
                           NULL,
                           sizeof( HICommand ),
                           NULL,
                           &command ) == noErr )
    {
        switch( command.commandID )
        {
            case kHICommandClose:
            case kHICommandQuit:
            {
                // Check if the program wants us to close the window
                if( _glfwWin.WindowCloseCallback )
                {
                    if( _glfwWin.WindowCloseCallback() )
                    {
                        glfwCloseWindow();
                    }
                }
                else
                {
                    glfwCloseWindow();
                }
                return noErr;
            }
        }
    }

    return eventNotHandledErr;
}
コード例 #15
0
void wsScreen::close() {
    #if (WS_SCREEN_BACKEND == WS_BACKEND_X11)
        glXMakeCurrent(xDisp, None, NULL);
        glXDestroyContext(xDisp, context);
        XDestroyWindow(xDisp, win);
        XCloseDisplay(xDisp);
    #elif (WS_SCREEN_BACKEND == WS_BACKEND_GLFW)
        glfwCloseWindow();
    #endif
}
コード例 #16
0
ファイル: main.cpp プロジェクト: lsouchet/gideros
EM_BOOL resize_callback(int eventType, const EmscriptenUiEvent *e, void *userData)
{
 int defWidth=e->windowInnerWidth;
 int defHeight=e->windowInnerHeight;	
 printf("Resize:%d,%d\n",e->windowInnerWidth,e->windowInnerHeight);
 glfwCloseWindow();
  initGL(defWidth,defHeight);   
//glfwSetWindowSize(defWidth,defHeight); 
    s_applicationManager->surfaceChanged(defWidth,defHeight,(defWidth>defHeight)?90:0);
}
コード例 #17
0
void run_loop(
	std::unique_ptr<Example>& example,
	GLuint width,
	GLuint height
)
{
	GLuint mouse_x = width / 2;
	GLuint mouse_y = height / 2;
	os::steady_clock os_clock;
	ExampleClock clock;
	while(true)
	{
		clock.Update(os_clock.seconds());
		if(!example->Continue(clock)) break;
		example->Render(clock);

		glfwSwapBuffers();

		int new_x, new_y;
		glfwGetWindowSize(&new_x, &new_y);
		if((int(width) != new_x) || (int(height) != new_y))
		{
			if(new_x <= 0) new_x = 1;
			if(new_y <= 0) new_y = 1;
			width = GLuint(new_x);
			height = GLuint(new_y);
			example->Reshape(width, height);
		}

		glfwGetMousePos(&new_x, &new_y);
		if((int(mouse_x) != new_x) || (int(mouse_y) != new_y))
		{
			if(new_x <= 0) new_x = 1;
			if(new_y <= 0) new_y = 1;
			mouse_x = GLuint(new_x);
			mouse_y = GLuint(new_y);
			example->MouseMove(
				mouse_x,
				height-
				mouse_y,
				width,
				height
			);
		}

		if(glfwGetKey(GLFW_KEY_ESC))
		{
			glfwCloseWindow();
			break;
		}
		if(!glfwGetWindowParam(GLFW_OPENED))
			break;
	}
}
コード例 #18
0
ファイル: GameMain_GLFW.cpp プロジェクト: ilijabc/Kosmos2D
static void cb_key(int key, int press)
{
    if (g_game)
    {
        g_game->onKeyEvent(key, press);
    }
    if (key == GLFW_KEY_ESC)
    {
        glfwCloseWindow();
    }
}
コード例 #19
0
ファイル: luview.cpp プロジェクト: ghl3/luview
  const char *render_scene(std::vector<DrawableObject*> &actors)
  {
    if (first_frame) {
      EntryCB cb = Callbacks.begin();
      while (cb != Callbacks.end()) {
	if (cb->first != "idle") {
	  std::cout<<cb->first<<": "<<cb->second->get_message()<<std::endl;
	}
	++cb;
      }
      first_frame = false;
    }

    character_input = ' ';
    CurrentWindow = this;

    glClearColor(Color[0], Color[1], Color[2], 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    GLfloat light_ambient [] = { 0.4, 0.4, 0.4, 1.0 };
    GLfloat light_diffuse [] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat light_position[] = { 0.0, 0.0, 1.0, 0.0 };

    glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
    glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);

    glTranslated(Position[0], Position[1], Position[2]);
    glRotated(Orientation[0], 1, 0, 0);
    glRotated(Orientation[1], 0, 1, 0);
    glScaled(Scale[0], Scale[1], Scale[2]);

    for (std::vector<DrawableObject*>::iterator a=actors.begin();
         a!=actors.end(); ++a) {
      DrawableObject *actor = *a;
      actor->draw();
    }

    glFlush();
    glfwSwapBuffers();

    if (glfwGetKey(GLFW_KEY_ESC) || !glfwGetWindowParam(GLFW_OPENED)) {
      glfwCloseWindow();
      return "terminate";
    }

    CurrentWindow->exec_callback("idle");
    return "continue";
  }
コード例 #20
0
ファイル: TwAdvanced1.cpp プロジェクト: davidcox/AntTweakBar
// Callback function called by GLFW on key event
void GLFWCALL OnKey(int glfwKey, int glfwAction)
{
    if( !TwEventKeyGLFW(glfwKey, glfwAction) )  // Send event to AntTweakBar
    {
        if( glfwKey==GLFW_KEY_ESC && glfwAction==GLFW_PRESS ) // Want to quit?
            glfwCloseWindow();
        else
        {
            // Event has not been handled
            // Do something if needed.
        }
    }
}
コード例 #21
0
ファイル: sys_osx.cpp プロジェクト: zachallett/spacecrash
//-----------------------------------------------------------------------------
int main(int argc, char *argv[])
{
  int retval = -1;

  if (glfwInit() == GL_TRUE)
  {
    if (glfwOpenWindow(SYS_WIDTH, SYS_HEIGHT, 0, 0, 0, 0, 8, 0, SYS_FULLSCREEN ? GLFW_FULLSCREEN : GLFW_WINDOW) == GL_TRUE) /* rgba, depth, stencil */
    {
        retval = Main();
        glfwCloseWindow();
    }
    glfwTerminate();
  }
  return retval;
}
コード例 #22
0
ファイル: main.cpp プロジェクト: dreamsxin/nawia
void keyPressListener( int key, int action )
{
	if( !running ) return;

	if( action == GLFW_PRESS )
	{
		int width = appWidth, height = appHeight;
		
		switch (key)
		{
		case GLFW_KEY_ESC:
			running = false;
			break;
		case GLFW_KEY_SPACE:
			app->keyPress( key, true );
			break;
		case GLFW_KEY_F1:
			app->release();
			glfwCloseWindow();
			
			// Toggle fullscreen mode
			fullScreen = !fullScreen;

			if( fullScreen )
			{
				GLFWvidmode mode;
				glfwGetDesktopMode( &mode );	
				// Use desktop resolution
				width = mode.Width; height = mode.Height;
			}
			
			if( !setupWindow( width, height, fullScreen ) )
			{
				glfwTerminate();
				exit( -1 );
			}
			
			app->init(sceneFile);
			app->resize( width, height );
			t0 = glfwGetTime();
			break;
		default:
			app->keyPress( key, true );
		}
	}

	if( key >= 0 ) app->keyPress( key, action == GLFW_PRESS );
}
コード例 #23
0
ファイル: main.cpp プロジェクト: anhhuybidv/snes9xnext
	void toggleFullScreen()
	{
		LOGD("toggleFullScreen()");

		g_isFullScreen = !g_isFullScreen;

		//glfwTerminate();
		glfwCloseWindow();

		openWindow(g_isFullScreen);

		input_resetStates();
		engine_unloadContent();

		engine_loadContent();
	}
コード例 #24
0
ファイル: Chapter-11.cpp プロジェクト: aggelog/CG-database
// Callback function called by GLFW on key event
void GLFWCALL OnKey(int glfwKey, int glfwAction)
{
    
    if( glfwKey==GLFW_KEY_ESC && glfwAction==GLFW_PRESS ) // Want to quit?
	{
        glfwCloseWindow();
	}
	else if( glfwGetKey(GLFW_KEY_SPACE) == GLFW_PRESS )
	{
		camera = false;
	}
    else
    {
        // Event has not been handled
        // Do something if needed.
    }
}
コード例 #25
0
ファイル: android_init.c プロジェクト: KTaskn/MMDAgent
int _glfwPlatformTerminate( void )
{
#ifdef _GLFW_HAS_PTHREAD
    // Only the main thread is allowed to do this...
    if( pthread_self() != _glfwThrd.First.PosixID )
    {
        return GL_FALSE;
    }
#endif // _GLFW_HAS_PTHREAD

    // Close OpenGL window
    glfwCloseWindow();

    // Kill thread package
    terminateThreads();

    return GL_TRUE;
}
コード例 #26
0
ファイル: dos_init.c プロジェクト: jaekim708/kiss
int _glfwPlatformTerminate( void )
{
    // Only the main thread is allowed to do this...
    // TODO

    // Close OpenGL window
    glfwCloseWindow();

    // Terminate joysticks
    _glfwTerminateJoysticks();

    // Kill timer
    _glfwTerminateTimer();

    // Kill thread package
    _glfwTerminateThreads();

    return GL_TRUE;
}
コード例 #27
0
ファイル: iconify.c プロジェクト: BorQube/glfw
static void key_callback(GLFWwindow window, int key, int action)
{
    printf("%0.2f Key %s\n",
           glfwGetTime(),
           action == GLFW_PRESS ? "pressed" : "released");

    if (action != GLFW_PRESS)
        return;

    switch (key)
    {
    case GLFW_KEY_SPACE:
        glfwIconifyWindow(window);
        break;
    case GLFW_KEY_ESCAPE:
        glfwCloseWindow(window);
        break;
    }
}
コード例 #28
0
ファイル: test.cpp プロジェクト: PureW/glftfont
int main(int argc, char** argv)
{
    if(argc != 2)
    {
        std::cerr << "Usage: test file.  Where file is a valid font\n";
    }
    else
    {
        glfwInit();
        glfwOpenWindow(800, 600, 8, 8, 8, 8, 0, 0, GLFW_WINDOW);
        
        GLFT_Font f;
        f.open(argv[1],24);
        
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, 800, 600, 0, -1.0, 1.0);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glDisable(GL_LIGHTING);
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
        
        do
        {
            glClear(GL_COLOR_BUFFER_BIT);
    
            f.drawText(0, 0, "drawText");
            f.drawText(f.calcStringWidth("drawText"), f.getHeight(), 
                        "drawText 0x%X", 250);
            f.beginDraw(200, 200) << "beginDraw: " << 10 << f.endDraw();
   
            glfwSwapBuffers();
            
        } while(glfwGetWindowParam(GLFW_OPENED) && 
                glfwGetKey(GLFW_KEY_ESC) != GLFW_PRESS);
    
        glfwCloseWindow();
        glfwTerminate();
    }
}
コード例 #29
0
    void Root::setFullscreen(bool fullscr)
    {
        if( fullscreen == fullscr ) return; //no difference
        fullscreen = fullscr;

        glfwCloseWindow();

        if(!glfwOpenWindow(windowWidth, windowHeight, 0, 0, 0, 0, 32, 0, (fullscreen ? GLFW_FULLSCREEN : GLFW_WINDOW)))
        {
            LOG_ERROR("Could not re-create window. Closing now.");
            stopRendering();
            return;
        }

        glfwSetWindowTitle("Arya");
        glfwEnable(GLFW_MOUSE_CURSOR);
        glfwSetKeyCallback(keyCallback);
        glfwSetMouseButtonCallback(mouseButtonCallback);
        glfwSetMousePosCallback(mousePosCallback);
        glfwSetMouseWheelCallback(mouseWheelCallback);
    }
コード例 #30
0
ファイル: amigaos_window.c プロジェクト: jaekim708/kiss
void _glfwPlatformPollEvents( void )
{
    int winclosed;

    // Process all pending window events
    winclosed = GL_FALSE;
    if( _glfwProcessEvents() )
    {
        winclosed = GL_TRUE;
    }

    // Was there a window close request?
    if( winclosed && _glfwWin.WindowCloseCallback )
    {
        // Check if the program wants us to close the window
        winclosed = _glfwWin.WindowCloseCallback();
    }
    if( winclosed )
    {
        glfwCloseWindow();
    }
}