ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/util.h
(Generate patch)

Comparing libgender/util.h (file contents):
Revision 1.21 by root, Wed Oct 6 05:24:03 2004 UTC vs.
Revision 1.22 by root, Wed Oct 6 06:05:23 2004 UTC

1#ifndef UTIL_H 1#ifndef UTIL_H
2#define UTIL_H 2#define UTIL_H
3 3
4#include <SDL/SDL.h>
5#include <SDL/SDL_image.h>
4#include <cmath> 6#include <cmath>
5#include <vector> 7#include <vector>
8#include <string>
6 9
7#include <Cg/cg.h> 10#include <Cg/cg.h>
8#include <Cg/cgGL.h> 11#include <Cg/cgGL.h>
9 12
10using namespace std; 13using namespace std;
221}; 224};
222 225
223extern skedjuhlar main_scheduler; 226extern skedjuhlar main_scheduler;
224*/ 227*/
225 228
229GLuint SDL_GL_LoadTexture (SDL_Surface * surface, GLfloat * texcoord);
230inline int power_of_two (int input)
231{
232 int value = 1;
233
234 while (value < input)
235 {
236 value <<= 1;
237 }
238 return value;
239}
240
241
242
243struct TextureExecption {
244 TextureExecption(string s) : msg(s) {}
245 string msg;
246};
247struct Texture {
248 SDL_Surface *image;
249 GLuint texture;
250 GLfloat texcoord[4];
251
252 public:
253 void new_from_file (const char *f) {
254 image = IMG_Load(f);
255 if(!image)
256 throw (TextureExecption("Couldn't load " + (string) f + ": " + (string) IMG_GetError ()));
257 texture = SDL_GL_LoadTexture (image, (GLfloat*)&texcoord);
258 if (texture == 0)
259 throw (TextureExecption("Couldn't make GL Texture, failed to create new RGB SWSurface"));
260 }
261};
262
226#endif 263#endif
227 264

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines