15 |
DBG(dbg) << "TexId:: allocating\n"; |
DBG(dbg) << "TexId:: allocating\n"; |
16 |
glGenTextures(1, &id); |
glGenTextures(1, &id); |
17 |
DBG(dbg) << "TexId:: got "<<id<<"\n"; |
DBG(dbg) << "TexId:: got "<<id<<"\n"; |
18 |
if(this->isGood()) throw InvalidTexture(); |
if(!this->isGood()) { |
19 |
|
DBG(dbg) << "Didn't get a texture, bailing out\n"; |
20 |
|
throw InvalidTexture(); |
21 |
|
} |
22 |
DBG(dbg) << "TexId:: allocated\n"; |
DBG(dbg) << "TexId:: allocated\n"; |
23 |
} |
} |
24 |
|
|
133 |
} |
} |
134 |
|
|
135 |
MosaicTile MosaicBuilder::alloc(int w, int h, int border) { |
MosaicTile MosaicBuilder::alloc(int w, int h, int border) { |
136 |
|
DBG(dbg) << "Alloc "<<w<<" "<<h<<" "<<border<<"\n"; |
137 |
if(textures.size() == 0) createNew(); |
if(textures.size() == 0) createNew(); |
138 |
int pw = w + 2*border; |
int pw = w + 2*border; |
139 |
int ph = h + 2*border; |
int ph = h + 2*border; |
142 |
if(!b.valid()) { |
if(!b.valid()) { |
143 |
createNew(); |
createNew(); |
144 |
b = textures.back()->talloc->alloc(pw, ph); |
b = textures.back()->talloc->alloc(pw, ph); |
145 |
if(!b.valid()) |
if(!b.valid()) { |
146 |
|
std::cerr << "Too large texture\n"; |
147 |
throw TooLarge(); |
throw TooLarge(); |
148 |
|
} |
149 |
} |
} |
150 |
return MosaicTile(textures.back()->tex, |
return MosaicTile(textures.back()->tex, |
151 |
b.x + border, b.y + border, b.x+b.w - border, |
b.x + border, b.y + border, b.x+b.w - border, |