void CImagePacker::GetMinimumDimensions( int *pReturnWidth, int *pReturnHeight ) { *pReturnWidth = CeilPow2( m_MaxLightmapWidth ); *pReturnHeight = CeilPow2( m_MinimumHeight ); int aspect = *pReturnWidth / *pReturnHeight; if (aspect > HardwareConfig()->MaxTextureAspectRatio()) { *pReturnHeight = *pReturnWidth / HardwareConfig()->MaxTextureAspectRatio(); } }
void PICvision_init(void) { HardwareConfig(); timers_init(TICK_FREQ); video_init(); sound_init(1000/TICK_FREQ); splash_screen(); }//f()
//----------------------------------------------------------------------------- // Initialization + shutdown //----------------------------------------------------------------------------- void CTextureManager::Init( int nFlags ) { m_nFlags = nFlags; color32 color, color2; m_iNextTexID = 4096; // setup the checkerboard generator for failed texture loading color.r = color.g = color.b = 0; color.a = 128; color2.r = color2.b = color2.a = 255; color2.g = 0; m_pErrorRegen = new CCheckerboardTexture( 4, color, color2 ); // Create an error texture m_pErrorTexture = CreateProceduralTexture( "error", TEXTURE_GROUP_OTHER, ERROR_TEXTURE_SIZE, ERROR_TEXTURE_SIZE, 1, IMAGE_FORMAT_BGRA8888, TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_SINGLECOPY ); CreateCheckerboardTexture( m_pErrorTexture, 4, color, color2 ); // Create a white texture m_pWhiteTexture = CreateProceduralTexture( "white", TEXTURE_GROUP_OTHER, WHITE_TEXTURE_SIZE, WHITE_TEXTURE_SIZE, 1, IMAGE_FORMAT_BGRX8888, TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_SINGLECOPY ); color.r = color.g = color.b = color.a = 255; CreateSolidTexture( m_pWhiteTexture, color ); // Create a black texture m_pBlackTexture = CreateProceduralTexture( "black", TEXTURE_GROUP_OTHER, BLACK_TEXTURE_SIZE, BLACK_TEXTURE_SIZE, 1, IMAGE_FORMAT_BGRX8888, TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_SINGLECOPY ); color.r = color.g = color.b = 0; CreateSolidTexture( m_pBlackTexture, color ); // Create a grey texture m_pGreyTexture = CreateProceduralTexture( "grey", TEXTURE_GROUP_OTHER, GREY_TEXTURE_SIZE, GREY_TEXTURE_SIZE, 1, IMAGE_FORMAT_BGRA8888, TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_SINGLECOPY ); color.r = color.g = color.b = 128; color.a = 255; CreateSolidTexture( m_pGreyTexture, color ); // Create a grey texture m_pGreyAlphaZeroTexture = CreateProceduralTexture( "greyalphazero", TEXTURE_GROUP_OTHER, GREY_TEXTURE_SIZE, GREY_TEXTURE_SIZE, 1, IMAGE_FORMAT_BGRA8888, TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_SINGLECOPY ); color.r = color.g = color.b = 128; color.a = 0; CreateSolidTexture( m_pGreyAlphaZeroTexture, color ); if ( HardwareConfig()->GetMaxDXSupportLevel() >= 80 ) { // Create a normalization cubemap m_pNormalizationCubemap = CreateProceduralTexture( "normalize", TEXTURE_GROUP_CUBE_MAP, NORMALIZATION_CUBEMAP_SIZE, NORMALIZATION_CUBEMAP_SIZE, 1, IMAGE_FORMAT_BGRX8888, TEXTUREFLAGS_ENVMAP | TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_SINGLECOPY | TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT ); CreateNormalizationCubemap( m_pNormalizationCubemap ); } if ( HardwareConfig()->GetMaxDXSupportLevel() >= 90 ) { // Create a normalization cubemap m_pSignedNormalizationCubemap = CreateProceduralTexture( "normalizesigned", TEXTURE_GROUP_CUBE_MAP, NORMALIZATION_CUBEMAP_SIZE, NORMALIZATION_CUBEMAP_SIZE, 1, IMAGE_FORMAT_UVWQ8888, TEXTUREFLAGS_ENVMAP | TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_NOLOD | TEXTUREFLAGS_SINGLECOPY | TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT ); CreateSignedNormalizationCubemap( m_pSignedNormalizationCubemap ); m_pIdentityLightWarp = FindOrLoadTexture( "dev/IdentityLightWarp", TEXTURE_GROUP_OTHER ); m_pIdentityLightWarp->IncrementReferenceCount(); } // High end hardware needs this texture for shadow mapping if ( HardwareConfig()->ActuallySupportsPixelShaders_2_b() ) { m_pShadowNoise2D = FindOrLoadTexture( "engine/NormalizedRandomDirections2D", TEXTURE_GROUP_OTHER ); m_pShadowNoise2D->IncrementReferenceCount(); } }
void CShaderAPIOES2::ResetRenderState(bool bFullReset) { int i; if (!IsDeactivated()) { glFrontFace(GL_CW); glEnable(GL_CULL_FACE); // glCullFace(GL_BACK); // Never changed. glDisable(GL_STENCIL_TEST); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilFunc(GL_ALWAYS, 0, 0xffffffff); glStencilMask(0xffffffff); glDisable(GL_SCISSOR_TEST); glDisable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0.0f, 0.0f); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // glBlendColor(1.0f, 1.0f, 1.0f, 1.0f); // Constant color blending modes are not used. // glBlendEquation(GL_FUNC_ADD); // Never changed. glActiveTexture(GL_TEXTURE0); glClearDepthf(1.0f); glClearStencil(0); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } m_CurrentSnapshot = -1; m_CachedFastClipProjectionMatrix.Identity(); m_SceneFogColor[0] = m_SceneFogColor[1] = m_SceneFogColor[2] = 0; m_SceneFogMode = MATERIAL_FOG_NONE; m_DynamicState.m_ClearColor[0] = m_DynamicState.m_ClearColor[1] = m_DynamicState.m_ClearColor[2] = m_DynamicState.m_ClearColor[3] = 0; m_ClearColorChanged = true; m_ClearReverseDepth = false; m_ClearStencil = 0; m_ZWriteEnable = true; StandardConstantChanged(OES2_SHADER_CONST_AMBIENT_LIGHT); m_WorldSpaceCameraPosition.Init(0.0f, 0.0f, 0.0f); m_DynamicState.m_PixelFogColor[0] = m_DynamicState.m_PixelFogColor[1] = m_DynamicState.m_PixelFogColor[2] = 0.0f; m_DynamicState.m_FogStart = 0.0f; m_DynamicState.m_FogEnd = 0.0f; m_DynamicState.m_FogMaxDensity = 1.0f; m_DynamicState.m_FogZ = 1.0f; UpdateFogConstant(); // Shadow state applied in ShaderAPI. m_DynamicState.m_CullEnabled = true; m_DynamicState.m_FrontFace = GL_CW; m_DynamicState.m_DepthBiasEnabled = false; m_DynamicState.m_NumBones = 0; for (i = HardwareConfig()->Caps().m_NumCombinedSamplers; i-- > 0; ) m_BoundTextures[i] = INVALID_SHADERAPI_TEXTURE_HANDLE; m_PixelShaderLightingChanged = true; m_VertexShaderLightingChanged = true; for (i = MAX_NUM_LIGHTS; i--; ) m_DynamicState.m_LightEnable[i] = false; for (i = NUM_MATRIX_MODES; i--; ) m_DynamicState.m_TransformType[i] = TRANSFORM_IS_GENERAL; StandardConstantChanged(OES2_SHADER_CONST_MODELVIEWPROJ); StandardConstantChanged(OES2_SHADER_CONST_VIEWPROJ); StandardConstantChanged(OES2_SHADER_CONST_MODEL); m_TransitionTable.UseDefaultState(); SetDefaultState(); if (bFullReset) { SetAnisotropicLevel(1); float *pBoneMatrix; for (i = 16; i--; ) { pBoneMatrix = m_BoneMatrix[i]; memset(pBoneMatrix, 0, sizeof(float) * 12); pBoneMatrix[0] = 1.0f; pBoneMatrix[5] = 1.0f; pBoneMatrix[10] = 1.0f; } MatrixMode(MATERIAL_VIEW); LoadIdentity(); MatrixMode(MATERIAL_PROJECTION); LoadIdentity(); } int width, height; GetBackBufferDimensions(width, height); m_Viewport.Init(0, 0, width, height); m_ViewportChanged = true; m_ViewportZChanged = true; m_ScissorEnabled = m_DynamicState.m_ScissorEnabled = false; m_DynamicState.m_ScissorRect.x = m_DynamicState.m_ScissorRect.y = m_DynamicState.m_ScissorRect.width = m_DynamicState.m_ScissorRect.height = -1; m_ScissorRectChanged = true; EnableFastClip(false); float fakePlane[4]; int fakePlaneVal = -1; fakePlane[0] = fakePlane[1] = fakePlane[2] = fakePlane[3] = *((float *)(&fakePlaneVal)); SetFastClipPlane(fakePlane); m_DynamicState.m_FastClipPlaneChanged = true; m_pRenderMesh = NULL; MeshMgr()->SetVertexDecl(VERTEX_FORMAT_UNKNOWN); SetRenderTarget(SHADER_RENDERTARGET_BACKBUFFER, SHADER_RENDERTARGET_DEPTHBUFFER); m_ActiveTexture = SHADER_SAMPLER0; m_UnpackAlignment = 4; }