Ejemplo n.º 1
0
void Init()
{
    InitializeGL(SCREEN_WIDTH, SCREEN_HEIGHT);    // Init OpenGL with the global rect

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
    
    // Here is where we define our triangle.  Remember it is important which
    // direction you define the vertices.  This is important because it allows
    // us to know which side the normal will be on when we calculate the triangle's
    // normal.  Though clockwise is more natural to me to use, more people use
    // counter-clockwise.  Also, if you enable back face culling in OpenGL, the
    // default is counter-clockwise (GL_CCW).  We start with the bottom-left
    // vertices, then the bottom-right and finally, the top vertex.
    g_vTriangle[0] = CVector3(-1,  0,   0);
    g_vTriangle[1] = CVector3( 1,  0,   0);
    g_vTriangle[2] = CVector3( 0,  1,   0);

    // We need an initial position for the sphere's center, so we place it
    // right in the middle of the triangle, initially colliding with it.
    g_vPosition = CVector3(0, 0.5f, 0);

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *


    // Enable Key Repeat
    if( SDL_EnableKeyRepeat(100,SDL_DEFAULT_REPEAT_INTERVAL) )
    {
        cerr << "Failed enabling key repeat" << endl;
        Quit(1);
    }
}
Ejemplo n.º 2
0
bool GameWindow::Initialize() {
	InitializeSDL();
	InitializeGL();
	InitializeShaderContext(); // In Shader.cpp

    audioManager->Initialize();
	gameModeManager->Initialize();

	//audioManager->Play("music/grinch.wav", AUDIO_LOCAL);

	return true;
}
Ejemplo n.º 3
0
int main(int argc, char**argv){
	//Load data and Initialize.
	loaddata(&model);
	loadfile(&deta);
	InitDispParam(&model, &disp);
	InitializeGL(argc, argv);

	glutMainLoop();
	free(mesh);


	return 0;
}
Ejemplo n.º 4
0
/**
 * @brief Updates the x- and y-coordinates on the OpenGL context with
 * the first two values in the glPoint array
 *
 * Updates the x- and y-coordinates on the OpenGL context with
 * the first two values in the glPoint array.
 *
 */
void ClickTool::UpdateGL()
{
	if (!glLoaded)
		InitializeGL();

	if (glLoaded)
	{
		if (VBOId)
		{
			glBindBuffer(GL_ARRAY_BUFFER, VBOId);
			glBufferSubData(GL_ARRAY_BUFFER, 0, 2*sizeof(GLfloat), &glPoint[0]);
		}
	}
}
Ejemplo n.º 5
0
    Screen::Screen(SORE_Graphics::ScreenInfo& _screen,
        const std::string& windowTitle_, const std::string& iconFilename,
        SORE_Utility::SettingsManager* _sm)
        : windowTitle(windowTitle_), screen(_screen), sm(_sm)
    {
        ENGINE_LOG(SORE_Logging::LVL_INFO, "Creating screen");

        if(sm!=NULL)
        {
            screen.width =
                sm->WatchVariable
                ("screen", "width",
                 boost::bind(std::mem_fun(&Screen::ChangeScreenOnSettingsChange),
                             this));
            screen.height =
                sm->WatchVariable
                ("screen", "height",
                 boost::bind(std::mem_fun(&Screen::ChangeScreenOnSettingsChange),
                             this));
            screen.fullscreen =
                sm->WatchVariable
                ("screen", "fullscreen",
                 boost::bind(std::mem_fun(&Screen::ChangeScreenOnSettingsChange),
                             this));
            screen.resizable  =
                sm->WatchVariable
                ("screen", "resizable",
                 boost::bind(std::mem_fun(&Screen::ChangeScreenOnSettingsChange),
                             this));
            screen.showCursor =
                sm->WatchVariable
                ("screen", "showcursor",
                 boost::bind(std::mem_fun(&Screen::ChangeScreenOnSettingsChange),
                             this));
            screen.useNativeResolution  =
                sm->WatchVariable
                ("screen", "native",
                 boost::bind(std::mem_fun(&Screen::ChangeScreenOnSettingsChange),
                             this));
        }

        CreateSFMLWindow();
        
        if(InitializeGL()!=0)
        {
            ENGINE_LOG(SORE_Logging::LVL_CRITICAL, "Could not initialize GL");
            quitFlag = true;
        }
    }
Ejemplo n.º 6
0
int main(int, char **){
    //Link the call backs
    canvas.SetMouseMove(MouseMove);
    canvas.SetMouseButton(MouseButton);
    canvas.SetKeyPress(KeyPress);
    canvas.SetOnPaint(OnPaint);
    canvas.SetTimer(0.05, OnTimer);
    //Show Window
    canvas.Initialize(width, height, "Rotating Square Demo");
    //Do our initialization
    InitializeGL();
    canvas.Show();

    return 0;
}
Ejemplo n.º 7
0
void Init()
{
    InitializeGL(SCREEN_WIDTH, SCREEN_HEIGHT);    // Init OpenGL with the global rect

    // Enable Key Repeat
    if( SDL_EnableKeyRepeat(100,SDL_DEFAULT_REPEAT_INTERVAL) )
    {
        cerr << "Failed enabling key repeat" << endl;
        Quit(1);
    }

    // *Hint* We will put all our game init stuff here
    // Some things include loading models, textures and network initialization
                         //Position      View          Up Vector
    g_Camera.PositionCamera(0, 0.5, 6,   0, 0.5, 0,   0, 1, 0 );    
}
Ejemplo n.º 8
0
void Quadtree::DrawOutlines()
{
	if (!glLoaded)
		InitializeGL();

	if (glLoaded)
	{
		glBindVertexArray(VAOId);
		if (outlineShader)
		{
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
			if (outlineShader->Use())
				glDrawElements(GL_LINES, 2*pointCount, GL_UNSIGNED_INT, (GLvoid*)0);
		}
		glBindVertexArray(0);
		glUseProgram(0);
	}
}
Ejemplo n.º 9
0
SquareRenderSurface::SquareRenderSurface(int tilesDimension)
{
	dimension = tilesDimension;
	numTiles = dimension*dimension;
	numNodes = numTiles*4;
	numElements = numTiles*2;

	nodes = new float[numNodes*6];
	elements = new int[numElements*3];

	positionSet = false;
	currX = 0.0;
	currY = 0.0;

	camera = 0;

	Initialize();
	InitializeGL();
}
Ejemplo n.º 10
0
  bool Initialize(const std::string& card) {
    std::unique_ptr<ged::DRMModesetter> drm = ged::DRMModesetter::Create(card);
    if (!drm) {
      fprintf(stderr, "failed to create DRMModesetter.\n");
      return false;
    }

    egl_ = ged::EGLDRMGlue::Create(
        std::move(drm),
        std::bind(&ES2Cube::DidSwapBuffer, this, std::placeholders::_1,
                  std::placeholders::_2));
    if (!egl_) {
      fprintf(stderr, "failed to create EGLDRMGlue.\n");
      return false;
    }

    display_size_ = egl_->GetDisplaySize();

    // Need to do the first mode setting before page flip.
    if (!InitializeGL())
      return false;
    return true;
  }
