mirror of
https://github.com/Halofreak1990/XFXFramework
synced 2024-12-26 13:49:34 +01:00
Added some ContentTypeReaders
Added xnbbuild project skeleton Added Model and supporting classes Updated files
This commit is contained in:
parent
535340971d
commit
c56db35373
2
.gitignore
vendored
2
.gitignore
vendored
@ -46,7 +46,7 @@ local.properties
|
||||
[Rr]elease/
|
||||
*_i.c
|
||||
*_p.c
|
||||
[Bb]uild[Ll]og.*
|
||||
[Bb]uild[Ll]og.htm
|
||||
*.a
|
||||
|
||||
*.ilk
|
||||
|
@ -1,7 +1,7 @@
|
||||
# XFXFramework
|
||||
## C++ implementation of XNA For XBOX
|
||||
|
||||
XFX, or [XNA](http://en.wikipedia.org/wiki/Microsoft_XNA) for [XBOX](http://en.wikipedia.org/wiki/Xbox_(console)) is an implementation of [XNA](http://en.wikipedia.org/wiki/Microsoft_XNA), written in C++ for Microsofts [XBOX](http://en.wikipedia.org/wiki/Xbox_(console)) console.
|
||||
XFX, or [XNA](http://en.wikipedia.org/wiki/Microsoft_XNA) for [XBOX](http://en.wikipedia.org/wiki/Xbox_(console)) is an implementation of [XNA](http://en.wikipedia.org/wiki/Microsoft_XNA) 4.0, written in C++ for Microsofts [XBOX](http://en.wikipedia.org/wiki/Xbox_(console)) console.
|
||||
It's written on top of [OpenXDK](http://sourceforge.net/projects/openxdk/), the open source, free, legal XBOX Development Kit.
|
||||
|
||||
XFX is an attempt to bring development for the original [XBOX](http://en.wikipedia.org/wiki/Xbox_(console)) console to the masses by wrapping all low-level code in the familiar XNA classes.
|
||||
@ -9,7 +9,7 @@ Being written in C++ allows XFX to be lightweight and as close to the hardware a
|
||||
|
||||
Compiling XFX requires at least OpenXDK version 0.7
|
||||
|
||||
|
||||
## Contents
|
||||
As of this writing, XFX Contains the following libraries:
|
||||
* libmscorlib - Provides the necessary classes found in mscorlib.dll to support the other libraries
|
||||
* libSystem - Implements any types in the System.dll required by the other libs
|
||||
@ -17,3 +17,5 @@ As of this writing, XFX Contains the following libraries:
|
||||
* libSystem.Xml - Implements the functions found in System.Xml.dll
|
||||
* libXFX - Implements the functions found in Microsoft.Xna.Framework.dll
|
||||
* libXFX.Game - Implements the functions found in Microsoft.Xna.Framework.Game.dll
|
||||
|
||||
XFX Supports loading assets both from precompiled .XNB files and most XNA-compatible formats.
|
||||
|
6
XFX.sln
6
XFX.sln
@ -18,6 +18,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSystem", "src\libSystem\
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSystem.Windows", "src\libSystem.Windows\libSystem.Windows.vcxproj", "{4A050C55-9479-4AE9-8B7A-62A6B89739BD}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xnbbuild", "src\xnbbuild\xnbbuild.vcxproj", "{E5F1599D-C9FE-4EFB-97B6-13B46D4A1E35}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
@ -48,6 +50,10 @@ Global
|
||||
{4A050C55-9479-4AE9-8B7A-62A6B89739BD}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{4A050C55-9479-4AE9-8B7A-62A6B89739BD}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{4A050C55-9479-4AE9-8B7A-62A6B89739BD}.Release|Win32.Build.0 = Release|Win32
|
||||
{E5F1599D-C9FE-4EFB-97B6-13B46D4A1E35}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E5F1599D-C9FE-4EFB-97B6-13B46D4A1E35}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E5F1599D-C9FE-4EFB-97B6-13B46D4A1E35}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E5F1599D-C9FE-4EFB-97B6-13B46D4A1E35}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,9 +1,9 @@
|
||||
/********************************************************
|
||||
* ContentReader.h *
|
||||
* *
|
||||
* XFX ContentReader class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
********************************************************/
|
||||
/*****************************************************************************
|
||||
* ContentReader.h *
|
||||
* *
|
||||
* XFX ContentReader class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _XFX_CONTENT_CONTENTREADER_
|
||||
#define _XFX_CONTENT_CONTENTREADER_
|
||||
|
||||
@ -28,8 +28,10 @@ namespace XFX
|
||||
template <typename T>
|
||||
class ContentTypeReader;
|
||||
|
||||
// A worker object that implements most of ContentManager.Load. A new ContentReader is constructed for each asset loaded.
|
||||
class ContentReader : public BinaryReader, public Object
|
||||
/**
|
||||
* A worker object that implements most of ContentManager.Load. A new ContentReader is constructed for each asset loaded.
|
||||
*/
|
||||
class ContentReader : public BinaryReader
|
||||
{
|
||||
private:
|
||||
ContentManager* contentManager;
|
||||
@ -40,8 +42,10 @@ namespace XFX
|
||||
static Stream* PrepareStream(Stream * const stream, const String& assetName);
|
||||
|
||||
public:
|
||||
String getAssetName() const;
|
||||
const String getAssetName() const;
|
||||
ContentManager* getContentManager() const;
|
||||
GraphicsDevice* getGraphicsDevice() const;
|
||||
int getVersion() const;
|
||||
|
||||
ContentReader(ContentManager * const manager, Stream * const stream, GraphicsDevice * const graphicsDevice);
|
||||
ContentReader(ContentManager * const manager, Stream * const input, const String& assetName);
|
||||
|
@ -90,10 +90,10 @@ namespace XFX
|
||||
|
||||
typedef ContainmentType::type ContainmentType_t; // Describes how one bounding volume contains another.
|
||||
typedef CurveContinuity::type CurveContinuity_t; // Defines the continuity of CurveKeys on a Curve.
|
||||
typedef CurveLoopType::type CurveLoopType_t; // Defines how the value of a Curve will be determined for positions before the first point on the Curve or after the last point on the Curve.
|
||||
typedef CurveTangent::type CurveTangent_t; // Specifies different tangent types to be calculated for CurveKey points in a Curve.
|
||||
typedef CurveLoopType::type CurveLoopType_t; // Defines how the value of a Curve will be determined for positions before the first point on the Curve or after the last point on the Curve.
|
||||
typedef CurveTangent::type CurveTangent_t; // Specifies different tangent types to be calculated for CurveKey points in a Curve.
|
||||
typedef PlaneIntersectionType::type PlaneIntersectionType_t; // Describes the intersection between a plane and a bounding volume.
|
||||
typedef PlayerIndex::type PlayerIndex_t; // Specifies the index of a player.
|
||||
typedef PlayerIndex::type PlayerIndex_t; // Specifies the index of a player.
|
||||
typedef TargetPlatform::type TargetPlatform_t; // Defines the target platform to be used when compiling content.
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace XFX
|
||||
class GraphicsResource : public IDisposable, public Object
|
||||
{
|
||||
private:
|
||||
bool isDisposed;
|
||||
bool isDisposed;
|
||||
|
||||
protected:
|
||||
GraphicsDevice* graphicsDevice;
|
||||
|
88
include/Graphics/Model.h
Normal file
88
include/Graphics/Model.h
Normal file
@ -0,0 +1,88 @@
|
||||
/*****************************************************************************
|
||||
* Model.h *
|
||||
* *
|
||||
* XFX::Graphics::Model class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _XFX_GRAPHICS_MODEL_
|
||||
#define _XFX_GRAPHICS_MODEL_
|
||||
|
||||
#include "ModelBoneCollection.h"
|
||||
#include "ModelMeshCollection.h"
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
struct Matrix;
|
||||
|
||||
namespace Graphics
|
||||
{
|
||||
/**
|
||||
* Represents a 3D model composed of multiple ModelMesh objects which may be moved independently.
|
||||
*/
|
||||
class Model
|
||||
{
|
||||
private:
|
||||
friend class XFX::Content::ModelReader;
|
||||
|
||||
List<ModelBone> bones;
|
||||
List<ModelMesh> meshes;
|
||||
static Matrix* sharedDrawBoneMatrices;
|
||||
static int sharedDrawBoneMatrixCount;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Gets a collection of ModelBone objects which describe how each mesh in the Meshes collection for this model relates to its parent mesh.
|
||||
*/
|
||||
ModelBoneCollection getBones();
|
||||
/**
|
||||
* Gets a collection of ModelMesh objects which compose the model. Each ModelMesh in a model may be moved independently and may be composed of multiple materials identified as ModelMeshPart objects.
|
||||
*/
|
||||
ModelMeshCollection getMeshes();
|
||||
/**
|
||||
* Gets the root bone for this model.
|
||||
*/
|
||||
ModelBone getRoot();
|
||||
/**
|
||||
* Gets or sets an object identifying this model.
|
||||
*/
|
||||
Object* Tag;
|
||||
|
||||
/**
|
||||
* Copies a transform of each bone in a model relative to all parent bones of the bone into a given array.
|
||||
*
|
||||
* @param destinationBoneTransforms
|
||||
* The array to receive bone transforms.
|
||||
*/
|
||||
void CopyAbsoluteBoneTransformsTo(Matrix destinationBoneTransforms[]);
|
||||
/**
|
||||
* Copies an array of transforms into each bone in the model.
|
||||
*
|
||||
* @param sourceBoneTransforms
|
||||
* An array containing new bone transforms.
|
||||
*/
|
||||
void CopyBoneTransformsFrom(Matrix sourceBoneTransforms[]);
|
||||
/**
|
||||
* Copies each bone transform relative only to the parent bone of the model to a given array.
|
||||
*
|
||||
* @param destinationBoneTransforms
|
||||
* The array to receive bone transforms.
|
||||
*/
|
||||
void CopyBoneTransformsTo(Matrix destinationBoneTransforms[]);
|
||||
/**
|
||||
* Renders the model after applying the matrix transformations.
|
||||
*
|
||||
* @param world
|
||||
* A world transformation matrix.
|
||||
*
|
||||
* @param view
|
||||
* A view transformation matrix.
|
||||
*
|
||||
* @param projection
|
||||
* A projection transformation matrix.
|
||||
*/
|
||||
void Draw(Matrix world, Matrix view, Matrix projection);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XFX_GRAPHICS_MODEL_
|
59
include/Graphics/ModelBone.h
Normal file
59
include/Graphics/ModelBone.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*****************************************************************************
|
||||
* ModelBone.h *
|
||||
* *
|
||||
* XFX::Graphics::ModelBone class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _XFX_GRAPHICS_MODELBONE_
|
||||
#define _XFX_GRAPHICS_MODELBONE_
|
||||
|
||||
#include <System/Collections/Generic/List.h>
|
||||
#include <Matrix.h>
|
||||
#include <System/String.h>
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
class ModelBoneCollection;
|
||||
|
||||
/**
|
||||
* Represents bone data for a model.
|
||||
*/
|
||||
class ModelBone
|
||||
{
|
||||
private:
|
||||
friend class XFX::Content::ModelReader;
|
||||
|
||||
List<ModelBone> children;
|
||||
String name;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Gets a collection of bones that are children of this bone.
|
||||
*/
|
||||
ModelBoneCollection getChildren() const;
|
||||
/**
|
||||
* Gets the index of this bone in the Bones collection.
|
||||
*/
|
||||
int getIndex() const;
|
||||
/**
|
||||
* Gets the name of this bone.
|
||||
*/
|
||||
const String getName() const;
|
||||
/**
|
||||
* Gets the paremt of this bone.
|
||||
*/
|
||||
ModelBone* getParent() const;
|
||||
/**
|
||||
* Gets or sets the matrix used to transform this bone relative to its parent bone.
|
||||
*/
|
||||
Matrix Transform;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XFX_GRAPHICS_MODELBONE_
|
52
include/Graphics/ModelBoneCollection.h
Normal file
52
include/Graphics/ModelBoneCollection.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*****************************************************************************
|
||||
* ModelBoneCollection.h *
|
||||
* *
|
||||
* XFX::Graphics::ModelBoneCollection class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _XFX_GRAPHICS_MODELBONECOLLECTION_
|
||||
#define _XFX_GRAPHICS_MODELBONECOLLECTION_
|
||||
|
||||
#include "ModelBone.h"
|
||||
#include <System/Collections/ObjectModel/ReadOnlyCollection.h>
|
||||
|
||||
using namespace System::Collections::ObjectModel;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
/**
|
||||
* Represents a set of bones associated with a model.
|
||||
*/
|
||||
class ModelBoneCollection : public ReadOnlyCollection<ModelBone>
|
||||
{
|
||||
private:
|
||||
friend class Model;
|
||||
|
||||
ModelBoneCollection(IList<ModelBone> * const list);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Finds a bone with a given name if it exists in the collection.
|
||||
*
|
||||
* @param boneName
|
||||
* The name of the bone to find.
|
||||
*
|
||||
* @param value
|
||||
* [OutAttribute] The bone named boneName, if found.
|
||||
*/
|
||||
bool TryGetValue(const String& boneName, out ModelBone * value);
|
||||
|
||||
/**
|
||||
* Retrieves a ModelBone from the collection, given the name of the bone.
|
||||
*
|
||||
* @param name
|
||||
* The name of the bone to retrieve.
|
||||
*/
|
||||
ModelBone& operator[](const String& name) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XFX_GRAPHICS_MODELBONECOLLECTION_
|
32
include/Graphics/ModelEffectCollection.h
Normal file
32
include/Graphics/ModelEffectCollection.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*****************************************************************************
|
||||
* ModelEffectCollection.h *
|
||||
* *
|
||||
* XFX::Graphics::ModelEffectCollection class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _XFX_GRAPHICS_MODELEFFECTCOLLECTION_
|
||||
#define _XFX_GRAPHICS_MODELEFFECTCOLLECTION_
|
||||
|
||||
#include "Effect.h"
|
||||
#include <System/Collections/ObjectModel/ReadOnlyCollection.h>
|
||||
|
||||
using namespace System::Collections::ObjectModel;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
/**
|
||||
* Represents a collection of effects associated with a model.
|
||||
*/
|
||||
class ModelEffectCollection : public ReadOnlyCollection<Effect*>
|
||||
{
|
||||
private:
|
||||
friend class Model;
|
||||
|
||||
ModelEffectCollection(IList<Effect*>* list);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XFX_GRAPHICS_MODELEFFECTCOLLECTION_
|
62
include/Graphics/ModelMesh.h
Normal file
62
include/Graphics/ModelMesh.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*****************************************************************************
|
||||
* ModelMesh.h *
|
||||
* *
|
||||
* XFX::Graphics::ModelMesh class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _XFX_GRAPHICS_MODELMESH_
|
||||
#define _XFX_GRAPHICS_MODELMESH_
|
||||
|
||||
#include "ModelBone.h"
|
||||
#include "ModelEffectCollection.h"
|
||||
#include "ModelMeshPartCollection.h"
|
||||
#include <System/String.h>
|
||||
|
||||
using namespace System;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
struct BoundingSphere;
|
||||
|
||||
namespace Graphics
|
||||
{
|
||||
/**
|
||||
* Represents a mesh that is part of a model.
|
||||
*/
|
||||
class ModelMesh
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Gets the BoundingSphere that contains this mesh.
|
||||
*/
|
||||
BoundingSphere getBoundingSphere() const;
|
||||
/**
|
||||
* Gets a collection of effects associated with this mesh.
|
||||
*/
|
||||
ModelEffectCollection getEffects() const;
|
||||
/**
|
||||
* Gets the ModelMeshPart objects that make up this mesh. Each part of a mesh is composed of a set of primitives that share the same material.
|
||||
*/
|
||||
ModelMeshPartCollection getMeshParts() const;
|
||||
/**
|
||||
* Gets the name of this mesh.
|
||||
*/
|
||||
const String& getName() const;
|
||||
/**
|
||||
* Gets the parent bone for this mesh. The parent bone of a mesh contains a transformation matrix that describes how the mesh is located relative to any parent meshes in a model.
|
||||
*/
|
||||
ModelBone getParentBone() const;
|
||||
/**
|
||||
* Gets or sets an object identifying this mesh.
|
||||
*/
|
||||
Object* Tag;
|
||||
|
||||
/**
|
||||
* Draws all of the ModelMeshPartObjects in this mesh, using their current Effect settings.
|
||||
*/
|
||||
void Draw();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XFX_GRAPHICS_MODELMESH_
|
52
include/Graphics/ModelMeshCollection.h
Normal file
52
include/Graphics/ModelMeshCollection.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*****************************************************************************
|
||||
* ModelMeshCollection.h *
|
||||
* *
|
||||
* XFX::Graphics::ModelMeshCollection class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _XFX_GRAPHICS_MODELMESHCOLLECTION_
|
||||
#define _XFX_GRAPHICS_MODELMESHCOLLECTION_
|
||||
|
||||
#include "ModelMesh.h"
|
||||
#include <System/Collections/ObjectModel/ReadOnlyCollection.h>
|
||||
|
||||
using namespace System::Collections::ObjectModel;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
/**
|
||||
* Represents a collection of ModelMesh objects.
|
||||
*/
|
||||
class ModelMeshCollection : public ReadOnlyCollection<ModelMesh>
|
||||
{
|
||||
private:
|
||||
friend class Model;
|
||||
|
||||
ModelMeshCollection(IList<ModelMesh>* list);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Finds a mesh with a given name if it exists in the collection.
|
||||
*
|
||||
* @param boneName
|
||||
* The name of the mesh to find.
|
||||
*
|
||||
* @param value
|
||||
* [OutAttribute] The bone named boneName, if found.
|
||||
*/
|
||||
bool TryGetValue(const String& meshName, out ModelMesh * value);
|
||||
|
||||
/**
|
||||
* Retrieves a ModelMesh from the collection, given the name of the mesh.
|
||||
*
|
||||
* @param name
|
||||
* The name of the bone to retrieve.
|
||||
*/
|
||||
ModelMesh& operator[](const String& name) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XFX_GRAPHICS_MODELMESHCOLLECTION_
|
60
include/Graphics/ModelMeshPart.h
Normal file
60
include/Graphics/ModelMeshPart.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* ModelMeshPart.h *
|
||||
* *
|
||||
* XFX::Graphics::ModelMeshPart class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _XFX_GRAPHICS_MODELMESHPART_
|
||||
#define _XFX_GRAPHICS_MODELMESHPART_
|
||||
|
||||
#include "Effect.h"
|
||||
#include "IndexBuffer.h"
|
||||
#include "VertexBuffer.h"
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
/**
|
||||
* Represents a batch of geometry information to submit to the graphics device during rendering. Each ModelMeshPart is a subdivision of a ModelMesh object. The ModelMesh class is split into multiple ModelMeshPart objects, typically based on material information.
|
||||
*/
|
||||
class ModelMeshPart
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Gets or sets the material effect for this mesh part.
|
||||
*/
|
||||
XFX::Graphics::Effect* Effect;
|
||||
/**
|
||||
* Gets the index buffer for this mesh part.
|
||||
*/
|
||||
IndexBuffer getIndexBuffer();
|
||||
/**
|
||||
* Gets the number of vertices used during a draw call.
|
||||
*/
|
||||
int getNumVertices();
|
||||
/**
|
||||
* Gets the number of primitives to render.
|
||||
*/
|
||||
int getPrimitiveCount();
|
||||
/**
|
||||
* Gets the location in the index array at which to start reading vertices.
|
||||
*/
|
||||
int getStartIndex();
|
||||
/**
|
||||
* Gets or sets an object identifying this model mesh part.
|
||||
*/
|
||||
Object* Tag;
|
||||
/**
|
||||
* Gets the vertex buffer for this mesh part.
|
||||
*/
|
||||
VertexBuffer getVertexBuffer();
|
||||
/**
|
||||
* Gets the offset (in vertices) from the top of vertex buffer.
|
||||
*/
|
||||
int getVertexOffset();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XFX_GRAPHICS_MODELMESHPART_
|
27
include/Graphics/ModelMeshPartCollection.h
Normal file
27
include/Graphics/ModelMeshPartCollection.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef _XFX_GRAPHICS_MODELMESHPARTCOLLECTION_
|
||||
#define _XFX_GRAPHICS_MODELMESHPARTCOLLECTION_
|
||||
|
||||
#include "ModelMeshPart.h"
|
||||
#include <System/Collections/ObjectModel/ReadOnlyCollection.h>
|
||||
|
||||
using namespace System::Collections::ObjectModel;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ModelMeshPartCollection : public ReadOnlyCollection<ModelMeshPart>
|
||||
{
|
||||
private:
|
||||
ModelMeshPartCollection(IList<ModelMeshPart> list);
|
||||
|
||||
public:
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XFX_GRAPHICS_MODELMESHPARTCOLLECTION_
|
@ -25,7 +25,7 @@ namespace XFX
|
||||
int _levelCount;
|
||||
|
||||
protected:
|
||||
virtual void Dispose(bool disposing);
|
||||
void Dispose(bool disposing);
|
||||
|
||||
public:
|
||||
SurfaceFormat_t getFormat() const;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Texture2D.h *
|
||||
* Texture2D.h *
|
||||
* *
|
||||
* XFX::Graphics::Texture2D class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
@ -11,12 +11,17 @@
|
||||
#include <System/IO/Stream.h>
|
||||
#include <System/Types.h>
|
||||
|
||||
using namespace System;
|
||||
using namespace System;
|
||||
using namespace System::IO;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
struct Rectangle;
|
||||
|
||||
namespace Content
|
||||
{
|
||||
class Texture2DReader;
|
||||
}
|
||||
|
||||
namespace Graphics
|
||||
{
|
||||
@ -27,35 +32,37 @@ namespace XFX
|
||||
*/
|
||||
class Texture2D : public Texture
|
||||
{
|
||||
friend class XFX::Content::Texture2DReader;
|
||||
|
||||
private:
|
||||
bool _isDisposed; // True when the texture has been disposed
|
||||
int _numberOfLevels; // The number of mip levels for the texture
|
||||
SurfaceFormat_t _surfaceFormat; // The colour format of the texture
|
||||
int textureId; // The reference ID of the texture in OpenGL memory
|
||||
bool _isDisposed; // True when the texture has been disposed
|
||||
int _numberOfLevels; // The number of mip levels for the texture
|
||||
SurfaceFormat_t _surfaceFormat; // The colour format of the texture
|
||||
int textureId; // The reference ID of the texture in OpenGL memory
|
||||
uint* textureData;
|
||||
|
||||
void Load(byte buffer[]);
|
||||
|
||||
protected:
|
||||
void Dispose(bool disposing);
|
||||
|
||||
public:
|
||||
|
||||
void Load(byte buffer[]);
|
||||
|
||||
protected:
|
||||
void Dispose(bool disposing);
|
||||
|
||||
public:
|
||||
Rectangle getBounds() const;
|
||||
SurfaceFormat_t Format() const;
|
||||
const int Height;
|
||||
const int Width;
|
||||
|
||||
Texture2D(GraphicsDevice * const graphicsDevice, const int width, const int height);
|
||||
SurfaceFormat_t Format() const;
|
||||
const int Height;
|
||||
const int Width;
|
||||
|
||||
Texture2D(GraphicsDevice * const graphicsDevice, const int width, const int height);
|
||||
Texture2D(GraphicsDevice * const graphicsDevice, const int width, const int height, bool mipmap, const SurfaceFormat_t format);
|
||||
virtual ~Texture2D();
|
||||
|
||||
static Texture2D* FromStream(GraphicsDevice * const graphicsDevice, Stream * const stream);
|
||||
static Texture2D* FromStream(GraphicsDevice * const graphicsDevice, Stream * const stream, int width, int height, bool zoom);
|
||||
void GetData(uint data[], const int startIndex, const int elementCount) const;
|
||||
void GetData(uint data[], const int startIndex, const int elementCount) const;
|
||||
static const Type& GetType();
|
||||
void SaveAsJpeg(Stream * const stream, int width, int height);
|
||||
void SaveAsPng(Stream * const stream, int width, int height);
|
||||
void SetData(uint data[], const int startIndex, const int elementCount);
|
||||
void SetData(uint data[], const int startIndex, const int elementCount);
|
||||
|
||||
bool operator ==(const Texture2D& right) const;
|
||||
bool operator !=(const Texture2D& right) const;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Array.h *
|
||||
* Array.h *
|
||||
* *
|
||||
* XFX generic Array class definition file *
|
||||
* Contains array helper methods *
|
||||
@ -99,7 +99,7 @@ namespace System
|
||||
sassert((startIndex + count) < Length, "");
|
||||
|
||||
int num = startIndex;
|
||||
int num2 = (startIndex + count) - 1;
|
||||
int num2 = (startIndex + count) - 1;
|
||||
while (num < num2)
|
||||
{
|
||||
swap(_array[num], _array[num2]);
|
||||
@ -226,7 +226,7 @@ namespace System
|
||||
sassert((startIndex + count) < Length, "");
|
||||
|
||||
int num = startIndex;
|
||||
int num2 = (startIndex + count) - 1;
|
||||
int num2 = (startIndex + count) - 1;
|
||||
while (num < num2)
|
||||
{
|
||||
swap(_array[num], _array[num2]);
|
||||
@ -283,14 +283,14 @@ namespace System
|
||||
sassert(array != null, String::Format("array; %s", FrameworkResources::ArgumentNull_Generic));
|
||||
|
||||
int num = index;
|
||||
int num2 = (index + length) - 1;
|
||||
int num2 = (index + length) - 1;
|
||||
while (num < num2)
|
||||
{
|
||||
T obj2 = array[num];
|
||||
array[num] = array[num2];
|
||||
array[num2] = obj2;
|
||||
num++;
|
||||
num2--;
|
||||
num2--;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* List.h *
|
||||
* List.h *
|
||||
* *
|
||||
* XFX Generic List definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
@ -107,7 +107,7 @@ namespace System
|
||||
}
|
||||
|
||||
// Initializes a new instance of the List<> class that is empty and has the default initial capacity.
|
||||
List()
|
||||
List()
|
||||
: _size(0), _actualSize(defaultCapacity), _version(0)
|
||||
{
|
||||
_items = new T[_actualSize];
|
||||
@ -137,7 +137,7 @@ namespace System
|
||||
/**
|
||||
* Adds an element to the end of the list
|
||||
*/
|
||||
void Add(const T& item)
|
||||
void Add(const T& item)
|
||||
{
|
||||
if (_size == _actualSize)
|
||||
{
|
||||
@ -150,7 +150,7 @@ namespace System
|
||||
/**
|
||||
* Removes all elements from the list
|
||||
*/
|
||||
void Clear()
|
||||
void Clear()
|
||||
{
|
||||
if (_size > 0)
|
||||
{
|
||||
@ -179,7 +179,7 @@ namespace System
|
||||
{
|
||||
sassert(array != null, String::Format("array; %s", FrameworkResources::ArgumentNull_Generic));
|
||||
|
||||
memcpy(array, &_items[arrayIndex], _size * sizeof(T))
|
||||
memcpy(&array[arrayIndex], _items, _size * sizeof(T))
|
||||
}
|
||||
|
||||
static const Type& GetType()
|
||||
@ -275,14 +275,14 @@ namespace System
|
||||
sassert(!((_size - index) < count), "Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.");
|
||||
|
||||
int num = index;
|
||||
int num2 = (index + count) - 1;
|
||||
int num2 = (index + count) - 1;
|
||||
while (num < num2)
|
||||
{
|
||||
T obj2 = _items[num];
|
||||
_items[num] = _items[num2];
|
||||
_items[num2] = obj2;
|
||||
num++;
|
||||
num2--;
|
||||
num2--;
|
||||
}
|
||||
_version++;
|
||||
}
|
||||
|
224
include/System/Collections/ObjectModel/ReadOnlyCollection.h
Normal file
224
include/System/Collections/ObjectModel/ReadOnlyCollection.h
Normal file
@ -0,0 +1,224 @@
|
||||
/*****************************************************************************
|
||||
* ReadOnlyCollection.h *
|
||||
* *
|
||||
* System::Collections::ObjectModel::ReadOnlyCollection definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _SYSTEM_COLLECTIONS_OBJECTMODEL_READONLYCOLLECTION_
|
||||
#define _SYSTEM_COLLECTIONS_OBJECTMODEL_READONLYCOLLECTION_
|
||||
|
||||
#include <System/Collections/Generic/List.h>
|
||||
|
||||
using namespace System::Collections::Generic;
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace Collections
|
||||
{
|
||||
namespace ObjectModel
|
||||
{
|
||||
/**
|
||||
* Provides the base class for a generic read-only collection.
|
||||
*/
|
||||
template <typename T>
|
||||
class ReadOnlyCollection : public IEnumerable<T>
|
||||
{
|
||||
private:
|
||||
IList<T>* items;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Gets the number of elements contained in the System::Collections::ObjectModel::ReadOnlyCollection<T> instance.
|
||||
*
|
||||
* @return
|
||||
* The number of elements contained in the System::Collections::ObjectModel::ReadOnlyCollection<T> instance.
|
||||
*/
|
||||
inline int Count() const { return items->Count(); }
|
||||
/**
|
||||
* Returns the System::Collections::Generic::IList<T> that the System::Collections::ObjectModel::ReadOnlyCollection<T> wraps.
|
||||
*
|
||||
* @return
|
||||
* The System::Collections::Generic::IList<T> that the System::Collections::ObjectModel::ReadOnlyCollection<T> wraps.
|
||||
*/
|
||||
inline IList<T> const * const getItems() const { return items; }
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the System::Collections::ObjectModel::ReadOnlyCollection<T> class that is a read-only wrapper around the specified list.
|
||||
*
|
||||
* @param list
|
||||
* The list to wrap.
|
||||
*/
|
||||
ReadOnlyCollection(IList<T> * const list)
|
||||
: items(list)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether an element is in the System::Collections::ObjectModel::ReadOnlyCollection<T>.
|
||||
*
|
||||
* @param item
|
||||
* The object to locate in the System::Collections::ObjectModel::ReadOnlyCollection<T>. The value can be null for reference types.
|
||||
*
|
||||
* @return
|
||||
* true if value is found in the System::Collections::ObjectModel::ReadOnlyCollection<T>; otherwise, false.
|
||||
*/
|
||||
inline bool Contains(const T& item) const
|
||||
{
|
||||
return items->Contains(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the entire System::Collections::ObjectModel::ReadOnlyCollection<T> to a compatible one-dimensional System::Array, starting at the specified index of the target array.
|
||||
*
|
||||
* @param array
|
||||
* The one-dimensional System::Array that is the destination of the elements copied from System::Collections::ObjectModel::ReadOnlyCollection<T>. The System::Array must have zero-based indexing.
|
||||
*
|
||||
* @param index
|
||||
* The zero-based index in array at which copying begins.
|
||||
*/
|
||||
inline void CopyTo(T array[], int index) const
|
||||
{
|
||||
items->CopyTo(array, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumerator that iterates through the System::Collections::ObjectModel::ReadOnlyCollection<T>.
|
||||
*
|
||||
* @return
|
||||
* An System::Collections::Generic::IEnumerator<T> for the System::Collections::ObjectModel::ReadOnlyCollection<T>.
|
||||
*/
|
||||
inline IEnumerator<T>* GetEnumerator()
|
||||
{
|
||||
return items->GetEnumerator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for the specified object and returns the zero-based index of the first occurrence within the entire System::Collections::ObjectModel::ReadOnlyCollection<T>.
|
||||
*
|
||||
* @param item
|
||||
* The object to locate in the System::Collections::Generic::List<T>. The value can be null for reference types.
|
||||
*
|
||||
* @return
|
||||
* The zero-based index of the first occurrence of item within the entire System::Collections::ObjectModel::ReadOnlyCollection<T>, if found; otherwise, -1.
|
||||
*/
|
||||
inline int IndexOf(const T& item) const
|
||||
{
|
||||
return items->IndexOf(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the element at the specified index.
|
||||
*
|
||||
* @param index
|
||||
* The zero-based index of the element to get.
|
||||
*
|
||||
* @return
|
||||
* The element at the specified index.
|
||||
*/
|
||||
inline T& operator[](int index) const { return *items[index]; }
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename T>
|
||||
class ReadOnlyCollection<T *> : public IEnumerable<T *>
|
||||
{
|
||||
private:
|
||||
IList<T *>* items;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Gets the number of elements contained in the System::Collections::ObjectModel::ReadOnlyCollection<T> instance.
|
||||
*
|
||||
* @return
|
||||
* The number of elements contained in the System::Collections::ObjectModel::ReadOnlyCollection<T> instance.
|
||||
*/
|
||||
inline int Count() const { return items->Count(); }
|
||||
/**
|
||||
* Returns the System::Collections::Generic::IList<T> that the System::Collections::ObjectModel::ReadOnlyCollection<T> wraps.
|
||||
*
|
||||
* @return
|
||||
* The System::Collections::Generic::IList<T> that the System::Collections::ObjectModel::ReadOnlyCollection<T> wraps.
|
||||
*/
|
||||
inline IList<T *> const * const getItems() const { return items; }
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the System::Collections::ObjectModel::ReadOnlyCollection<T> class that is a read-only wrapper around the specified list.
|
||||
*
|
||||
* @param list
|
||||
* The list to wrap.
|
||||
*/
|
||||
ReadOnlyCollection(IList<T *> * const list)
|
||||
: items(list)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether an element is in the System::Collections::ObjectModel::ReadOnlyCollection<T>.
|
||||
*
|
||||
* @param item
|
||||
* The object to locate in the System::Collections::ObjectModel::ReadOnlyCollection<T>. The value can be null for reference types.
|
||||
*
|
||||
* @return
|
||||
* true if value is found in the System::Collections::ObjectModel::ReadOnlyCollection<T>; otherwise, false.
|
||||
*/
|
||||
inline bool Contains(const T* item) const
|
||||
{
|
||||
return items->Contains(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the entire System::Collections::ObjectModel::ReadOnlyCollection<T> to a compatible one-dimensional System::Array, starting at the specified index of the target array.
|
||||
*
|
||||
* @param array
|
||||
* The one-dimensional System::Array that is the destination of the elements copied from System::Collections::ObjectModel::ReadOnlyCollection<T>. The System::Array must have zero-based indexing.
|
||||
*
|
||||
* @param index
|
||||
* The zero-based index in array at which copying begins.
|
||||
*/
|
||||
inline void CopyTo(T* array[], int index) const
|
||||
{
|
||||
items->CopyTo(array, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumerator that iterates through the System::Collections::ObjectModel::ReadOnlyCollection<T>.
|
||||
*
|
||||
* @return
|
||||
* An System::Collections::Generic::IEnumerator<T> for the System::Collections::ObjectModel::ReadOnlyCollection<T>.
|
||||
*/
|
||||
inline IEnumerator<T *>* GetEnumerator()
|
||||
{
|
||||
return items->GetEnumerator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for the specified object and returns the zero-based index of the first occurrence within the entire System::Collections::ObjectModel::ReadOnlyCollection<T>.
|
||||
*
|
||||
* @param item
|
||||
* The object to locate in the System::Collections::Generic::List<T>. The value can be null for reference types.
|
||||
*
|
||||
* @return
|
||||
* The zero-based index of the first occurrence of item within the entire System::Collections::ObjectModel::ReadOnlyCollection<T>, if found; otherwise, -1.
|
||||
*/
|
||||
inline int IndexOf(const T* item) const
|
||||
{
|
||||
return items->IndexOf(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the element at the specified index.
|
||||
*
|
||||
* @param index
|
||||
* The zero-based index of the element to get.
|
||||
*
|
||||
* @return
|
||||
* The element at the specified index.
|
||||
*/
|
||||
inline T* operator[](int index) const { return *items[index]; }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_SYSTEM_COLLECTIONS_OBJECTMODEL_READONLYCOLLECTION_
|
56
include/System/Diagnostics/Debug.h
Normal file
56
include/System/Diagnostics/Debug.h
Normal file
@ -0,0 +1,56 @@
|
||||
#ifndef _SYSTEM_DIAGNOSTICS_DEBUG_
|
||||
#define _SYSTEM_DIAGNOSTICS_DEBUG_
|
||||
|
||||
#if _MSC_VER
|
||||
#define FORMAT
|
||||
#else
|
||||
#define FORMAT __attribute__(format(printf, 1, 2));
|
||||
#endif
|
||||
|
||||
namespace System
|
||||
{
|
||||
class String;
|
||||
|
||||
namespace Diagnostics
|
||||
{
|
||||
/**
|
||||
* Provides a set of methods and properties that help debug your code. This class cannot be inherited.
|
||||
*/
|
||||
class Debug
|
||||
{
|
||||
private:
|
||||
Debug();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Checks for a condition; if the condition is false, displays a message box that shows the call stack.
|
||||
*
|
||||
* @param condition
|
||||
* The conditional expression to evaluate. If the condition is true, a failure message is not sent and the message box is not displayed.
|
||||
*/
|
||||
static void Assert(bool condition);
|
||||
/**
|
||||
* Checks for a condition; if the condition is false, outputs a specified message and displays a message box that shows the call stack.
|
||||
*
|
||||
* @param condition
|
||||
* The conditional expression to evaluate. If the condition is true, the message is not sent and the message box is not displayed.
|
||||
*
|
||||
* @param message
|
||||
* Checks for a condition; if the condition is false, outputs a specified message and displays a message box that shows the call stack.
|
||||
*/
|
||||
static void Assert(bool condition, const String& message);
|
||||
/**
|
||||
* Writes a formatted message followed by a line terminator to the attached debugger.
|
||||
*
|
||||
* @param format
|
||||
* A composite format string that contains text intermixed with zero or more format items, which correspond to objects in the args array.
|
||||
*
|
||||
* @param args
|
||||
* An object array containing zero or more objects to format.
|
||||
*/
|
||||
static void WriteLine(const String& format, ...) FORMAT;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_SYSTEM_DIAGNOSTICS_DEBUG_
|
@ -16,6 +16,7 @@ namespace System
|
||||
static const char* ArgumentNull_FileName;
|
||||
static const char* ArgumentNull_Generic;
|
||||
static const char* ArgumentNull_Path;
|
||||
static const char* ArgumentOutOfRange_Index;
|
||||
static const char* ArgumentOutOfRange_NeedNonNegNum;
|
||||
static const char* ArgumentOutOfRange_NeedPosNum;
|
||||
static const char* ArgumentOutOfRange_NegativeCapacity;
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <System/Interfaces.h>
|
||||
#include "Stream.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
namespace System
|
||||
{
|
||||
class String;
|
||||
@ -33,11 +35,13 @@ namespace System
|
||||
protected:
|
||||
virtual void Dispose(bool disposing);
|
||||
virtual void FillBuffer(int numBytes);
|
||||
int Read7BitEncodedInt();
|
||||
|
||||
public:
|
||||
virtual Stream* BaseStream();
|
||||
|
||||
BinaryReader(Stream* input);
|
||||
BinaryReader(FILE * const file);
|
||||
BinaryReader(Stream * const input);
|
||||
virtual ~BinaryReader();
|
||||
|
||||
virtual void Close();
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "Enums.h"
|
||||
#include "Stream.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace IO
|
||||
@ -22,6 +24,7 @@ namespace System
|
||||
class FileStream : public Stream
|
||||
{
|
||||
private:
|
||||
FILE* _file;
|
||||
void* handle;
|
||||
//int handle;
|
||||
byte* _buffer;
|
||||
@ -51,6 +54,7 @@ namespace System
|
||||
void setPosition(long long newPosition);
|
||||
|
||||
FileStream();
|
||||
FileStream(FILE * const file);
|
||||
FileStream(const String& path, const FileMode_t mode);
|
||||
FileStream(const String& path, const FileMode_t mode, const FileAccess_t access);
|
||||
FileStream(const String& path, const FileMode_t mode, const FileAccess_t access, const FileShare_t share);
|
||||
@ -58,10 +62,10 @@ namespace System
|
||||
FileStream(const String& path, const FileMode_t mode, const FileAccess_t access, const FileShare_t share, const int bufferSize, const bool useAsync);
|
||||
virtual ~FileStream();
|
||||
|
||||
virtual IAsyncResult* BeginRead(byte buffer[], int offset, int count, AsyncCallback callback, Object* state);
|
||||
virtual IAsyncResult* BeginWrite(byte buffer[], int offset, int count, AsyncCallback callback, Object* state);
|
||||
virtual int EndRead(IAsyncResult* asyncResult);
|
||||
virtual void EndWrite(IAsyncResult* asyncResult);
|
||||
virtual IAsyncResult* BeginRead(byte buffer[], int offset, int count, AsyncCallback callback, Object * const state);
|
||||
virtual IAsyncResult* BeginWrite(byte buffer[], int offset, int count, AsyncCallback callback, Object * const state);
|
||||
virtual int EndRead(IAsyncResult * const asyncResult);
|
||||
virtual void EndWrite(IAsyncResult * const asyncResult);
|
||||
void Flush();
|
||||
static const Type& GetType();
|
||||
int Read(byte array[], const int offset, const int count);
|
||||
|
@ -31,7 +31,7 @@ namespace System
|
||||
#if ENABLE_XBOX
|
||||
static int FileAttributeInfo(const String& path, PXBOX_FIND_DATA data, bool tryagain, bool returnErrorOnNotFound);
|
||||
#else
|
||||
static int FileAttributeInfo(char* path, <unknown> data, bool tryagain, bool returnErrorOnNotFound);
|
||||
static int FileAttributeInfo(const String& path, <unknown> data, bool tryagain, bool returnErrorOnNotFound);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*****************************************************************************
|
||||
* DependencyProperty.h *
|
||||
* *
|
||||
* System::Windows::DependencyProperty definition file *
|
||||
* Copyright (c) XFX Team. All rights reserved *
|
||||
* System::Windows::DependencyProperty definition file *
|
||||
* Copyright (c) XFX Team. All rights reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _SYSTEM_TYPE_
|
||||
#define _SYSTEM_TYPE_
|
||||
@ -38,7 +38,7 @@ namespace System
|
||||
Type(const String& name, const String& fullName, const TypeCode_t typeCode, const bool hasGenericParameters = false);
|
||||
|
||||
/**
|
||||
* Determines if the underlying system type of the current System::Type is the same as the underlying system type of the specified System::Object.
|
||||
* Determines if the underlying system type of the current System::Type is the same as the underlying system type of the specified System::Object.
|
||||
*
|
||||
* @param obj
|
||||
* The System::Object whose underlying system type is to be compared with the underlying system type of the current System::Type.
|
||||
|
@ -12,7 +12,7 @@ extern "C" {
|
||||
#ifdef NDEBUG /* required by ANSI standard */
|
||||
#define sassert(e,msg) ((void)0)
|
||||
#else
|
||||
//! Causes a blue screen of death if e is not true with the msg "msg" displayed
|
||||
// Causes a blue screen of death if e is not true with the msg "msg" displayed
|
||||
#define sassert(e,msg) ((e) ? (void)0 : __sassert(__FILE__, __LINE__, #e, msg))
|
||||
|
||||
#endif /* NDEBUG */
|
||||
|
83
src/libSystem/Debug.cpp
Normal file
83
src/libSystem/Debug.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
// Copyright (C) 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 <System/Diagnostics/Debug.h>
|
||||
#include <System/String.h>
|
||||
|
||||
#if ENABLE_XBOX
|
||||
#include <xboxkrnl/xboxkrnl.h>
|
||||
#else
|
||||
// TODO: include Linux' debug header
|
||||
#endif
|
||||
|
||||
namespace System
|
||||
{
|
||||
namespace Diagnostics
|
||||
{
|
||||
void Debug::Assert(bool condition)
|
||||
{
|
||||
#if DEBUG
|
||||
if (condition)
|
||||
{
|
||||
#endif
|
||||
return;
|
||||
#if DEBUG
|
||||
}
|
||||
|
||||
// TODO: implement
|
||||
#endif
|
||||
}
|
||||
|
||||
void Debug::Assert(bool condition, const String& message)
|
||||
{
|
||||
#if DEBUG
|
||||
if (condition)
|
||||
{
|
||||
#endif
|
||||
return;
|
||||
#if DEBUG
|
||||
}
|
||||
|
||||
// TODO: implement
|
||||
#endif
|
||||
}
|
||||
|
||||
void Debug::WriteLine(const String& format, ...)
|
||||
{
|
||||
#if !DEBUG
|
||||
return;
|
||||
#else
|
||||
if (String::IsNullOrEmpty(format))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: implement
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@ -72,6 +72,7 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Debug.cpp" />
|
||||
<ClCompile Include="SocketAddress.cpp" />
|
||||
<ClCompile Include="Socket.cpp" />
|
||||
<ClCompile Include="SocketAsyncEventArgs.cpp" />
|
||||
@ -79,6 +80,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\include\System\ComponentModel\CancelEventArgs.h" />
|
||||
<ClInclude Include="..\..\include\System\Diagnostics\Debug.h" />
|
||||
<ClInclude Include="..\..\include\System\Net\EndPoint.h" />
|
||||
<ClInclude Include="..\..\include\System\Net\SocketAddress.h" />
|
||||
<ClInclude Include="..\..\include\System\Net\Sockets\Enums.h" />
|
||||
|
@ -25,6 +25,18 @@
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Diagnostics">
|
||||
<UniqueIdentifier>{e5bf276b-a008-4dca-8230-a7bca29e8acb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Diagnostics">
|
||||
<UniqueIdentifier>{7ce6f2df-e8a4-4775-a038-97daadab1d8b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Net">
|
||||
<UniqueIdentifier>{56a599bf-d3a8-4e93-adb5-09b5ae4c5544}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Net\Sockets">
|
||||
<UniqueIdentifier>{0b37cc7b-fbd5-4d60-8e8d-99f0bde53754}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="SocketAddress.cpp">
|
||||
@ -39,25 +51,31 @@
|
||||
<ClCompile Include="CancelEventArgs.cpp">
|
||||
<Filter>Source Files\ComponentModel</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Debug.cpp">
|
||||
<Filter>Source Files\Diagnostics</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\include\System\ComponentModel\CancelEventArgs.h">
|
||||
<Filter>Header Files\ComponentModel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\System\Diagnostics\Debug.h">
|
||||
<Filter>Header Files\Diagnostics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\System\Net\EndPoint.h">
|
||||
<Filter>Source Files\Net</Filter>
|
||||
<Filter>Header Files\Net</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\System\Net\SocketAddress.h">
|
||||
<Filter>Source Files\Net</Filter>
|
||||
<Filter>Header Files\Net</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\System\Net\Sockets\Enums.h">
|
||||
<Filter>Source Files\Net\Sockets</Filter>
|
||||
<Filter>Header Files\Net\Sockets</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\System\Net\Sockets\Socket.h">
|
||||
<Filter>Source Files\Net\Sockets</Filter>
|
||||
<Filter>Header Files\Net\Sockets</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\System\Net\Sockets\SocketAsyncEventArgs.h">
|
||||
<Filter>Source Files\Net\Sockets</Filter>
|
||||
<Filter>Header Files\Net\Sockets</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -26,7 +26,7 @@ LD_FLAGS = $(CLINK) $(ALIGN) $(SHARED) $(ENTRYPOINT) $(STRIP)
|
||||
LD_DIRS = -L$(PREFIX)/i386-pc-xbox/lib -L$(PREFIX)/lib
|
||||
LD_LIBS = $(LD_DIRS) -lmscorlib -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc -lgcc -lstdc++
|
||||
|
||||
OBJS = CancelEventArgs.o Socket.o SocketAddress.o SocketAsyncEventArgs.o
|
||||
OBJS = CancelEventArgs.o Debug.o Socket.o SocketAddress.o SocketAsyncEventArgs.o
|
||||
|
||||
all: libSystem.a
|
||||
|
||||
|
74
src/libXFX/Enums.h
Normal file
74
src/libXFX/Enums.h
Normal file
@ -0,0 +1,74 @@
|
||||
#ifndef _XFX_GRAPHICS_ENUMS_LEGACY_
|
||||
#define _XFX_GRAPHICS_ENUMS_LEGACY_
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
struct SurfaceFormat_Legacy
|
||||
{
|
||||
enum type
|
||||
{
|
||||
Unknown = -1,
|
||||
Color = 1,
|
||||
Bgr32 = 2,
|
||||
Bgra1010102 = 3,
|
||||
Rgba32 = 4,
|
||||
Rgb32 = 5,
|
||||
Rgba1010102 = 6,
|
||||
Rg32 = 7,
|
||||
Rgba64 = 8,
|
||||
Bgr565 = 9,
|
||||
Bgra5551 = 10,
|
||||
Bgr555 = 11,
|
||||
Bgra4444 = 12,
|
||||
Bgr444 = 13,
|
||||
Bgra2338 = 14,
|
||||
Alpha8 = 15,
|
||||
Bgr233 = 16,
|
||||
Bgr24 = 17,
|
||||
NormalizedByte2 = 18,
|
||||
NormalizedByte4 = 19,
|
||||
NormalizedShort2 = 20,
|
||||
NormalizedShort4 = 21,
|
||||
Single = 22,
|
||||
Vector2 = 23,
|
||||
Vector4 = 24,
|
||||
HalfSingle = 25,
|
||||
HalfVector2 = 26,
|
||||
HalfVector4 = 27,
|
||||
Dxt1 = 28,
|
||||
Dxt2 = 29,
|
||||
Dxt3 = 30,
|
||||
Dxt4 = 31,
|
||||
Dxt5 = 32,
|
||||
Luminance8 = 33,
|
||||
Luminance16 = 34,
|
||||
LuminanceAlpha8 = 35,
|
||||
LuminanceAlpha16 = 36,
|
||||
Palette8 = 37,
|
||||
PaletteAlpha16 = 38,
|
||||
NormalizedLuminance16 = 39,
|
||||
NormalizedLuminance32 = 40,
|
||||
NormalizedAlpha1010102 = 41,
|
||||
NormalizedByte2Computed = 42,
|
||||
VideoYuYv = 43,
|
||||
VideoUyVy = 44,
|
||||
VideoGrGb = 45,
|
||||
VideoRgBg = 46,
|
||||
Multi2Bgra32 = 47,
|
||||
Depth24Stencil8 = 48,
|
||||
Depth24Stencil8Single = 49,
|
||||
Depth24Stencil4 = 50,
|
||||
Depth24 = 51,
|
||||
Depth32 = 52,
|
||||
Depth16 = 54,
|
||||
Depth15Stencil1 = 56,
|
||||
};
|
||||
};
|
||||
|
||||
typedef SurfaceFormat_Legacy::type SurfaceFormat_Legacy_t;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XFX_GRAPHICS_ENUMS_LEGACY_
|
110
src/libXFX/Model.cpp
Normal file
110
src/libXFX/Model.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
// Copyright (C) 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 <Graphics/Model.h>
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
ModelBoneCollection Model::getBones()
|
||||
{
|
||||
return ModelBoneCollection(&bones);
|
||||
}
|
||||
|
||||
ModelMeshCollection Model::getMeshes()
|
||||
{
|
||||
return ModelMeshCollection(&meshes);
|
||||
}
|
||||
|
||||
ModelBone Model::getRoot()
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
void Model::CopyAbsoluteBoneTransformsTo(Matrix destinationBoneTransforms[])
|
||||
{
|
||||
sassert(destinationBoneTransforms != null, FrameworkResources::ArgumentNull_Generic);
|
||||
|
||||
int count = bones.Count;
|
||||
for (int index1 = 0; index1 < count; ++index1)
|
||||
{
|
||||
ModelBone modelBone = bones[index1];
|
||||
if (modelBone.getParent() == null)
|
||||
{
|
||||
destinationBoneTransforms[index1] = modelBone.Transform;
|
||||
}
|
||||
else
|
||||
{
|
||||
int index2 = modelBone.getParent()->getIndex();
|
||||
Matrix::Multiply(modelBone.Transform, destinationBoneTransforms[index2], out destinationBoneTransforms[index1]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Model::CopyBoneTransformsFrom(Matrix sourceBoneTransforms[])
|
||||
{
|
||||
sassert(sourceBoneTransforms != null, FrameworkResources::ArgumentNull_Generic);
|
||||
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
void Model::CopyBoneTransformsTo(Matrix destinationBoneTransforms[])
|
||||
{
|
||||
sassert(destinationBoneTransforms != null, FrameworkResources::ArgumentNull_Generic);
|
||||
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
void Model::Draw(Matrix world, Matrix view, Matrix projection)
|
||||
{
|
||||
int boneCount = bones.Count;
|
||||
|
||||
if (sharedDrawBoneMatrices == null || sharedDrawBoneMatrixCount < boneCount)
|
||||
{
|
||||
if (sharedDrawBoneMatrices != null)
|
||||
{
|
||||
delete sharedDrawBoneMatrices;
|
||||
}
|
||||
|
||||
sharedDrawBoneMatrices = new Matrix[boneCount];
|
||||
sharedDrawBoneMatrixCount = boneCount;
|
||||
}
|
||||
|
||||
// Look up combined bone matrices for the entire model.
|
||||
CopyAbsoluteBoneTransformsTo(sharedDrawBoneMatrices);
|
||||
|
||||
for (int i = 0; i < meshes.Count(); i++)
|
||||
{
|
||||
// TODO: implement
|
||||
|
||||
meshes[i].Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
72
src/libXFX/ModelReader.cpp
Normal file
72
src/libXFX/ModelReader.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
// Copyright (C) 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 "ModelReader.h"
|
||||
|
||||
#include <Content/ContentReader.h>
|
||||
|
||||
#include <System/Diagnostics/Debug.h>
|
||||
|
||||
using namespace System::Diagnostics;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Content
|
||||
{
|
||||
Model* ModelReader::Read(ContentReader * const reader, Model* existingInstance)
|
||||
{
|
||||
Model* model = NULL;
|
||||
|
||||
if (existingInstance == NULL)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
model = existingInstance;
|
||||
|
||||
// TODO: clean up the old model data
|
||||
}
|
||||
|
||||
uint boneCount = reader->ReadUInt32();
|
||||
|
||||
for (uint i = 0; i < boneCount; i++)
|
||||
{
|
||||
ModelBone bone;
|
||||
|
||||
bone.Transform = reader->ReadMatrix();
|
||||
|
||||
model->bones.Add(bone);
|
||||
}
|
||||
|
||||
for (uint i = 0; i < boneCount; i++)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
27
src/libXFX/ModelReader.h
Normal file
27
src/libXFX/ModelReader.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*****************************************************************************
|
||||
* ModelReader.h *
|
||||
* *
|
||||
* XFX::Content::ModelReader class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _XFX_CONTENT_MODELREADER_
|
||||
#define _XFX_CONTENT_MODELREADER_
|
||||
|
||||
#include <Content/ContentTypeReader.h>
|
||||
#include <Graphics/Model.h>
|
||||
|
||||
using namespace XFX::Graphics;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Content
|
||||
{
|
||||
class ModelReader : public ContentTypeReader<Model>
|
||||
{
|
||||
public:
|
||||
Model* Read(ContentReader * const input, Model* existingInstance);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XFX_CONTENT_MODELREADER_
|
@ -32,6 +32,7 @@
|
||||
#include <System/FrameworkResources.h>
|
||||
|
||||
#include <sassert.h>
|
||||
#include <System/Type.h>
|
||||
|
||||
using namespace XFX;
|
||||
|
||||
@ -39,11 +40,13 @@ namespace XFX
|
||||
{
|
||||
namespace Graphics
|
||||
{
|
||||
static const Type Texture2DTypeInfo("Texture2D", "XFX::Graphics::Texture2D", TypeCode::Object);
|
||||
|
||||
SurfaceFormat_t Texture2D::Format() const
|
||||
{
|
||||
return _surfaceFormat;
|
||||
}
|
||||
|
||||
|
||||
Texture2D::Texture2D(GraphicsDevice * const graphicsDevice, const int width, const int height)
|
||||
: textureData(new uint[width * height]), Height(height), Width(width)
|
||||
{
|
||||
@ -63,7 +66,7 @@ namespace XFX
|
||||
this->graphicsDevice->getTextures().textures.Add(this);
|
||||
_surfaceFormat = format;
|
||||
}
|
||||
|
||||
|
||||
void Texture2D::Dispose(bool disposing)
|
||||
{
|
||||
if(!_isDisposed)
|
||||
@ -75,9 +78,7 @@ namespace XFX
|
||||
catch(Exception)
|
||||
{
|
||||
|
||||
}
|
||||
if(device.Textures().textures.Contains(this))
|
||||
device.Textures().textures.Remove(this);*/
|
||||
}*/
|
||||
|
||||
delete[] textureData;
|
||||
|
||||
@ -87,9 +88,9 @@ namespace XFX
|
||||
_isDisposed = true;
|
||||
}
|
||||
|
||||
int Texture2D::GetType()
|
||||
const Type& Texture2D::GetType()
|
||||
{
|
||||
// TODO: implement
|
||||
return Texture2DTypeInfo;
|
||||
}
|
||||
|
||||
void Texture2D::GetData(uint data[], const int startIndex, const int elementCount) const
|
||||
@ -115,24 +116,24 @@ namespace XFX
|
||||
data[i] = (textureData[j] & valueMask);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Texture2D::Load(byte buffer[])
|
||||
{
|
||||
/*imageId = Il::ilGenImage();
|
||||
Il::ilBindImage(imageId);
|
||||
Il::ilLoadL(Il::IL_JPG, buffer, buffer.Length);
|
||||
|
||||
int[] texture = int[1];
|
||||
glGenTextures(1, texture);
|
||||
textureId = texture[0];
|
||||
glBindTexture(GL_TEXTURE_2D, textureId);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, Il::ilGetInteger(Il::IL_IMAGE_BYTES_PER_PIXEL), _width, _height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Il::ilGetData());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);*/
|
||||
/*imageId = Il::ilGenImage();
|
||||
Il::ilBindImage(imageId);
|
||||
Il::ilLoadL(Il::IL_JPG, buffer, buffer.Length);
|
||||
|
||||
int[] texture = int[1];
|
||||
glGenTextures(1, texture);
|
||||
textureId = texture[0];
|
||||
glBindTexture(GL_TEXTURE_2D, textureId);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, Il::ilGetInteger(Il::IL_IMAGE_BYTES_PER_PIXEL), _width, _height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Il::ilGetData());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);*/
|
||||
}
|
||||
|
||||
void Texture2D::SetData(uint data[], const int startIndex, const int elementCount)
|
||||
{
|
||||
|
||||
void Texture2D::SetData(uint data[], const int startIndex, const int elementCount)
|
||||
{
|
||||
sassert(data != null, FrameworkResources::ArgumentNull_Buffer);
|
||||
|
||||
sassert(elementCount <= Width * Height, "elementCount is larger than the texture size");
|
||||
@ -151,7 +152,7 @@ namespace XFX
|
||||
{
|
||||
textureData[i] = (data[j] | dataMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Texture2D::operator ==(const Texture2D& right) const
|
||||
{
|
||||
|
228
src/libXFX/Texture2DReader.cpp
Normal file
228
src/libXFX/Texture2DReader.cpp
Normal file
@ -0,0 +1,228 @@
|
||||
// Copyright (C) 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 "Enums.h"
|
||||
#include "Texture2DReader.h"
|
||||
|
||||
#include <System/BitConverter.h>
|
||||
#include <Content/ContentReader.h>
|
||||
#include <System/Diagnostics/Debug.h>
|
||||
|
||||
using namespace System;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Content
|
||||
{
|
||||
Texture2D* Texture2DReader::Read(ContentReader * reader, Texture2D * existingInstance)
|
||||
{
|
||||
Texture2D* texture = null;
|
||||
|
||||
SurfaceFormat_t surfaceFormat;
|
||||
|
||||
if (reader->getVersion() < 5)
|
||||
{
|
||||
SurfaceFormat_Legacy_t legacyFormat = (SurfaceFormat_Legacy_t)reader->ReadInt32();
|
||||
switch(legacyFormat)
|
||||
{
|
||||
case SurfaceFormat_Legacy::Dxt1:
|
||||
surfaceFormat = SurfaceFormat::Dxt1;
|
||||
break;
|
||||
case SurfaceFormat_Legacy::Dxt3:
|
||||
surfaceFormat = SurfaceFormat::Dxt3;
|
||||
break;
|
||||
case SurfaceFormat_Legacy::Dxt5:
|
||||
surfaceFormat = SurfaceFormat::Dxt5;
|
||||
break;
|
||||
case SurfaceFormat_Legacy::Color:
|
||||
surfaceFormat = SurfaceFormat::Color;
|
||||
break;
|
||||
default:
|
||||
//throw new NotImplementedException();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
surfaceFormat = (SurfaceFormat_t)reader->ReadInt32();
|
||||
}
|
||||
|
||||
int width = reader->ReadInt32();
|
||||
int height = reader->ReadInt32();
|
||||
int levelCount = reader->ReadInt32();
|
||||
int levelCountOutput = levelCount;
|
||||
|
||||
// If the system does not fully support Power of Two textures,
|
||||
// skip any mip maps supplied with any non PoT textures.
|
||||
if (levelCount > 1 && !GraphicsCapabilities.SupportsNonPowerOfTwo &&
|
||||
(!MathHelper::IsPowerOfTwo(width) || !MathHelper::IsPowerOfTwo(height)))
|
||||
{
|
||||
levelCountOutput = 1;
|
||||
System::Diagnostics::Debug::WriteLine(
|
||||
"Device does not support non Power of Two textures. Skipping mipmaps.");
|
||||
}
|
||||
|
||||
SurfaceFormat_t convertedFormat = surfaceFormat;
|
||||
switch (surfaceFormat)
|
||||
{
|
||||
case SurfaceFormat::Dxt1:
|
||||
//case SurfaceFormat::Dxt1a:
|
||||
if (!GraphicsCapabilities.SupportsDxt1)
|
||||
convertedFormat = SurfaceFormat::Color;
|
||||
break;
|
||||
case SurfaceFormat::Dxt3:
|
||||
case SurfaceFormat::Dxt5:
|
||||
if (!GraphicsCapabilities.SupportsS3tc)
|
||||
convertedFormat = SurfaceFormat::Color;
|
||||
break;
|
||||
case SurfaceFormat::NormalizedByte4:
|
||||
convertedFormat = SurfaceFormat::Color;
|
||||
break;
|
||||
}
|
||||
|
||||
if (existingInstance == null)
|
||||
{
|
||||
texture = new Texture2D(reader->getGraphicsDevice(), width, height, levelCountOutput > 1, convertedFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = existingInstance;
|
||||
|
||||
texture->Dispose();
|
||||
|
||||
texture = new Texture2D(reader->getGraphicsDevice(), width, height, levelCountOutput > 1, convertedFormat);
|
||||
}
|
||||
|
||||
for (int level=0; level<levelCount; level++)
|
||||
{
|
||||
int levelDataSizeInBytes = reader->ReadInt32();
|
||||
byte* levelData = reader->ReadBytes(levelDataSizeInBytes);
|
||||
int levelWidth = width >> level;
|
||||
int levelHeight = height >> level;
|
||||
|
||||
if (level >= levelCountOutput)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (surfaceFormat)
|
||||
{
|
||||
case SurfaceFormat::Dxt1:
|
||||
//case SurfaceFormat::Dxt1a:
|
||||
if (!GraphicsCapabilities.SupportsDxt1)
|
||||
levelData = DxtUtil::DecompressDxt1(levelData, levelWidth, levelHeight);
|
||||
break;
|
||||
case SurfaceFormat::Dxt3:
|
||||
if (!GraphicsCapabilities.SupportsS3tc)
|
||||
levelData = DxtUtil::DecompressDxt3(levelData, levelWidth, levelHeight);
|
||||
break;
|
||||
case SurfaceFormat::Dxt5:
|
||||
if (!GraphicsCapabilities.SupportsS3tc)
|
||||
levelData = DxtUtil::DecompressDxt5(levelData, levelWidth, levelHeight);
|
||||
break;
|
||||
case SurfaceFormat::Bgr565:
|
||||
{
|
||||
/*
|
||||
// BGR -> BGR
|
||||
int offset = 0;
|
||||
for (int y = 0; y < levelHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < levelWidth; x++)
|
||||
{
|
||||
ushort pixel = BitConverter.ToUInt16(levelData, offset);
|
||||
pixel = (ushort)(((pixel & 0x0FFF) << 4) | ((pixel & 0xF000) >> 12));
|
||||
levelData[offset] = (byte)(pixel);
|
||||
levelData[offset + 1] = (byte)(pixel >> 8);
|
||||
offset += 2;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
break;
|
||||
case SurfaceFormat::Bgra5551:
|
||||
{
|
||||
#if OPENGL
|
||||
// Shift the channels to suit OPENGL
|
||||
int offset = 0;
|
||||
for (int y = 0; y < levelHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < levelWidth; x++)
|
||||
{
|
||||
ushort pixel = BitConverter::ToUInt16(levelData, offset);
|
||||
pixel = (ushort)(((pixel & 0x7FFF) << 1) | ((pixel & 0x8000) >> 15));
|
||||
levelData[offset] = (byte)(pixel);
|
||||
levelData[offset + 1] = (byte)(pixel >> 8);
|
||||
offset += 2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case SurfaceFormat::Bgra4444:
|
||||
{
|
||||
#if OPENGL
|
||||
// Shift the channels to suit OPENGL
|
||||
int offset = 0;
|
||||
for (int y = 0; y < levelHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < levelWidth; x++)
|
||||
{
|
||||
ushort pixel = BitConverter::ToUInt16(levelData, offset);
|
||||
pixel = (ushort)(((pixel & 0x0FFF) << 4) | ((pixel & 0xF000) >> 12));
|
||||
levelData[offset] = (byte)(pixel);
|
||||
levelData[offset + 1] = (byte)(pixel >> 8);
|
||||
offset += 2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case SurfaceFormat::NormalizedByte4:
|
||||
{
|
||||
int bytesPerPixel = surfaceFormat.Size();
|
||||
int pitch = levelWidth * bytesPerPixel;
|
||||
for (int y = 0; y < levelHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < levelWidth; x++)
|
||||
{
|
||||
int color = BitConverter::ToInt32(levelData, y * pitch + x * bytesPerPixel);
|
||||
levelData[y * pitch + x * 4] = (byte)(((color >> 16) & 0xff)); //R:=W
|
||||
levelData[y * pitch + x * 4 + 1] = (byte)(((color >> 8) & 0xff)); //G:=V
|
||||
levelData[y * pitch + x * 4 + 2] = (byte)(((color) & 0xff)); //B:=U
|
||||
levelData[y * pitch + x * 4 + 3] = (byte)(((color >> 24) & 0xff)); //A:=Q
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//texture->SetData(levelData, 0,
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
}
|
27
src/libXFX/Texture2DReader.h
Normal file
27
src/libXFX/Texture2DReader.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*****************************************************************************
|
||||
* Texture2DReader.h *
|
||||
* *
|
||||
* XFX::Content::Texture2DReader class definition file *
|
||||
* Copyright (c) XFX Team. All Rights Reserved *
|
||||
*****************************************************************************/
|
||||
#ifndef _XFX_CONTENT_TEXTURE2DREADER_
|
||||
#define _XFX_CONTENT_TEXTURE2DREADER_
|
||||
|
||||
#include <Content/ContentTypeReader.h>
|
||||
#include <Graphics/Texture2D.h>
|
||||
|
||||
using namespace XFX::Graphics;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Content
|
||||
{
|
||||
class Texture2DReader : public ContentTypeReader<Texture2D>
|
||||
{
|
||||
protected:
|
||||
Texture2D* Read(ContentReader * const input, Texture2D* existingInstance);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XFX_CONTENT_TEXTURE2DREADER_
|
26
src/libXFX/XNBFile.h
Normal file
26
src/libXFX/XNBFile.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef _XNBFILE_
|
||||
#define _XNBFILE_
|
||||
|
||||
#include <System/Types.h>
|
||||
|
||||
using namespace System;
|
||||
|
||||
namespace XFX
|
||||
{
|
||||
namespace Content
|
||||
{
|
||||
struct XNBFile
|
||||
{
|
||||
byte FormatID1;
|
||||
byte FormatID2;
|
||||
byte FormatID3;
|
||||
byte TargetPlatform;
|
||||
byte XNBVersion;
|
||||
byte FlagBits;
|
||||
uint CompressedSize;
|
||||
uint UncompressedSize;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //_XNBFILE_
|
@ -43,7 +43,7 @@
|
||||
<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">make -f makefile clean 2>&1 | sed -e %27s/\(\w\+\):\([0-9]\+\):/\1(\2):/%27</NMakeCleanCommandLine>
|
||||
<NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">ENABLE_XBOX; DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\cygwin\usr\local\openxdk\include;C:\cygwin\usr\local\openxdk\i386-pc-xbox\include;C:\cygwin\usr\local\openxdk\include\SDL;..\..\include</NMakeIncludeSearchPath>
|
||||
<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\cygwin\usr\local\openxdk\include;C:\cygwin\usr\local\openxdk\i386-pc-xbox\include;C:\cygwin\usr\local\openxdk\include\SDL;$(SolutionDir)include</NMakeIncludeSearchPath>
|
||||
<NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
|
||||
<NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
|
||||
<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
|
||||
@ -53,6 +53,9 @@
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(SolutionDir)include</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<BuildLog>
|
||||
<Path>BuildLog.htm</Path>
|
||||
@ -79,12 +82,15 @@
|
||||
<ClCompile Include="Effect.cpp" />
|
||||
<ClCompile Include="MathHelper.cpp" />
|
||||
<ClCompile Include="Matrix.cpp" />
|
||||
<ClCompile Include="Model.cpp" />
|
||||
<ClCompile Include="ModelReader.cpp" />
|
||||
<ClCompile Include="Plane.cpp" />
|
||||
<ClCompile Include="Point.cpp" />
|
||||
<ClCompile Include="Quaternion.cpp" />
|
||||
<ClCompile Include="Ray.cpp" />
|
||||
<ClCompile Include="Rectangle.cpp" />
|
||||
<ClCompile Include="SoundEffectInstance.cpp" />
|
||||
<ClCompile Include="Texture2DReader.cpp" />
|
||||
<ClCompile Include="Vector2.cpp" />
|
||||
<ClCompile Include="Vector3.cpp" />
|
||||
<ClCompile Include="Vector4.cpp" />
|
||||
@ -148,6 +154,14 @@
|
||||
<ClInclude Include="..\..\include\Graphics\EffectTechniqueCollection.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\IndexBuffer.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\IVertexType.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\Model.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\ModelBone.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\ModelBoneCollection.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\ModelEffectCollection.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\ModelMesh.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\ModelMeshCollection.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\ModelMeshPart.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\ModelMeshPartCollection.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\RasterizerState.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\SamplerState.h" />
|
||||
<ClInclude Include="..\..\include\Graphics\VertexBuffer.h" />
|
||||
@ -226,6 +240,9 @@
|
||||
<ClInclude Include="..\..\include\Net\PacketReader.h" />
|
||||
<ClInclude Include="..\..\include\Net\PacketWriter.h" />
|
||||
<ClInclude Include="BlendState.cpp" />
|
||||
<ClInclude Include="Enums.h" />
|
||||
<ClInclude Include="ModelReader.h" />
|
||||
<ClInclude Include="Texture2DReader.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
|
@ -60,6 +60,12 @@
|
||||
<Filter Include="Header Files\Net">
|
||||
<UniqueIdentifier>{c6888ccb-ccfe-447e-877d-1ee15a7bae48}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Content\ContentReaders">
|
||||
<UniqueIdentifier>{6660d5ba-e9f3-4326-8e2e-074328719d1a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Content\ContentReaders">
|
||||
<UniqueIdentifier>{dfe18763-6837-43b8-a2f6-65708ca1a24e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="BoundingBox.cpp">
|
||||
@ -221,6 +227,15 @@
|
||||
<ClCompile Include="AlphaTestEffect.cpp">
|
||||
<Filter>Source Files\Graphics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Texture2DReader.cpp">
|
||||
<Filter>Source Files\Content\ContentReaders</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelReader.cpp">
|
||||
<Filter>Source Files\Content\ContentReaders</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Model.cpp">
|
||||
<Filter>Source Files\Graphics</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\include\BoundingBox.h">
|
||||
@ -520,6 +535,39 @@
|
||||
<ClInclude Include="..\..\include\Input\GamePadTriggers.h">
|
||||
<Filter>Header Files\Input</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Texture2DReader.h">
|
||||
<Filter>Header Files\Content\ContentReaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Enums.h">
|
||||
<Filter>Source Files\Content</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ModelReader.h">
|
||||
<Filter>Header Files\Content\ContentReaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\Graphics\Model.h">
|
||||
<Filter>Header Files\Graphics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\Graphics\ModelBone.h">
|
||||
<Filter>Header Files\Graphics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\Graphics\ModelBoneCollection.h">
|
||||
<Filter>Header Files\Graphics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\Graphics\ModelMesh.h">
|
||||
<Filter>Header Files\Graphics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\Graphics\ModelMeshCollection.h">
|
||||
<Filter>Header Files\Graphics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\Graphics\ModelEffectCollection.h">
|
||||
<Filter>Header Files\Graphics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\Graphics\ModelMeshPart.h">
|
||||
<Filter>Header Files\Graphics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\Graphics\ModelMeshPartCollection.h">
|
||||
<Filter>Header Files\Graphics</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <System/Array.h>
|
||||
#include <System/FrameworkResources.h>
|
||||
#include <System/IO/BinaryReader.h>
|
||||
#include <System/IO/FileStream.h>
|
||||
#include <System/String.h>
|
||||
#include <System/IO/MemoryStream.h>
|
||||
|
||||
@ -43,7 +44,7 @@ namespace System
|
||||
return m_stream;
|
||||
}
|
||||
|
||||
BinaryReader::BinaryReader(Stream* input)
|
||||
BinaryReader::BinaryReader(Stream * const input)
|
||||
{
|
||||
sassert(input->CanRead(), FrameworkResources::NotSupported_UnreadableStream);
|
||||
|
||||
@ -52,6 +53,11 @@ namespace System
|
||||
m_buffer = new byte[32];
|
||||
}
|
||||
|
||||
BinaryReader::BinaryReader(FILE * const file)
|
||||
: m_stream(new FileStream(file))
|
||||
{
|
||||
}
|
||||
|
||||
BinaryReader::~BinaryReader()
|
||||
{
|
||||
Dispose(false);
|
||||
@ -283,6 +289,23 @@ namespace System
|
||||
return InternalReadChars(buffer, index, count);
|
||||
}
|
||||
|
||||
int BinaryReader::Read7BitEncodedInt()
|
||||
{
|
||||
uint result = 0;
|
||||
uint bitsRead = 0;
|
||||
uint value;
|
||||
|
||||
do
|
||||
{
|
||||
value = ReadByte();
|
||||
result |= (value & 0x7f) << bitsRead;
|
||||
bitsRead += 7;
|
||||
}
|
||||
while (value & 0x80);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool BinaryReader::ReadBoolean()
|
||||
{
|
||||
FillBuffer(1);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <System/String.h>
|
||||
|
||||
#include <sassert.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace System
|
||||
{
|
||||
@ -79,10 +80,7 @@ namespace System
|
||||
{
|
||||
byte *ret = new byte[count];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
ret[i] = ptr[i];
|
||||
}
|
||||
memcpy(ret, ptr, count);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -162,7 +160,9 @@ namespace System
|
||||
}*/
|
||||
|
||||
if (value[startIndex] != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -37,9 +37,9 @@
|
||||
|
||||
namespace System
|
||||
{
|
||||
unsigned long long rawNaND = 0x7ff8000000000000ULL;
|
||||
unsigned long long rawPosInfD = 0x7ff0000000000000ULL;
|
||||
unsigned long long rawNegInfD = 0xfff0000000000000ULL;
|
||||
static unsigned long long rawNaND = 0x7ff8000000000000ULL;
|
||||
static unsigned long long rawPosInfD = 0x7ff0000000000000ULL;
|
||||
static unsigned long long rawNegInfD = 0xfff0000000000000ULL;
|
||||
|
||||
const double Double::Epsilon = 4.94066e-324;
|
||||
const double Double::MaxValue = 1.79769e+308;
|
||||
|
@ -60,6 +60,11 @@ namespace System
|
||||
return "";
|
||||
}
|
||||
#else
|
||||
switch (folder)
|
||||
{
|
||||
case SpecialFolder::Personal:
|
||||
return "~";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -70,7 +75,11 @@ namespace System
|
||||
|
||||
OperatingSystem Environment::OSVersion()
|
||||
{
|
||||
#if ENABLE_XBOX
|
||||
return OperatingSystem(PlatformID::Xbox, Version(XboxKrnlVersion->VersionMajor, XboxKrnlVersion->VersionMinor, XboxKrnlVersion->Build));
|
||||
#else
|
||||
return OperatingSystem(PlatformID::Linux, Version());
|
||||
#endif
|
||||
}
|
||||
|
||||
int Environment::ProcessorCount()
|
||||
|
@ -57,7 +57,7 @@ namespace System
|
||||
|
||||
long long FileStream::Length()
|
||||
{
|
||||
sassert(handle != NULL, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
sassert(handle != NULL || _file != null, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
|
||||
sassert(canSeek, FrameworkResources::NotSupported_UnseekableStream);
|
||||
|
||||
@ -68,8 +68,20 @@ namespace System
|
||||
// return -1;
|
||||
//}
|
||||
|
||||
if (_file != null)
|
||||
{
|
||||
size_t curPos = ftell(_file);
|
||||
fseek(_file, 0, SEEK_END);
|
||||
length = ftell(_file);
|
||||
fseek(_file, curPos, SEEK_SET);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if ((_writePos > 0) && ((_pos + _writePos) > length))
|
||||
{
|
||||
{
|
||||
length = _writePos + _pos;
|
||||
}
|
||||
return length;
|
||||
@ -88,7 +100,7 @@ namespace System
|
||||
{
|
||||
sassert(canSeek, FrameworkResources::NotSupported_UnseekableStream);
|
||||
|
||||
if(newPosition < 0)
|
||||
if (newPosition < 0)
|
||||
{
|
||||
//printf("ARGUMENT_OUT_OF_RANGE in function %s, at line %i in file %s, argument \"%s\": %s\n", __FUNCTION__, __LINE__, __FILE__, "newPosition", "Attempt to set the position to a negative value.");
|
||||
return;
|
||||
@ -98,11 +110,17 @@ namespace System
|
||||
}
|
||||
|
||||
FileStream::FileStream()
|
||||
: handle(NULL), _file(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
FileStream::FileStream(FILE * const file)
|
||||
: handle(NULL), _file(file)
|
||||
{
|
||||
handle = NULL;
|
||||
}
|
||||
|
||||
FileStream::FileStream(const String& path, const FileMode_t mode)
|
||||
: handle(NULL), _file(NULL)
|
||||
{
|
||||
sassert(!String::IsNullOrEmpty(path), FrameworkResources::ArgumentNull_Path);
|
||||
|
||||
@ -166,11 +184,16 @@ namespace System
|
||||
// Invalidate the handle
|
||||
handle = null;
|
||||
}
|
||||
if (_file != null)
|
||||
{
|
||||
fclose(_file);
|
||||
_file = null;
|
||||
}
|
||||
}
|
||||
|
||||
void FileStream::Flush()
|
||||
{
|
||||
sassert(handle != null, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
sassert(handle != null || _file != null, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
|
||||
if (_writePos > 0)
|
||||
{
|
||||
@ -181,7 +204,7 @@ namespace System
|
||||
FlushRead();
|
||||
}
|
||||
_readPos = 0;
|
||||
_readLen = 0;
|
||||
_readLen = 0;
|
||||
}
|
||||
|
||||
void FileStream::FlushWrite(bool calledFromFinalizer)
|
||||
@ -192,7 +215,7 @@ namespace System
|
||||
|
||||
int FileStream::Read(byte array[], const int offset, const int count)
|
||||
{
|
||||
sassert(handle != null, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
sassert(handle != null || _file != null, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
|
||||
sassert(array != null, String::Format("array; %s", FrameworkResources::ArgumentNull_Generic));
|
||||
|
||||
@ -209,7 +232,15 @@ namespace System
|
||||
sassert(!(offset > (len - count)), "Reading would overrun buffer.");
|
||||
|
||||
uint bytesRead;
|
||||
//XReadFile(handle, &array[offset], count, &bytesRead);
|
||||
|
||||
if (_file != null)
|
||||
{
|
||||
bytesRead = fread(&array[offset], 1, count, _file);
|
||||
}
|
||||
else
|
||||
{
|
||||
//XReadFile(handle, &array[offset], count, &bytesRead);
|
||||
}
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
@ -234,7 +265,7 @@ namespace System
|
||||
IO_STATUS_BLOCK ioStatusBlock;
|
||||
NTSTATUS status;
|
||||
uint filesize;
|
||||
|
||||
|
||||
// Calculate the target pointer
|
||||
switch (origin)
|
||||
{
|
||||
@ -244,13 +275,17 @@ namespace System
|
||||
case SeekOrigin::Current: // From the current position
|
||||
status = NtQueryInformationFile(handle, &ioStatusBlock, &positionInfo, sizeof(positionInfo), FilePositionInformation);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
return RtlNtStatusToDosError(status);
|
||||
}
|
||||
targetPointer.QuadPart = positionInfo.CurrentByteOffset.QuadPart + offset;
|
||||
break;
|
||||
case SeekOrigin::End: // From the end of the file
|
||||
//status = XGetFileSize(handle, &filesize);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
return RtlNtStatusToDosError(status);
|
||||
}
|
||||
targetPointer.QuadPart -= offset;
|
||||
break;
|
||||
}
|
||||
@ -262,7 +297,9 @@ namespace System
|
||||
// Set the new position
|
||||
status = NtSetInformationFile(handle, &ioStatusBlock, &positionInfo, sizeof(positionInfo), FilePositionInformation);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
return RtlNtStatusToDosError(status);
|
||||
}
|
||||
else
|
||||
{
|
||||
return targetPointer.QuadPart;
|
||||
@ -275,28 +312,44 @@ namespace System
|
||||
|
||||
sassert(CanWrite(), FrameworkResources::NotSupported_UnwritableStream);
|
||||
|
||||
sassert(handle != null, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
sassert(handle != null || _file != null, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
|
||||
sassert(value >= 0, String::Format("value; %s", FrameworkResources::ArgumentOutOfRange_NeedNonNegNum));
|
||||
|
||||
Flush();
|
||||
|
||||
if (getPosition() > value)
|
||||
{
|
||||
setPosition(value);
|
||||
}
|
||||
}
|
||||
|
||||
void FileStream::Write(byte array[], const int offset, const int count)
|
||||
{
|
||||
sassert(handle != null, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
sassert(handle != null || _file != null, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
|
||||
//XWriteFile(handle, &array[offset], count, null);
|
||||
if (_file != null)
|
||||
{
|
||||
fwrite(&array[offset], sizeof(byte), count, _file);
|
||||
}
|
||||
else
|
||||
{
|
||||
//XWriteFile(handle, &array[offset], count, null);
|
||||
}
|
||||
}
|
||||
|
||||
void FileStream::WriteByte(byte value)
|
||||
{
|
||||
sassert(handle != null, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
sassert(handle != null || _file != null, FrameworkResources::ObjectDisposed_FileClosed);
|
||||
|
||||
//XWriteFile(handle, &value, 1, null);
|
||||
if (_file != null)
|
||||
{
|
||||
fwrite(&value, 1, 1, _file);
|
||||
}
|
||||
else
|
||||
{
|
||||
//XWriteFile(handle, &value, 1, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,22 +3,23 @@
|
||||
|
||||
namespace System
|
||||
{
|
||||
const char* FrameworkResources::Arg_ParamName_Name = "Parameter name: %s";
|
||||
const char* FrameworkResources::Argument_InvalidOffLen = "Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection";
|
||||
const char* FrameworkResources::Arg_ParamName_Name = "Parameter name: %s";
|
||||
const char* FrameworkResources::Argument_InvalidOffLen = "Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection";
|
||||
const char* FrameworkResources::Argument_InvalidSeekOrigin = "Invalid SeekOrigin.";
|
||||
const char* FrameworkResources::ArgumentNull_Buffer = "Buffer cannot be null.";
|
||||
const char* FrameworkResources::ArgumentNull_Buffer = "Buffer cannot be null.";
|
||||
const char* FrameworkResources::ArgumentNull_FileName = "File name cannot be null.";
|
||||
const char* FrameworkResources::ArgumentNull_Generic = "Value cannot be null.";
|
||||
const char* FrameworkResources::ArgumentNull_Path = "Path cannot be null.";
|
||||
const char* FrameworkResources::ArgumentOutOfRange_Index = "Index was out of range. Must be non-negative and less than the size of the collection.";
|
||||
const char* FrameworkResources::ArgumentOutOfRange_NeedNonNegNum = "Non-negative number required.";
|
||||
const char* FrameworkResources::ArgumentOutOfRange_NeedPosNum = "Positive number required.";
|
||||
const char* FrameworkResources::ArgumentOutOfRange_NegativeCapacity = "Capacity must be positive.";
|
||||
const char* FrameworkResources::ArgumentOutOfRange_SmallCapacity = "capacity was less than the current size.";
|
||||
const char* FrameworkResources::ArgumentOutOfRange_StreamLength = "Stream length must be non-negative and less than 2^31 - 1 - origin.";
|
||||
const char* FrameworkResources::IO_SeekBeforeBegin = "Attempting to seek before the start of the Stream.";
|
||||
const char* FrameworkResources::ArgumentOutOfRange_StreamLength = "Stream length must be non-negative and less than 2^31 - 1 - origin.";
|
||||
const char* FrameworkResources::IO_SeekBeforeBegin = "Attempting to seek before the start of the Stream.";
|
||||
const char* FrameworkResources::IO_StreamTooLong = "Stream was too long.";
|
||||
const char* FrameworkResources::ObjectDisposed_FileClosed = "Cannot access a closed file.";
|
||||
const char* FrameworkResources::ObjectDisposed_StreamClosed = "Cannot access a closed Stream.";
|
||||
const char* FrameworkResources::ObjectDisposed_StreamClosed = "Cannot access a closed Stream.";
|
||||
const char* FrameworkResources::NotSupported_MemStreamNotExpandable = "MemoryStream is not expandable.";
|
||||
const char* FrameworkResources::NotSupported_UnreadableStream = "Stream does not support reading.";
|
||||
const char* FrameworkResources::NotSupported_UnseekableStream = "Stream does not support seeking.";
|
||||
|
@ -126,6 +126,7 @@
|
||||
<ClInclude Include="..\..\include\System\Boolean.h" />
|
||||
<ClInclude Include="..\..\include\System\Buffer.h" />
|
||||
<ClInclude Include="..\..\include\System\Byte.h" />
|
||||
<ClInclude Include="..\..\include\System\Collections\ObjectModel\ReadOnlyCollection.h" />
|
||||
<ClInclude Include="..\..\include\System\Console.h" />
|
||||
<ClInclude Include="..\..\include\System\DateTime.h" />
|
||||
<ClInclude Include="..\..\include\System\Delegates.h" />
|
||||
|
@ -49,6 +49,9 @@
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Collections\ObjectModel">
|
||||
<UniqueIdentifier>{8567ce7a-ac9d-41e0-94da-66c21844aa83}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="BitConverter.cpp">
|
||||
@ -398,6 +401,9 @@
|
||||
<ClInclude Include="..\..\include\System\Enums.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\System\Collections\ObjectModel\ReadOnlyCollection.h">
|
||||
<Filter>Header Files\Collections\ObjectModel</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
|
@ -1,10 +1,10 @@
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* File: misc.cpp */
|
||||
/* Author: bkenwright@xbdev.net */
|
||||
/* Desc: Misc functions, making our usb/gamepad code lib independent */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* File: misc.cpp *
|
||||
* Author: bkenwright@xbdev.net *
|
||||
* Desc: Misc functions, making our usb/gamepad code lib independent *
|
||||
* *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <System/misc.h>
|
||||
#include <xboxkrnl/xboxkrnl.h>
|
||||
|
145
src/xnbbuild/src/Path.c
Normal file
145
src/xnbbuild/src/Path.c
Normal file
@ -0,0 +1,145 @@
|
||||
#if _MSC_VER
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Path.h"
|
||||
|
||||
const char * Path_Combine(char const * const path1, char const * const path2)
|
||||
{
|
||||
const char * strPtr = NULL;
|
||||
char * pathString = NULL;
|
||||
size_t newLen = 0;
|
||||
|
||||
strPtr = strrchr(path1, '\\');
|
||||
|
||||
if (((size_t)strPtr - (size_t)path1) != 0)
|
||||
{
|
||||
newLen = strlen(path1) + 1 + strlen(path2);
|
||||
|
||||
pathString = (char *)malloc(newLen + 1);
|
||||
|
||||
sprintf(pathString, "%s\\%s", path1, path2);
|
||||
}
|
||||
else
|
||||
{
|
||||
newLen = strlen(path1) + strlen(path2);
|
||||
|
||||
pathString = (char *)malloc(newLen + 1);
|
||||
|
||||
sprintf(pathString, "%s%s", path1, path2);
|
||||
}
|
||||
|
||||
pathString[newLen] = '\0';
|
||||
|
||||
return pathString;
|
||||
}
|
||||
|
||||
const char * Path_GetDirectory(char const * const path)
|
||||
{
|
||||
const char * strPtr = NULL;
|
||||
size_t pathLen = 0;
|
||||
char * pathString;
|
||||
|
||||
strPtr = strrchr(path, '\\');
|
||||
|
||||
pathLen = (size_t)strPtr - (size_t)path;
|
||||
|
||||
pathString = (char *)malloc(pathLen + 1);
|
||||
|
||||
strncpy(pathString, path, pathLen);
|
||||
|
||||
pathString[pathLen] = '\0';
|
||||
|
||||
return pathString;
|
||||
}
|
||||
|
||||
const char * Path_GetExtension(char const * const path)
|
||||
{
|
||||
const char * strPtr = NULL;
|
||||
size_t pathLen = 0;
|
||||
size_t strLen = 0;
|
||||
char * pathString = NULL;
|
||||
|
||||
strPtr = strrchr(path, '.');
|
||||
|
||||
if (strPtr == NULL)
|
||||
{
|
||||
// no extension, return an empty string.
|
||||
return "";
|
||||
}
|
||||
|
||||
strLen = strlen(path);
|
||||
|
||||
pathLen = (size_t)strPtr - (size_t)path;
|
||||
|
||||
strLen -= pathLen;
|
||||
|
||||
pathString = (char *)malloc(strLen + 1);
|
||||
|
||||
strncpy(pathString, strPtr + 1, strLen);
|
||||
|
||||
pathString[strLen] = '\0';
|
||||
|
||||
return pathString;
|
||||
}
|
||||
|
||||
const char * Path_GetFileName(char const * const path)
|
||||
{
|
||||
const char * strPtr = NULL;
|
||||
size_t pathLen = 0;
|
||||
size_t strLen = 0;
|
||||
char * pathString = NULL;
|
||||
|
||||
strPtr = strrchr(path, '\\');
|
||||
|
||||
strLen = strlen(path);
|
||||
|
||||
pathLen = (size_t)strPtr - (size_t)path;
|
||||
|
||||
strLen -= pathLen;
|
||||
|
||||
pathString = (char *)malloc(strLen + 1);
|
||||
|
||||
strncpy(pathString, strPtr + 1, strLen);
|
||||
|
||||
pathString[strLen] = '\0';
|
||||
|
||||
return pathString;
|
||||
}
|
||||
|
||||
const char * Path_GetFileNameWithoutExtension(char const * const path)
|
||||
{
|
||||
const char * strPtr = NULL;
|
||||
size_t pathLen = 0;
|
||||
char * pathString = NULL;
|
||||
const char * fileName = NULL;
|
||||
|
||||
fileName = Path_GetFileName(path);
|
||||
|
||||
strPtr = strchr(fileName, '.');
|
||||
|
||||
pathLen = (size_t)strPtr - (size_t)fileName;
|
||||
|
||||
pathString = (char *)malloc(pathLen + 1);
|
||||
|
||||
strncpy(pathString, fileName, pathLen);
|
||||
|
||||
free((void *)fileName);
|
||||
|
||||
pathString[pathLen] = '\0';
|
||||
|
||||
return pathString;
|
||||
}
|
||||
|
||||
struct _path Path =
|
||||
{
|
||||
Path_Combine,
|
||||
Path_GetDirectory,
|
||||
Path_GetExtension,
|
||||
Path_GetFileName,
|
||||
Path_GetFileNameWithoutExtension
|
||||
};
|
15
src/xnbbuild/src/Path.h
Normal file
15
src/xnbbuild/src/Path.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef _PATH_H
|
||||
#define _PATH_H
|
||||
|
||||
struct _path
|
||||
{
|
||||
const char * (*Combine)(char const * const, char const * const);
|
||||
const char * (*GetDirectory)(char const * const);
|
||||
const char * (*GetExtension)(char const * const);
|
||||
const char * (*GetFileName)(char const * const);
|
||||
const char * (*GetFileNameWithoutExtension)(char const * const);
|
||||
};
|
||||
|
||||
extern struct _path Path;
|
||||
|
||||
#endif //_PATH_H
|
13
src/xnbbuild/src/TryCatchFinally.h
Normal file
13
src/xnbbuild/src/TryCatchFinally.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef _TRYCATCHFINALLY_H
|
||||
#define _TRYCATCHFINALLY_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#define TRY do{ jmp_buf ex_buf__; switch(setjmp(ex_buf__) ){ case 0: while(1){
|
||||
#define CATCH(x) break; case x:
|
||||
#define FINALLY break; } default:
|
||||
#define ETRY } }while(0)
|
||||
#define THROW(x) longjmp(ex_buf__, x)
|
||||
|
||||
#endif //_TRYCATCHFINALLY_H
|
62
src/xnbbuild/src/main.c
Normal file
62
src/xnbbuild/src/main.c
Normal file
@ -0,0 +1,62 @@
|
||||
#if _MSC_VER
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Path.h"
|
||||
#include "TryCatchFinally.h"
|
||||
|
||||
/**
|
||||
* Application entry point
|
||||
*
|
||||
* @param argc
|
||||
* The amount of values passed in argv.
|
||||
*
|
||||
* @param argv
|
||||
* An array of strings that contains the command-line arguments.
|
||||
*
|
||||
* @return
|
||||
* Application error code
|
||||
*/
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FILE *fpIn = NULL;
|
||||
FILE *fpOut = NULL;
|
||||
const char * inFile = NULL;
|
||||
const char * outDir = NULL;
|
||||
int i;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
printf("");
|
||||
}
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if (strncmp(argv[i], "-outdir", 7) == 0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (argc > 0)
|
||||
{
|
||||
inFile = Path.GetFileName(argv[argc - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
TRY
|
||||
fpIn = fopen(inFile, "rb");
|
||||
fpOut = fopen(Path.Combine(outDir, inFile), "wb");
|
||||
|
||||
|
||||
FINALLY
|
||||
break;
|
||||
ETRY;
|
||||
|
||||
return 0;
|
||||
}
|
79
src/xnbbuild/xnbbuild.vcxproj
Normal file
79
src/xnbbuild/xnbbuild.vcxproj
Normal file
@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{E5F1599D-C9FE-4EFB-97B6-13B46D4A1E35}</ProjectGuid>
|
||||
<RootNamespace>xnbbuild</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<StringPooling>true</StringPooling>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\main.c" />
|
||||
<ClCompile Include="src\Path.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\Path.h" />
|
||||
<ClInclude Include="src\TryCatchFinally.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
33
src/xnbbuild/xnbbuild.vcxproj.filters
Normal file
33
src/xnbbuild/xnbbuild.vcxproj.filters
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\main.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Path.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\TryCatchFinally.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Path.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user