2010-07-27 17:42:29 +00:00
|
|
|
//
|
|
|
|
// GraphicsDevice.h
|
|
|
|
// XNI
|
|
|
|
//
|
|
|
|
// Created by Matej Jan on 27.7.10.
|
|
|
|
// Copyright 2010 Retronator. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
#import <QuartzCore/QuartzCore.h>
|
|
|
|
#import <OpenGLES/ES1/glext.h>
|
|
|
|
#import <OpenGLES/ES2/glext.h>
|
|
|
|
|
2010-10-19 13:31:39 +00:00
|
|
|
#import "System.classes.h"
|
2010-07-27 17:42:29 +00:00
|
|
|
#import "Retronator.Xni.Framework.classes.h"
|
|
|
|
#import "Retronator.Xni.Framework.Graphics.classes.h"
|
|
|
|
|
|
|
|
@interface GraphicsDevice : NSObject {
|
|
|
|
Game *game;
|
|
|
|
EAGLContext *context;
|
|
|
|
|
2010-12-14 23:28:16 +00:00
|
|
|
// Presentation parameters
|
|
|
|
BOOL multisampling;
|
|
|
|
|
2010-07-27 17:42:29 +00:00
|
|
|
// The pixel dimensions of the CAEAGLLayer
|
|
|
|
GLint backingWidth;
|
|
|
|
GLint backingHeight;
|
|
|
|
|
|
|
|
// The OpenGL names for the buffers used to render to this view
|
2010-12-14 23:28:16 +00:00
|
|
|
GLuint resolveFramebuffer, resolveRenderbuffer;
|
2010-07-27 17:42:29 +00:00
|
|
|
GLuint defaultFramebuffer, colorRenderbuffer, depthRenderbuffer;
|
2010-09-21 21:46:53 +00:00
|
|
|
|
|
|
|
// Device state
|
|
|
|
Color *blendFactor;
|
|
|
|
BlendState *blendState;
|
|
|
|
DepthStencilState *depthStencilState;
|
|
|
|
GraphicsDeviceStatus graphicsDeviceStatus;
|
|
|
|
IndexBuffer *indices;
|
|
|
|
RasterizerState *rasterizerState;
|
|
|
|
int referenceStencil;
|
|
|
|
SamplerStateCollection *samplerStates;
|
|
|
|
TextureCollection *textures;
|
2010-09-23 21:13:28 +00:00
|
|
|
Viewport *viewport;
|
2012-05-14 08:40:49 +00:00
|
|
|
int activeTextureIndex;
|
2010-09-21 21:46:53 +00:00
|
|
|
|
2010-10-19 13:31:39 +00:00
|
|
|
// Events
|
|
|
|
Event *deviceResetting;
|
|
|
|
Event *deviceReset;
|
|
|
|
|
2010-09-21 21:46:53 +00:00
|
|
|
NSMutableArray *vertices;
|
2010-07-27 17:42:29 +00:00
|
|
|
}
|
|
|
|
|
2010-09-21 21:46:53 +00:00
|
|
|
- (id) initWithGame:(Game*) theGame;
|
|
|
|
|
|
|
|
@property (nonatomic, retain) Color *blendFactor;
|
|
|
|
@property (nonatomic, retain) BlendState *blendState;
|
|
|
|
@property (nonatomic, retain) DepthStencilState *depthStencilState;
|
|
|
|
@property (nonatomic, readonly) GraphicsDeviceStatus graphicsDeviceStatus;
|
2010-07-27 18:23:25 +00:00
|
|
|
@property (nonatomic, readonly) GraphicsProfile graphicsProfile;
|
2010-09-21 21:46:53 +00:00
|
|
|
@property (nonatomic, retain) IndexBuffer *indices;
|
|
|
|
@property (nonatomic, retain) RasterizerState *rasterizerState;
|
|
|
|
@property (nonatomic) int referenceStencil;
|
|
|
|
@property (nonatomic, readonly) SamplerStateCollection *samplerStates;
|
|
|
|
@property (nonatomic, readonly) TextureCollection *textures;
|
2010-09-23 21:13:28 +00:00
|
|
|
@property (nonatomic, retain) Viewport *viewport;
|
2010-07-27 18:23:25 +00:00
|
|
|
|
2010-10-19 13:31:39 +00:00
|
|
|
@property (nonatomic, readonly) Event *deviceResetting;
|
|
|
|
@property (nonatomic, readonly) Event *deviceReset;
|
|
|
|
|
2010-09-21 21:46:53 +00:00
|
|
|
+ (int) getNumberOfVerticesForPrimitiveType:(PrimitiveType)primitiveType primitiveCount:(int)primitiveCount;
|
2010-07-27 17:42:29 +00:00
|
|
|
|
|
|
|
// Presentation
|
|
|
|
- (void) reset;
|
|
|
|
- (void) present;
|
|
|
|
|
|
|
|
// Render buffers
|
|
|
|
- (void) clearWithColor:(Color*)color;
|
|
|
|
- (void) clearWithOptions:(ClearOptions)options color:(Color*)color depth:(float)depth stencil:(int)stencil;
|
|
|
|
|
2010-09-21 21:46:53 +00:00
|
|
|
// Vertex buffers
|
|
|
|
- (NSArray*) getVertexBuffers;
|
|
|
|
- (void) setVertexBuffer:(VertexBuffer*)vertexBuffer;
|
|
|
|
- (void) setVertexBuffer:(VertexBuffer*)vertexBuffer vertexOffset:(int)vertexOffset;
|
|
|
|
- (void) setVertexBuffers:(VertexBufferBinding*)vertexBuffer, ... NS_REQUIRES_NIL_TERMINATION;
|
|
|
|
|
2012-09-15 15:33:22 +00:00
|
|
|
//Render Targets
|
|
|
|
- (void) setRenderTarget:(RenderTarget2D*)renderTarget;
|
|
|
|
//- (RenderTarget2D*) getRenderTarget;
|
|
|
|
|
2010-09-21 21:46:53 +00:00
|
|
|
// Drawing
|
|
|
|
|
2010-11-30 23:26:03 +00:00
|
|
|
// From buffers
|
|
|
|
- (void) drawPrimitivesOfType:(PrimitiveType)primitiveType
|
|
|
|
startVertex:(int)startVertex
|
|
|
|
primitiveCount:(int)primitiveCount;
|
2010-09-21 21:46:53 +00:00
|
|
|
|
2010-11-30 23:26:03 +00:00
|
|
|
- (void) drawIndexedPrimitivesOfType:(PrimitiveType)primitiveType
|
|
|
|
baseVertex:(int)baseVertex
|
|
|
|
minVertexIndex:(int)minVertexIndex
|
|
|
|
numVertices:(int)numVertices
|
|
|
|
startIndex:(int)startIndex
|
|
|
|
primitiveCount:(int)primitiveCount;
|
2010-09-21 21:46:53 +00:00
|
|
|
|
2010-11-30 23:26:03 +00:00
|
|
|
// From arrays
|
2010-09-21 21:46:53 +00:00
|
|
|
- (void) drawUserPrimitivesOfType:(PrimitiveType)primitiveType
|
2010-11-30 23:26:03 +00:00
|
|
|
vertexData:(VertexArray*)vertexData
|
|
|
|
vertexOffset:(int)vertexOffset
|
|
|
|
primitiveCount:(int)primitiveCount;
|
2010-09-21 21:46:53 +00:00
|
|
|
|
2010-11-30 23:26:03 +00:00
|
|
|
- (void) drawUserPrimitivesOfType:(PrimitiveType)primitiveType
|
|
|
|
vertexData:(void*)vertexData
|
|
|
|
vertexOffset:(int)vertexOffset
|
|
|
|
primitiveCount:(int)primitiveCount
|
|
|
|
vertexDeclaration:(VertexDeclaration*) vertexDeclaration;
|
2010-09-16 17:49:35 +00:00
|
|
|
|
2010-11-30 23:26:03 +00:00
|
|
|
- (void) drawUserIndexedPrimitivesOfType:(PrimitiveType)primitiveType
|
|
|
|
vertexData:(VertexArray*)vertexData
|
|
|
|
vertexOffset:(int)vertexOffset
|
|
|
|
numVertices:(int)numVertices
|
|
|
|
indexData:(IndexArray*)indexData
|
|
|
|
indexOffset:(int)indexOffset
|
|
|
|
primitiveCount:(int)primitiveCount;
|
2010-09-01 14:55:24 +00:00
|
|
|
|
2010-11-30 23:26:03 +00:00
|
|
|
- (void) drawUserIndexedPrimitivesOfType:(PrimitiveType)primitiveType
|
|
|
|
vertexData:(void*)vertexData
|
|
|
|
vertexOffset:(int)vertexOffset
|
|
|
|
numVertices:(int)numVertices
|
|
|
|
shortIndexData:(void*)indexData
|
|
|
|
indexOffset:(int)indexOffset
|
|
|
|
primitiveCount:(int)primitiveCount
|
|
|
|
vertexDeclaration:(VertexDeclaration*) vertexDeclaration;
|
2010-07-27 17:42:29 +00:00
|
|
|
|
|
|
|
@end
|