… | |
… | |
36 | -blue_size => 8, |
36 | -blue_size => 8, |
37 | -double_buffer => 1, |
37 | -double_buffer => 1, |
38 | -resizeable => 0; |
38 | -resizeable => 0; |
39 | |
39 | |
40 | glEnable GL_TEXTURE_2D; |
40 | glEnable GL_TEXTURE_2D; |
41 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL; |
41 | # glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
42 | glShadeModel GL_FLAT; |
42 | glShadeModel GL_FLAT; |
43 | glDisable GL_DEPTH_TEST; |
43 | glDisable GL_DEPTH_TEST; |
44 | glMatrixMode GL_PROJECTION; |
44 | glMatrixMode GL_PROJECTION; |
|
|
45 | glBlendFunc GL_SRC_ALPHA, GL_ZERO; |
|
|
46 | glEnable GL_BLEND; |
45 | |
47 | |
46 | glLoadIdentity; |
48 | glLoadIdentity; |
47 | glOrtho 0, $WIDTH / 32, $HEIGHT / 32, 0, -1 , 1; |
49 | glOrtho 0, $WIDTH / 32, $HEIGHT / 32, 0, -1 , 1; |
48 | |
50 | |
49 | # re-bind all textures |
51 | # re-bind all textures |
50 | } |
52 | } |
51 | |
53 | |
52 | sub refresh { |
54 | sub refresh { |
53 | glClearColor 0.5, 0.5, 0.7, 0; |
55 | glClearColor 0, 0, 0, 0; |
54 | glClear GL_COLOR_BUFFER_BIT; |
56 | glClear GL_COLOR_BUFFER_BIT; |
55 | |
57 | |
56 | my $map = $conn->{map}; |
58 | my $map = $conn->{map}; |
57 | |
59 | |
58 | for my $x (0 .. $conn->{mapw} - 1) { |
60 | for my $x (0 .. $conn->{mapw} - 1) { |
59 | for my $y (0 .. $conn->{maph} - 1) { |
61 | for my $y (0 .. $conn->{maph} - 1) { |
60 | |
62 | |
61 | my $cell = $map->[$x][$y] |
63 | my $cell = $map->[$x][$y] |
62 | or next; |
64 | or next; |
|
|
65 | |
|
|
66 | # my $darkness = $cell->[3] * (1 / 255); |
|
|
67 | # glColor $darkness, $darkness, $darkness; |
63 | |
68 | |
64 | for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) { |
69 | for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) { |
65 | my $tex = $conn->{face}[$num]{texture} || 0; |
70 | my $tex = $conn->{face}[$num]{texture} || 0; |
66 | |
71 | |
67 | glBindTexture GL_TEXTURE_2D, $tex; |
72 | glBindTexture GL_TEXTURE_2D, $tex; |
68 | |
73 | |
69 | glColor 1,0,1; |
|
|
70 | glBegin GL_QUADS; |
74 | glBegin GL_QUADS; |
71 | glTexCoord 0, 0; glVertex $x, $y; |
75 | glTexCoord 0, 0; glVertex $x, $y; |
72 | glTexCoord 0, 1; glVertex $x, $y + 0.9; |
76 | glTexCoord 0, 1; glVertex $x, $y + 1; |
73 | glTexCoord 1, 1; glVertex $x + 0.9, $y + 0.9; |
77 | glTexCoord 1, 1; glVertex $x + 1, $y + 1; |
74 | glTexCoord 1, 0; glVertex $x + 0.9, $y; |
78 | glTexCoord 1, 0; glVertex $x + 1, $y; |
75 | glEnd; |
79 | glEnd; |
76 | } |
80 | } |
77 | } |
81 | } |
78 | } |
82 | } |
79 | |
83 | |