Ejemplo n.º 11
0
Demo01::Demo01() {
	isEntered = true;
	InitializeGL();
	APP.SetCursorVisible(false);
}
Ejemplo n.º 12
0
int WINAPI WinMain (HINSTANCE hInstance,
					HINSTANCE hPrevInstance,
					LPSTR lpCmdLine,
					int iCmdShow)
{
	CLogger::GetSingleton()->Enable(CONSOLE | TXT);
	sf::Window App;
	{
		sf::ContextSettings Settings;
		Settings.depthBits         = 24; // Request a 24 bits depth buffer
		//Settings.StencilBits       = 8;  // Request a 8 bits stencil buffer
		//Settings.AntialiasingLevel = 2;  // Request 2 levels of antialiasing
		Settings.majorVersion = 3; // OpenGL 3.2
		Settings.minorVersion = 2;															 
		App.create(sf::VideoMode(1280,800), "Sample_Simple", 7, Settings);

		CResManager::GetSingleton()->AddCatalogEntry("Ball", SLoadParams("Ball.obj"));
		CResManager::GetSingleton()->AddCatalogEntry("Ship", SLoadParams("ship.obj"));
		CResManager::GetSingleton()->AddCatalogEntry("Cube", SLoadParams("Cube.obj"));

		CResManager::GetSingleton()->AddCatalogEntry("texturing", SLoadParams("texturing"));
		glewInit();
	}

	InitializeGL();
	//CResManager::GetSingleton()->GetResource<CShader>("texturing")->Bind();

	float FrameTimer = 0.f;
	const float UpdateTime = 1.f/30.f;
	sf::Clock Clock;

	CShip* Player = new CShip;
	CEntityMgr Emgr;
	Emgr.AddObject(Player);

	for (int i = 0; i < 20; ++i)
		Emgr.AddObject(new CRock());

	while (App.isOpen())
	{
		// Process events
		sf::Event Event;
		while (App.pollEvent(Event))
		{
			switch (Event.type)
			{
			case sf::Event::MouseWheelMoved:
				//Game.MouseWheel(Event.MouseWheel.Delta);
				break;

			case sf::Event::MouseMoved:
				//CGUI::GetSingleton()->MouseMove (Event);
				//Game.MouseMove(Event);
				break;

			// Close window : exit
			case sf::Event::Closed:
				App.close();
				break;
			case sf::Event::KeyPressed:
				switch (Event.key.code)
				{
				case sf::Keyboard::Escape:
					App.close();
					break;
				case sf::Keyboard::Space:
					CBullet* Temp = new CBullet(Player);
					Emgr.AddObject(Temp);
					break;
				}
				
				//CGUI::GetSingleton()->KeyPress (Event);
				break;
			case sf::Event::TextEntered:
				//CGUI::GetSingleton()->TextEnter (Event);
				break;
			case sf::Event::MouseButtonReleased:
				//CGUI::GetSingleton()->MouseRelease (Event);
				break;
			case sf::Event::MouseButtonPressed:
				//CGUI::GetSingleton()->MousePress (Event);
				break;
			}
		}

		FrameTimer += Clock.getElapsedTime().asMilliseconds();
		Clock.restart();
		while (FrameTimer > UpdateTime)
		{
			FrameTimer -= UpdateTime;
			Emgr.Update();

			if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
				Player->Acc();
			if (sf::Keyboard::isKeyPressed(sf::Keyboard::A))
				Player->Turn(false);
			if (sf::Keyboard::isKeyPressed(sf::Keyboard::D))
				Player->Turn(true);
			if (sf::Keyboard::isKeyPressed(sf::Keyboard::S))
				Player->Dec();

			//Game.Steer(App.GetInput());
			//Game.Update ();
		}
		glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		//glEnable (GL_TEXTURE_2D);
		//CResManager::GetSingleton()->GetResource<CShader>("shader")->Bind();
		//Game.Draw();
		//CShader::DisableAll();

		//App.SaveGLStates();
		//CGUI::GetSingleton()->Draw();
//		CGUI::GetSingleton()->DrawDebug();
		//App.RestoreGLStates();

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		//gluPerspective(45, 1280./800., 0.01, 1000);
		glOrtho (-24, 24, -15, 15, -100, 100);

		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		/*CCamera::SphericalProjection(
			CVector3(0.f,0.f,0.f),
			0.f,
			CVector2<float>(0.5f, .5f),
			100.f);*/
		glTranslatef (0.f,0.f,+10.f);

		/*float MouseX, MouseY;
		const sf::Input& Input = App.GetInput();
		MouseX = ((float)(Input.GetMouseX()) / (float)(App.GetWidth()) - 0.5f) * 8.f;
		MouseY = ((float)(Input.GetMouseY()) / (float)(App.GetHeight()) - 0.5f) * 8.f;

		/*glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho (-10, 10, -10, 10, -100, 100);*

		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		CCamera::SphericalProjection(
			CVector3(0.f, 0.f, 0.f),
			0.f,
			CVector2<float>(MouseX, MouseY),
			5.f
			);*/
		
		/*glDisable(GL_TEXTURE_2D);
		glBegin(GL_QUADS);
		glVertex2f (-5, -5);
		glVertex2f (5, -5);
		glVertex2f (5, 5);
		glVertex2f (-5, 5);
		glEnd();*/

		//BallModel->Draw();
		Emgr.Draw();

		App.display();
		//sf::sleep(sf::Time::Time(0));
	}
	// Wersja ze skryptami : u¿ycie CGameObject i tworzenie w³asnych typów w Lua
	// Wersja bez skryptów : dziedziczenie w³asnych typów po CGameObject

	/*CGame::GetSingleton()->Init(lpCmdLine);
	CGame::GetSingleton()->Go();
	CGame::GetSingleton()->Destroy();*/
	return 0;
}
Ejemplo n.º 13
0
bool App::InitApp (void)
{
#ifdef CONFDIR
    strcpy (settings_path, (std::string (CONFDIR) + PATH_SEPARATOR + "test3d.ini").c_str());
#else
    strcpy (settings_path, (std::string (SDL_GetBasePath ()) + "settings.ini").c_str());
#endif

    int w, h;

    // initialize SDL with screen sizes from settings file:
    w = LoadSetting (settings_path, SCREENWIDTH_SETTING);
    if (w < 640)
        w = 640;

    h = LoadSetting (settings_path, SCREENHEIGHT_SETTING);
    if (h < 480)
        h = 480;

    fullscreen = LoadSetting (settings_path, FULLSCREEN_SETTING) > 0 ? true : false;

    // Create a window:
    if (!InitializeSDL(w, h))
        return false;

    // Create a rendering context in the window:
    if (!InitializeGL())
        return false;

    pScene = new HubScene (this);

    RandomSeed ();

    Progress progress;
    Loader loader;

    // Collect jobs to be done:
    pScene->AddAll (&loader);

    // Progress bar is rendered in a different thread while the scene loads:
    bool error = false;
    SDL_Thread* progressThread = MakeSDLThread (
                                    [&] () { return ProgressLoop (mainWindow, &progress, error); },
                                    "progress"
                                 );
    if (!progressThread)
    {
        SetError ("failed to create progress thread: %s", SDL_GetError());
        return false;
    }

    /*
        Do all jobs while the progress bar is rendered.
        Some of them depend on the current thread's rendering context.
     */
    if (!loader.LoadAll (&progress))
    {
        error = true;
        SDL_DetachThread (progressThread);
        return false;
    }

    // progressThread will finish automatically, now that everything is loaded ..

    // Check for other errors:
    if (!CheckGLOK ("scene init"))
        return false;

    // Wait for progress display thread to finish:
    int progressReturn;
    SDL_WaitThread (progressThread, &progressReturn);
    if (progressReturn != 0)
    {
        SetError ("progress thread returned exit code %d", progressReturn);
        return false;
    }

    return true;
}
Ejemplo n.º 14
0
/**
 * @brief Function called when the user wants to use to tool
 *
 * Function called when the user wants to use to tool. Initializes the
 * OpenGL context if it has not already done so.
 *
 */
void ClickTool::UseTool()
{
	if (!glLoaded)
		InitializeGL();
	emit Instructions(QString("Click on any Element to select/deselect it"));
}
Ejemplo n.º 15
0
/**
 * @brief Loads the currently selected Element data to the GPU
 *
 * Loads the currently selected Element data to the GPU, getting rid of any element
 * data that is already there.
 *
 */
void CreationSelectionLayer::LoadDataToGPU()
{
	/* Make sure we've got all of the necessary Buffer Objects created */
	if (!glLoaded)
		InitializeGL();

	/* Make sure initialization succeeded */
	if (glLoaded && selectedState)
	{
		/* Load the connectivity data (elements) to the GPU, getting rid of any data that's already there */
		std::vector<Element*> *currSelection = selectedState->GetState();
		const size_t IndexBufferSize = 3*sizeof(GLuint)*currSelection->size() + sizeof(GLuint)*boundaryNodes.size();
		if (IndexBufferSize && VAOId && IBOId)
		{
			glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBOId);
			glBufferData(GL_ELEMENT_ARRAY_BUFFER, IndexBufferSize, NULL, GL_STATIC_DRAW);
			GLuint* glElementData = (GLuint*)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
			if (glElementData)
			{
				Element* currElement;
				unsigned int i=0;
				unsigned int currSelectionSize = currSelection->size();
				for (std::vector<Element*>::iterator it=currSelection->begin(); it != currSelection->end(); ++it, i++)
				{
					currElement = *it;
					glElementData[3*i+0] = (GLuint)currElement->n1->nodeNumber-1;
					glElementData[3*i+1] = (GLuint)currElement->n2->nodeNumber-1;
					glElementData[3*i+2] = (GLuint)currElement->n3->nodeNumber-1;
				}
				for (i=0; i<boundaryNodes.size(); i++)
				{
					glElementData[3*currSelectionSize+i] = boundaryNodes[i]-1;
				}
			} else {
				glLoaded = false;
				DEBUG("ERROR: Mapping index buffer for Subdomain Creation Selection Layer " << GetID());
				emit emitMessage("<p style:color='red'><strong>Error: Unable to load index data to GPU (Subdomain Creation Selection Layer)</strong>");
				return;
			}

			if (glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER) == GL_FALSE)
			{
				glLoaded = false;
				DEBUG("ERROR: Unmapping index buffer for Subdomain Creation Selection Layer " << GetID());
				return;
			}
		}

		GLenum errorCheck = glGetError();
		if (errorCheck == GL_NO_ERROR)
		{
			if (VAOId && VBOId && IBOId)
			{
				glLoaded = true;
			} else {
				DEBUG("Subdomain Creation Selection Layer Data Not Loaded");
			}
		} else {
			const GLubyte *errString = gluErrorString(errorCheck);
			DEBUG("CreationSelectionLayer OpenGL Error: " << errString);
			glLoaded = false;
		}

		emit Refreshed();
		emit NumElementsSelected(currSelection->size());
	}
}
// ==============================================================================
GlSpectrumAnalyzerWindow::GlSpectrumAnalyzerWindow(SoundPlayController *ctrl)
	: BDirectGLWindow(
//		BRect(200,100,199+640,99+480),
//		BRect(200,100,199+640,99+480),
		BRect( 100.0, 100.0, 739.0, 579.0 ),	// 640x480
		"OpenGL"B_UTF8_REGISTERED" Spectrum Analyzer",
		B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS/*|B_NOT_RESIZABLE|B_NOT_ZOOMABLE*/),
	name(NULL),
	xrot(10.0),
	yrot(35.0),
	zrot(0.0),
	needResize(false),
	opengl_device(BGL_DEVICE_SOFTWARE)
{
	controller=ctrl;
	controller->AddWindow(this);	// let SoundPlay handle some hotkeys for this window

	bView=new BView(Bounds(),"view",B_FOLLOW_ALL_SIDES, 0);
	bView->SetViewColor(0.0, 0.0, 0.0);
	bView->SetFontSize(20);
	AddChild(bView);

	for(int x=0;x<20;x++)
	{
		peak[x]=0;
		lastpeak[x]=0;
		peakdelay[x]=0;
	}

	// Add a shortcut so Alt-F will toggle fullscreen.
	AddShortcut( 'f', 0, new BMessage( GO_FULLSCREEN ) );

	// Initialize OpenGL
	//
	// In theory you can also use single-buffering, s/DOUBLE/SINGLE/ in
	// these two.
	EnumerateDevices( BGL_MONITOR_PRIMARY, BGL_ANY | BGL_DOUBLE, BGL_ANY, BGL_NONE, BGL_NONE );
	InitializeGL( opengl_device, BGL_ANY | BGL_DOUBLE, BGL_ANY, BGL_NONE, BGL_NONE );

	keeprunning=true;
	// Magically, the window will now appear on-screen.
	Show();
	Sync();	// <- should prevent the thread from racing the window
	
	//gInit
	MakeCurrent();
	// Clear to black
	glClearColor( 0.0, 0.0, 0.0, 0.0 );
	
	// Set up the depth buffer
	glClearDepth( 1.0 );
	// The type of depth test
	glDepthFunc( GL_LEQUAL );
//	glDepthFunc( GL_LESS );
	// Enable depth testing
	glEnable( GL_DEPTH_TEST );
	
	// Set up perspective view

	// Enable smooth shading
	glShadeModel( GL_SMOOTH );

	// Really nice perspective calculations
	glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
	
	// Back face is solid, front face is outlined
	glPolygonMode( GL_BACK, GL_FILL );
	glPolygonMode( GL_FRONT, GL_LINE );

//	glMatrixMode( GL_PROJECTION );
	
#if 0
	float local_view[] = {0.0,0.0};
	float position[] = {0.0, 3.0, 3.0, 0.0};
	glLightfv(GL_LIGHT0, GL_POSITION, position);
	glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view);

	float white[3] = {1.0,1.0,1.0};
	float dimWhite[3] = {0.25,0.25,0.25};

	glEnable(GL_LIGHT0);
	glLightfv(GL_LIGHT0, GL_SPECULAR, dimWhite);
	glLightfv(GL_LIGHT0, GL_DIFFUSE,white);
	glLightfv(GL_LIGHT0, GL_AMBIENT,white);

	glFrontFace(GL_CW);
	glEnable(GL_LIGHTING);
	glEnable(GL_AUTO_NORMAL);
	glEnable(GL_NORMALIZE);
	glMaterialf(GL_FRONT, GL_SHININESS, 0.6*128.0);

	glColor3f(1.0, 1.0, 1.0);

	glMatrixMode(GL_PROJECTION);
