1 #ifndef NXNA_GRAPHICS_GRAPHICSDEVICE_H
2 #define NXNA_GRAPHICS_GRAPHICSDEVICE_H
4 #ifdef NXNA_ENABLE_DIRECT3D11
8 #ifdef NXNA_ENABLE_MATH
9 #include "../Vector3.h"
10 #include "../Matrix.h"
13 #include "PipelineState.h"
46 bool SupportsS3tcTextureCompression;
86 unsigned int ByteLength;
89 #ifdef NXNA_ENABLE_DIRECT3D11
99 #ifndef NXNA_DISABLE_VALIDATION
100 unsigned int ByteLength;
111 unsigned int ByteLength;
115 #ifdef NXNA_ENABLE_DIRECT3D11
123 #ifndef NXNA_DISABLE_VALIDATION
124 unsigned int ByteLength;
135 unsigned int ByteLength;
136 unsigned int UniformBuffer;
138 #ifdef NXNA_ENABLE_DIRECT3D11
146 #ifndef NXNA_DISABLE_VALIDATION
148 unsigned int ByteLength;
170 unsigned int BufferHandle;
172 #ifdef NXNA_ENABLE_DIRECT3D11
175 ID3D11Buffer* BufferPtr;
180 #ifndef NXNA_DISABLE_VALIDATION
183 unsigned int ByteLength;
198 Viewport(
int x,
int y,
int width,
int height)
206 float GetAspectRatio()
const {
return Width / (float)Height; }
208 #ifdef NXNA_ENABLE_MATH
214 void Project(
const float* source3f,
215 const float* projectMatrix16f,
216 const float* viewMatrix16f,
217 const float* worldMatrix16f,
220 #ifdef NXNA_ENABLE_MATH
227 #ifdef NXNA_ENABLE_MATH
234 int X, Y, Width, Height;
243 enum class ShaderType
249 typedef void (*GraphicsDeviceMessageCallback)(GraphicsDeviceDebugMessage);
270 #ifdef NXNA_ENABLE_DIRECT3D11
273 ID3D11Device* Device;
274 ID3D11DeviceContext* DeviceContext;
275 ID3D11RenderTargetView* RenderTargetView;
276 IDXGISwapChain* SwapChain;
282 #ifdef NXNA_ENABLE_DIRECT3D11
283 struct D3D11DeviceState
285 ID3D11Device* Device;
286 ID3D11DeviceContext* Context;
287 ID3D11RenderTargetView* RenderTargetView;
288 IDXGISwapChain* SwapChain;
292 enum class SurfaceFormat
313 SurfaceFormat Format;
316 unsigned int InitialDataByteCount;
327 #ifdef NXNA_ENABLE_DIRECT3D11
330 ID3D11ShaderResourceView* m_shaderResourceView;
331 ID3D11Texture2D* m_texture;
351 unsigned int InitialDataByteCount;
359 int NumInputElements;
363 unsigned int InitialDataByteCount;
369 unsigned int ByteCount;
385 int m_screenWidth, m_screenHeight;
395 #ifdef NXNA_ENABLE_DIRECT3D11
396 D3D11DeviceState m_d3d11State;
407 void SetMessageCallback(GraphicsDeviceMessageCallback callback);
409 #ifndef NXNA_ENABLE_DIRECT3D11
419 void SetViewport(
int x,
int y,
int width,
int height);
443 void BindTexture(
Texture2D* texture,
int textureUnit);
501 void SetVertexBuffer(
VertexBuffer vertexBuffer,
unsigned int offset,
unsigned int stride);
549 void DrawIndexedPrimitives(
PrimitiveType primitiveType,
int baseVertex,
int minVertexIndex,
int numVertices,
int startIndex,
int primitiveCount);
550 void DrawPrimitives(
PrimitiveType primitiveType,
int startVertex,
int primitiveCount);
552 void Clear(
float r,
float g,
float b,
float a);
555 #ifdef NXNA_ENABLE_DIRECT3D11
556 const D3D11DeviceState* GetD3D11DeviceState() {
return &m_d3d11State; }
563 void applyDirtyStates();
568 #endif // NXNA_GRAPHICS_GRAPHICSDEVICE_H
NxnaResult CreateVertexBuffer(const VertexBufferDesc *desc, VertexBuffer *result)
Definition: GraphicsDevice.cpp:1097
NxnaResult CreateTexture2D(const TextureCreationDesc *desc, Texture2D *result)
Definition: GraphicsDevice.cpp:280
void * MapBuffer(IndexBuffer buffer, MapType type)
Definition: GraphicsDevice.cpp:1459
void UpdateConstantBuffer(ConstantBuffer buffer, void *data, unsigned int dataLengthInBytes)
Definition: GraphicsDevice.cpp:1372
Definition: PipelineState.h:191
NxnaResult CreateShader(ShaderType type, const void *bytecode, int bytecodeLength, Shader *result)
Definition: GraphicsDevice.cpp:183
Definition: PipelineState.h:142
void DestroyTexture2D(Texture2D *texture)
Definition: GraphicsDevice.cpp:397
Definition: GraphicsDevice.h:258
Default write-only usage.
Definition: PipelineState.h:183
Definition: PipelineState.h:51
Definition: GraphicsDevice.h:237
Usage
Definition: GraphicsDevice.h:50
void SetViewport(int x, int y, int width, int height)
Sets the current viewport.
Definition: GraphicsDevice.cpp:121
Definition: PipelineState.h:58
Definition: GraphicsDevice.h:105
Definition: GraphicsDevice.h:164
void DestroyConstantBuffer(ConstantBuffer *buffer)
Definition: GraphicsDevice.cpp:1415
Definition: NxnaCommon.h:24
Definition: GraphicsDevice.h:80
NxnaResult
Definition: NxnaCommon.h:12
Definition: GraphicsDevice.h:354
void UpdateIndexBuffer(IndexBuffer buffer, unsigned int startOffset, void *data, unsigned int dataLengthInBytes)
Definition: GraphicsDevice.cpp:1025
Definition: GraphicsDevice.h:344
Definition: GraphicsDevice.h:42
void DestroyBlendState(BlendState *state)
Definition: GraphicsDevice.cpp:780
PrimitiveType
Definition: GraphicsDevice.h:62
Definition: GraphicsDevice.h:129
Definition: GraphicsDevice.h:307
void DestroyIndexBuffer(IndexBuffer buffer)
Definition: GraphicsDevice.cpp:1006
void UnmapBuffer(IndexBuffer buffer)
Definition: GraphicsDevice.cpp:1608
void DestroyShaderPipeline(ShaderPipeline *pipeline)
Definition: GraphicsDevice.cpp:536
Definition: GraphicsDevice.h:188
GraphicsDeviceType
The type of graphics device.
Definition: GraphicsDevice.h:23
BufferType
Definition: GraphicsDevice.h:152
Definition: GraphicsDevice.h:366
NxnaResult CreateIndexBuffer(const IndexBufferDesc *desc, IndexBuffer *result)
Definition: GraphicsDevice.cpp:931
A constant (or uniform) buffer.
Definition: GraphicsDevice.h:381
NxnaResult CreateShaderPipeline(const ShaderPipelineDesc *desc, ShaderPipeline *result)
Definition: GraphicsDevice.cpp:402
Definition: GraphicsDevice.h:319
void DestroyShader(Shader *shader)
Definition: GraphicsDevice.cpp:258
NxnaResult CreateBlendState(const BlendStateDesc *desc, BlendState *result)
Definition: GraphicsDevice.cpp:604
NxnaResult CreateConstantBuffer(const ConstantBufferDesc *desc, ConstantBuffer *result)
Definition: GraphicsDevice.cpp:1285
static NxnaResult CreateGraphicsDevice(const GraphicsDeviceDesc *params, GraphicsDevice *result)
Definition: GraphicsDevice.cpp:42
void UpdateVertexBuffer(VertexBuffer buffer, unsigned int startOffset, void *data, unsigned int dataLengthInBytes)
Definition: GraphicsDevice.cpp:1227
Definition: PipelineState.h:133
IndexElementSize
Definition: GraphicsDevice.h:71
Definition: PipelineState.h:110
void DestroyVertexBuffer(VertexBuffer buffer)
Definition: GraphicsDevice.cpp:1207