framework2
60 строк · 1.5 Кб
1//
2// ofxAsssimpTexture.cpp
3//
4// Created by Lukasz Karluk on 27/03/13.
5//
6//
7
8#include "ofxAssimpTexture.h"
9#include "ofLog.h"
10#include "ofUtils.h"
11
12void ofxAssimpTexture::setup(const ofTexture & texture, const of::filesystem::path & texturePath, bool bTexRepeat) {
13this->texture = texture;
14if( bTexRepeat ){
15this->texture.setTextureWrap(GL_REPEAT, GL_REPEAT);
16}else{
17this->texture.setTextureWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
18}
19this->texturePath = texturePath;
20}
21
22#ifndef TARGET_WIN32
23//this is a hack to allow for weak definations of functions that might not exist in older assimp versions
24const char *aiTextureTypeToString(enum aiTextureType in)__attribute__((weak));
25#endif
26
27void ofxAssimpTexture::setTextureType(aiTextureType aTexType){
28textureType = aTexType;
29
30if( textureType >= 0 && textureType < AI_TEXTURE_TYPE_MAX){
31if(aiTextureTypeToString){
32mTexTypeStr = aiTextureTypeToString(getTextureType());
33}else{
34mTexTypeStr = "textureType:"+ofToString(getTextureType());
35}
36}else{
37ofLogError("ofxAssimpTexture::setTextureType") << ": unknown aiTextureType type " << aTexType;
38mTexTypeStr = "NONE";
39}
40}
41
42ofTexture & ofxAssimpTexture::getTextureRef() {
43return texture;
44}
45
46of::filesystem::path ofxAssimpTexture::getTexturePath() {
47return texturePath;
48}
49
50bool ofxAssimpTexture::hasTexture() {
51return texture.isAllocated();
52}
53
54aiTextureType ofxAssimpTexture::getTextureType() const{
55return textureType;
56}
57
58std::string ofxAssimpTexture::getTextureTypeAsString() const{
59return mTexTypeStr;
60}
61