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

Comparing libgender/material.C (file contents):
Revision 1.18 by root, Fri Oct 29 17:21:54 2004 UTC vs.
Revision 1.19 by root, Fri Oct 29 23:19:08 2004 UTC

28 28
29GLuint 29GLuint
30texture::load_texture (SDL_Surface * surface, GLfloat * tex2oord) 30texture::load_texture (SDL_Surface * surface, GLfloat * tex2oord)
31{ 31{
32 GLuint name; 32 GLuint name;
33 int w, h;
34 SDL_Surface *image; 33 SDL_Surface *image;
35 SDL_Rect area; 34 SDL_Rect area;
36 Uint32 saved_flags; 35 Uint32 saved_flags;
37 Uint8 saved_alpha; 36 Uint8 saved_alpha;
38 37
39 /* Use the surface width and height expanded to powers of 2 */ 38 /* Use the surface width and height expanded to powers of 2 */
40 //w = power_of_two (surface->w);
41 //h = power_of_two (surface->h);
42 w = power_of_two (surface->w);
43 h = power_of_two (surface->h);
44 tex2oord[0] = 0.0f; /* Min X */ 39 tex2oord[0] = 0.F; /* Min X */
45 tex2oord[1] = 0.0f; /* Min Y */ 40 tex2oord[1] = 0.F; /* Min Y */
46 tex2oord[2] = (GLfloat) surface->w / w; /* Max X */ 41 tex2oord[2] = 1.F; /* Max X */
47 tex2oord[3] = (GLfloat) surface->h / h; /* Max Y */ 42 tex2oord[3] = 1.F; /* Max Y */
48 43
49 image = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, 32, 44 image = SDL_CreateRGBSurface (SDL_SWSURFACE, surface->w, surface->h, 32,
50#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ 45#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
51 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 46 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000
52#else 47#else
53 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF 48 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF
54#endif 49#endif
80 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 75 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
81 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 76 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
82 glTexParameteri (GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); 77 glTexParameteri (GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
83 glTexImage2D (GL_TEXTURE_2D, 78 glTexImage2D (GL_TEXTURE_2D,
84 0, 79 0,
85 GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); 80 GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels);
86 SDL_FreeSurface (image); /* No longer needed */ 81 SDL_FreeSurface (image); /* No longer needed */
87 82
88 return name; 83 return name;
89} 84}
90 85
110 105
111 temp_1f fac; 106 temp_1f fac;
112 107
113 fac = max (dot (fin.tex_coord[1], lightpos), 0.0); 108 fac = max (dot (fin.tex_coord[1], lightpos), 0.0);
114 fac = pow (fac, 3); 109 fac = pow (fac, 3);
115 xyz(fout.frag_color) = texture_2d (texvar, fin.tex_coord[0]) * (fac + 0.3); 110 xyz (fout.frag_color) = texture_2d (texvar, fin.tex_coord[0]) * (fac + 0.3);
116 111
117 p.fsh->end (); 112 p.fsh->end ();
118 p.fsh->compile (); 113 p.fsh->compile ();
119 p.link (); 114 p.link ();
120} 115}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines