From ec0c1820dd42558d05754fde333f710a76dd6627 Mon Sep 17 00:00:00 2001 From: Halofreak1990 Date: Thu, 9 Jun 2011 12:57:16 +0000 Subject: [PATCH] Fixed TextureCollection issues caused by circular dependencies. Added RenderTarget and RenderTarget2D classes to the XFX::Graphics namespace Added Internal StorageDeviceAsyncResult class to the XFX::Storage namespace to aid in the implementation of the Guide. Added Guide::BeginShowMessageBox and Guide::EndShowMessageBox methods Began fixing comments to properly show up in IntelliSense --- include/Audio/Enums.h | 7 +- include/GamerServices/Enums.h | 30 +- include/GamerServices/Guide.h | 10 +- .../GamerServices/StorageDeviceAsyncResult.h | 33 ++ include/Graphics/GraphicsDevice.h | 34 ++- include/Graphics/RenderTarget.h | 62 ++++ include/Graphics/RenderTarget2D.h | 43 +++ include/Graphics/Texture2D.h | 3 +- include/Graphics/TextureCollection.h | 8 +- include/Graphics/Viewport.h | 5 + include/Net/Enums.h | 28 +- include/Net/PacketReader.h | 6 +- include/Storage/StorageContainer.h | 7 +- include/Storage/StorageDevice.h | 16 +- .../System/Collections/Generic/Dictionary.h | 287 ++++++++++-------- .../System/Collections/Generic/Interfaces.h | 6 +- include/System/Collections/Generic/List.h | 2 +- include/System/IO/StreamAsyncResult.h | 5 +- include/System/Interfaces.h | 4 +- src/libSystem/libSystem.vcproj | 4 + src/libSystem/makefile | 49 +++ src/libXFX/GraphicsDevice.cpp | 108 +++++-- src/libXFX/Guide.cpp | 22 +- src/libXFX/Matrix.cpp | 45 +-- src/libXFX/PacketReader.cpp | 6 +- src/libXFX/RenderTarget.cpp | 56 ++++ src/libXFX/RenderTarget2D.cpp | 35 +++ src/libXFX/StorageDevice.cpp | 10 +- src/libXFX/StorageDeviceAsyncResult.cpp | 35 +++ src/libXFX/Viewport.cpp | 22 ++ src/libXFX/libXFX.vcproj | 24 ++ src/libXFX/makefile | 2 +- src/libmscorlib/StreamAsyncResult.cpp | 5 + src/libmscorlib/makefile | 2 +- 34 files changed, 758 insertions(+), 263 deletions(-) create mode 100644 include/GamerServices/StorageDeviceAsyncResult.h create mode 100644 include/Graphics/RenderTarget.h create mode 100644 include/Graphics/RenderTarget2D.h create mode 100644 src/libSystem/makefile create mode 100644 src/libXFX/RenderTarget.cpp create mode 100644 src/libXFX/RenderTarget2D.cpp create mode 100644 src/libXFX/StorageDeviceAsyncResult.cpp diff --git a/include/Audio/Enums.h b/include/Audio/Enums.h index 6bcaa94..dcef4b8 100644 --- a/include/Audio/Enums.h +++ b/include/Audio/Enums.h @@ -11,9 +11,6 @@ namespace XFX { namespace Audio { - /// - /// Controls how Cue objects should stop when Cue.Stop is called. - /// struct AudioStopOptions { enum type @@ -23,8 +20,8 @@ namespace XFX }; }; - typedef AudioStopOptions::type AudioStopOptions_t; + typedef AudioStopOptions::type AudioStopOptions_t; // Controls how Cue objects should stop when Cue::Stop is called. } } -#endif //XFRAMEWORK_AUDIOSTOPOPTIONS_H +#endif //_XFX_AUDIO_ENUMS_ diff --git a/include/GamerServices/Enums.h b/include/GamerServices/Enums.h index 71d7258..884b2b9 100644 --- a/include/GamerServices/Enums.h +++ b/include/GamerServices/Enums.h @@ -5,9 +5,6 @@ namespace XFX { namespace GamerServices { - /// - /// Indicates how sensitive this gamer prefers controller input to be. - /// struct ControllerSensitivity { enum type @@ -18,9 +15,6 @@ namespace XFX }; }; - /// - /// Indicates how difficult this gamer likes things to be. - /// struct GameDifficulty { enum type @@ -31,9 +25,6 @@ namespace XFX }; }; - /// - /// This style of social gaming preferred by this Xbox Live member. - /// struct GamerZone { enum type @@ -46,9 +37,6 @@ namespace XFX }; }; - /// - /// Defines the different icons for a message box. - /// struct MessageBoxIcon { enum type @@ -60,9 +48,6 @@ namespace XFX }; }; - /// - /// Determines where notifications appear on the screen. - /// struct NotificationPosition { enum type @@ -79,9 +64,6 @@ namespace XFX }; }; - /// - /// Indicates which camera angle this gamer prefers to use in racing games. - /// struct RacingCameraAngle { enum type @@ -92,12 +74,12 @@ namespace XFX }; }; - typedef ControllerSensitivity::type ControllerSensitivity_t; - typedef GameDifficulty::type GameDifficulty_t; - typedef GamerZone::type GamerZone_t; - typedef MessageBoxIcon::type MessageBoxIcon_t; - typedef NotificationPosition::type NotificationPosition_t; - typedef RacingCameraAngle::type RacingCameraAngle_t; + typedef ControllerSensitivity::type ControllerSensitivity_t; // Indicates how sensitive this gamer prefers controller input to be. + typedef GameDifficulty::type GameDifficulty_t; // Indicates how difficult this gamer likes things to be. + typedef GamerZone::type GamerZone_t; // This style of social gaming preferred by this Xbox Live member. + typedef MessageBoxIcon::type MessageBoxIcon_t; // Defines the different icons for a message box. + typedef NotificationPosition::type NotificationPosition_t; // Determines where notifications appear on the screen. + typedef RacingCameraAngle::type RacingCameraAngle_t; // Indicates which camera angle this gamer prefers to use in racing games. } } diff --git a/include/GamerServices/Guide.h b/include/GamerServices/Guide.h index 65c96df..11b89b9 100644 --- a/include/GamerServices/Guide.h +++ b/include/GamerServices/Guide.h @@ -7,13 +7,16 @@ #ifndef _XFX_GAMERSERVICES_GUIDE_ #define _XFX_GAMERSERVICES_GUIDE_ +#include #include #include +#include #include #include #include "Enums.h" using namespace System; +using namespace System::Collections::Generic; using namespace XFX::Storage; namespace XFX @@ -32,16 +35,19 @@ namespace XFX Guide(); public: - static bool IsScreenSaverEnabled(); + static bool IsScreenSaverEnabled; static bool IsVisible(); - static NotificationPosition_t notificationPosition; + static NotificationPosition_t NotificationPosition; static IAsyncResult* BeginShowKeyboardInput(PlayerIndex_t player, char* title, char* description, char* defaultText, AsyncCallback callback, Object* state); + static IAsyncResult* BeginShowMessageBox(PlayerIndex_t player, char* title, char* text, IEnumerable* buttons, int focusButton, MessageBoxIcon_t icon, AsyncCallback callback, Object* state); static IAsyncResult* BeginShowStorageDeviceSelector(int sizeInBytes, int directoryCount, AsyncCallback callback, Object* state); static IAsyncResult* BeginShowStorageDeviceSelector(AsyncCallback callback, Object* state); static IAsyncResult* BeginShowStorageDeviceSelector(PlayerIndex_t player, int sizeInBytes, int directoryCount, AsyncCallback callback, Object* state); static IAsyncResult* BeginShowStorageDeviceSelector(PlayerIndex_t player, AsyncCallback callback, Object* state); + static void DelayNotifications(TimeSpan timespan); static char* EndShowKeyboardInput(IAsyncResult* result); + static int EndShowMessageBox(IAsyncResult* result); static StorageDevice EndShowStorageDeviceSelector(IAsyncResult* result); }; } diff --git a/include/GamerServices/StorageDeviceAsyncResult.h b/include/GamerServices/StorageDeviceAsyncResult.h new file mode 100644 index 0000000..cf3c80a --- /dev/null +++ b/include/GamerServices/StorageDeviceAsyncResult.h @@ -0,0 +1,33 @@ + +#include +#include + +using namespace System; +using namespace System::Threading; + +namespace XFX +{ + namespace GamerServices + { + class Guide; + + class StorageDeviceAsyncResult : public IAsyncResult + { + friend class Guide; + + private: + Object* syncObject; + int playerIndex; + + StorageDeviceAsyncResult(Object* stateObject, int player); + StorageDeviceAsyncResult(const StorageDeviceAsyncResult &obj); + StorageDeviceAsyncResult(IAsyncResult* &obj); + + public: + Object* AsyncState(); + bool CompletedSynchronously(); + bool IsCompleted(); + WaitHandle* AsyncWaitHandle(); + }; + } +} diff --git a/include/Graphics/GraphicsDevice.h b/include/Graphics/GraphicsDevice.h index 69a54a3..d986c6d 100644 --- a/include/Graphics/GraphicsDevice.h +++ b/include/Graphics/GraphicsDevice.h @@ -15,6 +15,7 @@ #include "GraphicsDeviceCapabilities.h" #include "GraphicsDeviceCreationParameters.h" #include "PresentationParameters.h" +#include "RenderTarget2D.h" #include "TextureCollection.h" #include "Viewport.h" @@ -34,10 +35,10 @@ namespace XFX /// Performs primitive-based rendering, creates resources, handles system-level /// variables, adjusts gamma ramp levels, and creates shaders. /// - class GraphicsDevice : public IDisposable + class GraphicsDevice : public IDisposable, virtual Object { private: - GraphicsAdapter _adapter; + GraphicsAdapter* _adapter; DepthStencilBuffer _depthStencilBuffer; DeviceType_t _deviceType; GraphicsDeviceCapabilities graphicsDeviceCapabilities; @@ -45,19 +46,31 @@ namespace XFX TextureCollection textures; Color clearColor; Viewport viewport; + + void setPresentationParameters(PresentationParameters* presentationParameters); protected: virtual void Dispose(bool disposing); + virtual void raise_DeviceLost(Object* sender, EventArgs e); + virtual void raise_DeviceReset(Object* sender, EventArgs e); + virtual void raise_DeviceResetting(Object* sender, EventArgs e); + virtual void raise_Disposing(Object* sender, EventArgs e); public: + EventHandler DeviceLost; + EventHandler DeviceReset; + EventHandler DeviceResetting; + EventHandler Disposing; + GraphicsDeviceCreationParameters CreationParameters(); - DepthStencilBuffer GetDepthStencilBuffer(); - void SetDepthStencilBuffer(DepthStencilBuffer buffer); + DepthStencilBuffer getDepthStencilBuffer(); + void setDepthStencilBuffer(DepthStencilBuffer buffer); + PresentationParameters* getPresentationParameters(); TextureCollection Textures(); - Viewport Viewport_(); - void Viewport_(Viewport newValue); + Viewport getViewport(); + void setViewport(Viewport value); - GraphicsDevice(GraphicsAdapter adapter, DeviceType_t deviceType, PresentationParameters presentationParameters); + GraphicsDevice(GraphicsAdapter* adapter, DeviceType_t deviceType, PresentationParameters* presentationParameters); GraphicsDevice(); virtual ~GraphicsDevice(); @@ -76,7 +89,7 @@ namespace XFX template void DrawUserPrimitives(PrimitiveType_t primitiveType, T vertexData[], int vertexOffset, int primitiveCount); void EvictManagedResources(); - GammaRamp GetGammaRamp(); + GammaRamp* GetGammaRamp(); int* GetPixelShaderBooleanConstant(int startRegister, int constantCount); int* GetPixelShaderInt32Constant(int startRegister, int constantCount); Matrix* GetPixelShaderMatrixArrayConstant(int startRegister, int constantCount); @@ -86,6 +99,11 @@ namespace XFX float* GetPixelShaderSingleConstant(int startRegister, int constantCount); Vector2* GetPixelShaderVector2ArrayConstant(int startRegister, int constantCount); Vector2 GetPixelShaderVector2Constant(int startRegister); + void Present(); + void Reset(); + void Reset(PresentationParameters* presentationParameters); + void SetGammaRamp(bool calibrate, GammaRamp* ramp); + void SetRenderTarget(int renderTargetIndex, RenderTarget2D* renderTarget); void SetVertexShaderConstant(int startRegister, Matrix constantData); void SetVertexShaderConstant(int startRegister, Vector4 constantData); }; diff --git a/include/Graphics/RenderTarget.h b/include/Graphics/RenderTarget.h new file mode 100644 index 0000000..7a12617 --- /dev/null +++ b/include/Graphics/RenderTarget.h @@ -0,0 +1,62 @@ +/******************************************************** + * RenderTarget.h * + * * + * XFX RenderTarget definition file * + * Copyright © XFX Team. All Rights Reserved * + ********************************************************/ +#ifndef _XFX_GRAPHICS_RENDERTARGET_ +#define _XFX_GRAPHICS_RENDERTARGET_ + +#include +#include +#include "Enums.h" + +using namespace System; + +namespace XFX +{ + namespace Graphics + { + class RenderTarget : public IDisposable, virtual Object + { + private: + bool isContentLost; + bool isDisposed; + + protected: + GraphicsDevice* graphicsDevice; + SurfaceFormat_t format; + int width; + int height; + int multiSampleQuality; + MultiSampleType_t multiSampleType; + RenderTargetUsage_t renderTargetUsage; + int numLevels; + + virtual void Dispose(bool disposing); + virtual void raise_ContentLost(Object* sender, EventArgs e); + void raise_Disposing(Object* sender, EventArgs e); + + public: + SurfaceFormat_t getFormat(); + GraphicsDevice* getGraphicsDevice(); + int Height(); + bool IsContentLost(); + bool IsDisposed(); + int MultiSampleQuality(); + MultiSampleType_t getMultiSampleType(); + char* Name; + Object* Tag; + int Width(); + + EventHandler ContentLost; + EventHandler Disposing; + + virtual ~RenderTarget(); + + void Dispose(); + }; + } +} + +#endif //_XFX_GRAPHICS_RENDERTARGET_ diff --git a/include/Graphics/RenderTarget2D.h b/include/Graphics/RenderTarget2D.h new file mode 100644 index 0000000..dd86e8c --- /dev/null +++ b/include/Graphics/RenderTarget2D.h @@ -0,0 +1,43 @@ +/******************************************************** + * RenderTarget2D.h * + * * + * XFX RenderTarget2D definition file * + * Copyright © XFX Team. All Rights Reserved * + ********************************************************/ +#ifndef _XFX_GRAPHICS_RENDERTARGET2D_ +#define _XFX_GRAPHICS_RENDERTARGET2D_ + +#include +#include "RenderTarget.h" +//#include "Texture2D.h" + +using namespace System; + +namespace XFX +{ + namespace Graphics + { + class GraphicsDevice; + class Texture2D; + + class RenderTarget2D : public RenderTarget, virtual Object + { + private: + Texture2D* texture; + int renderBufferIdentifier; + + protected: + void Dispose(bool disposing); + + public: + RenderTarget2D(GraphicsDevice* graphicsDevice, int width, int height, int numberLevels, SurfaceFormat_t format); + RenderTarget2D(GraphicsDevice* graphicsDevice, int width, int height, int numberLevels, SurfaceFormat_t format, MultiSampleType_t multiSampleType, int multiSampleQuality); + RenderTarget2D(GraphicsDevice* graphicsDevice, int width, int height, int numberLevels, SurfaceFormat_t format, RenderTargetUsage_t usage); + RenderTarget2D(GraphicsDevice* graphicsDevice, int width, int height, int numberLevels, SurfaceFormat_t format, MultiSampleType_t multiSampleType, int multiSampleQuality, RenderTargetUsage_t usage); + + Texture2D* GetTexture(); + }; + } +} + +#endif //_XFX_GRAPHICS_RENDERTARGET2D_ diff --git a/include/Graphics/Texture2D.h b/include/Graphics/Texture2D.h index ba68087..91e6e7f 100644 --- a/include/Graphics/Texture2D.h +++ b/include/Graphics/Texture2D.h @@ -9,6 +9,7 @@ #include "Texture.h" #include +#include using namespace System; using namespace System::IO; @@ -47,7 +48,7 @@ namespace XFX Texture2D(); Texture2D(GraphicsDevice* graphicsDevice, int width, int height); Texture2D(GraphicsDevice* graphicsDevice, int width, int height, int numberLevels, TextureUsage_t usage, SurfaceFormat_t format); - Texture2D(const Texture2D &obj); + Texture2D(const Texture2D &obj); // Copy constructor static Texture2D* FromFile(GraphicsDevice* graphicsDevice, Stream* textureStream); static Texture2D* FromFile(GraphicsDevice* graphicsDevice, Stream* textureStream, TextureCreationParameters creationParameters); diff --git a/include/Graphics/TextureCollection.h b/include/Graphics/TextureCollection.h index 37cb1a8..55bdedd 100644 --- a/include/Graphics/TextureCollection.h +++ b/include/Graphics/TextureCollection.h @@ -8,16 +8,15 @@ #define _XFX_GRAPHICS_TEXTURECOLLECTION_ #include -#include "Texture.h" using namespace System::Collections::Generic; namespace XFX { - class Texture; - namespace Graphics { + class Texture; + /// /// Represents a collection of Texture objects. /// @@ -26,13 +25,14 @@ namespace XFX private: bool disposed; List textures; - void Dispose(); void Dispose(bool disposing); public: TextureCollection(); ~TextureCollection(); + void Dispose(); + Texture* operator[](int index); }; } diff --git a/include/Graphics/Viewport.h b/include/Graphics/Viewport.h index 88c7811..0adc9e2 100644 --- a/include/Graphics/Viewport.h +++ b/include/Graphics/Viewport.h @@ -31,8 +31,13 @@ namespace XFX int X; int Y; + bool Equals(Viewport obj); + int GetHashCode(); Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world); Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world); + + bool operator !=(Viewport right); + bool operator ==(Viewport right); }; } } diff --git a/include/Net/Enums.h b/include/Net/Enums.h index 10f4135..de0f930 100644 --- a/include/Net/Enums.h +++ b/include/Net/Enums.h @@ -11,9 +11,6 @@ namespace XFX { namespace Net { - /// - /// Defines the reason a session ended. - /// struct NetworkSessionEndReason { enum type @@ -24,9 +21,7 @@ namespace XFX Disconnected }; }; - /// - /// Contains additional data about a NetworkSessionJoinException. - /// + struct NetworkSessionJoinError { enum type @@ -36,9 +31,7 @@ namespace XFX SessionFull }; }; - /// - /// Defines the different states of a multiplayer session. - /// + struct NetworkSessionState { enum type @@ -48,9 +41,7 @@ namespace XFX Ended }; }; - /// - /// Defines the different types of a multiplayer session. - /// + struct NetworkSessionType { enum type @@ -62,9 +53,6 @@ namespace XFX }; }; - /// - /// Defines options for network packet transmission. - /// struct SendDataOptions { enum type @@ -76,11 +64,11 @@ namespace XFX }; }; - typedef NetworkSessionEndReason::type NetworkSessionEndReason_t; - typedef NetworkSessionJoinError::type NetworkSessionJoinError_t; - typedef NetworkSessionState::type NetworkSessionState_t; - typedef NetworkSessionType::type NetworkSessionType_t; - typedef SendDataOptions::type SendDataOptions_t; + typedef NetworkSessionEndReason::type NetworkSessionEndReason_t; // Defines the reason a session ended. + typedef NetworkSessionJoinError::type NetworkSessionJoinError_t; // Contains additional data about a NetworkSessionJoinException. + typedef NetworkSessionState::type NetworkSessionState_t; // Defines the different states of a multiplayer session. + typedef NetworkSessionType::type NetworkSessionType_t; // Defines the different types of a multiplayer session. + typedef SendDataOptions::type SendDataOptions_t; // Defines options for network packet transmission. } } diff --git a/include/Net/PacketReader.h b/include/Net/PacketReader.h index e03e698..ef25736 100644 --- a/include/Net/PacketReader.h +++ b/include/Net/PacketReader.h @@ -15,10 +15,8 @@ namespace XFX namespace Net { - /// - /// Provides common functionality for efficiently reading incoming network packets. - /// - class PacketReader : public BinaryReader + // Provides common functionality for efficiently reading incoming network packets. + class PacketReader : public BinaryReader, virtual Object { public: int Length(); diff --git a/include/Storage/StorageContainer.h b/include/Storage/StorageContainer.h index ef80073..fcc9c8d 100644 --- a/include/Storage/StorageContainer.h +++ b/include/Storage/StorageContainer.h @@ -26,11 +26,12 @@ namespace XFX /// class StorageContainer : public IDisposable, virtual Object { + friend class StorageDevice; + private: bool isDisposed; DirectoryInfo containerFolder; StorageDevice* device; - EventHandler Disposing; PlayerIndex_t playerIndex; char* titleName; @@ -38,9 +39,11 @@ namespace XFX ~StorageContainer(); public: + EventHandler Disposing; + bool IsDisposed(); char* Path(); - StorageDevice StorageDevice_(); + StorageDevice* StorageDevice_(); static char* TitleLocation(); char* TitleName(); diff --git a/include/Storage/StorageDevice.h b/include/Storage/StorageDevice.h index 3045fc0..bacb20c 100644 --- a/include/Storage/StorageDevice.h +++ b/include/Storage/StorageDevice.h @@ -8,10 +8,18 @@ #define _XFX_STORAGE_STORAGEDEVICE_ #include +#include #include "../Enums.h" +using namespace System; + namespace XFX { + namespace GamerServices + { + class Guide; + } + namespace Storage { class StorageContainer; @@ -19,13 +27,15 @@ namespace XFX /// /// Represents a storage device for user data, such as a memory unit or hard drive. /// - class StorageDevice + class StorageDevice : virtual Object { + friend class XFX::GamerServices::Guide; + private: PlayerIndex_t _playerIndex; - bool _playerSpecified; + uint _deviceIndex; - StorageDevice(PlayerIndex_t playerIndex, bool playerSpecified); + StorageDevice(uint deviceIndex, PlayerIndex_t playerIndex); public: long long FreeSpace(); diff --git a/include/System/Collections/Generic/Dictionary.h b/include/System/Collections/Generic/Dictionary.h index a555e28..5fef776 100644 --- a/include/System/Collections/Generic/Dictionary.h +++ b/include/System/Collections/Generic/Dictionary.h @@ -9,9 +9,7 @@ #include #include -#include -#include -#include "HashHelpers.h" +#include "EqualityComparer.h" #include "Interfaces.h" #include "KeyValuePair.h" @@ -70,66 +68,16 @@ namespace System Dictionary* _dictionary; public: - int Count() - { - return _dictionary.Count(); - } + int Count(); - KeyCollection(Dictionary dictionary) - { - _dictionary = &dictionary; - } + KeyCollection(Dictionary dictionary); + KeyCollection(const KeyCollection &obj); - KeyCollection(const KeyCollection &obj) - { - _dictionary = &obj._dictionary; - } - - void Add(UKey item) - { - throw NotSupportedException("Adding keys directly to the Dictionary::Keycollection is not supported."); - } - - void Clear() - { - throw NotSupportedException("Directly clearing the Dictionary::KeyCollection is not supported."); - } - - bool Contains(UKey item) - { - return _dictionary.ContainsKey(item); - } - - void CopyTo(UKey array[], int index) - { - if(array == null) - { - throw ArgumentNullException("array"); - } - if((index < 0) ||(index > Array::Length(array))) - { - throw ArgumentOutOfRangeException("index", "Non-negative array index required."); - } - if((Array::Length(array) - index) < _dictionary.Count()) - { - throw ArgumentException("Array plus offset too small."); - } - int count = _dictionary.Count(); - Entry entries[] = _dictionary.entries; - for(int i = 0; i < count; i++) - { - if(entries[i].hashCode >= 0) - { - array[index++] = entries[i].key; - } - } - } - - bool Remove(UKey item) - { - throw NotSupportedException("Removing keys directly from the Dictionary::KeyCollection is not supported."); - return false; - } + void Add(UKey item); + void Clear(); + bool Contains(UKey item); + void CopyTo(UKey array[], int index); + bool Remove(UKey item); }; /// @@ -174,82 +122,171 @@ namespace System }*/ } Dictionary(int capacity); - ~Dictionary() - { - delete[] buckets; - delete[] entries; - } + ~Dictionary(); void Add(TKey key, TValue value) { Insert(key, value, true); } - void Clear() - { - if(count > 0) - { - for(int i = 0; i < Array::Length(buckets); i++) - { - buckets[i] = -1; - } - Array::Clear(entries, 0, count); - freeList = -1; - count = 0; - freeCount = 0; - version++; - } - } - + void Clear(); bool ContainsKey(TKey key); bool ContainsValue(TValue value); - bool Remove(TKey key) - { - if(buckets) - { - int num = comparer->GetHashCode(key) & 0x7fffffff; - int index = num % Array::Length(buckets); - int num3 = -1; - for(int i = buckets[index]; i >= 0; i = entries[i].next) - { - if((entries[i].hashCode == num) && comparer->Equals(entries[i].key, key)) - { - if(num3 < 0) - { - buckets[index] = entries[i].next; - } - else - { - entries[num3].next = entries[i].next; - } - entries[i].hashCode = -1; - entries[i].next = freeList; - entries[i].key = TKey(); - entries[i].value = TValue(); - freeList = i; - freeCount++; - version++; - return true; - } - num3 = i; - } - } - return false; - } + bool Remove(TKey key); + bool TryGetValue(TKey key, out TValue value); + }; - bool TryGetValue(TKey key, out TValue value) + ////////////////////////////////////////////////////////////////////// + + template + template + int Dictionary::KeyCollection::Count() + { + return _dictionary->Count(); + } + + template + template + Dictionary::KeyCollection::KeyCollection(Dictionary dictionary) + { + _dictionary = &dictionary; + } + + template + template + Dictionary::KeyCollection::KeyCollection(const KeyCollection &obj) + { + _dictionary = obj._dictionary; + } + + template + template + void Dictionary::KeyCollection::Add(UKey item) + { + throw NotSupportedException("Adding keys directly to the Dictionary::Keycollection is not supported."); + } + + template + template + void Dictionary::KeyCollection::Clear() + { + throw NotSupportedException("Directly clearing the Dictionary::KeyCollection is not supported."); + } + + template + template + bool Dictionary::KeyCollection::Contains(UKey item) + { + return _dictionary.ContainsKey(item); + } + + template + template + void Dictionary::KeyCollection::CopyTo(UKey array[], int index) + { + if(array == null) { - int index = FindEntry(key); - if(index >= 0) - { - value = entries[index].value; - return true; - } - value = TValue(); - return false; + throw ArgumentNullException("array"); } - }; + if((index < 0) ||(index > Array::Length(array))) + { + throw ArgumentOutOfRangeException("index", "Non-negative array index required."); + } + if((Array::Length(array) - index) < _dictionary.Count()) + { + throw ArgumentException("Array plus offset too small."); + } + int count = _dictionary.Count(); + Entry entries[] = _dictionary.entries; + for(int i = 0; i < count; i++) + { + if(entries[i].hashCode >= 0) + { + array[index++] = entries[i].key; + } + } + } + + template + template + bool Dictionary::KeyCollection::Remove(UKey item) + { + throw NotSupportedException("Removing keys directly from the Dictionary::KeyCollection is not supported."); + return false; + } + + template + Dictionary::~Dictionary() + { + delete[] buckets; + delete[] entries; + } + + template + void Dictionary::Clear() + { + if(count > 0) + { + for(int i = 0; i < Array::Length(buckets); i++) + { + buckets[i] = -1; + } + Array::Clear(entries, 0, count); + freeList = -1; + count = 0; + freeCount = 0; + version++; + } + } + + template + bool Dictionary::Remove(TKey key) + { + if(buckets) + { + int num = comparer->GetHashCode(key) & 0x7fffffff; + int index = num % Array::Length(buckets); + int num3 = -1; + for(int i = buckets[index]; i >= 0; i = entries[i].next) + { + if((entries[i].hashCode == num) && comparer->Equals(entries[i].key, key)) + { + if(num3 < 0) + { + buckets[index] = entries[i].next; + } + else + { + entries[num3].next = entries[i].next; + } + entries[i].hashCode = -1; + entries[i].next = freeList; + entries[i].key = TKey(); + entries[i].value = TValue(); + freeList = i; + freeCount++; + version++; + return true; + } + num3 = i; + } + } + return false; + } + + template + bool Dictionary::TryGetValue(TKey key, out TValue value) + { + int index = FindEntry(key); + if(index >= 0) + { + value = entries[index].value; + return true; + } + value = TValue(); + return false; + } } } } diff --git a/include/System/Collections/Generic/Interfaces.h b/include/System/Collections/Generic/Interfaces.h index 8a7dc4a..bcb97b0 100644 --- a/include/System/Collections/Generic/Interfaces.h +++ b/include/System/Collections/Generic/Interfaces.h @@ -54,8 +54,8 @@ namespace System virtual bool Remove(TKey key)=0; virtual bool TryGetValue(TKey key, out TValue value)=0; - virtual ICollection Keys()=0; - virtual ICollection Values()=0; + virtual ICollection& Keys()=0; + virtual ICollection& Values()=0; }; /// @@ -75,7 +75,7 @@ namespace System interface IEnumerable { public: - virtual IEnumerator GetEnumerator()=0; + virtual IEnumerator& GetEnumerator()=0; }; /// diff --git a/include/System/Collections/Generic/List.h b/include/System/Collections/Generic/List.h index e11c608..de65182 100644 --- a/include/System/Collections/Generic/List.h +++ b/include/System/Collections/Generic/List.h @@ -334,7 +334,7 @@ namespace System if (other._size == 0) // is other array is empty -- clear this array Clear(); - Capacity(other._size); // set size + setCapacity(other._size); // set size memcpy(_items, other._items, sizeof(T) * other._size); diff --git a/include/System/IO/StreamAsyncResult.h b/include/System/IO/StreamAsyncResult.h index 7cdcdb6..fcf7e2c 100644 --- a/include/System/IO/StreamAsyncResult.h +++ b/include/System/IO/StreamAsyncResult.h @@ -9,6 +9,7 @@ #include "../Exception.h" #include "../Interfaces.h" +#include "../Object.h" #include "../Types.h" #include "../Threading/WaitHandle.h" @@ -19,7 +20,7 @@ namespace System /// /// /// - class StreamAsyncResult : public IAsyncResult + class StreamAsyncResult : public IAsyncResult, virtual Object { Object* _state; bool completed; @@ -29,7 +30,7 @@ namespace System public: Object* ASyncState(); - Threading::WaitHandle AsyncWaitHandle(); + Threading::WaitHandle* AsyncWaitHandle(); virtual bool CompletedSynchronously(); bool IsCompleted(); Exception* Exception_(); diff --git a/include/System/Interfaces.h b/include/System/Interfaces.h index 32fa8d2..894c814 100644 --- a/include/System/Interfaces.h +++ b/include/System/Interfaces.h @@ -19,8 +19,8 @@ namespace System interface IAsyncResult { public: - virtual Object* ASyncState()=0; - virtual Threading::WaitHandle AsyncWaitHandle()=0; + virtual Object* AsyncState()=0; + virtual Threading::WaitHandle* AsyncWaitHandle()=0; virtual bool CompletedSynchronously()=0; virtual bool IsCompleted()=0; }; diff --git a/src/libSystem/libSystem.vcproj b/src/libSystem/libSystem.vcproj index 5952c2e..b5171b7 100644 --- a/src/libSystem/libSystem.vcproj +++ b/src/libSystem/libSystem.vcproj @@ -129,6 +129,10 @@ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > + + diff --git a/src/libSystem/makefile b/src/libSystem/makefile new file mode 100644 index 0000000..200bab4 --- /dev/null +++ b/src/libSystem/makefile @@ -0,0 +1,49 @@ +# +# update this variable to wherever you installed the OpenXDK libraries +# +######################################################################### +PREFIX = /usr/local/openxdk + +CC = gcc +CCAS = gcc +CPP = g++ +AR = ar rcu +RANLIB = ranlib +CXBE = $(PREFIX)/bin/cxbe + +SDLFLAGS = -DENABLE_XBOX -DDEBUG +CC_FLAGS = -c -g -std=gnu99 -ffreestanding -nostdlib -fno-builtin -fno-exceptions -mno-cygwin -march=i386 -mmmx -msse -mfpmath=sse $(SDLFLAGS) +CCAS_FLAGS = --32 -march=pentiumiii, mmx, sse -mtune=pentiumiii -msse-check=error +CPP_FLAGS = -c -O2 -Wall -nostdlib -fno-builtin -mno-cygwin -march=i386 -mmmx -msse -mfpmath=sse $(SDLFLAGS) +INCLUDE = -I$(PREFIX)/i386-pc-xbox/include -I$(PREFIX)/include -I$(PREFIX)/include/SDL -I../../include + +CLINK = -nostdlib +ALIGN = -Wl,--file-alignment,0x20 -Wl,--section-alignment,0x20 +SHARED = -shared +ENTRYPOINT = -Wl,--entry,_WinMainCRTStartup +STRIP = -Wl,--strip-all +LD_FLAGS = $(CLINK) $(ALIGN) $(SHARED) $(ENTRYPOINT) $(STRIP) +LD_DIRS = -L$(PREFIX)/i386-pc-xbox/lib -L$(PREFIX)/lib +LD_LIBS = $(LD_DIRS) -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc -lstdc++ -lgcc + +OBJS = + +all: libSystem.a + +rebuild: clean libSystem.a + +libSystem.a: $(OBJS) + $(AR) $@ $(OBJS) + $(RANLIB) $@ + +.c.o: + $(CC) -c $< $(CC_FLAGS) $(INCLUDE) + +.cpp.o: + $(CPP) -c $< $(CPP_FLAGS) $(INCLUDE) + +.s.o: + $(CCAS) -c $< $(CCAS_FLAGS) + +clean: + rm -f *.o *.exe *.dll *.xbe *.cxbe *.lib *.a diff --git a/src/libXFX/GraphicsDevice.cpp b/src/libXFX/GraphicsDevice.cpp index 8b18792..0f37787 100644 --- a/src/libXFX/GraphicsDevice.cpp +++ b/src/libXFX/GraphicsDevice.cpp @@ -44,13 +44,54 @@ namespace XFX { namespace Graphics { + GraphicsDeviceCreationParameters GraphicsDevice::CreationParameters() + { + + } + + DepthStencilBuffer GraphicsDevice::getDepthStencilBuffer() + { + return _depthStencilBuffer; + } + + void GraphicsDevice::setDepthStencilBuffer(DepthStencilBuffer buffer) + { + _depthStencilBuffer = buffer; + } + + void GraphicsDevice::setPresentationParameters(PresentationParameters* presentationParameters) + { + viewport.X = 0; + viewport.Y = 0; + viewport.Width = presentationParameters->BackBufferWidth; + viewport.Height = presentationParameters->BackBufferHeight; + + + } + + Viewport GraphicsDevice::getViewport() + { + return viewport; + } + + void GraphicsDevice::setViewport(Viewport value) + { + if (viewport != value) + { + + } + } + TextureCollection GraphicsDevice::Textures() { return textures; } - GraphicsDevice::GraphicsDevice(GraphicsAdapter adapter, DeviceType_t deviceType, PresentationParameters presentationParameters) + GraphicsDevice::GraphicsDevice(GraphicsAdapter* adapter, DeviceType_t deviceType, PresentationParameters* presentationParameters) { + if (adapter == null || presentationParameters == null) + throw new ArgumentNullException("adapter or presentationParameters is null."); + _adapter = adapter; if(deviceType != DeviceType::Hardware) throw DeviceNotSupportedException("Only DeviceType::Hardware is supported."); @@ -110,29 +151,6 @@ namespace XFX glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity();*/ } - - void GraphicsDevice::Clear(ClearOptions_t options, Color color, float depth, int stencil) - { - if(isDisposed) - throw ObjectDisposedException("GraphicsDevice"); - - switch(options) - { - case ClearOptions::Depth: - { - - } - case ClearOptions::Stencil: - { - - } - case ClearOptions::Target: - { - - } - - } - } void GraphicsDevice::Dispose() { @@ -141,15 +159,51 @@ namespace XFX void GraphicsDevice::Dispose(bool disposing) { - if(disposing) + if (!isDisposed) { - + if(disposing) + { + textures.Dispose(); + + isDisposed = true; + } } } - void GraphicsDevice::SetVertexShaderConstant(int startRegister, Vector4 constantData) + void GraphicsDevice::raise_DeviceLost(Object* sender, EventArgs e) { + if (DeviceLost != null) + DeviceLost(sender, e); + } + void GraphicsDevice::raise_DeviceReset(Object* sender, EventArgs e) + { + if (DeviceReset != null) + DeviceReset(sender, e); + } + + void GraphicsDevice::raise_DeviceResetting(Object* sender, EventArgs e) + { + if (DeviceResetting != null) + DeviceResetting(sender, e); + } + + void GraphicsDevice::raise_Disposing(Object* sender, EventArgs e) + { + if (Disposing != null) + Disposing(sender, e); + } + + void GraphicsDevice::Reset() + { + Reset(getPresentationParameters()); + } + + void GraphicsDevice::Reset(PresentationParameters* presentationParameters) + { + raise_DeviceResetting(this, EventArgs::Empty); + setPresentationParameters(presentationParameters); + raise_DeviceReset(this, EventArgs::Empty); } } } diff --git a/src/libXFX/Guide.cpp b/src/libXFX/Guide.cpp index e9b9750..0544e50 100644 --- a/src/libXFX/Guide.cpp +++ b/src/libXFX/Guide.cpp @@ -26,6 +26,8 @@ // POSSIBILITY OF SUCH DAMAGE. #include +#include +#include #include namespace XFX @@ -52,6 +54,12 @@ namespace XFX return null; } + IAsyncResult* Guide::BeginShowMessageBox(PlayerIndex_t player, char* title, char* text, IEnumerable* buttons, int focusButton, MessageBoxIcon_t icon, AsyncCallback callback, Object* state) + { + // just return null to stop warning until this thing's coded + return null; + } + IAsyncResult* Guide::BeginShowStorageDeviceSelector(int sizeInBytes, int directoryCount, AsyncCallback callback, Object* state) { // just return null to stop warning until this thing's coded @@ -82,8 +90,20 @@ namespace XFX return ""; } - StorageDevice Guide::EndShowStorageDeviceSelector(IAsyncResult* result) + int Guide::EndShowMessageBox(IAsyncResult* result) { + // Since C++ doesn't have a nullable type, we return -1, since it represents an invalid value anyways. + return -1; + } + + StorageDevice Guide::EndShowStorageDeviceSelector(IAsyncResult* asyncResult) + { + StorageDeviceAsyncResult* result = (StorageDeviceAsyncResult*)asyncResult; + if (!result) + { + throw ArgumentNullException("result"); + } + return StorageDevice(0, (PlayerIndex_t)result->playerIndex); } } } diff --git a/src/libXFX/Matrix.cpp b/src/libXFX/Matrix.cpp index 6eb91cd..16f8dc8 100644 --- a/src/libXFX/Matrix.cpp +++ b/src/libXFX/Matrix.cpp @@ -903,34 +903,35 @@ namespace XFX int Matrix::Decompose(Vector3 scale, Quaternion rotation, Vector3 translation) { - //Get the translation. translation.X = M41; translation.Y = M42; translation.Z = M43; - //Scaling is the length of the rows. - scale.X = (float)Math::Sqrt((M11 * M11) + (M12 * M12) + (M13 * M13)); - scale.Y = (float)Math::Sqrt((M21 * M21) + (M22 * M22) + (M23 * M23)); - scale.Z = (float)Math::Sqrt((M31 * M31) + (M32 * M32) + (M33 * M33)); - //If any of the scaling factors are zero, than the rotation matrix can not exist. - if (Math::Abs(scale.X) < 1e-6f || - Math::Abs(scale.Y) < 1e-6f || - Math::Abs(scale.Z) < 1e-6f) + float xs, ys, zs; + if (Math::Sign(M11 * M12 * M13 * M14) < 0) + xs = -1.0f; + else + xs = 1.0f; + if (Math::Sign(M21 * M22 * M23 * M24) < 0) + ys = -1.0f; + else + ys = 1.0f; + if (Math::Sign(M31 * M32 * M33 * M34) < 0) + zs = -1.0f; + else + zs = 1.0f; + scale.X = xs * (float)Math::Sqrt(M11 * M11 + M12 * M12 + M13 * M13); + scale.Y = ys * (float)Math::Sqrt(M21 * M21 + M22 * M22 + M23 * M23); + scale.Z = zs * (float)Math::Sqrt(M31 * M31 + M32 * M32 + M33 * M33); + if (scale.X == 0.0 || scale.Y == 0.0 || scale.Z == 0.0) { rotation = Quaternion::Identity; return false; - } //The rotation is the left over matrix after dividing out the scaling. - Matrix rotationmatrix = Matrix(); - rotationmatrix.M11 = M11 / scale.X; - rotationmatrix.M12 = M12 / scale.X; - rotationmatrix.M13 = M13 / scale.X; - rotationmatrix.M21 = M21 / scale.Y; - rotationmatrix.M22 = M22 / scale.Y; - rotationmatrix.M23 = M23 / scale.Y; - rotationmatrix.M31 = M31 / scale.Z; - rotationmatrix.M32 = M32 / scale.Z; - rotationmatrix.M33 = M33 / scale.Z; - rotationmatrix.M44 = 1.0f; - Quaternion::CreateFromRotationMatrix(rotationmatrix, rotation); + } + Matrix m1 = Matrix(M11/scale.X, M12/scale.X, M13/scale.X, 0, + M21/scale.Y, M22/scale.Y, M23/scale.Y, 0, + M31/scale.Z, M32/scale.Z, M33/scale.Z, 0, + 0, 0, 0, 1); + rotation = Quaternion::CreateFromRotationMatrix(m1); return true; } diff --git a/src/libXFX/PacketReader.cpp b/src/libXFX/PacketReader.cpp index 0f7dd65..cfb2284 100644 --- a/src/libXFX/PacketReader.cpp +++ b/src/libXFX/PacketReader.cpp @@ -38,17 +38,17 @@ namespace XFX { int PacketReader::Length() { - return (int)BaseStream().Length(); + return (int)BaseStream()->Length(); } int PacketReader::Position() { - return (int)BaseStream().Position; + return (int)BaseStream()->Position; } int PacketReader::Position(int newValue) { - BaseStream().Position = newValue; + BaseStream()->Position = newValue; } PacketReader::PacketReader() diff --git a/src/libXFX/RenderTarget.cpp b/src/libXFX/RenderTarget.cpp new file mode 100644 index 0000000..b22952b --- /dev/null +++ b/src/libXFX/RenderTarget.cpp @@ -0,0 +1,56 @@ +// Copyright (C) 2010-2012, XFX Team +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the copyright holder nor the names of any +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#include + +namespace XFX +{ + namespace Graphics + { + RenderTarget::~RenderTarget() + { + Dispose(false); + } + + void RenderTarget::Dispose() + { + Dispose(true); + } + + void RenderTarget::Dispose(bool disposing) + { + if (!isDisposed) + { + if (disposing) + { + } + + isDisposed = true; + } + } + } +} diff --git a/src/libXFX/RenderTarget2D.cpp b/src/libXFX/RenderTarget2D.cpp new file mode 100644 index 0000000..56bb7c3 --- /dev/null +++ b/src/libXFX/RenderTarget2D.cpp @@ -0,0 +1,35 @@ +// Copyright (C) 2010-2012, XFX Team +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the copyright holder nor the names of any +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#include + +namespace XFX +{ + namespace Graphics + { + } +} diff --git a/src/libXFX/StorageDevice.cpp b/src/libXFX/StorageDevice.cpp index 028c5c8..f1107ce 100644 --- a/src/libXFX/StorageDevice.cpp +++ b/src/libXFX/StorageDevice.cpp @@ -47,12 +47,18 @@ namespace XFX { } + StorageDevice::StorageDevice(uint deviceIndex, PlayerIndex_t playerIndex) + { + _playerIndex = playerIndex; + _deviceIndex = deviceIndex; + } + StorageContainer StorageDevice::OpenContainer(char* titleName) { - if(titleName == null || titleName == "") + if(!titleName || titleName == "") throw ArgumentNullException("Non-null title name required."); - //return StorageContainer(*this, titleName, _playerSpecified, _playerIndex); + return StorageContainer(*this, titleName, _deviceIndex, _playerIndex); } } } diff --git a/src/libXFX/StorageDeviceAsyncResult.cpp b/src/libXFX/StorageDeviceAsyncResult.cpp new file mode 100644 index 0000000..7f1ea5d --- /dev/null +++ b/src/libXFX/StorageDeviceAsyncResult.cpp @@ -0,0 +1,35 @@ + +#include + +namespace XFX +{ + namespace GamerServices + { + Object* StorageDeviceAsyncResult::AsyncState() + { + return syncObject; + } + + bool StorageDeviceAsyncResult::CompletedSynchronously() + { + return true; + } + + StorageDeviceAsyncResult::StorageDeviceAsyncResult(Object* stateObject, int player) + { + syncObject = stateObject; + playerIndex = player; + } + + StorageDeviceAsyncResult::StorageDeviceAsyncResult(const StorageDeviceAsyncResult &obj) + { + syncObject = obj.syncObject; + playerIndex = obj.playerIndex; + } + + StorageDeviceAsyncResult::StorageDeviceAsyncResult(IAsyncResult* &obj) + { + + } + } +} diff --git a/src/libXFX/Viewport.cpp b/src/libXFX/Viewport.cpp index d765abc..2f64ea6 100644 --- a/src/libXFX/Viewport.cpp +++ b/src/libXFX/Viewport.cpp @@ -48,6 +48,18 @@ namespace XFX return ((-1.401298E-45f <= num) && (num <= 1.401298E-45f)); } + bool Viewport::Equals(Viewport obj) + { + return ((AspectRatio() == obj.AspectRatio()) && (Height == obj.Height) && + (MaxDepth == obj.MaxDepth) && (MinDepth == obj.MinDepth) && + (Width == obj.Width) && (X == obj.X) && (Y == obj.Y)); + } + + int Viewport::GetHashCode() + { + return ((int)AspectRatio() + Height + MaxDepth + MinDepth + Width + X + Y); + } + Vector3 Viewport::Project(Vector3 source, Matrix projection, Matrix view, Matrix world) { Matrix matrix = Matrix::Multiply(Matrix::Multiply(world, view), projection); @@ -78,5 +90,15 @@ namespace XFX } return position; } + + bool Viewport::operator !=(Viewport right) + { + return !Equals(right); + } + + bool Viewport::operator ==(Viewport right) + { + return Equals(right); + } } } diff --git a/src/libXFX/libXFX.vcproj b/src/libXFX/libXFX.vcproj index a3c9c82..1e1aafe 100644 --- a/src/libXFX/libXFX.vcproj +++ b/src/libXFX/libXFX.vcproj @@ -223,6 +223,14 @@ RelativePath=".\PresentationParameters.cpp" > + + + + @@ -327,6 +335,10 @@ RelativePath=".\Guide.cpp" > + + + + + + @@ -645,6 +665,10 @@ RelativePath="..\..\include\GamerServices\Guide.h" > + +