Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
OOTextureLoader.h
Go to the documentation of this file.
1/*
2
3OOTextureLoader.h
4
5Abstract base class for asynchronous texture loaders, which are dispatched by
6OOTextureLoadDispatcher. In general, this should be used through OOTexture.
7
8Note: interface is likely to change in future to support other buffer types
9(like S3TC/DXT#).
10
11
12Copyright (C) 2007-2014 Jens Ayton
13
14Permission is hereby granted, free of charge, to any person obtaining a copy
15of this software and associated documentation files (the "Software"), to deal
16in the Software without restriction, including without limitation the rights
17to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18copies of the Software, and to permit persons to whom the Software is
19furnished to do so, subject to the following conditions:
20
21The above copyright notice and this permission notice shall be included in all
22copies or substantial portions of the Software.
23
24THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30SOFTWARE.
31
32*/
33
34#import "OOTexture.h"
36
37
38@interface OOTextureLoader: NSObject <OOAsyncWorkTask>
39{
40@protected
41 NSString *_path;
44 uint8_t _generateMipMaps: 1,
55 void *_data;
56 uint32_t _width,
62 size_t _rowBytes;
64
65+ (id)loaderWithPath:(NSString *)path options:(uint32_t)options;
66
67/* Convenience method to load images not destined for normal texture use.
68 Specifier is a string or a dictionary as with textures. ExtraOptions is
69 ored into the option flags interpreted from the specifier. Folder is the
70 directory to look in, typically Textures or Images. Options in the
71 specifier which are applied at the OOTexture level will be ignored.
72*/
73+ (id)loaderWithTextureSpecifier:(id)specifier extraOptions:(uint32_t)extraOptions folder:(NSString *)folder;
74
75- (BOOL)isReady;
76
77/* Return value indicates success. This may only be called once (subsequent
78 attempts will return failure), and only on the main thread.
79*/
80- (BOOL) getResult:(OOPixMap *)result
81 format:(OOTextureDataFormat *)outFormat
82 originalWidth:(uint32_t *)outWidth
83 originalHeight:(uint32_t *)outHeight;
84
85/* Hopefully-unique string for texture loader; analagous, but not identical,
86 to corresponding texture cacheKey.
87*/
88- (NSString *) cacheKey;
89
90
91
92/*** Subclass interface; do not use on pain of pain. Unless you're subclassing. ***/
93
94// Subclasses shouldn't do much on init, because of the whole asynchronous thing.
95- (id)initWithPath:(NSString *)path options:(uint32_t)options;
96
97- (NSString *)path;
98
99/* Load data, setting up _data, _format, _width, and _height; also _rowBytes
100 if it's not _width * OOTextureComponentsForFormat(_format), and
101 _originalWidth/_originalHeight if _width and _height for some reason aren't
102 the original pixel dimensions.
103
104 Thread-safety concerns: this will be called in a worker thread, and there
105 may be several worker threads. The caller takes responsibility for
106 autorelease pools and exception safety.
107
108 Superclass will handle scaling and mip-map generation. Data must be
109 allocated with malloc() family.
110*/
111- (void)loadTexture;
112
113@end
OOPixMapFormat
Definition OOPixMap.h:39
uint32_t OOTextureFlags
Definition OOTexture.h:98
uint8_t _scaleAsNormalMap
OOTextureDataFormat _format
uint32_t _originalWidth
uint8_t _extractChannelIndex
OOTextureFlags _options
uint32_t _shrinkThreshold
uint32_t _originalHeight
uint8_t _noScalingWhatsoever