mirror of
https://github.com/thes3m/XNI
synced 2024-12-26 13:26:06 +01:00
- cleaned RenderTarget2D code. - fixed graphics device bug when switching from rendertarget to backbuffer. git-svn-id: http://xni.googlecode.com/svn/XNI@129 ac433895-eea3-a490-d80a-17149a75e588
75 lines
2.3 KiB
Objective-C
75 lines
2.3 KiB
Objective-C
//
|
|
// RenderTarget2D.m
|
|
// XNI
|
|
//
|
|
// Created by Samo Pajk on 9/3/12.
|
|
// Copyright (c) 2012 Samo Pajk. All rights reserved.
|
|
//
|
|
|
|
#import "RenderTarget2D.h"
|
|
#import "Retronator.Xni.Framework.h"
|
|
#import "Retronator.Xni.Framework.Graphics.h"
|
|
|
|
#import <QuartzCore/QuartzCore.h>
|
|
#import <OpenGLES/ES1/gl.h>
|
|
#import <OpenGLES/ES2/gl.h>
|
|
#import <OpenGLES/ES2/glext.h>
|
|
|
|
@interface RenderTarget2D (){
|
|
GLuint framebuffer;
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation RenderTarget2D
|
|
|
|
- (id)initWithGraphicsDevice:(GraphicsDevice *)theGraphicsDevice width:(int)theWidth height:(int)theHeight{
|
|
|
|
return [self initWithGraphicsDevice:theGraphicsDevice width:theWidth height:theHeight mipmap:NO surfaceFormat:SurfaceFormatAlpha8 depthFormat:DepthFormatNone multiSampleCount:0 usage:RenderTargetUsageDiscardContents];
|
|
}
|
|
|
|
- (id)initWithGraphicsDevice:(GraphicsDevice *)theGraphicsDevice
|
|
width:(int)theWidth
|
|
height:(int)theHeight
|
|
mipmap:(BOOL)theMipmap
|
|
surfaceFormat:(SurfaceFormat)theSurfaceFormat
|
|
depthFormat:(DepthFormat)theDepthFormat{
|
|
|
|
return [self initWithGraphicsDevice:theGraphicsDevice width:theWidth height:theHeight mipmap:NO surfaceFormat:theSurfaceFormat depthFormat:theDepthFormat multiSampleCount:0 usage:RenderTargetUsageDiscardContents];
|
|
}
|
|
|
|
- (id)initWithGraphicsDevice:(GraphicsDevice *)theGraphicsDevice
|
|
width:(int)theWidth
|
|
height:(int)theHeight
|
|
mipmap:(BOOL)theMipmap
|
|
surfaceFormat:(SurfaceFormat)theSurfaceFormat
|
|
depthFormat:(DepthFormat)theDepthFormat
|
|
multiSampleCount:(int) theMultisampleCount
|
|
usage:(RenderTargetUsage)theUsage{
|
|
|
|
self = [super initWithGraphicsDevice:theGraphicsDevice width:theWidth height:theHeight mipMaps:theMipmap format:theSurfaceFormat];
|
|
if (self) {
|
|
//Texture is already created by super object.
|
|
//Here we only create a framebuffer.
|
|
glGenFramebuffersOES(1, &framebuffer);
|
|
}
|
|
return self;
|
|
}
|
|
|
|
@synthesize renderTargetUsage, isContentLost;
|
|
|
|
-(GLuint) colorFramebuffer{
|
|
return framebuffer;
|
|
}
|
|
|
|
- (void)dealloc{
|
|
glDeleteFramebuffers(1, &framebuffer);
|
|
[super dealloc];
|
|
}
|
|
|
|
//- (void) saveAsPng:(NSData*)textureData width:(int)width height:(int)height{
|
|
//
|
|
//}
|
|
|
|
@end
|