… | |
… | |
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 | |
127 | sub new_from_opengl { |
127 | sub new_from_opengl { |
… | |
… | |
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; |
144 | glMatrixMode GL_PROJECTION; |
145 | glLoadIdentity; |
145 | glLoadIdentity; |
146 | glOrtho 0, $self->{width}, $self->{height}, 0, -100, 100; |
146 | glOrtho 0, $self->{width}, 0, $self->{height}, -100, 100; |
147 | glMatrixMode GL_MODELVIEW; |
147 | glMatrixMode GL_MODELVIEW; |
148 | glPushmatrix; |
148 | glPushmatrix; |
149 | glLoadIdentity; |
149 | glLoadIdentity; |
150 | glClear GL_COLOR_BUFFER_BIT; |
150 | glClear GL_COLOR_BUFFER_BIT; |
151 | |
151 | |
… | |
… | |
166 | |
166 | |
167 | ($self->{name}) = @{glGenTextures 1}; |
167 | ($self->{name}) = @{glGenTextures 1}; |
168 | |
168 | |
169 | glBindTexture GL_TEXTURE_2D, $self->{name}; |
169 | glBindTexture GL_TEXTURE_2D, $self->{name}; |
170 | |
170 | |
171 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; |
171 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST; |
172 | 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; |
173 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; |
173 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; |
174 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; |
174 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; |
175 | |
175 | |
176 | if (defined $data) { |
176 | if (defined $data) { |
177 | glTexImage2D GL_TEXTURE_2D, 0, |
177 | glTexImage2D GL_TEXTURE_2D, 0, |
… | |
… | |
192 | 0, 0, |
192 | 0, 0, |
193 | $self->{width}, $self->{height}, |
193 | $self->{width}, $self->{height}, |
194 | 0; |
194 | 0; |
195 | glPopmatrix; |
195 | glPopmatrix; |
196 | warn "ERR: ". (glGetError). "\n"; |
196 | warn "ERR: ". (glGetError). "\n"; |
|
|
197 | SDL::GLSwapBuffers; |
197 | sleep 1; |
198 | sleep 1; |
198 | } |
199 | } |
199 | } |
200 | } |
200 | |
201 | |
201 | sub DESTROY { |
202 | sub DESTROY { |