예제 #1
0
static void gearsTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 /*time*/)
{
    fAngle += 2.0;
    view_roty += 1.0;
	GHOST_IWindow* window = (GHOST_IWindow*)task->getUserData();
	if (fApp->m_fullScreenWindow) {
		// Running full screen
		fApp->m_fullScreenWindow->invalidate();
	}
	else {
		if (fSystem->validWindow(window)) {
			window->invalidate();
		}
	}
}
예제 #2
0
파일: GHOST_C-api.cpp 프로젝트: jinjoh/NOOR
GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
										GHOST_TGrabCursorMode mode,
										int *bounds)
{
	GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
	GHOST_Rect bounds_rect, bounds_win;

	if(bounds) {
		/* if this is X11 specific we need a function that converts */
		window->getClientBounds(bounds_win);
		window->clientToScreen(bounds[0], bounds_win.getHeight() - bounds[1], bounds_rect.m_l, bounds_rect.m_t);
		window->clientToScreen(bounds[2], bounds_win.getHeight() - bounds[3], bounds_rect.m_r, bounds_rect.m_b);

	}
	
	return window->setCursorGrab(mode, bounds ? &bounds_rect:NULL);
}
예제 #3
0
char *GHOST_GetTitle(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
	STR_String title;

	window->getTitle(title);

	char *ctitle = (char *) malloc(title.Length() + 1);

	if (ctitle == NULL) {
		return NULL;
	}

	strcpy(ctitle, title.Ptr());

	return ctitle;
}
GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
                                   GHOST_TGrabCursorMode mode,
                                   int bounds[4], const int mouse_ungrab_xy[2])
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
	GHOST_Rect bounds_rect;
	GHOST_TInt32 mouse_xy[2];

	if (bounds) {
		bounds_rect = GHOST_Rect(bounds[0], bounds[1], bounds[2], bounds[3]);
	}
	if (mouse_ungrab_xy) {
		mouse_xy[0] = mouse_ungrab_xy[0];
		mouse_xy[1] = mouse_ungrab_xy[1];
	}

	return window->setCursorGrab(mode,
	                             bounds ? &bounds_rect : NULL,
	                             mouse_ungrab_xy ? mouse_xy : NULL);
}
예제 #5
0
GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
                                   GHOST_TGrabCursorMode mode,
                                   int bounds[4], const int mouse_ungrab_xy[2])
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
	GHOST_Rect bounds_rect, bounds_win;
	GHOST_TInt32 mouse_ungrab_xy_global[2];

	if (bounds) {
		/* if this is X11 specific we need a function that converts */
		window->getClientBounds(bounds_win);
		window->clientToScreen(bounds[0], bounds_win.getHeight() - bounds[1], bounds_rect.m_l, bounds_rect.m_t);
		window->clientToScreen(bounds[2], bounds_win.getHeight() - bounds[3], bounds_rect.m_r, bounds_rect.m_b);

	}
	
	if (mouse_ungrab_xy) {
		if (bounds == NULL)
			window->getClientBounds(bounds_win);
		window->clientToScreen(mouse_ungrab_xy[0], bounds_win.getHeight() - mouse_ungrab_xy[1],
		                       mouse_ungrab_xy_global[0], mouse_ungrab_xy_global[1]);
	}

	return window->setCursorGrab(mode,
	                             bounds ? &bounds_rect : NULL,
	                             mouse_ungrab_xy ? mouse_ungrab_xy_global : NULL);
}
예제 #6
0
GHOST_IWindow* GHOST_SystemCarbon::createWindow(
	const STR_String& title, 
	GHOST_TInt32 left,
	GHOST_TInt32 top,
	GHOST_TUns32 width,
	GHOST_TUns32 height,
	GHOST_TWindowState state,
	GHOST_TDrawingContextType type,
	bool stereoVisual,
	const GHOST_TUns16 numOfAASamples,
	const GHOST_TEmbedderWindowID parentWindow
)
{
	GHOST_IWindow* window = 0;

	window = new GHOST_WindowCarbon (title, left, top, width, height, state, type);

	if (window) {
		if (window->getValid()) {
			// Store the pointer to the window
			GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
			m_windowManager->addWindow(window);
			m_windowManager->setActiveWindow(window);
			pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
		}
		else {
			GHOST_PRINT("GHOST_SystemCarbon::createWindow(): window invalid\n");
			delete window;
			window = 0;
		}
	}
	else {
		GHOST_PRINT("GHOST_SystemCarbon::createWindow(): could not create window\n");
	}
	return window;
}
예제 #7
0
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
	
	return window->activateDrawingContext();
}
예제 #8
0
GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int interval)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->setSwapInterval(interval);
}
예제 #9
0
GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle, GHOST_TUns8 isUnsavedChanges)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
	
	return window->setModifiedState(isUnsavedChanges);
}	
예제 #10
0
int GHOST_GetValid(GHOST_WindowHandle windowhandle) 
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return (int) window->getValid();
}
예제 #11
0
GHOST_TSuccess GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle, int* intervalOut)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->getSwapInterval(*intervalOut);
}
예제 #12
0
bool Application::processEvent(GHOST_IEvent* event)
{
    GHOST_IWindow* window = event->getWindow();
    bool handled = true;

    switch (event->getType()) {
    /*	case GHOST_kEventUnknown:
    		break;
    	case GHOST_kEventCursorButton:
    		std::cout << "GHOST_kEventCursorButton"; break;
    	case GHOST_kEventCursorMove:
    		std::cout << "GHOST_kEventCursorMove"; break;
    */
    case GHOST_kEventWheel:
    {
        GHOST_TEventWheelData* wheelData = (GHOST_TEventWheelData*) event->getData();
        if (wheelData->z > 0)
        {
            view_rotz += 5.f;
        }
        else
        {
            view_rotz -= 5.f;
        }
    }
    break;

    case GHOST_kEventKeyUp:
        break;

    case GHOST_kEventKeyDown:
    {
        GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*) event->getData();
        switch (keyData->key) {
        case GHOST_kKeyC:
        {
            int cursor = m_cursor;
            cursor++;
            if (cursor >= GHOST_kStandardCursorNumCursors) {
                cursor = GHOST_kStandardCursorFirstCursor;
            }
            m_cursor = (GHOST_TStandardCursor)cursor;
            window->setCursorShape(m_cursor);
        }
        break;

        case GHOST_kKeyE:
        {
            int x = 200, y= 200;
            m_system->setCursorPosition(x,y);
            break;
        }

        case GHOST_kKeyF:
            if (!m_system->getFullScreen()) {
                // Begin fullscreen mode
                GHOST_DisplaySetting setting;

                setting.bpp = 16;
                setting.frequency = 50;
                setting.xPixels = 640;
                setting.yPixels = 480;
                m_system->beginFullScreen(setting, &m_fullScreenWindow, false /* stereo flag */);
            }
            else {
                m_system->endFullScreen();
                m_fullScreenWindow = 0;
            }
            break;

        case GHOST_kKeyH:
            window->setCursorVisibility(!window->getCursorVisibility());
            break;

        case GHOST_kKeyM:
        {
            bool down = false;
            m_system->getModifierKeyState(GHOST_kModifierKeyLeftShift,down);
            if (down) {
                std::cout << "left shift down\n";
            }
            m_system->getModifierKeyState(GHOST_kModifierKeyRightShift,down);
            if (down) {
                std::cout << "right shift down\n";
            }
            m_system->getModifierKeyState(GHOST_kModifierKeyLeftAlt,down);
            if (down) {
                std::cout << "left Alt down\n";
            }
            m_system->getModifierKeyState(GHOST_kModifierKeyRightAlt,down);
            if (down) {
                std::cout << "right Alt down\n";
            }
            m_system->getModifierKeyState(GHOST_kModifierKeyLeftControl,down);
            if (down) {
                std::cout << "left control down\n";
            }
            m_system->getModifierKeyState(GHOST_kModifierKeyRightControl,down);
            if (down) {
                std::cout << "right control down\n";
            }
        }
        break;

        case GHOST_kKeyQ:
            if (m_system->getFullScreen())
            {
                m_system->endFullScreen();
                m_fullScreenWindow = 0;
            }
            m_exitRequested = true;
            break;

        case GHOST_kKeyS:  // toggle mono and stereo
            if(stereo)
                stereo = false;
            else
                stereo = true;
            break;

        case GHOST_kKeyT:
            if (!m_testTimer) {
                m_testTimer = m_system->installTimer(0, 1000, testTimerProc);
            }

            else {
                m_system->removeTimer(m_testTimer);
                m_testTimer = 0;
            }

            break;

        case GHOST_kKeyW:
            if (m_mainWindow)
            {
                STR_String title;
                m_mainWindow->getTitle(title);
                title += "-";
                m_mainWindow->setTitle(title);

            }
            break;

        default:
            break;
        }
    }
    break;

    case GHOST_kEventWindowClose:
    {
        GHOST_IWindow* window2 = event->getWindow();
        if (window2 == m_mainWindow) {
            m_exitRequested = true;
        }
        else {
            m_system->disposeWindow(window2);
        }
    }
    break;

    case GHOST_kEventWindowActivate:
        handled = false;
        break;

    case GHOST_kEventWindowDeactivate:
        handled = false;
        break;

    case GHOST_kEventWindowUpdate:
    {
        GHOST_IWindow* window2 = event->getWindow();
        if(!m_system->validWindow(window2))
            break;

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        if(stereo)
        {
            View(window2, stereo, LEFT_EYE);
            glPushMatrix();
            RenderCamera();
            RenderScene();
            glPopMatrix();

            View(window2, stereo, RIGHT_EYE);
            glPushMatrix();
            RenderCamera();
            RenderScene();
            glPopMatrix();
        }
        else
        {
            View(window2, stereo);
            glPushMatrix();
            RenderCamera();
            RenderScene();
            glPopMatrix();
        }
        window2->swapBuffers();
    }
    break;

    default:
        handled = false;
        break;
    }
    return handled;
}
예제 #13
0
bool GPG_Application::processEvent(GHOST_IEvent* event)
{
	bool handled = true;

	switch (event->getType())
	{
		case GHOST_kEventUnknown:
			break;

		case GHOST_kEventButtonDown:
			handled = handleButton(event, true);
			break;

		case GHOST_kEventButtonUp:
			handled = handleButton(event, false);
			break;
			
		case GHOST_kEventWheel:
			handled = handleWheel(event);
			break;

		case GHOST_kEventCursorMove:
			handled = handleCursorMove(event);
			break;

		case GHOST_kEventKeyDown:
			handleKey(event, true);
			break;

		case GHOST_kEventKeyUp:
			handleKey(event, false);
			break;


		case GHOST_kEventWindowClose:
		case GHOST_kEventQuit:
			m_exitRequested = KX_EXIT_REQUEST_OUTSIDE;
			break;

		case GHOST_kEventWindowActivate:
			handled = false;
			break;
		case GHOST_kEventWindowDeactivate:
			handled = false;
			break;

		case GHOST_kEventWindowUpdate:
			{
				GHOST_IWindow* window = event->getWindow();
				if (!m_system->validWindow(window)) break;
				// Update the state of the game engine
				if (m_kxsystem && !m_exitRequested)
				{
					// Proceed to next frame
					window->activateDrawingContext();

					// first check if we want to exit
					m_exitRequested = m_ketsjiengine->GetExitCode();
					
					// kick the engine
					bool renderFrame = m_ketsjiengine->NextFrame();
					if (renderFrame)
					{
						// render the frame
						m_ketsjiengine->Render();
					}
				}
				m_exitString = m_ketsjiengine->GetExitString();
			}
			break;
		
		case GHOST_kEventWindowSize:
			{
			GHOST_IWindow* window = event->getWindow();
			if (!m_system->validWindow(window)) break;
			if (m_canvas) {
				GHOST_Rect bnds;
				window->getClientBounds(bnds);
				m_canvas->Resize(bnds.getWidth(), bnds.getHeight());
			}
			}
			break;
		
		default:
			handled = false;
			break;
	}
	return handled;
}
예제 #14
0
bool ofxFensterManager::processEvent(GHOST_IEvent* event)
{
	if(event->getType()==GHOST_kEventUnknown)
		return false;
	
	GHOST_IWindow* window = event->getWindow();
	bool handled = true;
	
	ofxFenster* win=getFensterByHandler(window);
	
	GHOST_Rect winPos; //why on every process...?
	window->getWindowBounds(winPos);
	
	switch (event->getType())
	{
			//////////////////// MOUSE
        case GHOST_kEventCursorMove:
        {
            GHOST_TEventCursorData* bd=(GHOST_TEventCursorData*)event->getData();
			GHOST_TInt32 x,y;
			window->screenToClient(bd->x, bd->y, x, y);
			
			ofPoint p(x, y);
			p.y -= 1;
			
            if(win->isButtonDown) {
                //win->mouseDragged(bd->x-winPos.m_l, bd->y-winPos.m_t, win->buttonDown);
                win->mouseDragged(p.x, p.y, win->buttonDown);
            } else {
                //win->mouseMoved(bd->x-winPos.m_l, bd->y-winPos.m_t);
                win->mouseMoved(p.x, p.y);
            }
            break;
        }
        case GHOST_kEventWheel:
        {
            break;
        }
        case GHOST_kEventButtonDown:
        {
            GHOST_TEventButtonData* bd=(GHOST_TEventButtonData*)event->getData();
            win->isButtonDown=true;
            win->buttonDown=bd->button;
            win->mousePressed(bd->button);
            break;
        }
        case GHOST_kEventButtonUp:
        {
            GHOST_TEventButtonData* bd=(GHOST_TEventButtonData*)event->getData();
            win->isButtonDown=false;
            win->mouseReleased(bd->button);
            break;
        }
			////////////////// KEYBOARD
        case GHOST_kEventKeyUp:
        {
            int key=handleKeyData((GHOST_TEventKeyData*) event->getData());
            if(key==OF_KEY_ESC)
                break;
            win->keyReleased(key);
            break;
        }
        case GHOST_kEventKeyDown:
        {
            int key=handleKeyData((GHOST_TEventKeyData*) event->getData());
            if(key==OF_KEY_ESC)
                ofExit(0);
            win->keyPressed(key);
            break;
        }
			////////////////// WINDOW
        case GHOST_kEventWindowSize:
        {
            GHOST_Rect rect;
            window->getClientBounds(rect);
            win->windowResized(rect.getWidth(), rect.getHeight());
            break;
        }
        case GHOST_kEventWindowMove:
        {
            GHOST_Rect rect;
            window->getWindowBounds(rect);
			//cout << rect.m_t << endl;
			//GHOST_TInt32 x,y;
			//window->screenToClient(rect.m_l, rect.m_t, x, y);
            win->windowMoved(rect.m_l, rect.m_t);
			
            break;
        }
        case GHOST_kEventWindowUpdate:
        {
            win->draw();
			window->swapBuffers();
            break;
        }
        case GHOST_kEventWindowActivate:
        {
            break;
        }
        case GHOST_kEventWindowDeactivate:
        {
            break;
        }
        case GHOST_kEventWindowClose:
        {
            deleteFenster(win);
            break;
        }
		//drag and drop
		case GHOST_kEventDraggingEntered:
		{
			GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData();
			//needs to be handled, but of doesn't really provide anything out of the box
			break;
		}
		case GHOST_kEventDraggingUpdated:
		{
			GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData();
			//needs to be handled, but of doesn't really provide anything out of the box
			break;
		}
		case GHOST_kEventDraggingExited:
		{
			GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData();
			//needs to be handled, but of doesn't really provide anything out of the box
			break;
		}
		case GHOST_kEventDraggingDropDone:
		{
			GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData();
			if(dragnDropData->dataType == GHOST_kDragnDropTypeFilenames){//TODO: STRING AND BITMAP IS ALSO SUPPORTED IN GHOST
				static ofDragInfo info;
				GHOST_TStringArray *strArray = (GHOST_TStringArray*)dragnDropData->data;
				for (int i=0;i<strArray->count;i++){
					const char* filename = (char*)strArray->strings[i];
					info.files.push_back(filename);
				}
				info.position.set(dragnDropData->x, dragnDropData->y); //TODO check if drag'n'drop position is actually correct
				win->fileDropped(info);
			}
			break;
		}
	}
	return handled;
}
예제 #15
0
GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->getCursorShape();
}
예제 #16
0
int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return (int) window->getCursorVisibility();
}
예제 #17
0
GHOST_TUns16 GHOST_GetNumOfAASamples(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->getNumOfAASamples();
}
예제 #18
0
void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	window->setAcceptDragOperation(canAccept);
}
예제 #19
0
void GHOST_EndIME(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
	window->endIME();
}
예제 #20
0
GHOST_TDrawingContextType GHOST_GetDrawingContextType(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->getDrawingContextType();
}
예제 #21
0
bool GPG_Application::processEvent(GHOST_IEvent* event)
{
	bool handled = true;

	switch (event->getType())
	{
		case GHOST_kEventUnknown:
			break;

		case GHOST_kEventButtonDown:
			handled = handleButton(event, true);
			break;

		case GHOST_kEventButtonUp:
			handled = handleButton(event, false);
			break;
			
		case GHOST_kEventWheel:
			handled = handleWheel(event);
			break;

		case GHOST_kEventCursorMove:
			handled = handleCursorMove(event);
			break;

		case GHOST_kEventKeyDown:
			handleKey(event, true);
			break;

		case GHOST_kEventKeyUp:
			handleKey(event, false);
			break;


		case GHOST_kEventWindowClose:
		case GHOST_kEventQuit:
			m_exitRequested = KX_EXIT_REQUEST_OUTSIDE;
			break;

		case GHOST_kEventWindowActivate:
			handled = false;
			break;
		case GHOST_kEventWindowDeactivate:
			handled = false;
			break;

		// The player now runs as often as it can (repsecting vsync and fixedtime).
		// This allows the player to break 100fps, but this code is being left here
		// as reference. (see EngineNextFrame)
		//case GHOST_kEventWindowUpdate:
		//	{
		//		GHOST_IWindow* window = event->getWindow();
		//		if (!m_system->validWindow(window)) break;
		//		// Update the state of the game engine
		//		if (m_kxsystem && !m_exitRequested)
		//		{
		//			// Proceed to next frame
		//			window->activateDrawingContext();

		//			// first check if we want to exit
		//			m_exitRequested = m_ketsjiengine->GetExitCode();
		//
		//			// kick the engine
		//			bool renderFrame = m_ketsjiengine->NextFrame();
		//			if (renderFrame)
		//			{
		//				// render the frame
		//				m_ketsjiengine->Render();
		//			}
		//		}
		//		m_exitString = m_ketsjiengine->GetExitString();
		//	}
		//	break;
		//
		case GHOST_kEventWindowSize:
			{
			GHOST_IWindow* window = event->getWindow();
			if (!m_system->validWindow(window)) break;
			if (m_canvas) {
				GHOST_Rect bnds;
				window->getClientBounds(bnds);
				m_canvas->Resize(bnds.getWidth(), bnds.getHeight());
				m_ketsjiengine->Resize();
			}
			}
			break;
		
		default:
			handled = false;
			break;
	}
	return handled;
}
예제 #22
0
GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->getState();
}
예제 #23
0
GHOST_TUserDataPtr GHOST_GetWindowUserData(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->getUserData();
}
예제 #24
0
GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->swapBuffers();
}
예제 #25
0
void GHOST_SetWindowUserData(GHOST_WindowHandle windowhandle, GHOST_TUserDataPtr userdata)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	window->setUserData(userdata);
}
예제 #26
0
int GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->getSwapInterval();
}
예제 #27
0
GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle, float progress)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->setProgressBar(progress);
}
예제 #28
0
GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->invalidate();
}
예제 #29
0
GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle)
{
	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

	return window->endProgressBar();
}