void GraphicsBase::draw() { if (indices.empty()) return; if (isWhite_ == false) { glPushColor(); glMultColor(r_, g_, b_, a_); } if (data) { oglEnable(GL_TEXTURE_2D); oglBindTexture(GL_TEXTURE_2D, data->id()); oglEnableClientState(GL_VERTEX_ARRAY); oglEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(2, GL_FLOAT, 0, &vertices[0]); glTexCoordPointer(2, GL_FLOAT, 0, &texcoords[0]); oglDrawElements(mode, indices.size(), GL_UNSIGNED_SHORT, &indices[0]); oglDisableClientState(GL_VERTEX_ARRAY); oglDisableClientState(GL_TEXTURE_COORD_ARRAY); } else { oglDisable(GL_TEXTURE_2D); oglEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, &vertices[0]); oglDrawElements(mode, indices.size(), GL_UNSIGNED_SHORT, &indices[0]); oglDisableClientState(GL_VERTEX_ARRAY); } if (isWhite_ == false) { glPopColor(); } }
void GraphicsBase::draw(ShaderProgram *shp, VertexBuffer<unsigned short> *commonIndices) { if (!commonIndices) commonIndices = &indices; if (commonIndices->empty()) return; if (isWhite_ == false) { glPushColor(); glMultColor(r_, g_, b_, a_); } if (data) { ShaderEngine::Engine->bindTexture(0,data->id()); if (!shp) shp=ShaderProgram::stdTexture; shp->setData(ShaderProgram::DataVertex,ShaderProgram::DFLOAT,2,&vertices[0],vertices.size(),vertices.modified,&vertices.bufferCache); shp->setData(ShaderProgram::DataTexture,ShaderProgram::DFLOAT,2,&texcoords[0],texcoords.size(),texcoords.modified,&texcoords.bufferCache); shp->drawElements(mode, commonIndices->size(), ShaderProgram::DUSHORT, &((*commonIndices)[0]), commonIndices->modified, &commonIndices->bufferCache); vertices.modified = false; texcoords.modified = false; commonIndices->modified = false; } else { if (!shp) shp=ShaderProgram::stdBasic; shp->setData(ShaderProgram::DataVertex,ShaderProgram::DFLOAT,2,&vertices[0],vertices.size(),vertices.modified,&vertices.bufferCache); shp->drawElements(mode, commonIndices->size(), ShaderProgram::DUSHORT, &((*commonIndices)[0]), commonIndices->modified, &commonIndices->bufferCache); vertices.modified = false; commonIndices->modified = false; } if (isWhite_ == false) { glPopColor(); } }
static void drawIP(const char* ip, int size, int xx, int yy) { static const char* chardot = " " " " " " " " "."; static const char* charcolon = " " "." " " "." " "; static const char* char0 = " .. " ". ." ". ." ". ." " .. "; static const char* char1 = " . " ".. " " . " " . " "..."; static const char* char2 = " .. " ". ." " . " " . " "...."; static const char* char3 = "... " " ." " .. " " ." "... "; static const char* char4 = " .." " . ." ". ." "...." " ."; static const char* char5 = "...." ". " "...." " ." "... "; static const char* char6 = " .. " ". " "... " ". ." " .. "; static const char* char7 = "...." " ." " . " " . " " . "; static const char* char8 = " .. " ". ." " .. " ". ." " .. "; static const char* char9 = " .. " ". ." " ..." " ." " .. "; static const char* chara = " .. " ". ." "...." ". ." ". ."; static const char* charb = "... " ". ." "... " ". ." "... "; static const char* charc = " ..." ". " ". " ". " " ..."; static const char* chard = "... " ". ." ". ." ". ." "... "; static const char* chare = "...." ". " "... " ". " "...."; static const char* charf = "...." ". " "... " ". " ". "; static const char* charPercent = ". ." " . " " . " " . " ". ."; static const char* charX = ". ." ". ." " .. " ". ." ". ."; static const char* charSpace = " " " " " " " " " "; static const char* loading = ". .. .. ... . . . ..." ". . . . . . . . .. . . " ". . . .... . . . . .. . .." ". . . . . . . . . . . ." "... .. . . ... . . . ..."; static const char* localip = ". .. ... .. . . ... . . . ... .. " ". . . . . . . . . . . .. . . . . ." ". . . . .... . . ... . . .. ... . . " ". . . . . . . . . . . . . . . ." "... .. ... . . ... . . . . . . .. "; static const char* resolution = "... ... ... .. . . . ..... . .. . . " ". . . . . . . . . . . . . .. . ." "... ... .. . . . . . . . . . . .. " ". . . . . . . . . . . . . . . ." ". . ... ... .. ... .. . . .. . . "; static const char* hardware = ". . .. ... ... . . . .. ... ... " ". . . . . . . . . . . . . . . . ." ".... .... ... . . . . . .... ... ... " ". . . . . . . . . . . . . . . ." ". . . . . . ... . . . . . . ... "; static const char* zoom = ".... .. .. . . " " . . . . . .. .. ." " .. . . . . . . . " ". . . . . . . ." ".... .. .. . . "; static const char* chars[] = {char0, char1, char2, char3, char4, char5, char6, char7, char8, char9, chara, charb, charc, chard, chare, charf }; glPushColor(); glSetColor(infoColor_[0], infoColor_[1], infoColor_[2], 1); float v[8]; int len = strlen(ip); for (int i = 0; i < len; ++i) { const char* chr=charSpace; if (ip[i] == '.') chr = chardot; else if (ip[i] == ':') chr = charcolon; else if(ip[i] == ' ') chr = charSpace; else if(ip[i] == 'X') chr = charX; else if(ip[i] == '%') chr = charPercent; else if (ip[i] == 'I') chr = localip; else if (ip[i] == 'L') chr = loading; else if (ip[i] == 'R') chr = resolution; else if (ip[i] == 'H') chr = hardware; else if (ip[i] == 'Z') chr = zoom; else if ((ip[i]>='a')&&(ip[i]<='f')) chr = chars[ip[i] - 'a'+10]; else if ((ip[i] >= '0') && (ip[i] <= '9')) chr = chars[ip[i] - '0']; int height = 5; int width = strlen(chr) / height; for (int y = 0; y < height; ++y) for (int x = 0; x < width; ++x) { if (chr[x + y * width] == '.') { //glBegin(GL_QUADS); //glVertex2i((x + xx) * size, (y + yy) * size); //glVertex2i((x + xx + 1) * size, (y + yy) * size); //glVertex2i((x + xx + 1) * size, (y + yy + 1) * size); //glVertex2i((x + xx) * size, (y + yy + 1) * size); //glEnd(); v[0] = (x + xx) * size; v[1] = (y + yy) * size; v[2] = (x + xx + 1) * size; v[3] = (y + yy) * size; v[4] = (x + xx) * size; v[5] = (y + yy + 1) * size; v[6] = (x + xx + 1) * size; v[7] = (y + yy + 1) * size; ShaderProgram::stdBasic->setData(ShaderProgram::DataVertex,ShaderProgram::DFLOAT,2, v,4, true, NULL); ShaderProgram::stdBasic->drawArrays(ShaderProgram::TriangleStrip, 0, 4); } } xx = xx + width + 1; } glPopColor(); }