Example #1
0
bool GLPresenter::run()
{
	if(!running) {
		return false;
	}
	if(frameIndex > drawnFrameIndex) {
		glBindTexture(GL_TEXTURE_2D, texId);
		drawnFrameIndex = frameIndex;
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, reqW/2, reqH, GL_ABGR_EXT, GL_UNSIGNED_BYTE, dataPointers[drawnFrameIndex%2]);
		NONRELEASE( RT_GL_ASSERT("Error uploading frame data.") );

		// convert UYVY
		buffer->makeCurrent();
		convertUYVY->use();
		glutil::drawQuad();
		convertUYVY->stopUsing();
		buffer->releaseCurrent();
		// apply AA
		aaManager->applyAA(buffer, buffer2);
		// apply IP
		ipManager->applyIP(buffer2, buffer);	
		display();
	}
	glfwPollEvents();
	if(clock()>cursorTimeout) {
		if(GetFocus() == hwnd) glfwDisable(GLFW_MOUSE_CURSOR);
	} else {
		glfwEnable(GLFW_MOUSE_CURSOR);
	}
	return true;
}
Example #2
0
bool init()
{

    glfwInit();
    
    renderer->init("Pyzzlix", 1280, 720, false);

    glfwDisable(GLFW_AUTO_POLL_EVENTS);
    glfwSetKeyCallback(&keyCallback);

    KeyMap* keymap = KeyMap::getInstance();

    keymap->setKey(GLFW_KEY_RIGHT, KEY_RIGHT);
    keymap->setKey(GLFW_KEY_LEFT, KEY_LEFT);
    keymap->setKey(GLFW_KEY_DOWN, KEY_DOWN);
    keymap->setKey(GLFW_KEY_UP, KEY_UP);
    keymap->setKey('X', KEY_ROTATE_RIGHT);
    keymap->setKey('Z', KEY_ROTATE_LEFT);
    
    sceneHandler->pushScene(scene_maingame);
    
    scene_maingame->startGame();
    
    return true;
}
Example #3
0
component_h add_input_handler_component(
    game_context_s *context,
    component_h parent)
{
    context = game_add_component(context, parent, release_component);

    component_subscribe(context, tick);

    input_handler_s *input_handler = malloc(sizeof(input_handler_s));
    game_set_component_data(context, input_handler);

    for(int i = 0; i < MAX_JOYSTICKS; i++)
    {
        input_handler->joysticks[i].joystick = i + 1;
        input_handler->joysticks[i].axes = array_new();
        input_handler->joysticks[i].buttons = array_new();
    }

    // only get input events when we explicitly ask with glfwPollEvents()
    glfwDisable(GLFW_AUTO_POLL_EVENTS);

    // set the callbacks. actually the callbacks might be called on setting
    // right now, particularly the window size one.
    target_context = context;
    glfwSetKeyCallback(key_callback);
    glfwSetWindowSizeCallback(window_size_callback);
    glfwSetWindowCloseCallback(window_close_callback);
    target_context = NULL;

    return game_get_self(context);
}
Example #4
0
GLPresenter::GLPresenter(DeckLinkCapture &capture, int w, int h, int hz) : 
	data_size(w*h*2),
	capture(capture), running(true), fullscreen(false), useVsync(false), rgbFull(false),
	texId(0), displayList(0), 
	convertUYVY(NULL),
	buffer(NULL), buffer2(NULL),
	reqW(w), reqH(h), reqHz(hz), 
	frameIndex(0), drawnFrameIndex(0), aspect(16.0/9.0), oneToNScaleFactor(-1.0)
{
	self = this;

	sprintf(prepend, "#define FRAME_WIDTH %d\n#define FRAME_HEIGHT %d\n", reqW, reqH);

	RT_ASSERT(glfwInit() == GL_TRUE, "Failed to initalize GLFW.");
	RT_ASSERT(glfwOpenWindow(w, h, 0, 0, 0, 0, 0, 0, GLFW_WINDOW) == GL_TRUE, "Failed to open GLFW window.");

	string title("PtBi ");
	title += VER_STRING;
	glfwSetWindowTitle(title.c_str());
	glfwSetWindowPos(10, 10);

	dataPointers[0] = malloc(data_size);
	dataPointers[1] = malloc(data_size);

	glewInit();
	checkExtensions();

	ilInit();

	glfwDisable(GLFW_AUTO_POLL_EVENTS);
	glfwSwapInterval(0);
	glfwSetWindowCloseCallback(closeCallback);
	glfwSetWindowSizeCallback(resizeCallback);
	glfwSetMousePosCallback(mousePosCallback);
	glfwSetKeyCallback(keyCallback);

	hdc = wglGetCurrentDC();
	hrc = wglGetCurrentContext();

	initGL();

	convertUYVY = new GLFragmentProgram("shaders/uyvy_to_rgb_smooth.glsl", getShaderPrependString());

	buffer = new GLRenderTexture(getW(), getH(), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE);
	buffer->setFilterMode(GL_LINEAR);
	buffer2 = new GLRenderTexture(getW(), getH(), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE);
	buffer2->setFilterMode(GL_LINEAR);

	scalingManager = new ScalingManager(*this);
	aaManager = new AAManager(*this);
	ipManager = new IPManager(*this);
	keyBinding = new KeyBinding(this);
	capture.registerDisplayListener(this);

	hwnd = GetForegroundWindow();

	RT_GL_ASSERT("Error during GL initialization.");

	reshape(reqW, reqH);
}
Example #5
0
void View::initWindow(){

	glfwInit();  // init GLFW and open an OpenGL Window
	glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE); // disable resize
	glfwOpenWindow(windowWidth, windowHeight, 8, 8, 8, 8, 24, 0, GLFW_WINDOW);
	
	glfwSetWindowTitle("PolyFun");
	
	// init viewport to canvassize
    glViewport( 0, 0, windowWidth, windowHeight);
    
	// projection matrix with clipping planes in three directions (same as window size and +- 1 in z)
	glMatrixMode( GL_PROJECTION);
    glLoadIdentity();
	glOrtho( 0, windowWidth, windowHeight, 0, -1, 1);

	// modelview transform (identity)
	glMatrixMode( GL_MODELVIEW);
	glLoadIdentity();
	
	// enable blending for soft lines
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
	
	glClearColor(1.0, 1.0, 1.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	// display buttons and canvas
	displayBase();
	glfwDisable(GLFW_AUTO_POLL_EVENTS);
	glfwSwapBuffers();
}
void init(void)
{
	//Smooth shading
	glShadeModel(GL_SMOOTH);

	//Activa o teste de profundidade
	glEnable(GL_DEPTH_TEST);

	//Define shading e correção de perspetiva de alta qualidade
	glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	//Estas linhas impediam o openGL de desenhar as back faces, mas
	//não pode ficar por causa de problemas com a skybox que já não temos tempo de resolver
	//(quads desenhados ao contrário)
	/*glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);*/

	//Antialising das linhas das órbitas
	glEnable(GL_MULTISAMPLE_ARB);
	glEnable(GL_LINE_SMOOTH);
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glfwDisable(GLFW_MOUSE_CURSOR);   // Hide the mouse cursor
	glfwSwapInterval(0);              // Disable vsync

	glClearColor(0.0, 0.0, 0.0, 0.0);
	glPolygonMode(GL_FRONT, GL_FILL); // GL_LINE, GL_POINT, GL_FILL
}
Example #7
0
void GLFWApp::SetCursorVisible(bool b)
{
	if (!b)
		glfwDisable(GLFW_MOUSE_CURSOR);
	else
		glfwEnable(GLFW_MOUSE_CURSOR);
}
Example #8
0
void Input::mouseVisible(bool visible)
{
    if (visible)
    {
#ifdef __APPLE__
    	CGAssociateMouseAndMouseCursorPosition(TRUE);
	    CGDisplayShowCursor(kCGDirectMainDisplay);
#else
        glfwEnable(GLFW_MOUSE_CURSOR);
        glfwSetMousePos(m_mouseMiddleX, m_mouseMiddleY);
#endif
    }
    else
    {
#ifdef __APPLE__
	    glfwSetMousePos(m_mouseMiddleX, m_mouseMiddleY);
        CGDisplayHideCursor(kCGDirectMainDisplay);
	    CGPoint p;
	    p.x = m_mouseMiddleX;
	    p.y = m_mouseMiddleY;
	    //CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, p);
	    CGWarpMouseCursorPosition(p);
	    CGAssociateMouseAndMouseCursorPosition(FALSE);
#else
        glfwDisable(GLFW_MOUSE_CURSOR);
        glfwSetMousePos(m_mouseMiddleX, m_mouseMiddleY);
#endif
    }
    m_mouseVisible = visible;
}
Example #9
0
void InputManager::SetMouseCursorVisibility(bool Visible)
{
	static int MouseCursorDesktopPositionX, MouseCursorDesktopPositionY;

	// Hide Mouse Cursor
	if (!Visible && m_MouseCursorVisible)
	{
		glfwPollEvents();
		m_MouseIgnorePositionAlways = true;
		glfwGetMousePos(&MouseCursorDesktopPositionX, &MouseCursorDesktopPositionY);
		glfwDisable(GLFW_MOUSE_CURSOR);
		m_MouseIgnorePositionOnce = true;
		m_MouseIgnorePositionAlways = false;

		m_MouseCursorVisible = false;
	}
	// Show Mouse Cursor
	else if (Visible && !m_MouseCursorVisible)
	{
		m_MouseIgnorePositionAlways = true;
		glfwEnable(GLFW_MOUSE_CURSOR);
		glfwSetMousePos(MouseCursorDesktopPositionX, MouseCursorDesktopPositionY);
		m_MouseIgnorePositionOnce = true;
		m_MouseIgnorePositionAlways = false;

		m_MouseCursorVisible = true;

		// Create a mouse position event
		//ProcessMousePos(m_MousePositionX, m_MousePositionY);
	}
}
void ofAppGLFWWindow::hideCursor(){
//	#ifdef TARGET_OSX
//		CGDisplayHideCursor(kCGDirectMainDisplay);
//	#else
		glfwDisable( GLFW_MOUSE_CURSOR );
//	#endif
};
Example #11
0
void CGraphicsModule::setCursorVisible( bool visible ) {
    if ( visible ) {
        glfwEnable( GLFW_MOUSE_CURSOR );
    } else {
        glfwDisable( GLFW_MOUSE_CURSOR );
    }
}
Example #12
0
	void Mouse::ShowCustomCursor(bool enable)
	{
		instance->enableCustomMouseCursor = enable;
		if(enable == true)
		{
			glfwDisable(GLFW_MOUSE_CURSOR);
		}
	}
Example #13
0
SGenum SG_EXPORT sgmCoreMouseHide(void* mouse)
{
    if(mouse == NULL)
        return SG_OK; // SG_INVALID_VALUE

    glfwDisable(GLFW_MOUSE_CURSOR);
    return SG_OK;
}
Example #14
0
bool Application::InitialseWindow(unsigned int a_uiWindowWidth, unsigned int a_uiWindowHeight, bool a_bFullScreen /*= false*/)
{
	m_uiWindowWidth		= a_uiWindowWidth;
	m_uiWinidowHeight	= a_uiWindowHeight;
	m_bFullScreen		= a_bFullScreen;

	if(!glfwInit())
	{
		return false;
	}

	// this creates the window to the size that was passed in and checks if full screen or not 
	glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE,GL_TRUE);
	glfwOpenWindow(m_uiWindowWidth, m_uiWinidowHeight, 8,8,8,8, 24, 8,(m_bFullScreen) ? GLFW_FULLSCREEN:GLFW_WINDOW);

	glfwDisable(GLFW_AUTO_POLL_EVENTS);

	glfwSetWindowTitle("Application");

	// enable / disable vSync
	EnableVSync(m_bVSyncEnabled);

	glewExperimental = true;
	if(glewInit() != GLEW_OK)
	{
		glfwTerminate();
		return false;
	}

	// Setup OpenGL error callbacks if supported
	if (glewIsSupported("GL_ARB_debug_output"))
	{
		glDebugMessageCallbackARB(glErrorCallback, nullptr);
		glEnable(GL_DEBUG_OUTPUT);
	}
	else
	{
		printf("OpenGL error callbacks are not supported");
	}

	const char* fontName = "./arial.png";
	const char* xmlName = "./arial.xml";

	m_texture = new CTexture();
	m_spriteBatch = new CSpritebatch(m_uiWindowWidth, m_uiWinidowHeight);
	m_spriteBatch->Begin();

	// sets the colour for the screen
	glClearColor(0.2f, 0.2f, 0.2f, 1.0f);

	//Enable some Blending.
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
	glDisable(GL_CULL_FACE);

	return true;
}
Example #15
0
int main()
{
    // Initialize GLFW
    glfwInit();
    if( !setupWindow( appWidth, appHeight, fullScreen ) ) return -1;

    // Initalize application and engine
    app = new Application();
    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 );

    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 );
        glfwSwapBuffers();
    }

    glfwEnable( GLFW_MOUSE_CURSOR );

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

    return 0;
}
Example #16
0
void GameOver( void )
{
    // Enable sticky keys
    glfwEnable( GLFW_STICKY_KEYS );

    // Until the user presses ESC or SPACE
    while( !glfwGetKey( GLFW_KEY_ESC ) && !glfwGetKey( ' ' ) &&
           glfwGetWindowParam( GLFW_OPENED ) )
    {
        // Draw display
        UpdateDisplay();

        // Setup projection matrix
        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        glOrtho( 0.0f, 1.0f, 1.0f, 0.0f, -1.0f, 1.0f );

        // Setup modelview matrix
        glMatrixMode( GL_MODELVIEW );
        glLoadIdentity();

        // Enable blending
        glEnable( GL_BLEND );

        // Dim background
        glBlendFunc( GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA );
        glColor4f( 0.3f, 0.3f, 0.3f, 0.3f );
        glBegin( GL_QUADS );
          glVertex2f( 0.0f, 0.0f );
          glVertex2f( 1.0f, 0.0f );
          glVertex2f( 1.0f, 1.0f );
          glVertex2f( 0.0f, 1.0f );
        glEnd();

        // Display winner text
        glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_COLOR );
        if( winner == PLAYER1 )
        {
            glColor4f( 1.0f, 0.5f, 0.5f, 1.0f );
            DrawImage( TEX_WINNER1, 0.35f, 0.65f, 0.46f, 0.54f );
        }
        else if( winner == PLAYER2 )
        {
            glColor4f( 0.5f, 1.0f, 0.5f, 1.0f );
            DrawImage( TEX_WINNER2, 0.35f, 0.65f, 0.46f, 0.54f );
        }

        // Disable blending
        glDisable( GL_BLEND );

        // Swap buffers
        glfwSwapBuffers();
    }

    // Disable sticky keys
    glfwDisable( GLFW_STICKY_KEYS );
}
Example #17
0
static void toggle_mouse_cursor(void)
{
    if (cursor_enabled)
        glfwDisable(GLFW_MOUSE_CURSOR);
    else
        glfwEnable(GLFW_MOUSE_CURSOR);

    cursor_enabled = !cursor_enabled;
}
void CApplication::SetMouseCursorEnabled(bool bEnabled)
{
	if (bEnabled)
		glfwEnable(GLFW_MOUSE_CURSOR);
	else
		glfwDisable(GLFW_MOUSE_CURSOR);

	m_bMouseEnabled = bEnabled;
}
Example #19
0
void AppMain() {
    if(!glfwInit())
        throw std::runtime_error("glfwInit failed");
    
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
    glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_FALSE);
    
    if(!glfwOpenWindow(SCREEN_SIZE.x, SCREEN_SIZE.y, 8, 8, 8, 8, 0, 0, GLFW_WINDOW))
        throw std::runtime_error("glfwOpenWindow failed. Can your hardware handle OpenGL 3.2?");
    
    glewExperimental = GL_TRUE; //stops glew crashing on OSX :-/
    if(glewInit() != GLEW_OK)
        throw std::runtime_error("glewInit failed");
    
    
    std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
    std::cout << "GLSL version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
    std::cout << "Vendor: " << glGetString(GL_VENDOR) << std::endl;
    std::cout << "Renderer: " << glGetString(GL_RENDERER) << std::endl;
    
    if(!GLEW_VERSION_3_2)
        throw std::runtime_error("OpenGL 3.2 API is not available.");
    
    glfwDisable(GLFW_MOUSE_CURSOR);
    glfwSetMousePos(0,0);
    glfwSetMouseWheel(0);
    
    LoadShaders();
    LoadTriangle();
    
    //intialise the Camera position
    gCamera.setPosition(glm::vec3(0,0,4));
    gCamera.setViewportAspectRatio(SCREEN_SIZE.x / SCREEN_SIZE.y);
    gCamera.setNearAndFarPlanes(0.5, 100.0f);
    Axis = glm::vec3(0,1,0);
    
    //intialise the Light attribute
    gLight.position = glm::vec3(0.0f,0.1f,-0.1f);
    gLight.intensities = glm::vec3(0.8,0.78,1); // white light
    gLight.attenuation = 0.2f;
    gLight.ambientCoefficient = 0.005f;
    
    double lastTime = glfwGetTime();
    while(glfwGetWindowParam(GLFW_OPENED)){
        
        double thisTime = glfwGetTime();
        Update(thisTime - lastTime);
        lastTime  = thisTime;
        Render();
        
    }
    
    glfwTerminate();
}
Example #20
0
/////////////////////////////////////////////////////////
// cursorMess
//
/////////////////////////////////////////////////////////
void gemglfw2window :: cursorMess(bool setting)
{
  m_cursor=setting;
  if(makeCurrent()) {
    if(m_cursor)
      glfwEnable(GLFW_MOUSE_CURSOR);
    else
      glfwDisable(GLFW_MOUSE_CURSOR);
  }
}
Example #21
0
static void GLFWCALL key_callback(int key, int action)
{
    const char* name = get_key_name(key);

    printf("%08x at %0.3f: Key 0x%04x", counter++, glfwGetTime(), key);

    if (name)
        printf(" (%s) was %s\n", name, get_action_name(action));
    else if (isgraph(key))
        printf(" (%c) was %s\n", key, get_action_name(action));
    else
        printf(" was %s\n", get_action_name(action));

    if (action != GLFW_PRESS)
        return;

    switch (key)
    {
        case 'R':
        {
            keyrepeat = !keyrepeat;
            if (keyrepeat)
                glfwEnable(GLFW_KEY_REPEAT);
            else
                glfwDisable(GLFW_KEY_REPEAT);

            printf("(( key repeat %s ))\n", keyrepeat ? "enabled" : "disabled");
            break;
        }

        case 'S':
        {
            systemkeys = !systemkeys;
            if( systemkeys )
                glfwEnable(GLFW_SYSTEM_KEYS);
            else
                glfwDisable(GLFW_SYSTEM_KEYS);

            printf("(( system keys %s ))\n", systemkeys ? "enabled" : "disabled");
            break;
        }
    }
}
Example #22
0
void InitWindow(int _width, int _height)
{
	glfwInit();
	glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 0);
	glfwOpenWindow(_width, _height, /* rgba */ 0,0,0,8, /* depth, stencil, mode */ 32,1, GLFW_WINDOW);
	glewInit();

	// The window title will be overridden less than a second from startup anyways.
	glfwSetWindowTitle("RStation");
	glfwDisable(GLFW_AUTO_POLL_EVENTS);
	glfwDisable(GLFW_MOUSE_CURSOR);

	int vsync = atoi(ini->getValue("Preferences","VSync").c_str());
	vsync = vsync ? 1 : 0;
	glfwSwapInterval(vsync); // vsync

	glfwSetWindowSizeCallback(ResizeViewport);
	RegisterKeyboardCallbacks();
}
Example #23
0
void GameControl::CaptureKeys(bool Capture) {
    if (Capture) {
        glfwEnable(GLFW_STICKY_KEYS);
        glfwSetKeyCallback(KeyHandle);
    }
    else {
        glfwDisable(GLFW_STICKY_KEYS);
        glfwSetKeyCallback(NULL);
    }
}
Example #24
0
File: kiss.c Project: kipr/libkiss
DWORD WINAPI kiss_main_thread( LPVOID lpParam )
#endif
{
	glfwInit();

	kiss_g_glfw_mutex = glfwCreateMutex();
	kiss_g_key_mutex = glfwCreateMutex();
	kiss_g_mouse_mutex = glfwCreateMutex();

	if(!kiss_g_glfw_mutex) {
		kiss_g_glfw_initting = 0;
		glfwTerminate();
		return 0;
	}

	glfwDisable(GLFW_AUTO_POLL_EVENTS);

	kiss_g_glfw_enabled = 1;
	kiss_g_glfw_initting = 0;

	while(!kiss_g_glfw_quit) {
		if(kiss_g_op) {
			switch(kiss_g_op) {
				case KISS_OPEN_WINDOW:
					kiss_graphics_open_window(kiss_g_op_arg1, kiss_g_op_arg2);
					glfwSetKeyCallback(kiss_input_callback);
					kiss_g_graphics_enabled=1;
					break;
				case KISS_CLOSE_WINDOW:
					kiss_graphics_close_window();
					kiss_g_graphics_enabled=0;
					break;
				case KISS_COPY:
					if(!kiss_g_graphics_enabled)
						break;
					kiss_graphics_update();
					glfwSwapBuffers();
					break;
			}
			kiss_g_op = 0;
		}
		if(kiss_g_graphics_enabled)
			glfwPollEvents();
	}

	if(kiss_g_graphics_enabled)
		kiss_graphics_close_window();

	glfwTerminate();

	kiss_g_glfw_enabled = 0;
	kiss_g_glfw_quit = 0;

	return 0;
}
Example #25
0
	void OpenGL::Fog(bool enableFog)
	{
		if(enableFog == true)
		{
			glfwEnable(GL_FOG);
		}
		else
		{
			glfwDisable(GL_FOG);
		}
	}
Example #26
0
void inpHideCursor(int hidecursor)
{
	if(hidecursor)
	{
		glfwDisable(GLFW_MOUSE_CURSOR);
	}
	else
	{
		glfwEnable(GLFW_MOUSE_CURSOR);
	}
}
Example #27
0
bool IGame::Init(int w, int h, std::string title)
{
	if (!glfwInit())
	{
		log(LOG_TYPE_ERROR, "Failed to initialize GLFW!");
		return false;
	}

	// Set our initialization parameters
	//glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
	//glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 1);
	//glfwOpenWindowHint(GLFW_OPENGL_PROFILE, 0);

	m_WindowWidth = w;
	m_WindowHeight = h;
	
	if (!glfwOpenWindow(m_WindowWidth, m_WindowHeight, 0, 0, 0, 0, 24, 0, GLFW_WINDOW))
	{
		log(LOG_TYPE_ERROR, "Failed to create window!");
		glfwTerminate();
		return false;
	}

	if (glewInit() != GLEW_OK)
	{
		log(LOG_TYPE_ERROR, "Failed to initialize GLEW!");
		return false;
	}

	glfwSetWindowTitle(title.c_str());
	glfwDisable(GLFW_MOUSE_CURSOR);

	// Clear log.txt
	std::ofstream logFile("log.txt");
	logFile << " " << std::endl;
	logFile.close();

	log(LOG_TYPE_DEFAULT, "OpenGL successfully initialized..");
		
	DetectHardware();

	m_LuaInterface = new ILuaInterface();
	m_SceneManager = new ISceneManager();
	m_RenderSystem = new IRenderSystem();
	m_InputSystem = new IInputSystem();
	m_ContentSystem = new IContentSystem();

	//temp
	//m_LuaInterface->LoadScript("lua/lib/kopengi.lua");

	m_bRun = true;

	return true;
}
Example #28
0
	void Mouse::ShowWindowsCursor(bool enable)
	{
		if(enable == true)
		{
			instance->enableCustomMouseCursor = false;
			glfwEnable(GLFW_MOUSE_CURSOR);
		}
		else
		{
			glfwDisable(GLFW_MOUSE_CURSOR);
		}
	}
