… | |
… | |
18 | } |
18 | } |
19 | void osama_material::begin () |
19 | void osama_material::begin () |
20 | { |
20 | { |
21 | cgGLEnableProfile (vsh_profile); |
21 | cgGLEnableProfile (vsh_profile); |
22 | cgGLEnableProfile (fsh_profile); |
22 | cgGLEnableProfile (fsh_profile); |
23 | cgGLBindProgram (vsh); |
|
|
24 | cgGLBindProgram (fsh); |
|
|
25 | cgGLEnableTextureParameter(g_Texture); |
23 | cgGLEnableTextureParameter(g_Texture); |
26 | } |
24 | } |
27 | void osama_material::end () |
25 | void osama_material::end () |
28 | { |
26 | { |
29 | cgGLDisableTextureParameter(g_Texture); |
27 | cgGLDisableTextureParameter(g_Texture); |
30 | cgGLUnbindProgram (vsh_profile); |
28 | // cgGLUnbindProgram (vsh_profile); |
31 | cgGLUnbindProgram (fsh_profile); |
29 | // cgGLUnbindProgram (fsh_profile); |
32 | cgGLDisableProfile (vsh_profile); |
30 | cgGLDisableProfile (vsh_profile); |
33 | cgGLDisableProfile (fsh_profile); |
31 | cgGLDisableProfile (fsh_profile); |
34 | } |
32 | } |
35 | |
33 | |
36 | |
34 | |
37 | GLuint texture::load_texture (SDL_Surface *surface, GLfloat *texcoord) |
35 | GLuint texture::load_texture (SDL_Surface *surface, GLfloat *texcoord) |
38 | { |
36 | { |
39 | GLuint texture; |
37 | GLuint textur; |
40 | int w, h; |
38 | int w, h; |
41 | SDL_Surface *image; |
39 | SDL_Surface *image; |
42 | SDL_Rect area; |
40 | SDL_Rect area; |
43 | Uint32 saved_flags; |
41 | Uint32 saved_flags; |
44 | Uint8 saved_alpha; |
42 | Uint8 saved_alpha; |
… | |
… | |
85 | { |
83 | { |
86 | SDL_SetAlpha (surface, saved_flags, saved_alpha); |
84 | SDL_SetAlpha (surface, saved_flags, saved_alpha); |
87 | } |
85 | } |
88 | |
86 | |
89 | /* Create an OpenGL texture for the image */ |
87 | /* Create an OpenGL texture for the image */ |
90 | glGenTextures (1, &texture); |
88 | glGenTextures (1, &textur); |
91 | glBindTexture (GL_TEXTURE_2D, texture); |
89 | glBindTexture (GL_TEXTURE_2D, textur); |
92 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
90 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
93 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
91 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
94 | glTexImage2D (GL_TEXTURE_2D, |
92 | glTexImage2D (GL_TEXTURE_2D, |
95 | 0, |
93 | 0, |
96 | GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); |
94 | GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); |
97 | SDL_FreeSurface (image); /* No longer needed */ |
95 | SDL_FreeSurface (image); /* No longer needed */ |
98 | |
96 | |
99 | return texture; |
97 | return textur; |
100 | } |
98 | } |
101 | |
99 | |
102 | |
100 | |
103 | CGcontext cgc; |
101 | CGcontext cgc; |
104 | void init_shaders () { |
102 | void init_shaders () { |