int main(int argc, char** argv) { int width, height, ch; int mode = GLFW_WINDOWED; GLFWwindow window; while ((ch = getopt(argc, argv, "fh")) != -1) { switch (ch) { case 'h': usage(); exit(EXIT_SUCCESS); case 'f': mode = GLFW_FULLSCREEN; break; default: usage(); exit(EXIT_FAILURE); } } glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); if (mode == GLFW_FULLSCREEN) { GLFWvidmode desktop_mode; glfwGetDesktopMode(&desktop_mode); width = desktop_mode.width; height = desktop_mode.height; } else { width = 200; height = 200; } window = glfwCreateWindow(width, height, mode, "Gamma Test", NULL); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } set_gamma(1.f); glfwMakeContextCurrent(window); glfwSwapInterval(1); glfwSetKeyCallback(window, key_callback); glfwSetWindowCloseCallback(window, window_close_callback); glfwSetWindowSizeCallback(window, size_callback); glMatrixMode(GL_PROJECTION); glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f); glMatrixMode(GL_MODELVIEW); glClearColor(0.5f, 0.5f, 0.5f, 0); while (!closed) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.8f, 0.2f, 0.4f); glRectf(-0.5f, -0.5f, 0.5f, 0.5f); glfwSwapBuffers(window); glfwPollEvents(); } glfwTerminate(); exit(EXIT_SUCCESS); }
/* main call for drawing a single NLA-strip */ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStrip *strip, View2D *v2d, float yminc, float ymaxc) { short nonSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0); float color[3]; /* get color of strip */ nla_strip_get_color_inside(adt, strip, color); /* draw extrapolation info first (as backdrop) * - but this should only be drawn if track has some contribution */ if ((strip->extendmode != NLASTRIP_EXTEND_NOTHING) && (nonSolo == 0)) { /* enable transparency... */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); switch (strip->extendmode) { /* since this does both sides, only do the 'before' side, and leave the rest to the next case */ case NLASTRIP_EXTEND_HOLD: /* only need to draw here if there's no strip before since * it only applies in such a situation */ if (strip->prev == NULL) { /* set the drawing color to the color of the strip, but with very faint alpha */ glColor4f(color[0], color[1], color[2], 0.15f); /* draw the rect to the edge of the screen */ glBegin(GL_QUADS); glVertex2f(v2d->cur.xmin, yminc); glVertex2f(v2d->cur.xmin, ymaxc); glVertex2f(strip->start, ymaxc); glVertex2f(strip->start, yminc); glEnd(); } /* fall-through */ /* this only draws after the strip */ case NLASTRIP_EXTEND_HOLD_FORWARD: /* only need to try and draw if the next strip doesn't occur immediately after */ if ((strip->next == NULL) || (IS_EQF(strip->next->start, strip->end) == 0)) { /* set the drawing color to the color of the strip, but this time less faint */ glColor4f(color[0], color[1], color[2], 0.3f); /* draw the rect to the next strip or the edge of the screen */ glBegin(GL_QUADS); glVertex2f(strip->end, yminc); glVertex2f(strip->end, ymaxc); if (strip->next) { glVertex2f(strip->next->start, ymaxc); glVertex2f(strip->next->start, yminc); } else { glVertex2f(v2d->cur.xmax, ymaxc); glVertex2f(v2d->cur.xmax, yminc); } glEnd(); } break; } glDisable(GL_BLEND); } /* draw 'inside' of strip itself */ if (nonSolo == 0) { /* strip is in normal track */ glColor3fv(color); UI_draw_roundbox_corner_set(UI_CNR_ALL); /* all corners rounded */ UI_draw_roundbox_shade_x(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1); } else { /* strip is in disabled track - make less visible */ glColor4f(color[0], color[1], color[2], 0.1f); glEnable(GL_BLEND); glRectf(strip->start, yminc, strip->end, ymaxc); glDisable(GL_BLEND); } /* draw strip's control 'curves' * - only if user hasn't hidden them... */ if ((snla->flag & SNLA_NOSTRIPCURVES) == 0) nla_draw_strip_curves(strip, yminc, ymaxc); /* draw strip outline * - color used here is to indicate active vs non-active */ if (strip->flag & NLASTRIP_FLAG_ACTIVE) { /* strip should appear 'sunken', so draw a light border around it */ glColor3f(0.9f, 1.0f, 0.9f); // FIXME: hardcoded temp-hack colors } else { /* strip should appear to stand out, so draw a dark border around it */ glColor3f(0.0f, 0.0f, 0.0f); } /* - line style: dotted for muted */ if (strip->flag & NLASTRIP_FLAG_MUTED) setlinestyle(4); /* draw outline */ UI_draw_roundbox_shade_x(GL_LINE_LOOP, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1); /* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */ if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQF(strip->repeat, 1.0f) == 0) { float repeatLen = (strip->actend - strip->actstart) * strip->scale; int i; /* only draw lines for whole-numbered repeats, starting from the first full-repeat * up to the last full repeat (but not if it lies on the end of the strip) */ for (i = 1; i < strip->repeat; i++) { float repeatPos = strip->start + (repeatLen * i); /* don't draw if line would end up on or after the end of the strip */ if (repeatPos < strip->end) fdrawline(repeatPos, yminc + 4, repeatPos, ymaxc - 4); } } /* or if meta-strip, draw lines delimiting extents of sub-strips (in same color as outline, if more than 1 exists) */ else if ((strip->type == NLASTRIP_TYPE_META) && (strip->strips.first != strip->strips.last)) { NlaStrip *cs; float y = (ymaxc - yminc) / 2.0f + yminc; /* only draw first-level of child-strips, but don't draw any lines on the endpoints */ for (cs = strip->strips.first; cs; cs = cs->next) { /* draw start-line if not same as end of previous (and only if not the first strip) * - on upper half of strip */ if ((cs->prev) && IS_EQF(cs->prev->end, cs->start) == 0) fdrawline(cs->start, y, cs->start, ymaxc); /* draw end-line if not the last strip * - on lower half of strip */ if (cs->next) fdrawline(cs->end, yminc, cs->end, y); } } /* reset linestyle */ setlinestyle(0); }
// Generate the Graphics void displayFcn(void) { // Clear display window. glClear(GL_COLOR_BUFFER_BIT); // Set graphic objects color to Red or change for your choice glColor3f(0.0, 1.0, 0.0); //Empty bitmap GLubyte bitShape[72] = {}; glColor3f(0.0, 0.0, 1.0); //Unique Bitmap 1 created. General block structure used to create Clint Eastwood GLubyte bitShape3[72] = { 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, }; glColor3f(1.0, 0.0, 0.0); //The Unique Bitmap 2 created: Eyes, Mouth GLubyte bitShape4[72] = { 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0x00, 0x7F, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x63, 0xFF, 0x00, 0x63, 0x00, 0xFF, 0x63, 0xFF, 0xFF, 0x63, 0xFF, 0x00, 0x63, 0x00, 0xFF, 0x63, 0xFF, }; // Needed for reading from memory. 1 indicates byte alignment glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // Center the bitmap image glRasterPos2i(0, 0); /*--------------------------RECTANGLES--------------------------------*/ //3rd Quadrant the Ugly Rectangle float vertex3[] = { -1.0f, -0.67f }; float vertex4[] = { 0, 0 }; glColor3f(0.6, 0.0, 1.0); glRectf(-1.0f, -0.67f, 0, 0); //2nd Quadrant, the Bad Rectangle double vertex1[] = { 0, 0 }; double vertex2[] = { -100, 100 }; glColor3f(0.4, 0.4, 0.4); glRectdv(vertex1, vertex2); //Yellow Rectangle, 2st Quadrant double vertex5[] = { 0, 0 }; double vertex6[] = { 100, 100 }; glColor3f(1.4, 4.4, 0.4); glRectdv(vertex5, vertex6); //The Ground glColor3f(0.85, 0.64, 0.52); glRectf(-1.0f, -0.67f, 1.0f, -1.0f); // Using the Bitmaps created glBitmap(24.0, 24.0, 0.0, 0.0, 20, 120.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -60.0, 0.0, bitShape4); glBitmap(24.0, 24.0, 0.0, 0.0, 10.0, -120.0, bitShape4); glBitmap(24.0, 24.0, 0.0, 0.0, 20, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -25.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -25.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -25.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 150.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -25.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -25.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, 100.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -100.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 60.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, -180.0, -40.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 0.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 35.0, -100.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, -20.0, bitShape3); glBitmap(24.0, 24.0, 0.0, 0.0, 60.0, -80.0, bitShape3); /*----------------POLYGONS: Traingles, Quads-------------------*/ //Machete 1 - Traingle glColor3f(0.9, 0.55, 0.12); glBegin(GL_TRIANGLES); glVertex3f(0.2f, -0.45f, 0.0f); glVertex3f(0.5f, 0.0f, 0.0f); glVertex3f(0.6f, -0.2f, 0.0f); glEnd(); //Machete 2 - Quadilateral glColor3f(0.4, 0.2, 0.18); glBegin(GL_QUADS); glVertex3f(-0.20f, -0.45f, 0.0f); glVertex3f(-0.2f, -0.4f, 0.0f); glVertex3f(-0.30f, 0.15f, 0.0f); glVertex3f(-0.40f, 0.05f, 0.0f); glEnd(); //The Moustache glColor3f(0.0, 0.0, 0.0); glBegin(GL_QUADS); glVertex3f(-0.30f, 0.23f, 0.0f); glVertex3f(-0.30f, 0.35f, 0.0f); glVertex3f(0.30f, 0.23f, 0.0f); glVertex3f(0.30f, 0.35f, 0.0f); glEnd(); //The Cactus 1 glColor3f(0.08, 0.56, 0.002); glBegin(GL_QUADS); glVertex3f(-0.60f, -0.67f, 0.0f); glVertex3f(-0.50f, -0.67f, 0.0f); glVertex3f(-0.60f, -0.23f, 0.0f); glVertex3f(-0.50f, -0.285f, 0.0f); glEnd(); //The Cactus 2 glColor3f(0.08, 0.56, 0.002); glBegin(GL_QUADS); glVertex3f(0.83f, -0.67f, 0.0f); glVertex3f(0.96f, -0.67f, 0.0f); glVertex3f(0.93, 0.43f, 0.0f); glVertex3f(0.85f, 0.485f, 0.0f); glEnd(); //The Cactus 3 glColor3f(0.08, 0.56, 0.002); glBegin(GL_QUADS); glVertex3f(0.33f, -0.67f, 0.0f); glVertex3f(0.46f, -0.67f, 0.0f); glVertex3f(0.33, -0.43f, 0.0f); glVertex3f(0.45f, -0.485f, 0.0f); glEnd(); /*-----------------------------TEXTS------------------------------------*/ //"Happy Halloween" Message glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'H'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'A'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'P'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'P'); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'y'); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, ' '); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'H'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'A'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'L'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'L'); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'O'); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'W'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'E'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'e'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'N'); glBitmap(24.0, 24.0, 0.0, 0.0, 0.0, 300.0, bitShape); // glBitmap(24.0, 24.0, 0.0, 0.0, 30.0, 80.0, bitShape3); //"The Good" Text glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'T'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'H'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'E'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ' '); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'G'); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'O'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'o'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'D'); //"The Bad" Text glBitmap(24.0, 24.0, 0.0, 0.0, -660.0, 0.0, bitShape); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'T'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'H'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'E'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ' '); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'B'); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'a'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'D'); // "The Ugly" Message glBitmap(24.0, 24.0, 0.0, 0.0, -100.0, -200.0, bitShape); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'T'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'H'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'E'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ' '); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'U'); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'g'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 'L'); glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'y'); glBitmap(24.0, 24.0, 0.0, 0.0, 230.0, 240.0, bitShape); glBitmap(24.0, 24.0, 0.0, 0.0, -80.0, -350.0, bitShape4); //The "2014" Text glBitmap(24.0, 24.0, 0.0, 0.0, 20.0, 20.0, bitShape); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, '2'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, '0'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, '1'); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, '5'); /*--------------THE LINES-------------------------*/ glBegin(GL_LINES); //3rd Quadrant glColor3f(0.0, 1.0, 0.0); glVertex2f(0.0f, -0.67f); glVertex2f(-1.0f, -1.0f); //4th Quadrant glColor3f(0.0, 0.0, 1.0); glVertex2f(0.0f, -0.67f); glVertex2f(1.0f, -1.0f); //Ground Line glColor3f(0.4256, 0.207, 0.101); glVertex2f(-1.0f, -0.67f); glVertex2f(1.0f, -0.67f); glEnd(); // Execute OpenGL functions glFlush(); }
void CMiniMap::IntBox::DrawBox() const { glViewport(xmin, gu->viewSizeY - ymax - 1, (xmax - xmin) + 1, (ymax - ymin) + 1); glRectf(0.0f, 0.0f, 1.0f, 1.0f); }
void CMiniMap::DrawForReal() { SCOPED_TIMER("Draw minimap"); setSurfaceCircleFunc(DrawSurfaceCircle); setSurfaceSquareFunc(DrawSurfaceSquare); cursorIcons.Enable(false); //glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthFunc(GL_LEQUAL); if (minimized) { if (!slaveDrawMode) { DrawMinimizedButton(); } cursorIcons.Enable(true); setSurfaceCircleFunc(NULL); setSurfaceSquareFunc(NULL); return; } glViewport(xpos, ypos, width, height); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0e6, +1.0e6); glMatrixMode(GL_MODELVIEW); glColor4f(0.6f, 0.6f, 0.6f, 1.0f); // draw the map glDisable(GL_BLEND); readmap->DrawMinimap(); glEnable(GL_BLEND); // move some of the transform to the GPU glTranslatef(0.0f, +1.0f, 0.0f); glScalef(+1.0f / (gs->mapx * SQUARE_SIZE), -1.0f / (gs->mapy * SQUARE_SIZE), 1.0); glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.0f); // draw the units std::list<CUnit*>::iterator ui; for (ui = uh->activeUnits.begin(); ui != uh->activeUnits.end(); ui++) { DrawUnit(*ui); } // highlight the selected unit CUnit* unit = GetSelectUnit(GetMapPosition(mouse->lastx, mouse->lasty)); if (unit != NULL) { DrawUnitHighlight(unit); } glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D); left.clear(); // add restraints for camera sides GetFrustumSide(cam2->bottom); GetFrustumSide(cam2->top); GetFrustumSide(cam2->rightside); GetFrustumSide(cam2->leftside); if (!minimap->maximized) { // draw the camera lines std::vector<fline>::iterator fli,fli2; for(fli=left.begin();fli!=left.end();fli++){ for(fli2=left.begin();fli2!=left.end();fli2++){ if(fli==fli2) continue; float colz=0; if(fli->dir-fli2->dir==0) continue; colz=-(fli->base-fli2->base)/(fli->dir-fli2->dir); if(fli2->left*(fli->dir-fli2->dir)>0){ if(colz>fli->minz && colz<400096) fli->minz=colz; } else { if(colz<fli->maxz && colz>-10000) fli->maxz=colz; } } } glColor4f(1,1,1,0.5f); glBegin(GL_LINES); for(fli = left.begin(); fli != left.end(); fli++) { if(fli->minz < fli->maxz) { DrawInMap2D(fli->base + (fli->dir * fli->minz), fli->minz); DrawInMap2D(fli->base + (fli->dir * fli->maxz), fli->maxz); } } glEnd(); } glRotatef(-90.0f, +1.0f, 0.0f, 0.0f); // real 'world' coordinates // draw the projectiles if (drawProjectiles && ph->ps.size()>0) { CVertexArray* lines=GetVertexArray(); CVertexArray* points=GetVertexArray(); lines->Initialize(); lines->EnlargeArrays(ph->ps.size()*2,0,VA_SIZE_C); points->Initialize(); points->EnlargeArrays(ph->ps.size(),0,VA_SIZE_C); static unsigned char red[4] = {255,0,0,255}; static unsigned char redA[4] = {255,0,0,128}; static unsigned char yellow[4] = {255,255,0,255}; static unsigned char green[4] = {0,255,0,25}; static unsigned char white[4] = {255,255,255,25}; Projectile_List::iterator psi; for(psi = ph->ps.begin(); psi != ph->ps.end(); ++psi) { CProjectile* p = *psi; if ((p->owner && (p->owner->allyteam == gu->myAllyTeam)) || gu->spectatingFullView || loshandler->InLos(p, gu->myAllyTeam)) { if (dynamic_cast<CGeoThermSmokeProjectile*>(p)) { } else if (dynamic_cast<CGfxProjectile*>(p)) {//Nano-piece points->AddVertexQC(p->pos,green); } else if (dynamic_cast<CBeamLaserProjectile*>(p)) { CBeamLaserProjectile& beam = *(CBeamLaserProjectile*)p; unsigned char color[4] = {beam.kocolstart[0],beam.kocolstart[1],beam.kocolstart[2],255}; lines->AddVertexQC(beam.startPos,color); lines->AddVertexQC(beam.endPos,color); } else if (dynamic_cast<CLargeBeamLaserProjectile*>(p)) { CLargeBeamLaserProjectile& beam = *(CLargeBeamLaserProjectile*)p; unsigned char color[4] = {beam.kocolstart[0],beam.kocolstart[1],beam.kocolstart[2],255}; lines->AddVertexQC(beam.startPos,color); lines->AddVertexQC(beam.endPos,color); } else if (dynamic_cast<CLightingProjectile*>(p)) { CLightingProjectile& beam = *(CLightingProjectile*)p; unsigned char color[4] = {(unsigned char)beam.color[0]*255,(unsigned char)beam.color[1]*255,(unsigned char)beam.color[2]*255,255}; lines->AddVertexQC(beam.pos,color); lines->AddVertexQC(beam.endPos,color); } else if (dynamic_cast<CPieceProjectile*>(p)) { points->AddVertexQC(p->pos,red); } else if (dynamic_cast<CWreckProjectile*>(p)) { points->AddVertexQC(p->pos,redA); } else if (dynamic_cast<CWeaponProjectile*>(p)) { points->AddVertexQC(p->pos,yellow); } else { points->AddVertexQC(p->pos,white); } } } lines->DrawArrayC(GL_LINES); points->DrawArrayC(GL_POINTS); } // draw the queued commands // // NOTE: this needlessly adds to the CursorIcons list, but at least // they are not drawn (because the input receivers are drawn // after the command queues) LuaUnsyncedCtrl::DrawUnitCommandQueues(); if ((drawCommands > 0) && guihandler->GetQueueKeystate()) { selectedUnits.DrawCommands(); } glDisable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // draw the selection shape, and some ranges if (drawCommands > 0) { guihandler->DrawMapStuff(!!drawCommands); } // draw unit ranges const float radarSquare = (SQUARE_SIZE * RADAR_SIZE); CUnitSet& selUnits = selectedUnits.selectedUnits; for(CUnitSet::iterator si = selUnits.begin(); si != selUnits.end(); ++si) { CUnit* unit = *si; if (unit->radarRadius && !unit->beingBuilt && unit->activated) { glColor3fv(cmdColors.rangeRadar); DrawCircle(unit->pos, (unit->radarRadius * radarSquare)); } if (unit->sonarRadius && !unit->beingBuilt && unit->activated) { glColor3fv(cmdColors.rangeSonar); DrawCircle(unit->pos, (unit->sonarRadius * radarSquare)); } if (unit->jammerRadius && !unit->beingBuilt && unit->activated) { glColor3fv(cmdColors.rangeJammer); DrawCircle(unit->pos, (unit->jammerRadius * radarSquare)); } // change if someone someday create a non stockpiled interceptor const CWeapon* w = unit->stockpileWeapon; if((w != NULL) && w->weaponDef->interceptor) { if (w->numStockpiled) { glColor3fv(cmdColors.rangeInterceptorOn); } else { glColor3fv(cmdColors.rangeInterceptorOff); } DrawCircle(unit->pos, w->weaponDef->coverageRange); } } glRotatef(+90.0f, +1.0f, 0.0f, 0.0f); // revert to the 2d xform // selection box glColor4f(1.0f, 1.0f, 1.0f, 1.0f); CMouseHandler::ButtonPress& bp = mouse->buttons[SDL_BUTTON_LEFT]; if (selecting && fullProxy && (bp.movement > 4)) { const float3 oldPos = GetMapPosition(bp.x, bp.y); const float3 newPos = GetMapPosition(mouse->lastx, mouse->lasty); glColor4fv(cmdColors.mouseBox); glBlendFunc((GLenum)cmdColors.MouseBoxBlendSrc(), (GLenum)cmdColors.MouseBoxBlendDst()); glLineWidth(cmdColors.MouseBoxLineWidth()); glBegin(GL_LINE_LOOP); DrawInMap2D(oldPos.x, oldPos.z); DrawInMap2D(newPos.x, oldPos.z); DrawInMap2D(newPos.x, newPos.z); DrawInMap2D(oldPos.x, newPos.z); glEnd(); glLineWidth(1.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } DrawNotes(); // allow the LUA scripts to draw into the minimap eventHandler.DrawInMiniMap(); // reset the modelview glLoadIdentity(); if (!slaveDrawMode) { DrawButtons(); // outline glLineWidth(1.51f); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glViewport(xpos - 1, ypos - 1, width + 2, height + 2); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glRectf(0.0f, 0.0f, 1.0f, 1.0f); glViewport(xpos - 2, ypos - 2, width + 4, height + 4); glColor4f(0.0f, 0.0f, 0.0f, 1.0f); glRectf(0.0f, 0.0f, 1.0f, 1.0f); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLineWidth(1.0f); } glViewport(gu->viewPosX, 0, gu->viewSizeX, gu->viewSizeY); cursorIcons.Enable(true); setSurfaceCircleFunc(NULL); setSurfaceSquareFunc(NULL); }
void Bitmap::Draw(X3DDrawContext* pDC, X3DTextureNodeImplImpl* textureNode) { ASSERT(0); #if 0 if (true) { if (textureNode) { // TODO //CLMovieTexture* pMovieTexture = static_cast<CLMovieTexture*>(textureNode); //ILVideoMediaType* videoMediaType = pMovieTexture->m_pVideoFilter->m_pInput->m_mediaType; //if (videoMediaType) { long imageWidth = textureNode->GetWidth(); long imageHeight = textureNode->GetHeight(); //videoMediaType->GetWidth(&imageWidth); //videoMediaType->GetHeight(&imageHeight); if (imageWidth > 0 && imageHeight > 0) { float destWidth; float destHeight; if (m_scale->m_value[0] == -1) { destWidth = imageWidth; } else { destWidth = imageWidth * m_scale->m_value[0]; } if (m_scale->m_value[1] == -1) { destHeight = imageHeight; } else { destHeight = imageHeight * m_scale->m_value[1]; } //if (textureNode->m_pVideoFilter->m_pInput->m_pSample) //{ pDC->m_pGraphics3D->glBegin(GL_QUADS); pDC->m_pGraphics3D->glTexCoordf(0, 0); pDC->m_pGraphics3D->glVertexf(-destWidth/2, destHeight/2, 0); pDC->m_pGraphics3D->glTexCoordf(1, 0); pDC->m_pGraphics3D->glVertexf(destWidth/2, destHeight/2, 0); pDC->m_pGraphics3D->glTexCoordf(1, 1); pDC->m_pGraphics3D->glVertexf(destWidth/2, -destHeight/2, 0); pDC->m_pGraphics3D->glTexCoordf(0, 1); pDC->m_pGraphics3D->glVertexf(-destWidth/2, -destHeight/2, 0); pDC->m_pGraphics3D->glEnd(); #if 0 void* pixels = textureNode->GetData();//pMovieTexture->m_pVideoFilter->m_pInput->m_pSample->m_bits; if (pixels) { glRasterPos2f(0.0f, 0.0f); // TODO ?? ASSERT(glGetError() == GL_NO_ERROR); //destWidth *= 4; //destHeight *= 4; glPixelZoom(destWidth / imageWidth, destHeight / imageHeight); ASSERT(glGetError() == GL_NO_ERROR); glDrawPixels(imageWidth, imageHeight, GL_RGB, GL_UNSIGNED_BYTE, pixels); ASSERT(glGetError() == GL_NO_ERROR); } #endif } } } } else { } #if 0 glRectf( -m_size->m_value[0]/2, -m_size->m_value[1]/2, m_size->m_value[0]/2, m_size->m_value[1]/2); #endif #if 0 glBegin(GL_QUADS); SFVec3f* size = static_cast<SFVec3f*>(m_size->m_value); gmVector3 s = size->m_v; // front (cw) /* glVertex3d(-m_boxSize[0]/2, -m_boxSize[1]/2, m_boxSize[2]/2); glVertex3d(m_boxSize[0]/2, -m_boxSize[1]/2, m_boxSize[2]/2); glVertex3d(m_boxSize[0]/2, m_boxSize[1]/2, m_boxSize[2]/2); glVertex3d(-m_boxSize[0]/2, m_boxSize[1]/2, m_boxSize[2]/2); */ // front (ccw) lglNormal( gmVector3(-s[0]/2, -s[1]/2, s[2]/2), gmVector3(-s[0]/2, s[1]/2, s[2]/2), gmVector3(s[0]/2, s[1]/2, s[2]/2)); glVertex3d(-s[0]/2, -s[1]/2, s[2]/2); glVertex3d(-s[0]/2, s[1]/2, s[2]/2); glVertex3d(s[0]/2, s[1]/2, s[2]/2); glVertex3d(s[0]/2, -s[1]/2, s[2]/2); // left side lglNormal( gmVector3(-s[0]/2, -s[1]/2, s[2]/2), gmVector3(-s[0]/2, -s[1]/2, -s[2]/2), gmVector3(-s[0]/2, s[1]/2, -s[2]/2)); glVertex3d(-s[0]/2, -s[1]/2, s[2]/2); glVertex3d(-s[0]/2, -s[1]/2, -s[2]/2); glVertex3d(-s[0]/2, s[1]/2, -s[2]/2); glVertex3d(-s[0]/2, s[1]/2, s[2]/2); glEnd(); #endif #endif }
static void scalefilterDrawFilterText (CompScreen *s, CompOutput *output) { FILTER_SCREEN (s); GLboolean wasBlend; GLint oldBlendSrc, oldBlendDst; int ox1, ox2, oy1, oy2; float width = fs->filterInfo->textWidth; float height = fs->filterInfo->textHeight; float border = scalefilterGetBorderSize (s); ox1 = output->region.extents.x1; ox2 = output->region.extents.x2; oy1 = output->region.extents.y1; oy2 = output->region.extents.y2; float x = ox1 + ((ox2 - ox1) / 2) - (width / 2); float y = oy1 + ((oy2 - oy1) / 2) + (height / 2); x = floor (x); y = floor (y); wasBlend = glIsEnabled (GL_BLEND); glGetIntegerv (GL_BLEND_SRC, &oldBlendSrc); glGetIntegerv (GL_BLEND_DST, &oldBlendDst); if (!wasBlend) glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glColor4us (scalefilterGetBackColorRed (s), scalefilterGetBackColorGreen (s), scalefilterGetBackColorBlue (s), scalefilterGetBackColorAlpha (s)); glPushMatrix (); glTranslatef (x, y - height, 0.0f); glRectf (0.0f, height, width, 0.0f); glRectf (0.0f, 0.0f, width, -border); glRectf (0.0f, height + border, width, height); glRectf (-border, height, 0.0f, 0.0f); glRectf (width, height, width + border, 0.0f); glTranslatef (-border, -border, 0.0f); #define CORNER(a,b) \ for (k = a; k < b; k++) \ {\ float rad = k* (3.14159 / 180.0f);\ glVertex2f (0.0f, 0.0f);\ glVertex2f (cos (rad) * border, sin (rad) * border);\ glVertex2f (cos ((k - 1) * (3.14159 / 180.0f)) * border, \ sin ((k - 1) * (3.14159 / 180.0f)) * border);\ } /* Rounded corners */ int k; glTranslatef (border, border, 0.0f); glBegin (GL_TRIANGLES); CORNER (180, 270) glEnd(); glTranslatef (-border, -border, 0.0f); glTranslatef (width + border, border, 0.0f); glBegin (GL_TRIANGLES); CORNER (270, 360) glEnd(); glTranslatef (-(width + border), -border, 0.0f); glTranslatef (border, height + border, 0.0f); glBegin (GL_TRIANGLES); CORNER (90, 180) glEnd(); glTranslatef (-border, -(height + border), 0.0f); glTranslatef (width + border, height + border, 0.0f); glBegin (GL_TRIANGLES); CORNER (0, 90) glEnd(); glTranslatef (-(width + border), -(height + border), 0.0f); glPopMatrix (); #undef CORNER glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glColor4f (1.0, 1.0, 1.0, 1.0); enableTexture (s, &fs->filterInfo->textTexture, COMP_TEXTURE_FILTER_GOOD); CompMatrix *m = &fs->filterInfo->textTexture.matrix; glBegin (GL_QUADS); glTexCoord2f (COMP_TEX_COORD_X(m, 0),COMP_TEX_COORD_Y(m ,0)); glVertex2f (x, y - height); glTexCoord2f (COMP_TEX_COORD_X(m, 0),COMP_TEX_COORD_Y(m, height)); glVertex2f (x, y); glTexCoord2f (COMP_TEX_COORD_X(m, width),COMP_TEX_COORD_Y(m, height)); glVertex2f (x + width, y); glTexCoord2f (COMP_TEX_COORD_X(m, width),COMP_TEX_COORD_Y(m, 0)); glVertex2f (x + width, y - height); glEnd (); disableTexture (s, &fs->filterInfo->textTexture); glColor4usv (defaultColor); if (!wasBlend) glDisable (GL_BLEND); glBlendFunc (oldBlendSrc, oldBlendDst); }
void display() { glClear(GL_COLOR_BUFFER_BIT); // clear color buffer glRectf(-5.0, 5.0, 5.0, -5.0); glutSwapBuffers(); }
/** \brief The per-frame OpenGL display routine * * This function does the complete OpenGL drawing. First * the 3D scene is drawn, then some 2D overlays * (wind and battery indicator, GUI). */ void display() { CRRCMath::Vector3 plane_pos = FDM2Graphics(Global::aircraft->getPos()); // Prepare the current frame buffer and reset // the modelview matrix (for non-SSG drawing) GLbitfield clearmask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT; if (vidbits.stencil) { clearmask |= GL_STENCIL_BUFFER_BIT; } glClear(clearmask); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); //~ glBlendFunc(GL_ONE, GL_ZERO); //~ glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); // Set up the viewing transformation (for SSG drawing) sgVec3 viewpos, planepos, up; sgSetVec3(viewpos, player_pos.r[0], player_pos.r[1], player_pos.r[2]); sgSetVec3(planepos, looking_pos.r[0], looking_pos.r[1], looking_pos.r[2]); sgSetVec3(up, 0.0, 1.0, 0.0); context->setCameraLookAt(viewpos, planepos, up); // 3D scene if( Global::scenery != NULL) { // 3D scene: sky sphere draw_sky(&viewpos, Global::Simulation->getTotalTime()); // 3D scene: airplane if (Global::aircraft->getModel() != NULL) { // For SSG rendering, this call does not draw anything, // but calculates the airplane's transformation matrix glDisable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); Global::aircraft->getModel()->draw(Global::aircraft->getFDM()); } // 3D scene: scenery Global::scenery->draw(Global::Simulation->getTotalTime()); } // Lighting setup. Only needed as long as there are // non-SSG parts that modify the light sources. sgVec4 lightamb; sgSetVec4(lightamb , 0.2f, 0.2f, 0.2f, 1.0f); ssgGetLight(0)->setPosition(lightposn); ssgGetLight(0)->setColour(GL_AMBIENT, lightamb); // Draw the scenegraph (airplane model, shadow) ssgCullAndDraw(scene); context->forceBasicState(); // ssgCullAndDraw() ends up with an identity modelview matrix, // so we have to set up our own viewing transformation for // the thermals glLoadIdentity(); gluLookAt(player_pos.r[0], player_pos.r[1], player_pos.r[2], looking_pos.r[0], looking_pos.r[1], looking_pos.r[2], 0.0, 1.0, 0.0); if (Global::training_mode==TRUE) { draw_thermals(Global::aircraft->getPos()); } // 3D scene: game-mode-specific stuff (pylons etc.) Global::gameHandler->draw(); glPopMatrix(); // Overlay: game handler Global::gameHandler->display_infos(window_xsize, window_ysize); // Overlay: scope for audio interface if ( Global::testmode.test_mode && (Global::TXInterface->inputMethod() == T_TX_Interface::eIM_audio) ) { GlOverlay::setupRenderingState(window_xsize, window_ysize); oscillo(); GlOverlay::restoreRenderingState(); } // Overlay: wind direction indicator { double dx = (plane_pos.r[2] - player_pos.r[2]); double dy = (player_pos.r[0] - plane_pos.r[0]); double dir = atan2(dy, dx); GlOverlay::setupRenderingState(window_xsize, window_ysize); draw_wind(dir); GlOverlay::restoreRenderingState(); } // Overlay: battery capacity/fuel left { int r = window_ysize >> 5; int w = r >> 1; int h = window_ysize >> 3; int ht = (int)(Global::aircraft->getFDM()->getBatCapLeft() * h); #if 0 glDisable(GL_LIGHTING); glMatrixMode (GL_PROJECTION); glPushMatrix(); glLoadIdentity (); gluOrtho2D (0, window_xsize-1, 0, window_ysize); #endif GlOverlay::setupRenderingState(window_xsize, window_ysize); // Background glColor3f (0, 0, 0); glRectf(window_xsize-w, r+ht, window_xsize-1, r+h); glTranslatef(0,0,0.1); // Indicator glColor3f (0, 1, 0.); glRectf(window_xsize-w, r, window_xsize-1, r+ht); #if 0 glPopMatrix(); glEnable(GL_LIGHTING); glMatrixMode(GL_MODELVIEW); #endif GlOverlay::restoreRenderingState(); } // Overlay: console console->render(window_xsize, window_ysize); // Overlay: gui Global::gui->draw(); // check for any OpenGL errors evaluateOpenGLErrors(); // Force pipeline flushing and flip front and back buffer glFlush(); SDL_GL_SwapBuffers(); }
void glRect() const { glRectf(x,y,x+width,y+height); }
void BaseElement::drawElement() { glRectf(0,0,width,height); }
void redraw(void) { if (newModel) recalcModelView(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); /* Draw the real scene in the left viewport... */ glViewport(0, 0, W / 2, H); glDisable(GL_STENCIL_TEST); glCallList(DINOSAUR); showMessage(2, 7.1, 4.1, "Spin me."); /* ...and the overdraw indicator in the right viewport */ glViewport(W / 2, 0, W / 2, H); /* First draw the scene again, this time without color updates, * just counting pixels drawn in the stencil buffer. */ glEnable(GL_STENCIL_TEST); glStencilFunc(GL_ALWAYS, 0, 0); glStencilOp(GL_KEEP, GL_INCR, GL_INCR); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glCallList(DINOSAUR); showMessage(2, 7.1, 4.1, "Spin me."); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glColor3f(1.0f, 1.0f, 1.0f); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); /* Copy bit 0 into the blue plane */ glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_FALSE); glStencilFunc(GL_NOTEQUAL, 0, 0xf8 | 0x01); glRectf(-1.0f, -1.0f, 1.0f, 1.0f); /* Copy bit 1 into the red plane */ glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); glStencilFunc(GL_NOTEQUAL, 0, 0xf8 | 0x02); glRectf(-1.0f, -1.0f, 1.0f, 1.0f); /* Copy bit 2 into the green plane */ glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); glStencilFunc(GL_NOTEQUAL, 0, 0xf8 | 0x04); glRectf(-1.0f, -1.0f, 1.0f, 1.0f); /* Note that anything greater than 7 will have one of bits 3-7 set, * hence will be drawn on all three planes by the mask with 0xf8 above. * So anything overdrawn 7 or more times will be drawn in white. */ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glutSwapBuffers(); }
void sceneview::paintGL() { //viewport glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glOrtho(0,width(),height(),0,-1000,1000); //clear glClearColor(0.8f,0.8f,0.8f,1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glTranslatef(extent-xx,extent-yy,0); glScalef(zoom,zoom,1); //draw the border glColor4f(0,0,0,0.2); glRectf(-1,-1,ww+1,hh+1); //the checkmarks { glDisable(GL_DEPTH_TEST); glTranslatef(0,0,-100); glEnable(GL_TEXTURE_2D); glColor3f(1,1,1); glBindTexture(GL_TEXTURE_2D,checkmarkT); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glBegin(GL_QUADS); //UL glTexCoord2f(0,0); glVertex3i(0,0,0); //UR glTexCoord2f(0,ww/16); glVertex3i(ww,0,0); //DR glTexCoord2f(hh/16,ww/16); glVertex3i(ww,hh,0); //DL glTexCoord2f(hh/16,0); glVertex3i(0,hh,0); glEnd(); glTranslatef(0,0,100); //todo: display list! } //draw the layers { //TODO: Draw them recursively } //draw the grid { gridx = nfmod(gridx,gridw); gridy = nfmod(gridy,gridh); glDisable(GL_TEXTURE_2D); glLineWidth(1); if(enableGrid and drawGrid) { glColor4f(gridR,gridG,gridB,gridA); if(gridw==0)gridw=1; if(gridh==0)gridh=1; int bx = extent/gridw , by = extent/gridh ; glDisable(GL_MULTISAMPLE_ARB); glBegin(GL_LINES); if(gridw>1) for(GLfloat X = -bx*gridw +gridx; X<ww+extent;X+=gridw) { glVertex2f(X,-extent); glVertex2f(X,extent+hh); } glEnd(); glBegin(GL_LINES); if(gridh>1) for(GLfloat Y = -by*gridh+gridy; Y<hh+extent;Y+=gridh) { glVertex2f(-extent,Y); glVertex2f(extent+ww,Y); } glEnd(); glEnable(GL_MULTISAMPLE_ARB); } } //draw the layer overlays (selected items, hovered items and so on) { //TODO: Draw them } //draw the mouse hint for the object { if(toolmode==1) { glPointSize(8.0); glBegin(GL_POINTS); glColor4f(1.0f,0.0f,0.0f,1.0f); glVertex2i(mx,my); glEnd(); /* classObj* c = getClass(currentClassName); if(c!=0) { glBegin(GL_LINE_LOOP); glVertex2i(mx-c->xoff,my-c->yoff); glVertex2i(mx+c->width-c->xoff,my-c->yoff); glVertex2i(mx+c->width-c->xoff,my+c->height-c->yoff); glVertex2i(mx-c->xoff,my+c->height-c->yoff); glEnd(); } /**/ } } glColor3f(0,0,0); glBegin(GL_LINES); glVertex2i(0,0); glVertex2i(width(),height()); glEnd(); }
static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, int width, int height, float zoomx, float zoomy) { int x, y; MovieClip *clip = ED_space_clip_get_clip(sc); /* find window pixel coordinates of origin */ UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); if (sc->flag & SC_MUTE_FOOTAGE) { glColor3f(0.0f, 0.0f, 0.0f); glRectf(x, y, x + zoomx * width, y + zoomy * height); } else { verify_buffer_float(ibuf); if (ibuf->rect) { int need_fallback = 1; if (ED_space_clip_texture_buffer_supported(sc)) { if (ED_space_clip_load_movieclip_buffer(sc, ibuf)) { glPushMatrix(); glTranslatef(x, y, 0.0f); glScalef(zoomx, zoomy, 1.0f); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(width, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(width, height); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, height); glEnd(); glPopMatrix(); ED_space_clip_unload_movieclip_buffer(sc); need_fallback = 0; } } /* if texture buffers aren't efficiently supported or texture is too large to * be binder fallback to simple draw pixels solution */ if (need_fallback) { /* set zoom */ glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y); glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); /* reset zoom */ glPixelZoom(1.0f, 1.0f); } } } /* draw boundary border for frame if stabilization is enabled */ if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) { glColor3f(0.0f, 0.0f, 0.0f); glLineStipple(3, 0xaaaa); glEnable(GL_LINE_STIPPLE); glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_NOR); glPushMatrix(); glTranslatef(x, y, 0.0f); glScalef(zoomx, zoomy, 1.0f); glMultMatrixf(sc->stabmat); glBegin(GL_LINE_LOOP); glVertex2f(0.0f, 0.0f); glVertex2f(width, 0.0f); glVertex2f(width, height); glVertex2f(0.0f, height); glEnd(); glPopMatrix(); glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_LINE_STIPPLE); } }
void CMiniMap::IntBox::DrawBox() const { glRectf(float(xmin)/globalRendering->viewSizeX, 1.0f - float(ymin)/globalRendering->viewSizeY, float(xmax+1)/globalRendering->viewSizeX, 1.0f - float(ymax+1)/globalRendering->viewSizeY); }
/** * base de este codigo tomado de la pagina que * hace picking con hombres de nieve */ void pick_points(int x, int y) { int i,j; int cursorX = x; int cursorY = y; GLint hits; // inicializo el picking GLint viewport[4]; float ratio; GLuint selectBuf[BUFSIZE]; glSelectBuffer(BUFSIZE,selectBuf); glGetIntegerv(GL_VIEWPORT,viewport); glRenderMode(GL_SELECT); glInitNames(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluPickMatrix(cursorX,viewport[3]-cursorY,1,1,viewport); ratio = (viewport[2]+0.0) / viewport[3]; gluPerspective(camera->aperture,ratio,0.1,1000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(camera->position.x, camera->position.y, camera->position.z, camera->center.x, camera->center.y, camera->center.z, camera->up.x, camera->up.y, camera->up.z); glRotatef(surface->alphax,1.0,0.0,0.0); glRotatef(surface->alphaz,0.0,0.0,1.0); for (i=0;i<11;i++) { for (j=0;j<11;j++) { POINT3D punto = *(surface->ptscontrol+i*11+j); glPushMatrix(); glPushName(11*i + j); glTranslatef(punto.x, punto.y+2.0, punto.z); glRectf(-0.25f,0.25f,0.25f,-0.25f); glRotatef(90,1,0,0); glRectf(-0.25f,0.25f,0.25f,-0.25f); glRotatef(90,0,1,0); glRectf(-0.25f,0.25f,0.25f,-0.25f); glPopName(); glPopMatrix(); } } // termino de pickear y testeo glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glFlush(); hits = glRenderMode(GL_RENDER); if (hits != 0){ processHits(hits,selectBuf,0); } }
void mitk::PlanarFigureMapper2D::DrawMarker( const mitk::Point2D &point, float* lineColor, float lineOpacity, float* markerColor, float markerOpacity, float lineWidth, PlanarFigureControlPointStyleProperty::Shape shape, const mitk::Geometry2D *objectGeometry, const mitk::Geometry2D *rendererGeometry, const mitk::DisplayGeometry *displayGeometry ) { mitk::Point2D displayPoint; this->TransformObjectToDisplay( point, displayPoint, objectGeometry, rendererGeometry, displayGeometry ); glColor4f( markerColor[0], markerColor[1], markerColor[2], markerOpacity ); glLineWidth( lineWidth ); switch ( shape ) { case PlanarFigureControlPointStyleProperty::Square: default: // Paint filled square // Disable line antialiasing (does not look nice for squares) glDisable( GL_LINE_SMOOTH ); glRectf( displayPoint[0] - 4, displayPoint[1] - 4, displayPoint[0] + 4, displayPoint[1] + 4 ); // Paint outline glColor4f( lineColor[0], lineColor[1], lineColor[2], lineOpacity ); glBegin( GL_LINE_LOOP ); glVertex2f( displayPoint[0] - 4, displayPoint[1] - 4 ); glVertex2f( displayPoint[0] - 4, displayPoint[1] + 4 ); glVertex2f( displayPoint[0] + 4, displayPoint[1] + 4 ); glVertex2f( displayPoint[0] + 4, displayPoint[1] - 4 ); glEnd(); break; case PlanarFigureControlPointStyleProperty::Circle: // Paint filled circle glBegin( GL_POLYGON ); float radius = 4.0; for ( int angle = 0; angle < 8; ++angle ) { float angleRad = angle * (float) 3.14159 / 4.0; float x = displayPoint[0] + radius * (float)cos( angleRad ); float y = displayPoint[1] + radius * (float)sin( angleRad ); glVertex2f(x,y); } glEnd(); // Paint outline glColor4f( lineColor[0], lineColor[1], lineColor[2], lineOpacity ); glBegin( GL_LINE_LOOP ); for ( int angle = 0; angle < 8; ++angle ) { float angleRad = angle * (float) 3.14159 / 4.0; float x = displayPoint[0] + radius * (float)cos( angleRad ); float y = displayPoint[1] + radius * (float)sin( angleRad ); glVertex2f(x,y); } glEnd(); break; } // end switch }
int main(int argc, char** argv) { int count = 0; GLFWwindow* window; srand((unsigned int) time(NULL)); glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); for (;;) { GLFWmonitor* monitor = NULL; if (count & 1) { int monitorCount; GLFWmonitor** monitors = glfwGetMonitors(&monitorCount); monitor = monitors[rand() % monitorCount]; } window = open_window(640, 480, monitor); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } glMatrixMode(GL_PROJECTION); glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); glMatrixMode(GL_MODELVIEW); glfwSetTime(0.0); while (glfwGetTime() < 5.0) { glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glRotatef((GLfloat) glfwGetTime() * 100.f, 0.f, 0.f, 1.f); glRectf(-0.5f, -0.5f, 1.f, 1.f); glPopMatrix(); glfwSwapBuffers(window); glfwPollEvents(); if (glfwWindowShouldClose(window)) { close_window(window); printf("User closed window\n"); glfwTerminate(); exit(EXIT_SUCCESS); } } printf("Closing window\n"); close_window(window); count++; } glfwTerminate(); }
void intro_do(long t) { char errorText[MAX_ERROR_LENGTH+1]; float ftime = 0.001f*(float)t; GLuint textureID; glDisable(GL_BLEND); glDisable(GL_DEPTH_TEST); // Those are key-Press indicators. I only act on 0-to-1. for (int i = 0; i < maxNumParameters; i++) { interpolatedParameters[i] = 0.98f * interpolatedParameters[i] + 0.02f * params.getParam(i, defaultParameters[i]); } // Update key press events. for (int i = 0; i < NUM_KEYS; i++) { if (params.getParam(i, 0.0) > 0.5f) keyPressed[i]++; else keyPressed[i] = 0; } // BPM => spike calculation float BPS = BPM / 60.0f; float jumpsPerSecond = BPS / 1.0f; // Jump on every fourth beat. static float phase = 0.0f; float jumpTime = (ftime * jumpsPerSecond) + phase; jumpTime -= floor(jumpTime); if (keyPressed[41] == 1) { phase -= jumpTime; jumpTime = 0.0f; if (phase < 0.0f) phase += 1.0; } jumpTime = jumpTime * jumpTime; // spike is between 0.0 and 1.0 depending on the position within whatever. float spike = 0.5f * cosf(jumpTime * 3.1415926f * 1.5f) + 0.5f; // Set the program uniforms GLuint programID; shaderManager.getProgramID(usedProgram[usedIndex], &programID, errorText); glUseProgram(programID); GLuint loc = glGetUniformLocation(programID, "time"); glUniform1f(loc, (float)(t * 0.001f)); // For now I am just sending the spike to the shader. I might need something better... loc = glGetUniformLocation(programID, "spike"); glUniform1f(loc, spike); loc = glGetUniformLocation(programID, "knob1"); glUniform1f(loc, interpolatedParameters[14]); loc = glGetUniformLocation(programID, "knob2"); glUniform1f(loc, interpolatedParameters[15]); loc = glGetUniformLocation(programID, "knob3"); glUniform1f(loc, interpolatedParameters[16]); loc = glGetUniformLocation(programID, "knob4"); glUniform1f(loc, interpolatedParameters[17]); loc = glGetUniformLocation(programID, "knob5"); glUniform1f(loc, interpolatedParameters[18]); loc = glGetUniformLocation(programID, "knob6"); glUniform1f(loc, interpolatedParameters[19]); loc = glGetUniformLocation(programID, "knob7"); glUniform1f(loc, interpolatedParameters[20]); loc = glGetUniformLocation(programID, "knob8"); glUniform1f(loc, interpolatedParameters[21]); loc = glGetUniformLocation(programID, "knob9"); glUniform1f(loc, interpolatedParameters[22]); loc = glGetUniformLocation(programID, "slider1"); glUniform1f(loc, interpolatedParameters[2]); loc = glGetUniformLocation(programID, "slider2"); glUniform1f(loc, interpolatedParameters[3]); loc = glGetUniformLocation(programID, "slider3"); glUniform1f(loc, interpolatedParameters[4]); loc = glGetUniformLocation(programID, "slider4"); glUniform1f(loc, interpolatedParameters[5]); loc = glGetUniformLocation(programID, "slider5"); glUniform1f(loc, interpolatedParameters[6]); loc = glGetUniformLocation(programID, "slider6"); glUniform1f(loc, interpolatedParameters[8]); loc = glGetUniformLocation(programID, "slider7"); glUniform1f(loc, interpolatedParameters[9]); loc = glGetUniformLocation(programID, "slider8"); glUniform1f(loc, interpolatedParameters[12]); loc = glGetUniformLocation(programID, "slider9"); glUniform1f(loc, interpolatedParameters[13]); // render to larger offscreen texture textureManager.getTextureID("noise3D", &textureID, errorText); glBindTexture(GL_TEXTURE_3D, textureID); glViewport(0, 0, X_OFFSCREEN, Y_OFFSCREEN); glRectf(-1.0, -1.0, 1.0, 1.0); // Copy backbuffer to texture textureManager.getTextureID("renderTarget", &textureID, errorText); glBindTexture(GL_TEXTURE_2D, textureID); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, X_OFFSCREEN, Y_OFFSCREEN); // Copy backbuffer to front (so far no improvement) int xres = windowRect.right - windowRect.left; int yres = windowRect.bottom - windowRect.top; glViewport(0, 0, xres, yres); shaderManager.getProgramID("SimpleTexture.gprg", &programID, errorText); glUseProgram(programID); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glDisable(GL_BLEND); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, -1.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f, 1.0f); glEnd(); }
void tmp_draw_hexplane(void) { glRectf(-2.0, -2.0, 2.0, 2.0); }
static void time_draw_cache(Main *bmain, SpaceTime *stime, Object *ob, Scene *scene) { PTCacheID *pid; ListBase pidlist; SpaceTimeCache *stc = stime->caches.first; const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize); float yoffs = 0.f; if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob)) return; BKE_ptcache_ids_from_object(bmain, &pidlist, ob, scene, 0); /* iterate over pointcaches on the active object, * add spacetimecache and vertex array for each */ for (pid = pidlist.first; pid; pid = pid->next) { float col[4], *fp; int i, sta = pid->cache->startframe, end = pid->cache->endframe; int len = (end - sta + 1) * 4; switch (pid->type) { case PTCACHE_TYPE_SOFTBODY: if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue; break; case PTCACHE_TYPE_PARTICLES: if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue; break; case PTCACHE_TYPE_CLOTH: if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue; break; case PTCACHE_TYPE_SMOKE_DOMAIN: case PTCACHE_TYPE_SMOKE_HIGHRES: if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue; break; case PTCACHE_TYPE_DYNAMICPAINT: if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue; break; case PTCACHE_TYPE_RIGIDBODY: if (!(stime->cache_display & TIME_CACHE_RIGIDBODY)) continue; break; } if (pid->cache->cached_frames == NULL) continue; /* make sure we have stc with correct array length */ if (stc == NULL || MEM_allocN_len(stc->array) != len * 2 * sizeof(float)) { if (stc) { MEM_freeN(stc->array); } else { stc = MEM_callocN(sizeof(SpaceTimeCache), "spacetimecache"); BLI_addtail(&stime->caches, stc); } stc->array = MEM_callocN(len * 2 * sizeof(float), "SpaceTimeCache array"); } /* fill the vertex array with a quad for each cached frame */ for (i = sta, fp = stc->array; i <= end; i++) { if (pid->cache->cached_frames[i - sta]) { fp[0] = (float)i - 0.5f; fp[1] = 0.0; fp += 2; fp[0] = (float)i - 0.5f; fp[1] = 1.0; fp += 2; fp[0] = (float)i + 0.5f; fp[1] = 1.0; fp += 2; fp[0] = (float)i + 0.5f; fp[1] = 0.0; fp += 2; } } glPushMatrix(); glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0); glScalef(1.0, cache_draw_height, 0.0); switch (pid->type) { case PTCACHE_TYPE_SOFTBODY: col[0] = 1.0; col[1] = 0.4; col[2] = 0.02; col[3] = 0.1; break; case PTCACHE_TYPE_PARTICLES: col[0] = 1.0; col[1] = 0.1; col[2] = 0.02; col[3] = 0.1; break; case PTCACHE_TYPE_CLOTH: col[0] = 0.1; col[1] = 0.1; col[2] = 0.75; col[3] = 0.1; break; case PTCACHE_TYPE_SMOKE_DOMAIN: case PTCACHE_TYPE_SMOKE_HIGHRES: col[0] = 0.2; col[1] = 0.2; col[2] = 0.2; col[3] = 0.1; break; case PTCACHE_TYPE_DYNAMICPAINT: col[0] = 1.0; col[1] = 0.1; col[2] = 0.75; col[3] = 0.1; break; case PTCACHE_TYPE_RIGIDBODY: col[0] = 1.0; col[1] = 0.6; col[2] = 0.0; col[3] = 0.1; break; default: col[0] = 1.0; col[1] = 0.0; col[2] = 1.0; col[3] = 0.1; BLI_assert(0); break; } glColor4fv(col); glEnable(GL_BLEND); glRectf((float)sta, 0.0, (float)end, 1.0); col[3] = 0.4f; if (pid->cache->flag & PTCACHE_BAKED) { col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f; } else if (pid->cache->flag & PTCACHE_OUTDATED) { col[0] += 0.4f; col[1] += 0.4f; col[2] += 0.4f; } glColor4fv(col); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, stc->array); glDrawArrays(GL_QUADS, 0, (fp - stc->array) / 2); glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_BLEND); glPopMatrix(); yoffs += cache_draw_height; stc = stc->next; } BLI_freelistN(&pidlist); /* free excessive caches */ while (stc) { SpaceTimeCache *tmp = stc->next; BLI_remlink(&stime->caches, stc); MEM_freeN(stc->array); MEM_freeN(stc); stc = tmp; } }
void RealRect::draw(void) {//draw this rectangle using OpenGL glRectf(l,b,r,t); glFlush(); }
void CMiniMap::DrawButtons() { const int x = mouse->lastx; const int y = mouse->lasty; // update the showButtons state if (!showButtons) { if (mapBox.Inside(x, y) && (buttonSize > 0) && !gu->dualScreenMode) { showButtons = true; } else { return; } } else if (!mouseMove && !mouseResize && !mapBox.Inside(x, y) && !buttonBox.Inside(x, y)) { showButtons = false; return; } if (buttonsTexture) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, buttonsTexture); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); resizeBox.DrawTextureBox(); moveBox.DrawTextureBox(); maximizeBox.DrawTextureBox(); minimizeBox.DrawTextureBox(); glDisable(GL_TEXTURE_2D); } else { glColor4f(0.1f, 0.1f, 0.8f, 0.8f); resizeBox.DrawBox(); // blue glColor4f(0.0f, 0.8f, 0.0f, 0.8f); moveBox.DrawBox(); // green glColor4f(0.8f, 0.8f, 0.0f, 0.8f); maximizeBox.DrawBox(); // yellow glColor4f(0.8f, 0.0f, 0.0f, 0.8f); minimizeBox.DrawBox(); // red } // highlight glBlendFunc(GL_SRC_ALPHA, GL_ONE); glColor4f(1.0f, 1.0f, 1.0f, 0.4f); if (mouseResize || (!mouseMove && resizeBox.Inside(x, y))) { if (!buttonsTexture) { glColor4f(0.3f, 0.4f, 1.0f, 0.9f); } resizeBox.DrawBox(); } else if (mouseMove || (!mouseResize && moveBox.Inside(x, y))) { if (!buttonsTexture) { glColor4f(1.0f, 1.0f, 1.0f, 0.3f); } moveBox.DrawBox(); } else if (!mouseMove && !mouseResize) { if (minimizeBox.Inside(x, y)) { if (!buttonsTexture) { glColor4f(1.0f, 0.2f, 0.2f, 0.6f); } minimizeBox.DrawBox(); } else if (maximizeBox.Inside(x, y)) { if (!buttonsTexture) { glColor4f(1.0f, 1.0f, 1.0f, 0.3f); } maximizeBox.DrawBox(); } } glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // outline the button box glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glLineWidth(1.51f); glColor4f(0.0f, 0.0f, 0.0f, 1.0f); glViewport(buttonBox.xmin - 2, (gu->viewSizeY - buttonBox.ymax - 1) - 2, (buttonBox.xmax - buttonBox.xmin + 1) + 4, (buttonBox.ymax - buttonBox.ymin + 1) + 4 - 3); glRectf(0.0f, 0.0f, 1.0f, 1.0f); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glViewport(buttonBox.xmin - 1, (gu->viewSizeY - buttonBox.ymax - 1) - 1, (buttonBox.xmax - buttonBox.xmin + 1) + 2, (buttonBox.ymax - buttonBox.ymin + 1) + 2 - 3); glRectf(0.0f, 0.0f, 1.0f, 1.0f); glLineWidth(1.0f); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); }
/** * 界面绘制事件 */ void onDisplay(void){ glClear(GL_COLOR_BUFFER_BIT);// use current color to clear window. // reset matrix glLoadIdentity(); //----- import code start -------- // loop many time. for(loop = 0; loop < MAX_POINTS; loop++){ // random color r = rand()%MAX_COLOR; g = rand()%MAX_COLOR; b = rand()%MAX_COLOR; // set color. glColor3f( (float)r/(float)MAX_COLOR, (float)g/(float)MAX_COLOR, (float)b/(float)MAX_COLOR); // random position // set left and right value. int m,n,r; m = rand()%(2 * (int)nRange); n = rand()%(2 * (int)nRange); if(m>n){ r = m; m = n; n=r; }// end if l = m - nRange;// set left. r = n - nRange;// set right. // set top and bottom value. m = rand()%(2 * (int)nRange); n = rand()%(2 * (int)nRange); if(m>n){ r = m; m = n; n=r; }// end if t = m - nRange;// set top. b = n - nRange;// set bottom. // (left, top, right, bottom) glRectf(l, t, r, b); }// end for // 画一个测试样本 glBegin(GL_LINES); glColor3f(1.0f, 0.0f, 0.0f); glVertex2f(0.0f, 100.0f); glVertex2f(100.0f, 0.0f); glColor3f(0.0f, 1.0f, 0.0f); glVertex2f(100.0f, 0.0f); glVertex2f(0.0f, -100.0f); glColor3f(0.0f, 0.0f, 1.0f); glVertex2f(0.0f, -100.0f); glVertex2f(-100.0f, 0.0f); glColor3f(1.0f, 1.0f, 0.0f); glVertex2f(-100.0f, 0.0f); glVertex2f(0.0f, 100.0f); glEnd(); //glutPostRedisplay();// force refresh(animation effective). //----- import code end -------- //-------- //glFlush();// (Single Buffer)force flush screen buffer. glutSwapBuffers();// (Double Buffer)swap buffers. }
int nos_frame(void) { unsigned int q, v; struct nos_model *mod = &model; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(camera_rotate) { int x, y; nos_mouse_delta(&x, &y); camera_angles[0] += y * 0.5f; camera_angles[1] += x * 0.5f; } camera_distance_actual = camera_distance_actual*0.9f + camera_distance*0.1f; glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -camera_distance_actual); glRotatef(camera_angles[0], 1.0f, 0.0f, 0.0f); // up/down glRotatef(camera_angles[1], 0.0f, 1.0f, 0.0f); // left/right glRotatef(camera_angles[2], 0.0f, 0.0f, 1.0f); if(moving_code[0]) { int x; nos_mouse_delta(&x, NULL); mod = &moving_model; if(x) { moving_delta += x * 0.01f; if(moving_delta > 3.99f) { moving_delta = 3.99f; } if(moving_delta < -3.99f) { moving_delta = -3.99f; } moving_model = model; *((unsigned short *)&moving_code[1]) = (unsigned short)((moving_delta + 4.0f) * 8192.0f); nos_model_command(moving_code, &unpacker, mod); } } else { select_quad(); } glBegin(GL_QUADS); for(q = 0; q < mod->quads; ++q) { if(unpacker.deleted_quads[q]) { continue; } if(unpacker.selected_quads[q]) { if(q == best_quad) { glColor3f(0.6f, 0.6f, 0.3f); } else { glColor3f(0.5f, 0.5f, 0.2f); } } else { if(q == best_quad) { glColor3f(0.2f, 0.2f, 0.6f); } else { glColor3f(0.1f, 0.1f, 0.5f); } } glVertex3fv(mod->vertex_pos[mod->quad_index[q][0]]); glVertex3fv(mod->vertex_pos[mod->quad_index[q][1]]); glVertex3fv(mod->vertex_pos[mod->quad_index[q][2]]); glVertex3fv(mod->vertex_pos[mod->quad_index[q][3]]); } glEnd(); if(show_axis_lines) { glBegin(GL_LINES); glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(10.0f, 0.0f, 0.0f); glColor3f(0.0f, 1.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 10.0f, 0.0f); glColor3f(0.0f, 0.0f, 1.0f); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 0.0f, 10.0f); glEnd(); } if(show_edges) { glColor3f(0.2f, 0.2f, 1.0f); glBegin(GL_LINES); for(q = 0; q < mod->quads; ++q) { glVertex3fv(mod->vertex_pos[mod->quad_index[q][0]]); glVertex3fv(mod->vertex_pos[mod->quad_index[q][1]]); glVertex3fv(mod->vertex_pos[mod->quad_index[q][1]]); glVertex3fv(mod->vertex_pos[mod->quad_index[q][2]]); glVertex3fv(mod->vertex_pos[mod->quad_index[q][2]]); glVertex3fv(mod->vertex_pos[mod->quad_index[q][3]]); glVertex3fv(mod->vertex_pos[mod->quad_index[q][3]]); glVertex3fv(mod->vertex_pos[mod->quad_index[q][0]]); } glEnd(); } if(show_quad_normals) { glColor3f(0.25f, 0.25f, 0.25f); glBegin(GL_LINES); for(q = 0; q < mod->quads; ++q) { glVertex3fv(unpacker.quad_center[q]); glVertex3f(unpacker.quad_center[q][0] + mod->quad_normal[q][0], unpacker.quad_center[q][1] + mod->quad_normal[q][1], unpacker.quad_center[q][2] + mod->quad_normal[q][2]); } glEnd(); } if(show_vertex_normals) { glColor3f(0.25f, 0.25f, 0.25f); glBegin(GL_LINES); for(v = 0; v < mod->vertexes; ++v) { glVertex3fv(mod->vertex_pos[v]); glVertex3f(mod->vertex_pos[v][0] + mod->vertex_normal[v][0], mod->vertex_pos[v][1] + mod->vertex_normal[v][1], mod->vertex_pos[v][2] + mod->vertex_normal[v][2]); } glEnd(); } glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glScalef(2.0f, -2.0f, 0.0f); glTranslatef(-0.5f, -0.5f, 0.0f); glScalef(1.0f/NOS_XRES, 1.0f/NOS_YRES, 0.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glColor3f(0.2f, 0.2f, 0.2f); glRectf(0.0f, 0.0f, 128.0f, NOS_YRES); glColor3f(1.0f, 1.0f, 1.0f); { float y = 0; for(q = 0; q < command_index; q++) { nos_draw_text(2.0f, y += 12, cmd2text[command[q].code[0]], command[q].code[1] | command[q].code[2] << 8); } } { float y = 0; switch(last_sym) { case 't': nos_draw_text(128.0f, y += 12, "Translate faces"); nos_draw_text(128.0f, y += 12, "n: normal"); nos_draw_text(128.0f, y += 12, "x: X"); nos_draw_text(128.0f, y += 12, "y: Y"); nos_draw_text(128.0f, y += 12, "z: Z"); break; case 'T': nos_draw_text(128.0f, y += 12, "Translate all"); nos_draw_text(128.0f, y += 12, "x: X"); nos_draw_text(128.0f, y += 12, "y: Y"); nos_draw_text(128.0f, y += 12, "z: Z"); break; case 's': nos_draw_text(128.0f, y += 12, "Scale faces"); nos_draw_text(128.0f, y += 12, "n: normal"); nos_draw_text(128.0f, y += 12, "x: X"); nos_draw_text(128.0f, y += 12, "y: Y"); nos_draw_text(128.0f, y += 12, "z: Z"); break; case 'S': nos_draw_text(128.0f, y += 12, "Scale all"); nos_draw_text(128.0f, y += 12, "x: X"); nos_draw_text(128.0f, y += 12, "y: Y"); nos_draw_text(128.0f, y += 12, "z: Z"); break; case 'r': nos_draw_text(128.0f, y += 12, "Rotate faces"); nos_draw_text(128.0f, y += 12, "x: X"); nos_draw_text(128.0f, y += 12, "y: Y"); nos_draw_text(128.0f, y += 12, "z: Z"); break; case 'e': nos_draw_text(128.0f, y += 12, "Extra"); nos_draw_text(128.0f, y += 12, "s: Smooth all"); nos_draw_text(128.0f, y += 12, "d: Subdivide all"); nos_draw_text(128.0f, y += 12, "a: Add Cube"); nos_draw_text(128.0f, y += 12, "i: Inset faces"); nos_draw_text(128.0f, y += 12, "e: Extrude faces"); nos_draw_text(128.0f, y += 12, "t: Taper faces"); nos_draw_text(128.0f, y += 12, "r: Remove faces"); nos_draw_text(128.0f, y += 12, "c: Cage faces"); break; case 'x': nos_draw_text(128.0f, y += 12, "Select"); nos_draw_text(128.0f, y += 12, "a: All"); nos_draw_text(128.0f, y += 12, "n: None"); nos_draw_text(128.0f, y += 12, "i: Invert"); nos_draw_text(128.0f, y += 12, "g: Grow selection"); nos_draw_text(128.0f, y += 12, "j: Select Adjacent"); nos_draw_text(128.0f, y += 12, "x: Simular X"); nos_draw_text(128.0f, y += 12, "y: Simular Y"); nos_draw_text(128.0f, y += 12, "z: Simular Z"); break; default: nos_draw_text(128.0f, y += 12, "t: Translate Face"); nos_draw_text(128.0f, y += 12, "T: Translate All"); nos_draw_text(128.0f, y += 12, "s: Scale Face"); nos_draw_text(128.0f, y += 12, "S: Scale All"); nos_draw_text(128.0f, y += 12, "r: Rotate Faces"); nos_draw_text(128.0f, y += 12, "e: Extra"); break; } } glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glPopMatrix(); nos_sleep(10); return 0; }
void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) { MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; /* frame range */ clip_draw_sfra_efra(v2d, scene); if (clip) { MovieTracking *tracking = &clip->tracking; MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; MovieTrackingDopesheetChannel *channel; float y, xscale, yscale; float strip[4], selected_strip[4]; float height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT); /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); y = (float) CHANNEL_FIRST; UI_view2d_getscale(v2d, &xscale, &yscale); /* setup colors for regular and selected strips */ UI_GetThemeColor3fv(TH_STRIP, strip); UI_GetThemeColor3fv(TH_STRIP_SELECT, selected_strip); strip[3] = 0.5f; selected_strip[3] = 1.0f; glEnable(GL_BLEND); clip_draw_dopesheet_background(ar, clip); for (channel = dopesheet->channels.first; channel; channel = channel->next) { float yminc = (float) (y - CHANNEL_HEIGHT_HALF); float ymaxc = (float) (y + CHANNEL_HEIGHT_HALF); /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { MovieTrackingTrack *track = channel->track; float alpha; int i, sel = track->flag & TRACK_DOPE_SEL; /* selection background */ if (sel) { float color[4] = {0.0f, 0.0f, 0.0f, 0.3f}; float default_color[4] = {0.8f, 0.93f, 0.8f, 0.3f}; track_channel_color(track, default_color, color); glColor4fv(color); glRectf(v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF); } alpha = (track->flag & TRACK_LOCKED) ? 0.5f : 1.0f; /* tracked segments */ for (i = 0; i < channel->tot_segment; i++) { int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i]); int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i + 1]); if (sel) glColor4fv(selected_strip); else glColor4fv(strip); if (start_frame != end_frame) { glRectf(start_frame, (float) y - STRIP_HEIGHT_HALF, end_frame, (float) y + STRIP_HEIGHT_HALF); draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha); draw_keyframe_shape(end_frame, y, xscale, yscale, sel, alpha); } else { draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha); } } /* keyframes */ i = 0; while (i < track->markersnr) { MovieTrackingMarker *marker = &track->markers[i]; if ((marker->flag & (MARKER_DISABLED | MARKER_TRACKED)) == 0) { int framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr); draw_keyframe_shape(framenr, y, xscale, yscale, sel, alpha); } i++; } } /* adjust y-position for next one */ y -= CHANNEL_STEP; } glDisable(GL_BLEND); } /* current frame */ clip_draw_cfra(sc, ar, scene); }
void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; View2D *v2d = &ar->v2d; float y = 0.0f; size_t items; int height; /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): * - this is done to allow the channel list to be scrollable, but must be done here * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2)); /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); /* loop through channels, and set up drawing depending on their type */ y = (float)(-NLACHANNEL_HEIGHT(snla)); for (ale = anim_data.first; ale; ale = ale->next) { const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* data to draw depends on the type of channel */ switch (ale->type) { case ANIMTYPE_NLATRACK: { AnimData *adt = ale->adt; NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; int index; /* draw each strip in the track (if visible) */ for (strip = nlt->strips.first, index = 1; strip; strip = strip->next, index++) { if (BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, v2d->cur.xmax)) { /* draw the visualization of the strip */ nla_draw_strip(snla, adt, nlt, strip, v2d, yminc, ymaxc); /* add the text for this strip to the cache */ nla_draw_strip_text(adt, nlt, strip, index, v2d, yminc, ymaxc); /* if transforming strips (only real reason for temp-metas currently), * add to the cache the frame numbers of the strip's extents */ if (strip->flag & NLASTRIP_FLAG_TEMP_META) nla_draw_strip_frames_text(nlt, strip, v2d, yminc, ymaxc); } } break; } case ANIMTYPE_NLAACTION: { AnimData *adt = ale->adt; float color[4]; /* just draw a semi-shaded rect spanning the width of the viewable area if there's data, * and a second darker rect within which we draw keyframe indicator dots if there's data */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); /* get colors for drawing */ nla_action_get_color(adt, ale->data, color); glColor4fv(color); /* draw slightly shifted up for greater separation from standard channels, * but also slightly shorter for some more contrast when viewing the strips */ glRectf(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); /* draw keyframes in the action */ nla_action_draw_keyframes(adt, ale->data, v2d, y, yminc + NLACHANNEL_SKIP, ymaxc - NLACHANNEL_SKIP); /* draw 'embossed' lines above and below the strip for effect */ /* white base-lines */ glLineWidth(2.0f); glColor4f(1.0f, 1.0f, 1.0f, 0.3); fdrawline(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); fdrawline(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); /* black top-lines */ glLineWidth(1.0f); glColor3f(0.0f, 0.0f, 0.0f); fdrawline(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); fdrawline(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); glDisable(GL_BLEND); break; } } } /* adjust y-position for next one */ y -= NLACHANNEL_STEP(snla); } /* free tempolary channels */ ANIM_animdata_freelist(&anim_data); }
void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) { ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); View2D *v2d = &ar->v2d; MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking; MovieTrackingDopesheet *dopesheet; MovieTrackingDopesheetChannel *channel; uiStyle *style = UI_GetStyle(); uiBlock *block; int fontid = style->widget.uifont_id; int height; float y; PropertyRNA *chan_prop_lock; if (!clip) return; tracking = &clip->tracking; dopesheet = &tracking->dopesheet; height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT); if (height > BLI_rcti_size_y(&v2d->mask)) { /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); } /* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */ UI_view2d_sync(NULL, sa, v2d, V2D_LOCK_COPY); /* loop through channels, and set up drawing depending on their type * first pass: just the standard GL-drawing for backdrop + text */ y = (float) CHANNEL_FIRST; BLF_size(fontid, 11.0f * U.pixelsize, U.dpi); for (channel = dopesheet->channels.first; channel; channel = channel->next) { float yminc = (float) (y - CHANNEL_HEIGHT_HALF); float ymaxc = (float) (y + CHANNEL_HEIGHT_HALF); /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { MovieTrackingTrack *track = channel->track; float font_height, color[3]; int sel = track->flag & TRACK_DOPE_SEL; track_channel_color(track, NULL, color); glColor3fv(color); glRectf(v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF); if (sel) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); font_height = BLF_height(fontid, channel->name, sizeof(channel->name)); BLF_position(fontid, v2d->cur.xmin + CHANNEL_PAD, y - font_height / 2.0f, 0.0f); BLF_draw(fontid, channel->name, strlen(channel->name)); } /* adjust y-position for next one */ y -= CHANNEL_STEP; } /* second pass: widgets */ block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); y = (float) CHANNEL_FIRST; /* get RNA properties (once) */ chan_prop_lock = RNA_struct_type_find_property(&RNA_MovieTrackingTrack, "lock"); BLI_assert(chan_prop_lock); glEnable(GL_BLEND); for (channel = dopesheet->channels.first; channel; channel = channel->next) { float yminc = (float)(y - CHANNEL_HEIGHT_HALF); float ymaxc = (float)(y + CHANNEL_HEIGHT_HALF); /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { MovieTrackingTrack *track = channel->track; const int icon = (track->flag & TRACK_LOCKED) ? ICON_LOCKED : ICON_UNLOCKED; PointerRNA ptr; RNA_pointer_create(&clip->id, &RNA_MovieTrackingTrack, track, &ptr); uiBlockSetEmboss(block, UI_EMBOSSN); uiDefIconButR_prop(block, ICONTOG, 1, icon, v2d->cur.xmax - UI_UNIT_X - CHANNEL_PAD, y - UI_UNIT_Y / 2.0f, UI_UNIT_X, UI_UNIT_Y, &ptr, chan_prop_lock, 0, 0, 0, 0, 0, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } /* adjust y-position for next one */ y -= CHANNEL_STEP; } glDisable(GL_BLEND); uiEndBlock(C, block); uiDrawBlock(C, block); }
void my_display(void) { glClear(GL_COLOR_BUFFER_BIT); glRectf(-0.5f, -0.5f, 0.5f, 0.5f); glFlush(); }
void do_widget_canvas(fz_irect canvas_area) { pdf_widget *widget; fz_rect bounds; fz_irect area; if (!pdf) return; for (widget = pdf_first_widget(ctx, page); widget; widget = pdf_next_widget(ctx, widget)) { bounds = pdf_bound_widget(ctx, widget); bounds = fz_transform_rect(bounds, view_page_ctm); area = fz_irect_from_rect(bounds); if (ui_mouse_inside(&canvas_area) && ui_mouse_inside(&area)) { if (!widget->is_hot) pdf_annot_event_enter(ctx, widget); widget->is_hot = 1; ui.hot = widget; if (!ui.active && ui.down) { ui.active = widget; pdf_annot_event_down(ctx, widget); if (selected_annot != widget) { if (selected_annot && pdf_annot_type(ctx, selected_annot) == PDF_ANNOT_WIDGET) pdf_annot_event_blur(ctx, selected_annot); selected_annot = widget; pdf_annot_event_focus(ctx, widget); } } } else { if (widget->is_hot) pdf_annot_event_exit(ctx, widget); widget->is_hot = 0; } /* Set is_hot and is_active to select current appearance */ widget->is_active = (ui.active == widget && ui.down); if (showform) { glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(0, 0, 1, 0.1f); glRectf(area.x0, area.y0, area.x1, area.y1); glDisable(GL_BLEND); } if (ui.active == widget || (!ui.active && ui.hot == widget)) { glLineStipple(1, 0xAAAA); glEnable(GL_LINE_STIPPLE); glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); glEnable(GL_BLEND); glColor4f(1, 1, 1, 1); glBegin(GL_LINE_LOOP); glVertex2f(area.x0-0.5f, area.y0-0.5f); glVertex2f(area.x1+0.5f, area.y0-0.5f); glVertex2f(area.x1+0.5f, area.y1+0.5f); glVertex2f(area.x0-0.5f, area.y1+0.5f); glEnd(); glDisable(GL_BLEND); glDisable(GL_LINE_STIPPLE); } if (ui.hot == widget && ui.active == widget && !ui.down) { pdf_annot_event_up(ctx, widget); if (pdf_field_flags(ctx, widget->obj) & PDF_FIELD_IS_READ_ONLY) continue; switch (pdf_widget_type(ctx, widget)) { default: break; case PDF_WIDGET_TYPE_CHECKBOX: case PDF_WIDGET_TYPE_RADIOBUTTON: pdf_toggle_widget(ctx, widget); break; case PDF_WIDGET_TYPE_TEXT: show_tx_dialog(widget); break; case PDF_WIDGET_TYPE_COMBOBOX: case PDF_WIDGET_TYPE_LISTBOX: ui.dialog = ch_dialog; ch_widget = widget; break; case PDF_WIDGET_TYPE_SIGNATURE: show_sig_dialog(widget); break; } } } if (pdf_update_page(ctx, page)) render_page(); }