Example #29
0
static void GLFWCALL keyboardInput(int key, int state)
{
	if (key == GLFW_KEY_RCTRL && state == GLFW_PRESS)
	{
		mouselocked = !mouselocked;
		if (mouselocked)
			glfwDisable(GLFW_MOUSE_CURSOR);
		else
			glfwEnable(GLFW_MOUSE_CURSOR);
	}
	graphics.injectKeyboard(convertKey(key), state);
}
//----------------------------------------------------------------------------//
void GLFWCALL CEGuiGLFWSharedBase::glfwMousePosCallback(int x, int y)
{
    if (!d_mouseDisableCalled)
    {
        // if cursor didn't leave the window nothing changes
        d_sampleApp->injectMousePosition(static_cast<float>(x), static_cast<float>(y));
    }
    else
    {
        // if the cursor left the window, we need to use the saved position
        // because glfw beams the cursor to the middle of the window if 
        // the cursor is disabled
        d_sampleApp->injectMousePosition(static_cast<float>(d_oldMousePosX), static_cast<float>(d_oldMousePosY));
        glfwSetMousePos(d_oldMousePosX, d_oldMousePosY);
        d_mouseDisableCalled = false;
    }

#ifndef DEBUG
    if (x < 0 || y < 0
        || x > d_newWindowWidth
        || y > d_newWindowHeight)
    {
        // show cursor
        glfwEnable(GLFW_MOUSE_CURSOR);

        // move the cursor to the position where it left the window
        glfwSetMousePos(x, y);
        
        // "note down" that the cursor left the window
        d_mouseLeftWindow = true;
    }
    else
    {
        if (d_mouseLeftWindow)
        {
            // get cursor position to restore afterwards
            glfwGetMousePos(&d_oldMousePosX, &d_oldMousePosY);

            // we need to inject the previous cursor position because
            // glfw moves the cursor to the centre of the render 
            // window if it gets disabled. therefore notify the 
            // next MousePosCallback invocation of the "mouse disabled" event.
            d_mouseDisableCalled = true;

            // disable cursor
            glfwDisable(GLFW_MOUSE_CURSOR);

            // "note down" that the cursor is back in the render window
            d_mouseLeftWindow = false;
        }
    }
#endif
}