void Device_OpenGL::Draw2DTextureFullViewport(Texture* texture) { DisableDepthTest(); PushMatrix(); SetIdentityMatrix(); UnbindVBO(VBO::VBO_TARGET_ARRAY_BUFFER); //------------------------------------------- float x = Screen::GetInstance()->GetRatio(); float y = 1.0f; float z = -1.0f; float vertices[30] = { -x, y, z, 0.0f, 1.0f, -x, -y, z, 0.0f, 0.0f, x, -y, z, 1.0f, 0.0f, -x, y, z, 0.0f, 1.0f, x, -y, z, 1.0f, 0.0f, x, y, z, 1.0f, 1.0f }; SetAttributePointer(ATTRIBUTE_FLOAT3_POSITION, vertices, sizeof(float) * 5); SetAttributePointer(ATTRIBUTE_FLOAT2_TEXCOORD_DIFFUSE, vertices + 3, sizeof(float) * 5); Device_Base::GetInstance()->UpdateVertexAttribPointer(); Device_Base::GetInstance()->SetUniformTexture(UNIFORM_TEXTURE_DIFFUSE, texture); Device_Base::GetInstance()->SetUniformMatrix(UNIFORM_MATRIX_MODEL, Device_Base::GetInstance()->GetMatrixWorld()); Device_Base::GetInstance()->SetUniformMatrix(UNIFORM_MATRIX_PROJECTION, m_MatrixProjection2DLogical); Device_Base::GetInstance()->DrawArray(Device_Base::PRIMITIVE_TRIANGLE_LIST, 0, 6); //------------------------------------------- EnableDepthTest(); PopMatrix(); }
Bool OpenGLGraphicDeviceLinux::Open( const RenderWindow & p_RenderOutput, const Version & p_Version ) { // Make sure that the GD is not already open. if( m_Open == true ) { std::cout << "[OpenGLGraphicDeviceLinux::BindOpenGLExtensions] The graphic device is already loaded.\n"; return false; } // Make sure that the render output is loaded if( p_RenderOutput.IsOpen( ) == false ) { std::cout << "[OpenGLGraphicDeviceLinux::BindOpenGLExtensions] The render output is not loaded.\n"; return false; } // Store the version of the opengl context that we want to create. // This function will create the best as possible if the version is set to 0.0 Version contextVersion( p_Version ); // Try to load the best context as possible if the version is set to the default version if( contextVersion == Version::Default ) { if( OpenBestVersion( p_RenderOutput, contextVersion ) != true ) { return false; } } // Try to load the requested context, if it fails, create the best context as possible. else { if( OpenVersion( p_RenderOutput, contextVersion ) == false ) { if( OpenBestVersion( p_RenderOutput, contextVersion ) != true ) { return false; } } } // Bind the OpenGL extensions if( OpenGL::BindOpenGLExtensions( contextVersion.GetMajor( ), contextVersion.GetMinor( ) ) != true ) { //bitTrace( "[GraphicDeviceWin32::Open] Can not bind the OpenGL extensions.\n" ); std::cout << "[OpenGL::BindOpenGLExtensions] Binding opengl extensions failed.\n"; return false; } // Set the default viewport to the window's size SetViewport( Vector2u32( 0, 0 ), p_RenderOutput.GetVideoMode( ).GetSize( ) ); // Set the some member varaibles m_Open = true; m_Version = contextVersion; m_pRenderOutput = const_cast<RenderWindow*>( &p_RenderOutput ); // Set default settings. DisableDepthTest( ); EnableTexture( ); DisableFaceCulling( ); DisableSmoothLines( ); // Return true at success. return true; }