1
0
mirror of https://github.com/thes3m/XNI synced 2024-12-26 13:26:06 +01:00
XNI/Classes/Retronator/Xni/Framework/Content/VertexBufferReader.m
Matej Jan d5b2897d8b Added 3D Model support.
git-svn-id: http://xni.googlecode.com/svn/XNI@42 ac433895-eea3-a490-d80a-17149a75e588
2010-11-30 23:26:03 +00:00

37 lines
1.1 KiB
Objective-C

//
// VertexBufferReader.m
// XNI
//
// Created by Matej Jan on 23.11.10.
// Copyright 2010 Retronator. All rights reserved.
//
#import "VertexBufferReader.h"
#import "Retronator.Xni.Framework.Content.h"
#import "Retronator.Xni.Framework.Graphics.h"
#import "Retronator.Xni.Framework.Content.Pipeline.Processors.h"
#import "GraphicsDevice+Internal.h"
@implementation VertexBufferReader
- (id) readFromInput:(ContentReader *)input into:(id)existingInstance {
VertexBufferContent *content = input.content;
GraphicsDevice *graphicsDevice = [[input.contentManager.serviceProvider getServiceOfType:@protocol(IGraphicsDeviceService)] graphicsDevice];
VertexDeclaration *vertexDeclaration = [input readObjectFrom:content.vertexDeclaration];
int vertexCount = [content.vertexData length] / vertexDeclaration.vertexStride;
VertexBuffer *buffer = [[[VertexBuffer alloc] initWithGraphicsDevice:graphicsDevice
vertexDeclaration:vertexDeclaration
vertexCount:vertexCount usage:BufferUsageWriteOnly] autorelease];
[graphicsDevice setData:(void*)[content.vertexData bytes] toVertexBuffer:buffer];
return buffer;
}
@end