2010-09-21 21:46:53 +00:00
|
|
|
//
|
|
|
|
// TextureCollection.m
|
|
|
|
// XNI
|
|
|
|
//
|
|
|
|
// Created by Matej Jan on 21.9.10.
|
|
|
|
// Copyright 2010 Retronator. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "TextureCollection.h"
|
2010-11-02 09:29:19 +00:00
|
|
|
#import "TextureCollection+Internal.h"
|
|
|
|
#import "XniSamplerEventArgs.h"
|
2012-10-15 15:01:36 +00:00
|
|
|
#import "XniSamplerEventArgs+Internal.h"
|
2010-09-21 21:46:53 +00:00
|
|
|
|
|
|
|
#import "Retronator.Xni.Framework.Graphics.h"
|
|
|
|
|
2012-10-15 15:01:36 +00:00
|
|
|
@interface TextureCollection (){
|
|
|
|
XniSamplerEventArgs *eventArgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2010-09-21 21:46:53 +00:00
|
|
|
@implementation TextureCollection
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self != nil) {
|
2010-11-02 09:29:19 +00:00
|
|
|
for (int i = 0; i < GL_MAX_TEXTURE_UNITS; i++) {
|
|
|
|
textures[i] = nil;
|
|
|
|
}
|
2012-10-15 15:01:36 +00:00
|
|
|
eventArgs = [[XniSamplerEventArgs alloc] initWithSamplerIndex:0];
|
2010-11-02 09:29:19 +00:00
|
|
|
textureChanged = [[Event alloc] init];
|
2010-09-21 21:46:53 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-11-02 09:29:19 +00:00
|
|
|
- (Event *) textureChanged {
|
|
|
|
return textureChanged;
|
2010-09-21 21:46:53 +00:00
|
|
|
}
|
|
|
|
|
2010-11-02 09:29:19 +00:00
|
|
|
- (Texture*)itemAtIndex:(NSUInteger)index {
|
|
|
|
return textures[index];
|
2010-09-21 21:46:53 +00:00
|
|
|
}
|
|
|
|
|
2010-11-02 09:29:19 +00:00
|
|
|
- (void)setItem:(Texture*)item atIndex:(NSUInteger)index {
|
|
|
|
if (textures[index] != item) {
|
|
|
|
textures[index] = item;
|
2012-10-15 15:01:36 +00:00
|
|
|
eventArgs.samplerIndex = index;
|
|
|
|
[textureChanged raiseWithSender:self eventArgs:eventArgs];
|
2010-11-02 09:29:19 +00:00
|
|
|
}
|
2010-09-21 21:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
2012-10-15 15:01:36 +00:00
|
|
|
[eventArgs release];
|
2010-11-02 09:29:19 +00:00
|
|
|
[textureChanged release];
|
2010-09-21 21:46:53 +00:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|