ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.10 by elmex, Sat Apr 8 17:21:01 2006 UTC vs.
Revision 1.13 by elmex, Sat Apr 8 22:23:57 2006 UTC

117 my ($class, $ttf, $text) = @_; 117 my ($class, $ttf, $text) = @_;
118 118
119 utf8::encode $text; 119 utf8::encode $text;
120 120
121 my $surface = SDL::TTFRenderUTF8Blended $ttf, $text, 121 my $surface = SDL::TTFRenderUTF8Blended $ttf, $text,
122 (new SDL::Color -r => 255, -g => 255, -b => 255); 122 (new SDL::Color -r => 0, -g => 0, -b => 0);
123 123
124 $class->new_from_surface (bless \$surface, SDL::Surface::) 124 $class->new_from_surface (bless \$surface, SDL::Surface::)
125} 125}
126 126
127sub new_from_opengl { 127sub new_from_opengl {
139 139
140 if (exists $self->{data}) { 140 if (exists $self->{data}) {
141 $data = $self->{data}; 141 $data = $self->{data};
142 } elsif (exists $self->{rendercb}) { 142 } elsif (exists $self->{rendercb}) {
143 glViewport 0, 0, $self->{width}, $self->{height}; 143 glViewport 0, 0, $self->{width}, $self->{height};
144 glMatrixMode GL_PROJECTION;
145 glLoadIdentity;
146 glOrtho 0, $self->{width}, 0, $self->{height}, -100, 100;
147 glMatrixMode GL_MODELVIEW;
148 glPushmatrix;
149 glLoadIdentity;
144 glClear GL_COLOR_BUFFER_BIT; 150 glClear GL_COLOR_BUFFER_BIT;
145 151
146 $self->{rendercb}->($self, $self->{width}, $self->{height}); 152 $self->{rendercb}->($self, $self->{width}, $self->{height});
147 } else { 153 } else {
148 my $pb = new Gtk2::Gdk::PixbufLoader; 154 my $pb = new Gtk2::Gdk::PixbufLoader;
160 166
161 ($self->{name}) = @{glGenTextures 1}; 167 ($self->{name}) = @{glGenTextures 1};
162 168
163 glBindTexture GL_TEXTURE_2D, $self->{name}; 169 glBindTexture GL_TEXTURE_2D, $self->{name};
164 170
165 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; 171 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST;
166 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR;#_MIPMAP_LINEAR; 172 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST;#_MIPMAP_LINEAR;
167 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; 173 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP;
168 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; 174 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP;
169 175
170 if (defined $data) { 176 if (defined $data) {
171 glTexImage2D GL_TEXTURE_2D, 0, 177 glTexImage2D GL_TEXTURE_2D, 0,
174 0, 180 0,
175 GL_RGBA, 181 GL_RGBA,
176 GL_UNSIGNED_BYTE, 182 GL_UNSIGNED_BYTE,
177 $data; 183 $data;
178 } else { 184 } else {
185 warn "I{DTEDRAW TEX: $self->{width} $self->{height} \n";
186 warn "ERR: ". (glGetError). "\n";
187 my ($bd, $br) = (glGet (GL_DRAW_BUFFER), glGet (GL_READ_BUFFER));
188 warn "BUF:[$bd $br]\n";
189
179 glCopyTexImage2D GL_TEXTURE_2D, 0, 190 glCopyTexImage2D GL_TEXTURE_2D, 0,
180 GL_RGBA8, 191 GL_RGBA8,
181 0, 0, 192 0, 0,
182 $self->{width}, $self->{height}, 193 $self->{width}, $self->{height},
183 0; 194 0;
195 glPopmatrix;
196 warn "ERR: ". (glGetError). "\n";
197 SDL::GLSwapBuffers;
198 sleep 1;
184 } 199 }
185} 200}
186 201
187sub DESTROY { 202sub DESTROY {
188 my ($self) = @_; 203 my ($self) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines