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(); } }
Context::Context(HDC hdc) { timeT = clock(); frameCount = 0; ctx = owglCreateContext(hdc); owglMakeCurrent(hdc, ctx); // Here we go. From the top. Where is glResetState? oglDisable(GL_ALPHA_TEST); oglDisable(GL_AUTO_NORMAL); oglEnable(GL_BLEND); // Skip clip planes, there are thousands of them. oglDisable(GL_COLOR_LOGIC_OP); oglDisable(GL_COLOR_MATERIAL); oglDisable(GL_COLOR_TABLE); oglDisable(GL_CONVOLUTION_1D); oglDisable(GL_CONVOLUTION_2D); oglDisable(GL_CULL_FACE); oglDisable(GL_DEPTH_TEST); oglDisable(GL_DITHER); oglDisable(GL_FOG); oglDisable(GL_HISTOGRAM); oglDisable(GL_INDEX_LOGIC_OP); oglDisable(GL_LIGHTING); // Skip line smmooth // Skip map oglDisable(GL_MINMAX); // Skip polygon offset oglDisable(GL_SEPARABLE_2D); oglDisable(GL_SCISSOR_TEST); oglDisable(GL_STENCIL_TEST); oglEnable(GL_TEXTURE_2D); oglDisable(GL_TEXTURE_GEN_Q); oglDisable(GL_TEXTURE_GEN_R); oglDisable(GL_TEXTURE_GEN_S); oglDisable(GL_TEXTURE_GEN_T); oglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); texture = ~0; }
static void drawIP(const char* ip, int size, int xx, int yy) { static const char* chardot = " " " " " " " " "."; 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* loading = ". ... ... .. . ... ... " ". . . . . . . . . . . " ". . . ... . . . . . . . " ". . . . . . . . . . . . " "... ... . . .. . . . ... . . ."; static const char* localip = ". ... ... ... . . ... . ... ... ... " ". . . . . . . . . . . . . . . . ." ". . . . ... . . ... . . . .. . . " ". . . . . . . . . . . . . . . ." "... ... ... . . ... . . . . . . ... "; static const char* ipinfo = ". ... . ... ... ... " ". . . . . . . . . " ". ... . . . .. . . ." ". . . . . . . . " ". . . . . . ... ."; static const char* version = "... ... . . ... . " " . . . . . . . . . ." "... . . . . . . . . ." ". . . . ... . . ..." "... ... . . . ... ."; static const char* chars[] = {char0, char1, char2, char3, char4, char5, char6, char7, char8, char9}; gglColor4f(0, 0, 0, 1); oglDisable(GL_TEXTURE_2D); oglEnableClientState(GL_VERTEX_ARRAY); float v[8]; glVertexPointer(2, GL_FLOAT, 0, v); int len = strlen(ip); for (int i = 0; i < len; ++i) { const char* chr; if (ip[i] == '.') chr = chardot; else if (ip[i] == 'I') chr = localip; else if (ip[i] == 'L') chr = loading; else if (ip[i] == 'V') chr = version; else 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; oglDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } } xx = xx + width + 1; } oglDisableClientState(GL_VERTEX_ARRAY); }
void Context::initContext() { // Here we go. From the top. Where is glResetState? oglDisable(GL_ALPHA_TEST); oglDisable(GL_AUTO_NORMAL); oglEnable(GL_BLEND); // Skip clip planes, there are thousands of them. oglDisable(GL_COLOR_LOGIC_OP); oglDisable(GL_COLOR_MATERIAL); oglDisable(GL_COLOR_TABLE); oglDisable(GL_CONVOLUTION_1D); oglDisable(GL_CONVOLUTION_2D); oglDisable(GL_CULL_FACE); oglDisable(GL_DEPTH_TEST); oglDisable(GL_DITHER); oglDisable(GL_FOG); oglDisable(GL_HISTOGRAM); oglDisable(GL_INDEX_LOGIC_OP); oglDisable(GL_LIGHTING); // Skip line smmooth // Skip map oglDisable(GL_MINMAX); // Skip polygon offset oglDisable(GL_SEPARABLE_2D); oglDisable(GL_SCISSOR_TEST); oglDisable(GL_STENCIL_TEST); oglEnable(GL_TEXTURE_2D); oglDisable(GL_TEXTURE_GEN_Q); oglDisable(GL_TEXTURE_GEN_R); oglDisable(GL_TEXTURE_GEN_S); oglDisable(GL_TEXTURE_GEN_T); oglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); }