void CUIFrameLineWnd::Draw() { if(m_bTextureVisible) DrawElements (); inherited::Draw (); }
void sexyFillScreen(const ShaderState &ss, const View& view, uint color0, uint color1, float alpha) { if (alpha < epsilon || (color0 == 0 && color1 == 0)) return; glDepthMask(GL_FALSE); glDisable(GL_DEPTH_TEST); const float2 ws = 1.2f * view.sizePoints; const float2 ps = -0.1f * view.sizePoints; const float t = globals.renderTime / 20.f; const uint a = ALPHAF(alpha); // 1 2 // 0 3 const VertexPosColor v[] = { VertexPosColor(ps, a|rgb2bgr(lerpXXX(color0, color1, unorm_sin(t)))), VertexPosColor(ps + justY(ws), a|rgb2bgr(lerpXXX(color0, color1, unorm_sin(3.f * t)))), VertexPosColor(ps + ws, a|rgb2bgr(lerpXXX(color0, color1, unorm_sin(5.f * t)))), VertexPosColor(ps + justX(ws), a|rgb2bgr(lerpXXX(color0, color1, unorm_sin(7.f * t)))), }; static const uint i[] = {0, 1, 2, 0, 2, 3}; DrawElements(ShaderColorDither::instance(), ss, GL_TRIANGLES, v, i, arraySize(i)); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); }
void CUIFrameWindow::Draw() { if (m_bTextureVisible) DrawElements (); inherited::Draw(); }
// Draw a solid-color 1x1 quad at the origin of the XY plane (in model space) void QuadShaderProgram::DrawQuad( const Color::ColorVector& ac_roColor ) { // save previous program const ShaderProgram& oPrevious = ShaderProgram::Current(); Instance().Use(); // OpenGL uses column vectors, while the MathLibrary transforms are made for // use with row vectors. However, OpenGL stores matrix data in column-major // order, while the MathLibrary matrices store data in row-major order, so // feeding data from the latter to the former is an automatic transposition. glUniformMatrix4dv( Instance().m_iModelViewProjectionID, 1, false, &( GameEngine::ModelViewProjection()[0][0] ) ); // Set other uniforms and draw glUniform4fv( Instance().m_iColorID, 1, &( ac_roColor[0] ) ); DrawElements(); // return to previous program oPrevious.Use(); }
GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) { CONTEXT_EXEC(DrawElements(mode, count, type, indices)); }
int main() { char gameTitle[] = "pong"; int titleLength = strlen(gameTitle); Display *display = XOpenDisplay(NULL); if (!display) return 1; DisplayInfo(display); int screenNumber = DefaultScreen(display); unsigned long white = WhitePixel(display, screenNumber); unsigned long black = BlackPixel(display, screenNumber); Window window = XCreateSimpleWindow( display, DefaultRootWindow(display), 0, 0, // origin 200, 200, // size 0, black, // border white); // background color XStoreName(display, window, gameTitle); XFontStruct *fontInfo = XLoadQueryFont(display, "10x20"); XGCValues values; values.font = fontInfo->fid; values.foreground = XBlackPixel(display, screenNumber); unsigned long valueMask = GCFont+GCForeground; GC graphicalContext = XCreateGC(display, window, valueMask, &values); XMapWindow(display, window); Atom wmDeleteMessage = XInternAtom(display, "WM_DELETE_WINDOW", 0); XSetWMProtocols(display, window, &wmDeleteMessage, 1); XEvent event; int running = 1; long eventMask = ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask; XSelectInput(display, window, eventMask); while (running) { XNextEvent(display, (XEvent *)&event); switch (event.type) { case Expose: { /* if we have several other expose events waiting, don't redraw. */ /* we will do the redrawing when we receive the last of them. */ if (event.xexpose.count > 0) break; XWindowAttributes windowAttributes; int fontDirection, fontAscent, fontDescent; XCharStruct textStructure; XTextExtents( fontInfo, gameTitle, titleLength, &fontDirection, &fontAscent, &fontDescent, &textStructure); XGetWindowAttributes(display, window, &windowAttributes); int textX = (windowAttributes.width - textStructure.width) / 2; int textY = (windowAttributes.height - (textStructure.ascent + textStructure.descent)) / 2; XDrawString( display, window, graphicalContext, textX, textY, gameTitle, titleLength); DrawElements(display, window, graphicalContext); } break; case KeyPress: { /* translate the key code to a key symbol. */ KeySym keySymbol = XKeycodeToKeysym(display, event.xkey.keycode, 0); switch (keySymbol) { } } break; case ClientMessage: { if (event.xclient.data.l[0] == wmDeleteMessage) { running = 0; } } break; default: break; } } XDestroyWindow(display, window); XCloseDisplay(display); return 0; }