#endif

	glLoadIdentity();
	ReleaseCurrent();

	FrameResized(float(Bounds().IntegerWidth() + 1), float(Bounds().IntegerHeight() + 1));
}
Ejemplo n.º 17
0
		// -------------------------------- OpenGLRenderer::Impl definition
		OpenGLRenderer::OpenGLRenderer(Window& window)
			: m_wrapper { }, m_systemInfo { m_wrapper }, m_window{ window }, m_logManager { CROISSANT_GET_LOG(OpenGLRenderer) }
		{
			m_logManager.Write("Initialisation du renderer OpenGL");
			//serviceProvider.Resolve(m_frameProvider);

#if defined(CROISSANT_WINDOWS)
			auto hwnd = m_window.GetSystemHandle();
	        m_ghDC = GetDC(hwnd);
	        if (NULL == m_ghDC)
	        {
	        	throw OpenGLRendererException("Erreur lors de la récupération du Draw Context");
	        }

	        SetupPixelFormat(m_ghDC);

	        m_contextGl = wglCreateContext(m_ghDC);
	        if (NULL == m_contextGl)
	        {
	        	throw OpenGLRendererException("Erreur lors de la création du contexte OpenGL.");
	        }

	        if (FALSE == wglMakeCurrent(m_ghDC, m_contextGl))
	        {
	        	throw OpenGLRendererException("Erreur lors de la définition du contexte OpenGL comme courant.");
	        }


	        RECT rect;

	        GetClientRect(hwnd, &rect);
	        InitializeGLExtentions();
	        InitializeGL(rect.right, rect.bottom);
#elif defined(CROISSANT_LINUX)
            auto hwnd = m_window.GetSystemHandle();
			// Get a matching FB config
			static int visual_attribs[] =
					{
							GLX_X_RENDERABLE    , True,
							GLX_DRAWABLE_TYPE   , GLX_WINDOW_BIT,
							GLX_RENDER_TYPE     , GLX_RGBA_BIT,
							GLX_X_VISUAL_TYPE   , GLX_TRUE_COLOR,
							GLX_RED_SIZE        , 8,
							GLX_GREEN_SIZE      , 8,
							GLX_BLUE_SIZE       , 8,
							GLX_ALPHA_SIZE      , 8,
							GLX_DEPTH_SIZE      , 24,
							GLX_STENCIL_SIZE    , 8,
							GLX_DOUBLEBUFFER    , True,
							//GLX_SAMPLE_BUFFERS  , 1,
							//GLX_SAMPLES         , 4,
							None
					};

			int glx_major, glx_minor;

			// FBConfigs were added in GLX version 1.3.
			if ( !glXQueryVersion( hwnd.m_display, &glx_major, &glx_minor ) ||
				 ( ( glx_major == 1 ) && ( glx_minor < 3 ) ) || ( glx_major < 1 ) )
			{
				printf("Invalid GLX version");
				exit(1);
			}

			printf( "Getting matching framebuffer configs\n" );
			int fbcount;
			GLXFBConfig* fbc = glXChooseFBConfig(hwnd.m_display, DefaultScreen(hwnd.m_display), visual_attribs, &fbcount);
			if (!fbc)
			{
				printf( "Failed to retrieve a framebuffer config\n" );
				exit(1);
			}
			printf( "Found %d matching FB configs.\n", fbcount );

			// Pick the FB config/visual with the most samples per pixel
			printf( "Getting XVisualInfos\n" );
			int best_fbc = -1, worst_fbc = -1, best_num_samp = -1, worst_num_samp = 999;

			int i;
			for (i=0; i<fbcount; ++i)
			{
				XVisualInfo *vi = glXGetVisualFromFBConfig( hwnd.m_display, fbc[i] );
				if ( vi )
				{
					int samp_buf, samples;
					glXGetFBConfigAttrib( hwnd.m_display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf );
					glXGetFBConfigAttrib( hwnd.m_display, fbc[i], GLX_SAMPLES       , &samples  );

					printf( "  Matching fbconfig %d, visual ID 0x%2x: SAMPLE_BUFFERS = %d,"
									" SAMPLES = %d\n",
							i, vi -> visualid, samp_buf, samples );

					if ( best_fbc < 0 || samp_buf && samples > best_num_samp )
						best_fbc = i, best_num_samp = samples;
					if ( worst_fbc < 0 || !samp_buf || samples < worst_num_samp )
						worst_fbc = i, worst_num_samp = samples;
				}
				XFree( vi );
			}

			GLXFBConfig bestFbc = fbc[ best_fbc ];

			// Be sure to free the FBConfig list allocated by glXChooseFBConfig()
			XFree( fbc );

			// Get a visual
			//XVisualInfo *vi = glXGetVisualFromFBConfig( hwnd, bestFbc );
			//printf( "Chosen visual ID = 0x%x\n", vi->visualid );


			// NOTE: It is not necessary to create or make current to a context before
			// calling glXGetProcAddressARB
			glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
			glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)
					glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" );

			int context_attribs[] =
					{
							GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
							GLX_CONTEXT_MINOR_VERSION_ARB, 0,
							//GLX_CONTEXT_FLAGS_ARB        , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
							None
					};

			printf( "Creating context\n" );
			m_contextGl = glXCreateContextAttribsARB( hwnd.m_display, bestFbc, 0,
											  True, context_attribs );

			// Sync to ensure any errors generated are processed.
			XSync( hwnd.m_display, False );

			// Verifying that context is a direct context
			if ( ! glXIsDirect ( hwnd.m_display, m_contextGl ) )
			{
				printf( "Indirect GLX rendering context obtained\n" );
			}
			else
			{
				printf( "Direct GLX rendering context obtained\n" );
			}

			printf( "Making context current\n" );
			glXMakeCurrent( hwnd.m_display, hwnd.m_window, m_contextGl );

#endif


			//serviceProvider.Resolve(m_eventManager);
			//m_eventManager->RegisterListener("Frame::Render", m_renderDelegate);
		    m_logManager.Write("Renderer OpenGL initialisé avec succès");
		}