DrawBloomPass::DrawBloomPass(IRenderer* renderer, ConfigFile* config) : m_Renderer(renderer) , m_Config(config) { InitializeTextures(); ChangeQuality(m_Config->Get<int>("GLOW.Quality", 2)); }
PickingPass::PickingPass(IRenderer* renderer, EventBroker* eb) { m_Renderer = renderer; m_EventBroker = eb; InitializeTextures(); InitializeFrameBuffers(); InitializeShaderPrograms(); }
// ============================================================================================ // ================================ Texture helpers =========================================== // ============================================================================================ bool Renderer::LoadAssets() { if ( !LoadFontAndText() ) return false; LoadColors(); if( !InitializeTextures() ) return false; return true; }
void DrawBloomPass::ChangeQuality(int quality) { if (m_Quality == quality) { return; } m_Quality = quality; m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh"); if (m_Quality == 0) { CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz); CommonFunctions::DeleteTexture(&m_GaussianTexture_vert); CommonFunctions::DeleteTexture(&m_FinalGaussianTexture); return; } InitializeTextures(); InitializeBuffers(); InitializeShaderPrograms(); std::string qStr = std::to_string(m_Quality); m_Iterations = m_Config->Get<float>("GLOW" + qStr + ".NumIterations", 0); }
void KPboardView::Initialize(const std::string &TextureDirectory, const std::string &TextureName, unsigned int TextureSize /*=1*/, bool Nearest /*=true*/) { InitializeTextures(TextureDirectory, TextureName, TextureSize, Nearest); glNewList(DisplayList + BRONZE_MATERIAL, GL_COMPILE); { GLfloat mat_ambient[] = {0.50f, 0.50f, 0.50f, 1.0f}; GLfloat mat_diffuse[] = {0.60f, 0.60f, 0.60f, 1.0f}; GLfloat mat_specular[] = {0.15f, 0.15f, 0.15f, 1.0f}; auto mat_shininess = 20.0f; glDisable(GL_TEXTURE_2D); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialf(GL_FRONT, GL_SHININESS, mat_shininess); glEnable(GL_TEXTURE_2D); } glEndList(); // define a Display List BOARD containing the Khun Phan board glNewList(DisplayList + BOARD, GL_COMPILE); // Front end (with gap for Khun Phan to escape :-) CreateCuboid( DBOXW + DX + DGAP, DBOXW, DBOXH, -((HORIZONTAL_MAX * (DX + DGAP) - DGAP) / 2) - DGAP - DBOXW, ((VERTICAL_MAX * (DY + DGAP) - DGAP) / 2) + DGAP, 0); CreateCuboid( 2 * (DX + DGAP) + DGAP, DBOXW, DBOXH - (DZ * 2 / 3) - DGAP, -((2 * (DX + DGAP) - DGAP) / 2) - DGAP, ((VERTICAL_MAX * (DY + DGAP) - DGAP) / 2) + DGAP, (DZ * 2 / 3) + DGAP); CreateCuboid( DBOXW + DX + DGAP, DBOXW, DBOXH, ((2 * (DX + DGAP) - DGAP) / 2) + DGAP, ((VERTICAL_MAX * (DY + DGAP) - DGAP) / 2) + DGAP, 0); // Back end CreateCuboid( 2 * DBOXW + DGAP + (HORIZONTAL_MAX * (DX + DGAP)), DBOXW, DBOXH, -((HORIZONTAL_MAX * (DX + DGAP) - DGAP) / 2) - DGAP - DBOXW, -((VERTICAL_MAX * (DY + DGAP) - DGAP) / 2) - DGAP - DBOXW, 0); // Left end CreateCuboid( DBOXW, VERTICAL_MAX * (DY + DGAP) + DGAP, DBOXH, -((HORIZONTAL_MAX * (DX + DGAP) - DGAP) / 2) - DGAP - DBOXW, -((VERTICAL_MAX * (DY + DGAP) + DGAP) / 2), 0); // Right end CreateCuboid( DBOXW, VERTICAL_MAX * (DY + DGAP) + DGAP, DBOXH, ((HORIZONTAL_MAX * (DX + DGAP) - DGAP) / 2) + DGAP, -((VERTICAL_MAX * (DY + DGAP) - DGAP) / 2) - DGAP, 0); // Bottom end CreateCuboid( 2 * DBOXW + DGAP + (HORIZONTAL_MAX * (DX + DGAP)), 2 * DBOXW + DGAP + VERTICAL_MAX * (DY + DGAP), DBOXW, -(HORIZONTAL_MAX * (DX + DGAP) / 2) - DGAP - DBOXW, -(VERTICAL_MAX * (DY + DGAP) / 2) - DGAP - DBOXW, -DBOXW); glEndList(); // define a Display List CUBOID_1X1 containing a cuboid with size 1 x 1 glNewList(DisplayList + CUBOID_1X1_1, GL_COMPILE); CreateCuboid(DX, DY, DZ, 0, 0, 0, true); glEndList(); glNewList(DisplayList + CUBOID_1X1_2, GL_COMPILE); CreateCuboid(DX, DY, DZ, 0, 0, 0, true); glEndList(); glNewList(DisplayList + CUBOID_1X1_3, GL_COMPILE); CreateCuboid(DX, DY, DZ, 0, 0, 0, true); glEndList(); glNewList(DisplayList + CUBOID_1X1_4, GL_COMPILE); CreateCuboid(DX, DY, DZ, 0, 0, 0, true); glEndList(); // define a Display List CUBOID_1X2 containing a cuboid with size 1 x 2 glNewList(DisplayList + CUBOID_1X2_1, GL_COMPILE); CreateCuboid(DX, 2 * DY + DGAP, DZ, 0, 0, 0, true); glEndList(); glNewList(DisplayList + CUBOID_1X2_2, GL_COMPILE); CreateCuboid(DX, 2 * DY + DGAP, DZ, 0, 0, 0, true); glEndList(); glNewList(DisplayList + CUBOID_1X2_3, GL_COMPILE); CreateCuboid(DX, 2 * DY + DGAP, DZ, 0, 0, 0, true); glEndList(); glNewList(DisplayList + CUBOID_1X2_4, GL_COMPILE); CreateCuboid(DX, 2 * DY + DGAP, DZ, 0, 0, 0, true); glEndList(); // define a Display List CUBOID_2X1 containing a cuboid with size 2 x 1 glNewList(DisplayList + CUBOID_2X1, GL_COMPILE); CreateCuboid(2 * DX + DGAP, DY, DZ, 0, 0, 0, true); glEndList(); // define a Display List CUBOID_2X2 containing a cuboid with size 2 x 2 glNewList(DisplayList + CUBOID_2X2, GL_COMPILE); CreateCuboid(2 * DX + DGAP, 2 * DY + DGAP, DZ * 2 / 3, 0, 0, 0, true); glEndList(); }
void PickingPass::OnWindowResize() { InitializeTextures(); m_PickingBuffer.Generate(); }
void CDetailObject::Init( void ) { #if 0 GETRENDERERINTERFACEPARAMS renderInterfaceParam; static DWORD msgHash_GetRendererInterface = CHashString(_T("GetRendererInterface")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_GetRendererInterface, sizeof(GETRENDERERINTERFACEPARAMS), &renderInterfaceParam, NULL, NULL ); static DWORD msgHash_CreateController = CHashString(_T("CreateController")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_CreateController, sizeof( IController** ), &m_GeometryController ); static DWORD msgHash_CreateGeometry = CHashString(_T("CreateGeometry")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_CreateGeometry, sizeof( IGeometry** ), &m_Geometry ); m_IRenderer = renderInterfaceParam.m_RendererInterface; //load the shader IEffect * MyEffect = NULL; //load the shader LOADFILEEXTPARAMS lfep; if( m_ShaderFile == "" ) { m_ShaderFile = "SHADERS/DEFAULTSHADER.efx"; } m_ShaderFile.MakeSafeFileName(); CHashString filename( m_ShaderFile ); lfep.fileName = (TCHAR*)m_ShaderFile; lfep.bInternalLoad = true; static DWORD msgHash_LoadFileByExtension = CHashString(_T("LoadFileByExtension")).GetUniqueID(); DWORD retval = EngineGetToolBox()->SendMessage(msgHash_LoadFileByExtension, sizeof(LOADFILEEXTPARAMS), &lfep); if( retval == MSG_HANDLED ) { CREATEEFFECTINTERFACE cef; cef.m_Name = &filename; static DWORD msgHash_GetEffectInterface = CHashString(_T("GetEffectInterface")).GetUniqueID(); EngineGetToolBox()->SendMessage(msgHash_GetEffectInterface, sizeof(CREATEEFFECTINTERFACE ), &cef ); MyEffect = cef.m_EffectInterface; if( !MyEffect ) { EngineGetToolBox()->Log( LOGERROR, _T("Could not load DetailObject's shader" ) ); } } GenerateVertices(); CREATEMATERIALINTERFACE cmat; CREATEOBJECTPARAMS cop; TCHAR buf[ 512 ]; CHashString hszType( _T("CMaterial" ) ); IHashString * hname = GetName(); if( m_GeometryController && m_Geometry ) { m_Geometry->SetController( m_GeometryController ); //set shader IMaterial * material = NULL; _stprintf( buf, "%s_mat", hname->GetString()); CHashString hszName( buf ); //Create the material cop.parentName = NULL; cop.typeName = &hszType; cop.name = &hszName; static DWORD msgHash_CreateObject = CHashString(_T("CreateObject")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_CreateObject, sizeof(CREATEOBJECTPARAMS), &cop, NULL, NULL); if( material ) { cmat.m_Name = &hszName; static DWORD msgHash_GetMaterialInterface = CHashString(_T("GetMaterialInterface")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_GetMaterialInterface, sizeof(cmat), &cmat, NULL, NULL); if( cmat.m_MaterialInterface ) { material = cmat.m_MaterialInterface; material->SetEffect( MyEffect ); } } m_Geometry->SetMaterial( material ); //do the proper allocation for the geometry BUFFERALLOCATIONSTRUCT tempalloc; tempalloc.m_Offset = m_VertexBufferAllocation.m_Offset; tempalloc.m_Size = m_VertexBufferAllocation.m_Size; tempalloc.m_Stride = m_VertexBufferAllocation.m_Stride; tempalloc.m_InterfaceHandle = m_VertexBufferAllocation.m_InterfaceHandle; tempalloc.m_AllocationHandle = m_VertexBufferAllocation.m_AllocationHandle; ////vertex size and offset should be current m_Geometry->SetVertexBufferAllocation( tempalloc ); tempalloc.m_Offset = m_IndexBufferAllocation.m_Offset; tempalloc.m_Size = m_IndexBufferAllocation.m_Size; tempalloc.m_Stride = m_IndexBufferAllocation.m_Stride; tempalloc.m_InterfaceHandle = m_IndexBufferAllocation.m_InterfaceHandle; tempalloc.m_AllocationHandle = m_IndexBufferAllocation.m_AllocationHandle; ////vertex size and offset should be current m_Geometry->SetIndexBufferAllocation( tempalloc ); } else { } InitializeTextures(); UpdateBoundingObject(); #endif }