예제 #1
0
        private bool ResizeTextureIfNecessary( )
        {
            bool success = true;

            //handle resize
            if (doubleBuffer.LockFrontBufferForReading(500))
            {
                //Device parentDeviceForDx9ExShared = null;
                foreach (Device device in new List <Device>(device2DoubleTexture.Keys))
                {
                    DoubleTexture t2;
                    if (device2DoubleTexture.TryGetValue(device, out t2) &&
                        (t2.Width != doubleBuffer.Width || t2.Height != doubleBuffer.Height)
                        )
                    {
                        //Log( LogType.Debug, "[ResizeTextureIfNecessary] Recreating the texture because doubleTextSize != doubleBuffer size or " + t2.Width + "x" + t2.Height + " != " + doubleBuffer.Width + "x" + doubleBuffer.Height + " " );

                        //remove old texture (will be done when a new one is created)
                        //device2DoubleTexture[device].Dispose();
                        //create a new one
                        if (CreateTexture(device) == null)
                        {
                            success = false;
                        }
                        else
                        {
                            //Log( LogType.Debug, "[ResizeTextureIfNecessary] Setting deviceDataNeedsUpdatingOnEvaluate from " + deviceDataNeedsUpdatingOnEvaluate + " to true!" );
                            // Will be done IN CreateTexture: deviceDataNeedsUpdatingOnEvaluate = true;
                        }
                    }
                }
                doubleBuffer.UnlockFrontBuffer( );
            }
            return(success);
        }
예제 #2
0
        private bool ResizeTextureIfNecessary()
        {
            bool success = true;

            //handle resize
            if (doubleBuffer.LockFrontBufferForReading(500))
            {
                //Device parentDeviceForDx9ExShared = null;
                foreach (Device device in new List <Device>(device2DoubleTexture.Keys))
                {
//					DoubleTexture t2;
//					if (device2DoubleTexture.TryGetValue(device, out t2)) {
                    //Log( LogType.Debug, "SetNewSize on DoubleTexture (device " + t2.GetDevice().ComPointer.ToInt64() + "=" + deviceId + ", " + t2.GetWidth() + "x" + t2.GetHeight() +  ")" );
//						int result = t2.SetNewSize(doubleBuffer.GetWidth(), doubleBuffer.GetHeight());
//						success = success && (0 == result);
//						if (result != 0) {
//							Log( LogType.Error, "SetNewSize on DoubleTexture FAILED. Size = " + t2.GetWidth() + "x" + t2.GetHeight() + " but it should be " + doubleBuffer.GetWidth() + "x" + doubleBuffer.GetHeight() + " return value: " + result);
//						}
//					}

//					if ( parentDeviceForDx9ExShared == null ) {
//						parentDeviceForDx9ExShared = device;
//					}

                    DoubleTexture t2;
                    if (                                //device != parentDeviceForDx9ExShared ||
                        (
                            device2DoubleTexture.TryGetValue(device, out t2) &&
                            (t2.GetWidth() != doubleBuffer.GetWidth() || t2.GetHeight() != doubleBuffer.GetHeight())
                        )
                        )
                    {
                        //remove old texture (will be done when a new one is created)
                        //device2DoubleTexture[device].Dispose();
                        //create a new one
                        if (CreateOrReturnSharedTexture(device) == null)
                        {
                            success = false;
                        }
                        else
                        {
                            Log(LogType.Debug, "Setting deviceDataNeedsUpdatingOnEvaluate from " + deviceDataNeedsUpdatingOnEvaluate + " to true!");
                            deviceDataNeedsUpdatingOnEvaluate = true;
                        }
                    }
                }
                doubleBuffer.UnlockFrontBuffer();
            }
            return(success);
        }