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YB5G25OOGR3YU7UZKNA57EJG5HRMCQ7UAC XKNRIFG2ULQLAAQ5GC4RBZPOERV73DLCNILEA5EP37JLIX5EP3OQC 4EOIRJBTEWVOK4EXA4XAWWS5CHAWZHAYRO6BRZWZ2SU2CGKV6VQAC 4QREXSE4IVMKT2SF6MAKIGYBHU276HR7L32L7KAQZQMDQ3KHGD7QC MADTICUXDKQB7EKTXG7J2OIJGUM7A437FRWIBRA3BIVEKXEXHO6AC 25CH7HH4LKXFIZ75YNMXS3TSXO6O27DYSOPLOD45K4OCNFWLS4LQC void draw_background(unsigned int bg, int x, int y);void draw_mcache(mcache_entry *entry, int x, int y);void draw_player(int x, int y);void draw_foreground(unsigned int bg, unsigned int fg, int x, int y);void draw_doll(const dolls_data &doll, int x, int y);void draw_cursor(cursor_type type, unsigned int tile);
void pack_background(unsigned int bg, int x, int y);void pack_mcache(mcache_entry *entry, int x, int y);void pack_player(int x, int y);void pack_foreground(unsigned int bg, unsigned int fg, int x, int y);void pack_doll(const dolls_data &doll, int x, int y);void pack_cursor(cursor_type type, unsigned int tile);void pack_buffers();
{ 0, 0, 0}, // BLACK{128, 128, 128}, // DKGREY{160, 160, 160}, // MDGREY{192, 192, 192}, // LTGREY{255, 255, 255}, // WHITE
VColour( 0, 0, 0, 255), // BLACKVColour(128, 128, 128, 255), // DKGREYVColour(160, 160, 160, 255), // MDGREYVColour(192, 192, 192, 255), // LTGREYVColour(255, 255, 255, 255), // WHITE
{ 0, 64, 255}, // BLUE (actually cyan-blue){128, 128, 255}, // LTBLUE{ 0, 32, 128}, // DKBLUE (maybe too dark)
VColour( 0, 64, 255, 255), // BLUE (actually cyan-blue)VColour(128, 128, 255, 255), // LTBLUEVColour( 0, 32, 128, 255), // DKBLUE (maybe too dark)
{192, 0, 255}, // MAGENTA (actually blue-magenta){255, 128, 255}, // LTMAGENTA{ 96, 0, 128}, // DKMAGENTA
VColour(192, 0, 255, 255), // MAGENTA (actually blue-magenta)VColour(255, 128, 255, 255), // LTMAGENTAVColour( 96, 0, 128, 255), // DKMAGENTA
}void TileRegion::add_quad(TextureID tex, unsigned int idx, int x, int y, int ofs_x, int ofs_y, bool centre, int ymax){// Generate quad//// 0 - 3// | |// 1 - 2//// Data Layout:// float2 (position)// float2 (texcoord)float pos_sx = x;float pos_sy = y;float pos_ex, pos_ey, tex_sx, tex_sy, tex_ex, tex_ey;m_image->m_textures[tex].get_coords(idx, ofs_x, ofs_y,pos_sx, pos_sy, pos_ex, pos_ey,tex_sx, tex_sy, tex_ex, tex_ey,centre, ymax);tile_vert v;v.pos_x = pos_sx;v.pos_y = pos_sy;v.tex_x = tex_sx;v.tex_y = tex_sy;m_verts.push_back(v);v.pos_y = pos_ey;v.tex_y = tex_ey;m_verts.push_back(v);v.pos_x = pos_ex;v.tex_x = tex_ex;m_verts.push_back(v);v.pos_y = pos_sy;v.tex_y = tex_sy;m_verts.push_back(v);
if (m_tileb.size() == 0)return;glLoadIdentity();glTranslatef(sx + ox, sy + oy, 0);glScalef(dx, dy, 1);m_verts.clear();m_verts.reserve(4 * crawl_view.viewsz.x * crawl_view.viewsz.y);
m_buf_dngn.clear();m_buf_doll.clear();m_buf_main.clear();
if (m_verts.size() > 0){m_image->m_textures[TEX_DUNGEON].bind();glVertexPointer(2, GL_FLOAT, sizeof(tile_vert), &m_verts[0].pos_x);glTexCoordPointer(2, GL_FLOAT, sizeof(tile_vert), &m_verts[0].tex_x);glDrawArrays(GL_QUADS, 0, m_verts.size());}tile = 0;m_verts.clear();for (int y = 0; y < crawl_view.viewsz.y; y++){for (int x = 0; x < crawl_view.viewsz.x; x++){unsigned int fg = m_tileb[tile] & TILE_FLAG_MASK;if (fg >= TILEP_MCACHE_START)
if (fg_idx >= TILEP_MCACHE_START)
if (m_verts.size() > 0){m_image->m_textures[TEX_DOLL].bind();glVertexPointer(2, GL_FLOAT, sizeof(tile_vert), &m_verts[0].pos_x);glTexCoordPointer(2, GL_FLOAT, sizeof(tile_vert), &m_verts[0].tex_x);glDrawArrays(GL_QUADS, 0, m_verts.size());}
pack_foreground(bg, fg, x, y);
}if (m_verts.size() > 0){m_image->m_textures[TEX_DEFAULT].bind();glVertexPointer(2, GL_FLOAT, sizeof(tile_vert), &m_verts[0].pos_x);glTexCoordPointer(2, GL_FLOAT, sizeof(tile_vert), &m_verts[0].tex_x);glDrawArrays(GL_QUADS, 0, m_verts.size());
m_image->m_textures[TEX_DEFAULT].bind();glVertexPointer(2, GL_FLOAT, sizeof(tile_vert), &m_verts[0].pos_x);glTexCoordPointer(2, GL_FLOAT, sizeof(tile_vert), &m_verts[0].tex_x);glDrawArrays(GL_QUADS, 0, m_verts.size());
pack_buffers();m_dirty = false;
glLoadIdentity();glTranslatef(sx + ox, sy + oy, 0);glScalef(dx, dy, 1);GLState state;state.array_vertex = true;state.array_texcoord = true;state.blend = true;state.texture = true;GLStateManager::set(state);m_image->m_textures[TEX_DUNGEON].bind();glVertexPointer(2, GL_FLOAT, sizeof(tile_vert), &m_verts[0].pos_x);glTexCoordPointer(2, GL_FLOAT, sizeof(tile_vert), &m_verts[0].tex_x);glDrawArrays(GL_QUADS, 0, m_base_verts);
if (m_min_gx > m_max_gx || m_min_gy > m_max_gy)return;// [enne] - GL_POINTS should probably be used here, but there's (apparently)// a bug in the OpenGL driver that I'm using and it doesn't respect// glPointSize unless GL_SMOOTH_POINTS is on. GL_SMOOTH_POINTS is// *terrible* for performance if it has to fall back on software rendering,// so instead we'll just make quads.glLoadIdentity();glTranslatef(sx + ox, sy + oy, 0);glScalef(dx, dx, 1);std::vector<map_vertex> verts;verts.reserve(4 * (m_max_gx - m_min_gx + 1) * (m_max_gy - m_min_gy + 1));
m_buf_map.clear();m_buf_lines.clear();
int pos_x = x - m_min_gx;int pos_y = y - m_min_gy;map_vertex v;v.r = map_colours[c][0];v.g = map_colours[c][1];v.b = map_colours[c][2];v.a = 255;v.x = pos_x;v.y = pos_y;verts.push_back(v);v.x = pos_x;v.y = pos_y + 1;verts.push_back(v);v.x = pos_x + 1;v.y = pos_y + 1;verts.push_back(v);
GLState state;state.array_vertex = true;state.array_colour = true;GLStateManager::set(state);glVertexPointer(2, GL_FLOAT, sizeof(map_vertex), &verts[0].x);glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(map_vertex), &verts[0].r);glDrawArrays(GL_QUADS, 0, verts.size());// TODO enne - make sure we're drawing within the map square here...
v.r = map_colours[c][0];v.g = map_colours[c][1];v.b = map_colours[c][2];v.a = 255;
float pos_sx = (m_win_start.x - m_min_gx);float pos_sy = (m_win_start.y - m_min_gy);float pos_ex = (m_win_end.x - m_min_gx) + 1 / (float)dx;float pos_ey = (m_win_end.y - m_min_gy) + 1 / (float)dy;
v.y = dy * (m_win_start.y - m_min_gy);verts.push_back(v);glVertexPointer(2, GL_FLOAT, sizeof(map_vertex), &verts[0].x);glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(map_vertex), &verts[0].r);glDrawArrays(GL_LINE_LOOP, 0, verts.size());
set_transform();m_buf_map.draw();m_buf_lines.draw();
glVertexPointer(2, GL_FLOAT, sizeof(PTVert), &m_verts[0].pos_x);glTexCoordPointer(2, GL_FLOAT, sizeof(PTVert), &m_verts[0].tex_x);glDrawArrays(m_prim, 0, m_verts.size());
glVertexPointer(2, GL_FLOAT, sizeof(Vert), &(*this)[0].pos_x);glTexCoordPointer(2, GL_FLOAT, sizeof(Vert), &(*this)[0].tex_x);glDrawArrays(m_prim, 0, size());
glVertexPointer(2, GL_FLOAT, sizeof(PCVert), &m_verts[0].pos_x);glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(PCVert), &m_verts[0].col);glDrawArrays(m_prim, 0, m_verts.size());
glVertexPointer(2, GL_FLOAT, sizeof(Vert), &(*this)[0].pos_x);glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vert), &(*this)[0].col);glDrawArrays(m_prim, 0, size());
glVertexPointer(2, GL_FLOAT, sizeof(PTCVert), &m_verts[0].pos_x);glTexCoordPointer(2, GL_FLOAT, sizeof(PTCVert), &m_verts[0].tex_x);glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(PTCVert), &m_verts[0].col);glDrawArrays(m_prim, 0, m_verts.size());
glVertexPointer(2, GL_FLOAT, sizeof(Vert), &(*this)[0].pos_x);glTexCoordPointer(2, GL_FLOAT, sizeof(Vert), &(*this)[0].tex_x);glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vert), &(*this)[0].col);glDrawArrays(m_prim, 0, size());
ASSERT(_valid(m_verts.size(), m_prim));
void TileBuffer::add(int idx, int x, int y, int ox, int oy, bool centre, int ymax){float pos_sx = x;float pos_sy = y;float pos_ex, pos_ey, tex_sx, tex_sy, tex_ex, tex_ey;TilesTexture *tex = (TilesTexture *)m_tex;tex->get_coords(idx, ox, oy, pos_sx, pos_sy, pos_ex, pos_ey,tex_sx, tex_sy, tex_ex, tex_ey, centre, ymax);size_t last = std::vector<Vert>::size();std::vector<Vert>::resize(last + 4);{Vert &v = (*this)[last];v.pos_x = pos_sx;v.pos_y = pos_sy;v.tex_x = tex_sx;v.tex_y = tex_sy;}{Vert &v = (*this)[last + 1];v.pos_x = pos_sx;v.pos_y = pos_ey;v.tex_x = tex_sx;v.tex_y = tex_ey;}{Vert &v = (*this)[last + 2];v.pos_x = pos_ex;v.pos_y = pos_ey;v.tex_x = tex_ex;v.tex_y = tex_ey;}{Vert &v = (*this)[last + 3];v.pos_x = pos_ex;v.pos_y = pos_sy;v.tex_x = tex_ex;v.tex_y = tex_sy;}
// [enne] - GL_POINTS should probably be used here, but there's (apparently)// a bug in the OpenGL driver that I'm using and it doesn't respect// glPointSize unless GL_SMOOTH_POINTS is on. GL_SMOOTH_POINTS is// *terrible* for performance if it has to fall back on software rendering,// so instead we'll just make quads.