/* draw keyframes in each channel */ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; View2D *v2d = &ar->v2d; bDopeSheet *ads = &saction->ads; AnimData *adt = NULL; float act_start, act_end, y; size_t items; int height; unsigned char col1[3], col2[3]; unsigned char col1a[3], col2a[3]; unsigned char col1b[3], col2b[3]; /* get theme colors */ UI_GetThemeColor3ubv(TH_BACK, col2); UI_GetThemeColor3ubv(TH_HILITE, col1); UI_GetThemeColor3ubv(TH_GROUP, col2a); UI_GetThemeColor3ubv(TH_GROUP_ACTIVE, col1a); UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELOB, col1b); UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELSUBOB, col2b); /* set view-mapping rect (only used for x-axis), for NLA-scaling mapping with less calculation */ /* if in NLA there's a strip active, map the view */ if (ac->datatype == ANIMCONT_ACTION) { /* adt = ANIM_nla_mapping_get(ac, NULL); */ /* UNUSED */ /* start and end of action itself */ calc_action_range(ac->data, &act_start, &act_end, 0); } /* 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); height = ((items * ACHANNEL_STEP) + (ACHANNEL_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); /* first backdrop strips */ y = (float)(-ACHANNEL_HEIGHT); glEnable(GL_BLEND); for (ale = anim_data.first; ale; ale = ale->next) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int sel = 0; /* determine if any need to draw channel */ if (ale->datatype != ALE_NONE) { /* determine if channel is selected */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) sel = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); if (ELEM3(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) { switch (ale->type) { case ANIMTYPE_SUMMARY: { /* reddish color from NLA */ UI_ThemeColor4(TH_ANIM_ACTIVE); break; } case ANIMTYPE_SCENE: case ANIMTYPE_OBJECT: { if (sel) glColor4ub(col1b[0], col1b[1], col1b[2], 0x45); else glColor4ub(col1b[0], col1b[1], col1b[2], 0x22); break; } case ANIMTYPE_FILLACTD: case ANIMTYPE_DSSKEY: case ANIMTYPE_DSWOR: { if (sel) glColor4ub(col2b[0], col2b[1], col2b[2], 0x45); else glColor4ub(col2b[0], col2b[1], col2b[2], 0x22); break; } case ANIMTYPE_GROUP: { if (sel) glColor4ub(col1a[0], col1a[1], col1a[2], 0x22); else glColor4ub(col2a[0], col2a[1], col2a[2], 0x22); break; } default: { if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22); else glColor4ub(col2[0], col2[1], col2[2], 0x22); break; } } /* draw region twice: firstly backdrop, then the current range */ glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF); if (ac->datatype == ANIMCONT_ACTION) glRectf(act_start, (float)y - ACHANNEL_HEIGHT_HALF, act_end, (float)y + ACHANNEL_HEIGHT_HALF); } else if (ac->datatype == ANIMCONT_GPENCIL) { /* frames less than one get less saturated background */ if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22); else glColor4ub(col2[0], col2[1], col2[2], 0x22); glRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF); /* frames one and higher get a saturated background */ if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x44); else glColor4ub(col2[0], col2[1], col2[2], 0x44); glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF); } else if (ac->datatype == ANIMCONT_MASK) { /* TODO --- this is a copy of gpencil */ /* frames less than one get less saturated background */ if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22); else glColor4ub(col2[0], col2[1], col2[2], 0x22); glRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF); /* frames one and higher get a saturated background */ if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x44); else glColor4ub(col2[0], col2[1], col2[2], 0x44); glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF); } } } /* Increment the step */ y -= ACHANNEL_STEP; } glDisable(GL_BLEND); /* Draw keyframes * 1) Only channels that are visible in the Action Editor get drawn/evaluated. * This is to try to optimize this for heavier data sets * 2) Keyframes which are out of view horizontally are disregarded */ y = (float)(-ACHANNEL_HEIGHT); for (ale = anim_data.first; ale; ale = ale->next) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* check if anything to show for this channel */ if (ale->datatype != ALE_NONE) { adt = ANIM_nla_mapping_get(ac, ale); /* draw 'keyframes' for each specific datatype */ switch (ale->datatype) { case ALE_ALL: draw_summary_channel(v2d, ale->data, y); break; case ALE_SCE: draw_scene_channel(v2d, ads, ale->key_data, y); break; case ALE_OB: draw_object_channel(v2d, ads, ale->key_data, y); break; case ALE_ACT: draw_action_channel(v2d, adt, ale->key_data, y); break; case ALE_GROUP: draw_agroup_channel(v2d, adt, ale->data, y); break; case ALE_FCURVE: draw_fcurve_channel(v2d, adt, ale->key_data, y); break; case ALE_GPFRAME: draw_gpl_channel(v2d, ads, ale->data, y); break; case ALE_MASKLAY: draw_masklay_channel(v2d, ads, ale->data, y); break; } } } y -= ACHANNEL_STEP; } /* free tempolary channels used for drawing */ ANIM_animdata_freelist(&anim_data); /* black line marking 'current frame' for Time-Slide transform mode */ if (saction->flag & SACTION_MOVING) { glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_LINES); glVertex2f(saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD); glVertex2f(saction->timeslide, v2d->cur.ymax); glEnd(); } }
// // Draws pentagon from triangles: full pentagon if 5 triangle could be build from _vertexes array. // If generates less than 5 vertexes, than we have not a full pentagon. // void AsteroidEnemy::Draw() { if (!_isVisible) { return; } int size = _vertexes.size(); // Dust. if (size == 1) { glBegin(GL_POINTS); glColor3f(0.0, 1.0, 1.0); glVertex2f(_vertexes[0].x, _vertexes[0].y); glEnd(); glBegin(GL_POINTS); glColor3f(0.0, 1.0, 1.0); glVertex2f(_x, _y); glEnd(); return; } // Shape for (int i = 0; i < size; i++) { Vertex v1 = _vertexes[i]; int next = i + 1; if (next >= size) { // Draw last triangle ONLY if this is a full pentagon. if (size == PENTAGON_RIBERS_NUMBER) { next = 0; } else { continue; } } Vertex v2 = _vertexes[next]; glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); glColor3f(1.0, 0.0, 1.0); glBegin(GL_POLYGON); // Calculate visibility of first riber. if (_isPiece || (size != PENTAGON_RIBERS_NUMBER && i == 0)) { // First riber becomes visible if shape is not full. glEdgeFlag(GL_TRUE); } else { // No one internal riber should be visible in the Full Pentagon. glEdgeFlag(GL_FALSE); } glVertex2f(_x, _y); // Middle riber always visible. glEdgeFlag(GL_TRUE); glVertex2f(v1.x, v1.y); // Calculate visibility of last riber. if (_isPiece || (size != PENTAGON_RIBERS_NUMBER && i == size - 2)) { // First riber becomes visible if shape is not full. glEdgeFlag(GL_TRUE); } else { // No one internal riber should be visible in the Full Pentagon. glEdgeFlag(GL_FALSE); } glVertex2f(v2.x, v2.y); glEnd(); } //glBegin(GL_POINTS); //glColor3f(0.0, 1.0, 1.0); //glVertex2f(_x, _y); //glEnd(); }
void GUIQuad::render(RenderPass pass) { bool isTransparent = (_a < 1.0f) || (!_texture.empty() && _texture.getTexture().hasAlpha()); if (((pass == kRenderPassOpaque) && isTransparent) || ((pass == kRenderPassTransparent) && !isTransparent)) return; TextureMan.set(_texture); glColor4f(_r, _g, _b, _a); switch (_blendMode) { case kBlendAdditive: glPushAttrib(GL_COLOR_BUFFER_BIT); glBlendFunc(GL_ONE, GL_ONE); break; case kBlendMultiply: glPushAttrib(GL_COLOR_BUFFER_BIT); glBlendFunc(GL_DST_COLOR, GL_ZERO); break; default: break; } if (_xor) { glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); } if (_scissor) { glEnable(GL_SCISSOR_TEST); GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); glScissor(viewport[2]/2 + _x1 + _scissorX, viewport[3]/2 + _y1 + _scissorY, _scissorWidth, _scissorHeight); } if (_angle != 0.0f) { glTranslatef(_x1 + (_x2 - _x1) / 2.0f, _y1 + (_y2 - _y1) / 2.0f, 0); glRotatef(_angle, 0.0f, 0.0f, 1.0f); glTranslatef(-_x1 - (_x2 - _x1) / 2.0f, -_y1 - (_y2 - _y1) / 2.0f, 0); } glScalef(_xscale, _yscale, 1.0f); glBegin(GL_QUADS); glTexCoord2f(_tX1, _tY1); glVertex2f(_x1, _y1); glTexCoord2f(_tX2, _tY1); glVertex2f(_x2, _y1); glTexCoord2f(_tX2, _tY2); glVertex2f(_x2, _y2); glTexCoord2f(_tX1, _tY2); glVertex2f(_x1, _y2); glEnd(); if (_scissor) glDisable(GL_SCISSOR_TEST); if (_xor) glDisable(GL_COLOR_LOGIC_OP); if (_blendMode != kBlendDefault) { glPopAttrib(); } glColor4f(1.0f, 1.0f, 1.0f, 1.0f); }
static __inline__ void draw_actor_points(float zoom_multip, float px, float py) { float size_x = float_minimap_size / (tile_map_size_x * 6); float size_y = float_minimap_size / (tile_map_size_y * 6); actor *a; int i; float x, y; glPushMatrix(); glDisable(GL_TEXTURE_2D); //display the actors glEnable( GL_POINT_SMOOTH ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glPointSize(8); rotate_actor_points(zoom_multip,px,py); glBegin(GL_POINTS); for (i = 0; i < max_actors; i++) { if (actors_list[i]) { a = actors_list[i]; if (a->attached_actor != -1 && a->actor_id == -1) continue; x = a->x_tile_pos * size_x; y = float_minimap_size - (a->y_tile_pos * size_y); glColor4f(0.0f,0.0f,0.0f,1.0f); glVertex2f(x+2*zoom_multip, y+2*zoom_multip); if (a->kind_of_actor == NPC) elglColourN("minimap.npc"); else if(a->actor_id == yourself) elglColourN("minimap.yourself"); else if(a->is_enhanced_model && (a->kind_of_actor == PKABLE_HUMAN || a->kind_of_actor == PKABLE_COMPUTER_CONTROLLED)) elglColourN("minimap.pkable"); else if(a->is_enhanced_model && is_in_buddylist(a->actor_name)) elglColourN("minimap.buddy"); else if (is_color ((unsigned char)a->actor_name[0])) { if(a->is_enhanced_model && is_in_buddylist(a->actor_name)) elglColourN("minimap.buddy"); else { // Use the colour of their name. This gives purple bots, green demigods, etc. int color = from_color_char (a->actor_name[0]); glColor4ub (colors_list[color].r1, colors_list[color].g1, colors_list[color].b1, 255); } } else if(!a->is_enhanced_model) { if (a->dead) elglColourN("minimap.deadcreature"); else // alive elglColourN("minimap.creature"); } else elglColourN("minimap.otherplayer"); // Draw it! glVertex2f(x, y); } } // mines for (i = 0; i < NUM_MINES; i++) { mine *m = &mine_list[i]; if (m->obj_3d_id != -1) { x = m->x * size_x; y = float_minimap_size - (m->y * size_y); if(is_within_radius(x,y,px,py,zoom_multip*(minimap_size/2-15))) { elglColourN("minimap.mine"); glVertex2f(x, y); } } } glEnd();//GL_POINTS glDisable(GL_BLEND); glDisable(GL_POINT_SMOOTH); glPopMatrix(); if (pf_follow_path) { x = pf_dst_tile->x * size_x; y = float_minimap_size - (pf_dst_tile->y * size_y); if (x != px || y != py) { float diff = 6.0f*zoom_multip; if(is_within_radius(x,y,px,py,zoom_multip*(minimap_size/2-15))) { glPushMatrix(); glDisable(GL_TEXTURE_2D); rotate_actor_points(zoom_multip,px,py); glBegin(GL_LINES); glColor3f(1.0f,0.0f,1.0f); //purple glVertex2f(x-diff, y-diff); glVertex2f(x+diff, y+diff); glVertex2f(x-diff, y+diff); glVertex2f(x+diff, y-diff); glEnd();//GL_LINES glPopMatrix(); } } } //draw map markings for(i=0;i<max_mark;i++){ if(!marks[i].server_side) continue; x= marks[i].x*size_x; y= float_minimap_size-(marks[i].y*size_y); if (x != px || y != py) { float diff = 4.0f*zoom_multip; if(is_within_radius(x,y,px,py,zoom_multip*(minimap_size/2-15))) { glPushMatrix(); glDisable(GL_TEXTURE_2D); rotate_actor_points(zoom_multip,px,py); glBegin(GL_LINES); elglColourN("minimap.servermark"); glVertex2f(x-diff, y-diff); glVertex2f(x+diff, y+diff); glVertex2f(x-diff, y+diff); glVertex2f(x+diff, y-diff); glEnd();//GL_LINES glPopMatrix(); } } } glColor4f(1.0f,1.0f,1.0f,1.0f); glEnable(GL_TEXTURE_2D); }
void draw_minimap_title_bar(window_info *win) { #ifdef NEW_TEXTURES float u_first_start= (float)31/255; float u_first_end = 0.0f; float v_first_start = (float)160/255; float v_first_end = (float)175/255; float u_last_start = 0.0f; float u_last_end = (float)31/255; float v_last_start = (float)160/255; float v_last_end = (float)175/255; #else /* NEW_TEXTURES */ float u_first_start= (float)31/255; float u_first_end= 0; float v_first_start= 1.0f-(float)160/255; float v_first_end= 1.0f-(float)175/255; float u_last_start= 0; float u_last_end= (float)31/255; float v_last_start= 1.0f-(float)160/255; float v_last_end= 1.0f-(float)175/255; #endif /* NEW_TEXTURES */ int close_button_x = win->len_x/2 + 32 - 1; glPushMatrix(); glColor3f(1.0f,1.0f,1.0f); #ifdef NEW_TEXTURES bind_texture(icons_text); #else /* NEW_TEXTURES */ get_and_set_texture_id(icons_text); #endif /* NEW_TEXTURES */ glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER,0.03f); glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); glTexCoord2f(u_first_end, v_first_start); glVertex3i(win->len_x/2-32, ELW_TITLE_HEIGHT, 0); glTexCoord2f(u_first_end, v_first_end); glVertex3i(win->len_x/2-32, 0, 0); glTexCoord2f(u_first_start, v_first_end); glVertex3i(win->len_x/2, 0, 0); glTexCoord2f(u_first_start, v_first_start); glVertex3i(win->len_x/2, ELW_TITLE_HEIGHT, 0); glTexCoord2f(u_last_end, v_last_start); glVertex3i(win->len_x/2, ELW_TITLE_HEIGHT, 0); glTexCoord2f(u_last_end, v_last_end); glVertex3i(win->len_x/2, 0, 0); glTexCoord2f(u_last_start, v_last_end); glVertex3i(win->len_x/2+32, 0, 0); glTexCoord2f(u_last_start, v_last_start); glVertex3i(win->len_x/2+32, ELW_TITLE_HEIGHT, 0); glEnd(); glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D); //draw the X background glColor3f(0.156f,0.078f,0.0f); glBegin(GL_POLYGON); glVertex2f(close_button_x + ELW_TITLE_HEIGHT, ELW_TITLE_HEIGHT); glVertex2f(close_button_x, ELW_TITLE_HEIGHT); glVertex2f(close_button_x, 0); glVertex2f(close_button_x + ELW_TITLE_HEIGHT, 0); glEnd(); //draw the rectngle glColor3f(win->line_color[0],win->line_color[1],win->line_color[2]); glBegin(GL_LINE_STRIP); glVertex2i(close_button_x + ELW_TITLE_HEIGHT-2 - gx_adjust, ELW_TITLE_HEIGHT-1 - gy_adjust); glVertex2i(close_button_x + 1 - gx_adjust, ELW_TITLE_HEIGHT-1 - gy_adjust); glVertex2i(close_button_x + 1 - gx_adjust, 2 - gy_adjust); glVertex2i(close_button_x + ELW_TITLE_HEIGHT-2 - gx_adjust, 2 - gy_adjust); glVertex2i(close_button_x + ELW_TITLE_HEIGHT-2 - gx_adjust, ELW_TITLE_HEIGHT-1 - gy_adjust); glEnd(); //draw the X glLineWidth(2.0f); glBegin(GL_LINES); glVertex2i(close_button_x + 3, 4); glVertex2i(close_button_x + ELW_TITLE_HEIGHT-3, ELW_TITLE_HEIGHT-4); glVertex2i(close_button_x + ELW_TITLE_HEIGHT-3, 4); glVertex2i(close_button_x + 3, ELW_TITLE_HEIGHT-4); glEnd(); glLineWidth(1.0f); glPopMatrix(); #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE }
void EasyMask::drawMask ( ofTexture contentTex , ofTexture maskTex , float xOffset , float yOffset , float contentAlpha ) { /* if ( contentTex.getWidth() < maskArea.width ) maskArea.width = contentTex.getWidth() ; if ( contentTex.getHeight() < maskArea.height ) maskArea.height = contentTex.getHeight() ; */ //TEX0 = CONTENT //TEX1 = M //BEGIN MASK ofEnableAlphaBlending( ) ; //ofSetColor ( 255 , 255 , 255 ) ; // contentTex.setTextureWrap( GL_CLAMP, GL_CLAMP ) ; glActiveTexture(GL_TEXTURE0_ARB); contentTex.bind(); glActiveTexture(GL_TEXTURE1_ARB); maskTex.bind(); //prevents weird texture wrapping // contentTex.setTextureWrap( GL_CLAMP_TO_BORDER_ARB, GL_CLAMP_TO_BORDER_ARB ) ; contentTex.setTextureWrap( GL_CLAMP_TO_BORDER_ARB , GL_CLAMP_TO_BORDER_ARB ) ; // texture1.setTextureWrap( GL_CLAMP , GL_CLAMP ) ; //xOffset = sin ( ofGetElapsedTimef() ) * 500.0f ; maskShader.begin(); maskShader.setUniformTexture("Tex0", contentTex , 0); maskShader.setUniformTexture("Tex1", maskTex , 1); maskShader.setUniform1f( "alpha" , contentAlpha ) ; glBegin(GL_QUADS); ofFill() ; // ofSetColor ( 255 , 255 , 255 , 255 ) ; // maskOffset = 0 ; //sin ( ofGetElapsedTimef() ) * 200.0f ; glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset , yOffset ); glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, contentAlpha ); glVertex2f( maskArea.x , maskArea.y ); glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset + contentTex.getWidth(), yOffset ); glMultiTexCoord2d(GL_TEXTURE1_ARB, maskTex.getWidth(), 0 ); glVertex2f( maskArea.x + maskArea.width , maskArea.y ); glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset + contentTex.getWidth() , contentTex.getHeight() + yOffset ); glMultiTexCoord2d(GL_TEXTURE1_ARB, maskTex.getWidth() , maskTex.getHeight() ); glVertex2f( maskArea.x + maskArea.width , maskArea.height + maskArea.y ); glMultiTexCoord2d(GL_TEXTURE0_ARB, xOffset , contentTex.getHeight() + yOffset ); glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, maskTex.getHeight() ); glVertex2f( maskArea.x , maskArea.height + maskArea.y ) ; glEnd(); maskShader.end() ; //deactive and clean up glActiveTexture(GL_TEXTURE1_ARB); maskTex.unbind(); glActiveTexture(GL_TEXTURE0_ARB); contentTex.unbind(); //maskArea = originalMaskArea ; }
void drawPoint( float x, float y ) { glBegin(GL_POINTS); glVertex2f(x, y); glEnd(); }
void DesenhaQuadro(void) { glColor3f(1.0,1.0,1.0); glBegin(GL_QUADS); glVertex2f(-0.8,0.8); glVertex2f(0.8,0.8); glVertex2f(0.8,-0.8); glVertex2f(-0.8,-0.8); glEnd(); glColor3f(1.0,0.0,0.0); glBegin(GL_TRIANGLES); glVertex2f(-0.6,-0.6); glVertex2f(0.0,0.6); glVertex2f(0.6,-0.6); glEnd(); glColor3f(0.0,1.0,0.0); glBegin(GL_POLYGON); glVertex2f(-0.6,-0.4); glVertex2f(0.0,-0.3); glVertex2f(0.6,-0.4); glVertex2f(0.6,-0.6); glVertex2f(-0.6,-0.6); glEnd(); glColor3f(0.0,0.0,1.0); glLineWidth(2.0); glBegin(GL_LINES); glVertex2f(-1.0,1.0); glVertex2f(1.0,-1.0); glEnd(); glFlush(); }
void triCombo() { /* TOP and MIDDLE */ glBegin(GL_TRIANGLE_FAN); glVertex2f(x[1], y[1]); // 0.0, 1.0 glVertex2f(x[2], y[2]); // 0.6, 1.0 glVertex2f(x[6], y[6]); // 0.6, 0.6 glVertex2f(x[5], y[5]); // 0.2, 0.6 glVertex2f(x[9], y[9]); // 0.2, -0.6 glVertex2f(x[8], y[8]); // -0.2, -0.6 glVertex2f(x[4], y[4]); // -0.2, 0.6 glVertex2f(x[3], y[3]); // -0.6, 0.6 glVertex2f(x[0], y[0]); // -0.6, 1.0 glEnd(); /* BOTTOM */ glBegin(GL_TRIANGLE_STRIP); glVertex2f(x[10], y[10]); // 0.6, -1.0 glVertex2f(x[9], y[9]); // 0.2, -0.6 glVertex2f(x[12], y[12]); // 0.6, -1.0 glVertex2f(x[8], y[8]); // -0.2, -0.6 glVertex2f(x[11], y[11]); // -0.6, -1.0 glVertex2f(x[7], y[7]); // -0.6, -0.6 glEnd(); }
void GalacticView::Draw3D() { vector3f pos = Pi::sectorView->GetPosition(); float offset_x = (pos.x*Sector::SIZE + Galaxy::SOL_OFFSET_X)/Galaxy::GALAXY_RADIUS; float offset_y = (-pos.y*Sector::SIZE + Galaxy::SOL_OFFSET_Y)/Galaxy::GALAXY_RADIUS; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-Pi::GetScrAspect(), Pi::GetScrAspect(), 1.0, -1.0, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); m_texture->Bind(); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glScalef(m_zoom, m_zoom, 0.0f); glTranslatef(-offset_x, -offset_y, 0.0f); glBegin(GL_QUADS); float w = 1.0; float h = 1.0; glTexCoord2f(0,h); glVertex2f(-1.0,1.0); glTexCoord2f(w,h); glVertex2f(1.0,1.0); glTexCoord2f(w,0); glVertex2f(1.0,-1.0); glTexCoord2f(0,0); glVertex2f(-1.0,-1.0); glEnd(); m_texture->Unbind(); glDisable(GL_TEXTURE_2D); glColor3f(0.0,1.0,0.0); glPointSize(3.0); glBegin(GL_POINTS); glVertex2f(offset_x, offset_y); glEnd(); glLoadIdentity(); glColor3f(1,1,1); glPointSize(1.0); glBegin(GL_LINE_STRIP); glVertex2f(-0.25,-0.93); glVertex2f(-0.25,-0.94); glVertex2f(0.25,-0.94); glVertex2f(0.25,-0.93); glEnd(); m_labels->Clear(); PutLabels(-vector3d(offset_x, offset_y, 0.0)); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); }
void Colormap::render(float min, float max, int minorTicks) { int step = 1; int width = 50; glTranslatef(10, 10, 10); glColor3f(1, 1, 1); glBegin(GL_LINES); glVertex2f(1, 1); glVertex2f(1, 256 * step + 2); glVertex2f(1, 256 * step + 2); glVertex2f(width, 256 * step + 2); glVertex2f(width, 256 * step + 2); glVertex2f(width, 1); glVertex2f(width, 1); glVertex2f(1, 1); glEnd(); glBegin(GL_QUADS); for (size_t i = 0; i < 256; i++) { glColor3f(colors[i].red, colors[i].green, colors[i].blue); glVertex2f(1, 1 + (i * step) + step); // Top Left glVertex2f(width - 1, 1 + (i * step) + step); // Top Right glColor3f(colors[i].red, colors[i].green, colors[i].blue); glVertex2f(width - 1, 1 + i * step); // Bottom Right glVertex2f(1, 1 + i * step); // Bottom Left } glEnd(); glColor3f(1, 1, 1); glBegin(GL_LINES); glVertex2f(width, 2); glVertex2f(width + 5, 2); glEnd(); printText(width + 8, 1 - 3.5, float2str(min)); minorTicks = minorTicks + 1; for (int tick = 1; tick < minorTicks; tick++) { glBegin(GL_LINES); glVertex2f(width, tick * ((256 * step) / minorTicks)); glVertex2f(width + 2, tick * ((256 * step) / minorTicks)); glEnd(); float val = min + tick * (fabs(min - max) / minorTicks); printText(width + 5, tick * ((256 * step) / minorTicks) - 3.5, float2str(val)); } glBegin(GL_LINES); glVertex2f(width, 256 * step + 1); glVertex2f(width + 5, 256 * step + 1); glEnd(); printText(width + 8, 256 * step - 3.5, float2str(max)); glTranslatef(-10, -10, -10); }
void render() { int i; if( changeMon.hasChanged() ) { cheReactionReset(); } glScalef( 1.f/DIMX, 1.f/DIMX, 1.f ); glTranslatef( -DIMX/2.f, -DIMY/2.f, 0.f ); zviewpointSetupView(); zprofBeg( band_update ); for( i=0; i<Band_updates; i++ ) { partUpdate(); cheReactionUpdate(); } zprofEnd(); Band_avgZHits = (float)zReactHits / (float)framesSinceLastReset; zprofBeg( band_render ); glPointSize( Band_pointSize ); glVertexPointer( 2, GL_INT, sizeof(Part), &part[0].pos ); glEnableClientState( GL_VERTEX_ARRAY ); glColorPointer( 3, GL_UNSIGNED_BYTE, sizeof(Part), &part[0].color ); glEnableClientState( GL_COLOR_ARRAY ); glDrawArrays( GL_POINTS, 0, partCount ); glColor3ub( 100, 100, 100 ); glBegin( GL_LINES ); float cntf = (float)spatialHistogramCount; for( int x=0; x<DIMX; x++ ) { glVertex2f( (float)x, 0.f ); glVertex2f( (float)x, Band_histogramScale * (float)spatialHistogram[x] / cntf ); } glEnd(); glTranslatef( 0.f, -22, 0.f ); glBegin( GL_LINES ); glColor3ub( 255, 255, 255 ); glVertex2f( 0.f, 0.f ); glVertex2f( Band_plotScaleX * (float)inputHistory.size, 0.f ); glColor3ub( 50, 255, 50 ); glVertex2f( 0.f, Band_plotScaleY0 * Band_signalTop ); glVertex2f( Band_plotScaleX * (float)inputHistory.size, Band_plotScaleY0 * Band_signalTop ); glEnd(); glColor3ub( 100, 255, 100 ); glBegin( GL_LINE_STRIP ); for( i=0; i<inputHistory.size-1; i++ ) { glVertex2f( Band_plotScaleX * (float)i, Band_plotScaleY0 * inputHistory.getVal(i) ); } glEnd(); glColor3ub( 100, 100, 255 ); glBegin( GL_LINE_STRIP ); for( i=0; i<inputHistory.size-1; i++ ) { glVertex2f( Band_plotScaleX * (float)i, Band_plotScaleY1 * outputHistory.getAvg(i) ); } glEnd(); // DRAW the power spectrum glTranslatef( 0.f, -22, 0.f ); glBegin( GL_LINES ); glColor3ub( 255, 255, 255 ); glVertex2f( 0.f, 0.f ); glVertex2f( Band_plotFFTScaleX * (float)fftBufSize/2.f, 0.f ); glEnd(); glColor3ub( 200, 200, 50 ); glBegin( GL_LINE_STRIP ); for( i=1; i<fftBufSize/2-1; i++ ) { glVertex2f( Band_plotFFTScaleX * (float)i, Band_plotFFTScaleY * cumPowerSpectrumLog[i] ); } glEnd(); zprofEnd(); }
/* draw a given stroke in 2d */ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag, short debug, int offsx, int offsy, int winx, int winy) { /* otherwise thickness is twice that of the 3D view */ float thickness= (float)thickness_s * 0.5f; /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, 'smooth' opengl lines look better * - 'smooth' opengl lines are also required if Image Editor 'image-based' stroke */ if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) || ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) ) { bGPDspoint *pt; int i; glBegin(GL_LINE_STRIP); for (i=0, pt=points; i < totpoints && pt; i++, pt++) { if (sflag & GP_STROKE_2DSPACE) { glVertex2f(pt->x, pt->y); } else if (sflag & GP_STROKE_2DIMAGE) { const float x= (pt->x * winx) + offsx; const float y= (pt->y * winy) + offsy; glVertex2f(x, y); } else { const float x= (pt->x / 100 * winx) + offsx; const float y= (pt->y / 100 * winy) + offsy; glVertex2f(x, y); } } glEnd(); } /* tesselation code - draw stroke as series of connected quads with connection * edges rotated to minimise shrinking artifacts, and rounded endcaps */ else { bGPDspoint *pt1, *pt2; float pm[2]; int i; glShadeModel(GL_FLAT); glBegin(GL_QUADS); for (i=0, pt1=points, pt2=points+1; i < (totpoints-1); i++, pt1++, pt2++) { float s0[2], s1[2]; /* segment 'center' points */ float t0[2], t1[2]; /* tesselated coordinates */ float m1[2], m2[2]; /* gradient and normal */ float mt[2], sc[2]; /* gradient for thickness, point for end-cap */ float pthick; /* thickness at segment point */ /* get x and y coordinates from points */ if (sflag & GP_STROKE_2DSPACE) { s0[0]= pt1->x; s0[1]= pt1->y; s1[0]= pt2->x; s1[1]= pt2->y; } else if (sflag & GP_STROKE_2DIMAGE) { s0[0]= (pt1->x * winx) + offsx; s0[1]= (pt1->y * winy) + offsy; s1[0]= (pt2->x * winx) + offsx; s1[1]= (pt2->y * winy) + offsy; } else { s0[0]= (pt1->x / 100 * winx) + offsx; s0[1]= (pt1->y / 100 * winy) + offsy; s1[0]= (pt2->x / 100 * winx) + offsx; s1[1]= (pt2->y / 100 * winy) + offsy; } /* calculate gradient and normal - 'angle'=(ny/nx) */ m1[1]= s1[1] - s0[1]; m1[0]= s1[0] - s0[0]; normalize_v2(m1); m2[1]= -m1[0]; m2[0]= m1[1]; /* always use pressure from first point here */ pthick= (pt1->pressure * thickness); /* if the first segment, start of segment is segment's normal */ if (i == 0) { /* draw start cap first * - make points slightly closer to center (about halfway across) */ mt[0]= m2[0] * pthick * 0.5f; mt[1]= m2[1] * pthick * 0.5f; sc[0]= s0[0] - (m1[0] * pthick * 0.75f); sc[1]= s0[1] - (m1[1] * pthick * 0.75f); t0[0]= sc[0] - mt[0]; t0[1]= sc[1] - mt[1]; t1[0]= sc[0] + mt[0]; t1[1]= sc[1] + mt[1]; glVertex2fv(t0); glVertex2fv(t1); /* calculate points for start of segment */ mt[0]= m2[0] * pthick; mt[1]= m2[1] * pthick; t0[0]= s0[0] - mt[0]; t0[1]= s0[1] - mt[1]; t1[0]= s0[0] + mt[0]; t1[1]= s0[1] + mt[1]; /* draw this line twice (first to finish off start cap, then for stroke) */ glVertex2fv(t1); glVertex2fv(t0); glVertex2fv(t0); glVertex2fv(t1); } /* if not the first segment, use bisector of angle between segments */ else { float mb[2]; /* bisector normal */ float athick, dfac; /* actual thickness, difference between thicknesses */ /* calculate gradient of bisector (as average of normals) */ mb[0]= (pm[0] + m2[0]) / 2; mb[1]= (pm[1] + m2[1]) / 2; normalize_v2(mb); /* calculate gradient to apply * - as basis, use just pthick * bisector gradient * - if cross-section not as thick as it should be, add extra padding to fix it */ mt[0]= mb[0] * pthick; mt[1]= mb[1] * pthick; athick= len_v2(mt); dfac= pthick - (athick * 2); if ( ((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick)==0) ) { mt[0] += (mb[0] * dfac); mt[1] += (mb[1] * dfac); } /* calculate points for start of segment */ t0[0]= s0[0] - mt[0]; t0[1]= s0[1] - mt[1]; t1[0]= s0[0] + mt[0]; t1[1]= s0[1] + mt[1]; /* draw this line twice (once for end of current segment, and once for start of next) */ glVertex2fv(t1); glVertex2fv(t0); glVertex2fv(t0); glVertex2fv(t1); } /* if last segment, also draw end of segment (defined as segment's normal) */ if (i == totpoints-2) { /* for once, we use second point's pressure (otherwise it won't be drawn) */ pthick= (pt2->pressure * thickness); /* calculate points for end of segment */ mt[0]= m2[0] * pthick; mt[1]= m2[1] * pthick; t0[0]= s1[0] - mt[0]; t0[1]= s1[1] - mt[1]; t1[0]= s1[0] + mt[0]; t1[1]= s1[1] + mt[1]; /* draw this line twice (once for end of stroke, and once for endcap)*/ glVertex2fv(t1); glVertex2fv(t0); glVertex2fv(t0); glVertex2fv(t1); /* draw end cap as last step * - make points slightly closer to center (about halfway across) */ mt[0]= m2[0] * pthick * 0.5f; mt[1]= m2[1] * pthick * 0.5f; sc[0]= s1[0] + (m1[0] * pthick * 0.75f); sc[1]= s1[1] + (m1[1] * pthick * 0.75f); t0[0]= sc[0] - mt[0]; t0[1]= sc[1] - mt[1]; t1[0]= sc[0] + mt[0]; t1[1]= sc[1] + mt[1]; glVertex2fv(t1); glVertex2fv(t0); } /* store stroke's 'natural' normal for next stroke to use */ copy_v2_v2(pm, m2); } glEnd(); } /* draw debug points of curve on top? (original stroke points) */ if (debug) { bGPDspoint *pt; int i; glBegin(GL_POINTS); for (i=0, pt=points; i < totpoints && pt; i++, pt++) { if (sflag & GP_STROKE_2DSPACE) { glVertex2f(pt->x, pt->y); } else if (sflag & GP_STROKE_2DIMAGE) { const float x= (float)((pt->x * winx) + offsx); const float y= (float)((pt->y * winy) + offsy); glVertex2f(x, y); } else { const float x= (float)(pt->x / 100 * winx) + offsx; const float y= (float)(pt->y / 100 * winy) + offsy; glVertex2f(x, y); } } glEnd(); } }
void DrawRedar(float ne) { glEnable(GL_BLEND); GLint DRX=(GLint)(winwidth/5.0f); GLint DRY=(GLint)(winheight/5.0f); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA ); glDisable(GL_DEPTH_TEST); // Disables Depth Testing glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glPushMatrix(); // Store The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix glOrtho(-DRY,winwidth+(DRX-DRY),-DRY,winheight,-1,100); // Set Up An Ortho Screen glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glPushMatrix(); // Store The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix glColor4f(0.5f,1.0f,0.5f,1.0f); if(PlayerLocked) glColor4f(1.0f,0.5f,0.5f,1.0f); glPushMatrix(); glBindTexture(GL_TEXTURE_2D, textureRedar); //glTranslated(-DRY,DRY,0); if(hited>0) glTranslated(float(rand()%10-5),float(rand()%10-5),0); glBegin(GL_QUADS); // Use A Quad For Each Character glTexCoord2f(0.0f,0.0f);glVertex2f(-DRY*0.9f, DRY*0.9f); // Vertex Coord (Bottom Left) glTexCoord2f(1.0f,0.0f);glVertex2f( DRY*0.9f, DRY*0.9f); // Vertex Coord (Bottom Right) glTexCoord2f(1.0f,1.0f);glVertex2f( DRY*0.9f,-DRY*0.9f); // Vertex Coord (Top Right) glTexCoord2f(0.0f,1.0f);glVertex2f(-DRY*0.9f,-DRY*0.9f); // Vertex Coord (Top Left) glEnd(); glBindTexture(GL_TEXTURE_2D, CompassTexID); glRotatef(180.0f-ne,0.0f,0.0f,1.0f); glBegin(GL_QUADS); // Use A Quad For Each Character glTexCoord2f(0.0f,0.0f);glVertex2f(-DRY*1.1f, DRY*1.1f); // Vertex Coord (Bottom Left) glTexCoord2f(1.0f,0.0f);glVertex2f( DRY*1.1f, DRY*1.1f); // Vertex Coord (Bottom Right) glTexCoord2f(1.0f,1.0f);glVertex2f( DRY*1.1f,-DRY*1.1f); // Vertex Coord (Top Right) glTexCoord2f(0.0f,1.0f);glVertex2f(-DRY*1.1f,-DRY*1.1f); // Vertex Coord (Top Left) glEnd(); glPopMatrix(); glColor4f(1.0f,1.0f,1.0f,1.0f); glBlendFunc(GL_SRC_COLOR,GL_ONE_MINUS_SRC_COLOR ); glPushMatrix(); glRotatef(180.0f-ne+25.0f,0.0f,0.0f,1.0f); glBindTexture(GL_TEXTURE_2D, RedarTexture); glScaled(-0.0199*DRY*0.9, 0.0199*DRY*0.9, 0.0199*DRY*0.9); m_VBMD->ShowVBMD(ModelID_redarUI,false); glColor4f(1.0f,1.0f,1.0f,1.0f); glPopMatrix(); glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glPopMatrix(); // Restore The Old Projection Matrix glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glPopMatrix(); // Restore The Old Projection Matrix glEnable(GL_DEPTH_TEST); // Enables Depth Testing }
void display(void) { glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor3f(1.0f, 1.0f, 1.0f); if (ps.renderMode == 0) { int i; glColor3f(0.3f, 0.8f, 1.0f); glEnable(GL_BLEND); glEnable(GL_POINT_SMOOTH); glPointSize(5.0f); glBegin(GL_POINTS); for (i = 0; i < ps.pNum; i++) { // if(ps.p[i].phase == bubble) glColor3f(1.0f, 0.3f, 0.8f); else if(ps.p[i].phase == water) glColor3f(0.5f, 0.8f, 1.0f); else glColor3f(0.3f, 1.0f, 0.8f); glVertex2fv(&ps.p[i].pos.x); } glEnd(); glPointSize(1.0f); glDisable(GL_POINT_SMOOTH); glDisable(GL_BLEND); } else if (ps.renderMode > 0) { //glBindTexture(GL_TEXTURE_2D, waterTex); //glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, RENDER_SAMPLE, RENDER_SAMPLE, GL_RGBA, GL_FLOAT, ps.texture); //glEnable(GL_TEXTURE_2D); //glBegin(GL_QUADS); //glTexCoord2f(0.0f, 0.0f); //glVertex2f(0.0f, 0.0f); //glTexCoord2f(1.0f, 0.0f); //glVertex2f(1.0f, 0.0f); //glTexCoord2f(1.0f, 1.0f); //glVertex2f(1.0f, 1.0f); //glTexCoord2f(0.0f, 1.0f); //glVertex2f(0.0f, 1.0f); //glEnd(); //glDisable(GL_TEXTURE_2D); if (ps.renderMode == 2) { int i; glColor3f(0.3f, 0.8f, 1.0f); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); glLineWidth(1.5f); glBegin(GL_LINES); for (i = 0; i < ps.nLine0; i++) { glVertex2fv(&ps.line0[i].x); glVertex2fv(&ps.line1[i].x); } glEnd(); glColor3f(1.0f, 0.8f, 0.3f); glBegin(GL_LINES); for (i = 0; i < ps.nLine1; i++) { glVertex2fv(&ps.line2[i].x); glVertex2fv(&ps.line3[i].x); } glEnd(); glLineWidth(1.0f); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } // if (ps.renderMode == 1) { //int i; //glColor3f(0.3f, 0.8f, 1.0f); //glEnable(GL_BLEND); //glEnable(GL_POINT_SMOOTH); //glPointSize(5.0f); //glBegin(GL_POINTS); //for (i = 0; i < ps.pNum; i++) // glVertex2fv(&ps.p[i].pos.x); //glEnd(); //glPointSize(1.0f); //glDisable(GL_POINT_SMOOTH); ////draw contour //glLineWidth(1.5f); //glBegin(GL_LINES); //for (i = 0; i < ps.nLine; i++) { // glVertex2fv(&ps.line0[i].x); // glVertex2fv(&ps.line1[i].x); //} //glEnd(); //glLineWidth(1.0f); //glDisable(GL_LINE_SMOOTH); //glDisable(GL_BLEND); //glEnable(GL_TEXTURE_2D); glUseProgram(programObject); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, waterTex); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, RENDER_SAMPLE, RENDER_SAMPLE, GL_RGBA, GL_FLOAT, ps.textureWater); waterLoc = glGetUniformLocation(programObject, "tex_water"); if(waterLoc >= 0) glUniform1i(waterLoc, 0); else printf("Uniform variable tex_water not found!\n"); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, iceTex); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, RENDER_SAMPLE, RENDER_SAMPLE, GL_RGBA, GL_FLOAT, ps.textureIce); iceLoc = glGetUniformLocation(programObject, "tex_ice"); if(iceLoc >= 0) glUniform1i(iceLoc, 1); else printf("Uniform variable tex_ice not found!\n"); glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f); glEnd(); //glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); glUseProgram(0); /*glBindTexture(GL_TEXTURE_2D, iceTex); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, RENDER_SAMPLE, RENDER_SAMPLE, GL_RGBA, GL_FLOAT, ps.textureIce); glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f); glEnd(); glDisable(GL_TEXTURE_2D);*/ //glColor3f(0.3f, 0.8f, 1.0f); glEnable(GL_BLEND); glEnable(GL_POINT_SMOOTH); glPointSize(10.0f); //glBegin(GL_POINTS); int i; for (i = 0; i < ps.pNum; i++) { // if(ps.p[i].phase == bubble) { //glPointSize(10.0f * ps.p[i].volume); glColor3f(1.0f, 1.0f, 1.0f); DrawCircle(ps.p[i].pos.x, ps.p[i].pos.y, 0.005 * ps.p[i].volume, 10); //glVertex2fv(&ps.p[i].pos.x); } } //glEnd(); glPointSize(1.0f); glDisable(GL_POINT_SMOOTH); glDisable(GL_BLEND); } } if (systemRunning) { //if (frameNum % 10 == 0) //screenShot(frameNum / 10); frameNum++; } renderText(); glutSwapBuffers(); }
static void draw_text(const char *text, float xi, float yi, struct color *color, struct font *font) { const struct glyph *g; float x, y; int spacing; x = 0; y = 0; glColor3f(color->r, color->g, color->b); glPushMatrix(); glLoadIdentity(); glTranslatef(xi, yi, 0); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); spacing = font->spacing; while (*text) { if (*text == ' ') { x += TEXT_SPACING_FACTOR*spacing; text++; } else { g = font_get_glyph(font, *text); if (g == NULL) panic("Cannot load glyph for '%c'.", *text); glBindTexture(GL_TEXTURE_2D, g->texture); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex2f(x, y); glTexCoord2f(1.0, 0.0); glVertex2f(x + g->width, y); glTexCoord2f(1.0, 1.0); glVertex2f(x + g->width, g->height); glTexCoord2f(0.0, 1.0); glVertex2f(x, g->height); x += g->width + spacing; glEnd(); text++; } } glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); glPopMatrix(); }
void Route::DrawGLLines( ViewPort &VP, ocpnDC *dc ) { #ifdef ocpnUSE_GL float pix_full_circle = WGS84_semimajor_axis_meters * mercator_k0 * 2 * PI * VP.view_scale_ppm; bool r1valid = false; wxPoint2DDouble r1; wxRoutePointListNode *node = pRoutePointList->GetFirst(); RoutePoint *prp2 = node->GetData(); if(m_nPoints == 1 && dc) { // single point.. make sure it shows up for highlighting cc1->GetDoubleCanvasPointPix( prp2->m_lat, prp2->m_lon, &r1); dc->DrawLine(r1.m_x, r1.m_y, r1.m_x+2, r1.m_y+2); return; } // dc is passed for thicker highlighted lines (performance not very important) if( !dc ) glBegin(GL_LINES); unsigned short int FromSegNo = prp2->m_GPXTrkSegNo; for(node = node->GetNext(); node; node = node->GetNext()) { RoutePoint *prp1 = prp2; prp2 = node->GetData(); unsigned short int ToSegNo = prp2->m_GPXTrkSegNo; // Provisional, to properly set status of last point in route prp2->m_pos_on_screen = false; if (FromSegNo != ToSegNo) { FromSegNo = ToSegNo; r1valid = false; } else { // Handle offscreen points LLBBox bbox = VP.GetBBox(); // don't need to perform calculations or render segment // if both points are past any edge of the vp // TODO: use these optimizations for dc mode bool lat1l = prp1->m_lat < bbox.GetMinY(), lat2l = prp2->m_lat < bbox.GetMinY(); bool lat1r = prp1->m_lat > bbox.GetMaxY(), lat2r = prp2->m_lat > bbox.GetMaxY(); if( (lat1l && lat2l) || (lat1r && lat2r) ) { r1valid = false; prp1->m_pos_on_screen = false; continue; } bool lon1l, lon1r, lon2l, lon2r; TestLongitude(prp1->m_lon, bbox.GetMinX(), bbox.GetMaxX(), lon1l, lon1r); TestLongitude(prp2->m_lon, bbox.GetMinX(), bbox.GetMaxX(), lon2l, lon2r); if( (lon1l && lon2l) || (lon1r && lon2r) ) { r1valid = false; prp1->m_pos_on_screen = false; continue; } if(!r1valid) cc1->GetDoubleCanvasPointPix( prp1->m_lat, prp1->m_lon, &r1); wxPoint2DDouble r2; cc1->GetDoubleCanvasPointPix( prp2->m_lat, prp2->m_lon, &r2); // In the cases where one point is on, and one off // we must decide which way to go in longitude double adder1 = 0, adder2 = 0; if(!(lon1l || lon1r) && (lon2l || lon2r) ) { // first point is on screen, second not if( r2.m_x < r1.m_x ) adder2 = pix_full_circle; else adder2 = -pix_full_circle; if( fabs(r1.m_x - r2.m_x) < fabs(r1.m_x - ( r2.m_x + adder2 )) ) adder2 = 0; } else if(lon1l || lon1r) { // first point is off screen if( r1.m_x < r2.m_x ) adder1 = pix_full_circle; else adder1 = -pix_full_circle; if( fabs(r1.m_x - r2.m_x) < fabs(r2.m_x - (r1.m_x + adder1)) ) adder1 = 0; } if( dc ) dc->DrawLine(r1.m_x + adder1, r1.m_y, r2.m_x + adder2, r2.m_y); else { glVertex2f(r1.m_x + adder1, r1.m_y); glVertex2f(r2.m_x + adder2, r2.m_y); // cache screen position for arrows and points if(!r1valid) { prp1->m_pos_on_screen = !lat1l && !lat1r && !lon1l && !lon1r; prp1->m_screen_pos = r1; } prp2->m_pos_on_screen = !lat2l && !lat2r && !lon2l && !lon2r; prp2->m_screen_pos = r2; } r1 = r2; r1valid = true; } } if( !dc ) glEnd(); #endif }
/*! \fn void DataManager::displayPyramids(int winW, int winH, Kernel *kernel, Kernel *red, Kernel *blue) \brief Display the Pyramid Data Structure on the GPU. \param winW, winH : Window dimensions. \param kernel,red,blue : Use these fragment programs to display the texture memory */ void DataManager::displayPyramids(int winW, int winH, Kernel *kernel, Kernel *red, Kernel *blue) { int block_w = (_image_w + 2 * _boundary); int block_h = (_image_h + 2 * _boundary); int tex_w = block_w * 3; int tex_h = block_h * 2; int wtop, wbot, wleft, wright; int framePos[2][2]; framePos[0][0] = 0; framePos[0][1] = -tex_h; framePos[1][0] = 0; framePos[1][1] = 0; int auxix, auxiy, currx, curry, currb, currw, currh, factor; kernel->activate(); kernel->setRange(tex_w,tex_h*2); // Set up records for two successive frames. for (int i=0;i<_nFrames;i++) { currx = framePos[i][0]; curry = framePos[i][1]; auxix = tex_w - block_w; auxiy = curry; for (int j=0; j<_nLevels ; j++) { factor = pow(2.0,j); currb = _boundary / factor ; currw = _image_w / factor; currh = _image_h / factor; wtop = tex_h - (curry + currb); wleft = currx + currb; wbot = wtop - currh; wright= wleft + currw; kernel->bindInput( getPyramidBlock( i, j, _MAIN_BUF)->_texID ); if (_arch == GPU_ATI) kernel->execute(wtop, wleft, wbot, wright,0.0,0.0,1.0, 1.0); else if (_arch == GPU_NVIDIA) kernel->execute(wtop, wleft, wbot, wright, 0.0, 0.0, currh, currw); wtop = tex_h - (auxiy + currb); wleft = auxix + currb; wbot = wtop - currh; wright= wleft + currw; kernel->bindInput( getPyramidBlock( i, j, _AUXI_BUF)->_texID ); if (_arch == GPU_ATI) kernel->execute(wtop, wleft, wbot, wright,0.0,0.0,1.0, 1.0); else if (_arch == GPU_NVIDIA) kernel->execute(wtop, wleft, wbot, wright, 0.0, 0.0, currh, currw); currx+= (currw + 2*currb/2); auxix-= (currw/2 + 2*currb/2); auxiy+= (currh/2 + 2*currb/2); } } kernel->deactivate(); red->activate(); glDisable(_texTarget); glLineWidth(1.0); glBegin(GL_LINE_LOOP); glVertex2f(-0.998,0.998); glVertex2f(0.998,0.998); glVertex2f(0.998,0.002); glVertex2f(-0.998,0.002); glEnd(); char framestring[16]; sprintf(framestring,"Frame 0"); DrawText (10, 10 + winH - 0.5*winH , framestring, 1, 1, 1); red->deactivate(); blue->activate(); glLineWidth(1.0); glBegin(GL_LINE_LOOP); glVertex2f(-0.998,-0.002); glVertex2f(0.998,-0.002); glVertex2f(0.998,-0.998); glVertex2f(-0.998,-0.998); glEnd(); sprintf(framestring,"Frame 1"); DrawText (10, 10 , framestring, 1, 1, 1); blue->deactivate(); }
void GUIAttrEdit::render() { GUIPanel::render(); float lineH = getLineH(); int scroll = getAttrI( "scroll" ); glDisable( GL_BLEND ); float y = myH - lineH; for( int extra=scroll; extra<0; extra++ ) { y -= lineH; if( y < 0 ) break; } int textColor = getAttrI( "textColor" ); int selectedTextColor = getAttrI( "selectedTextColor" ); int highlightedTextColor = getAttrI( "highlightedTextColor" ); ZHashTable *hash = (ZHashTable *)attributeTable->getp( "hashPtr" ); if( !hash ) return; for( int i=0; i<view.count; i++ ) { int highlighted = (i == mouseOver && mouseWasInside); if( i == selected ) { setColorI( selectedTextColor ); } else if( highlighted ) { setColorI( highlightedTextColor ); } else { setColorI( textColor ); } if( i >= scroll ) { char buf[1024]; char *val = hash->getS( view[i] ); sprintf( buf, "%s = %s", view[i], val ); print( buf, 12, y ); y -= lineH; } if( y <= 0 ) { break; } } if( !optMenuUp && selected != -1 ) { glDisable( GL_LINE_SMOOTH ); glLineWidth( 1.f ); glColor3ub( 0xff, 0, 0 ); glBegin( GL_LINES ); glVertex2f( selectX, selectY ); glVertex2f( selectX, mouseY ); float sign = mouseY > selectY ? -1.f : 1.f; glVertex2f( selectX, mouseY ); glVertex2f( selectX-5, mouseY + sign*5 ); glVertex2f( selectX, mouseY ); glVertex2f( selectX+5, mouseY + sign*5 ); glEnd(); } }
void Sample_17::draw() { /* Clear The Screen And The Depth Buffer */ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glLoadIdentity( ); /* Select Our Second Texture */ glBindTexture( GL_TEXTURE_2D, m_texture[1] ); /* Move Into The Screen 5 Units */ glTranslatef( 0.0f, 0.0f, -5.0f ); /* Rotate On The Z Axis 45 Degrees (Clockwise) */ glRotatef( 45.0f, 0.0f, 0.0f, 1.0f ); /* Rotate On The X & Y Axis By cnt1 (Left To Right) */ glRotatef( m_cnt1 * 30.0f, 1.0f, 1.0f, 0.0f ); /* Disable Blending Before We Draw In 3D */ glDisable( GL_BLEND ); glColor3f( 1.0f, 1.0f, 1.0f ); /* Bright White */ glBegin( GL_QUADS ); /* Draw Our First Texture Mapped Quad */ glTexCoord2d( 0.0f, 0.0f ); /* First Texture Coord */ glVertex2f( -1.0f, 1.0f ); /* First Vertex */ glTexCoord2d( 1.0f, 0.0f ); /* Second Texture Coord */ glVertex2f( 1.0f, 1.0f ); /* Second Vertex */ glTexCoord2d( 1.0f, 1.0f ); /* Third Texture Coord */ glVertex2f( 1.0f, -1.0f ); /* Third Vertex */ glTexCoord2d( 0.0f, 1.0f ); /* Fourth Texture Coord */ glVertex2f( -1.0f, -1.0f ); /* Fourth Vertex */ glEnd( ); /* Rotate On The X & Y Axis By 90 Degrees (Left To Right) */ glRotatef( 90.0f, 1.0f, 1.0f, 0.0f ); glBegin( GL_QUADS ); /* Draw Our Second Texture Mapped Quad */ glTexCoord2d( 0.0f, 0.0f ); /* First Texture Coord */ glVertex2f( -1.0f, 1.0f ); /* First Vertex */ glTexCoord2d( 1.0f, 0.0f ); /* Second Texture Coord */ glVertex2f( 1.0f, 1.0f ); /* Second Vertex */ glTexCoord2d( 1.0f, 1.0f ); /* Third Texture Coord */ glVertex2f( 1.0f, -1.0f ); /* Third Vertex */ glTexCoord2d( 0.0f, 1.0f ); /* Fourth Texture Coord */ glVertex2f( -1.0f, -1.0f ); /* Fourth Vertex */ glEnd( ); /* Re-enable Blending */ glEnable( GL_BLEND ); /* Reset the view */ glLoadIdentity( ); /* Pulsing Colors Based On Text Position */ /* Print GL Text To The Screen */ glColor3f( 1.0f * ( float )cos( m_cnt1 ), 1.0f * ( float )sin( m_cnt2 ), 1.0f - 0.5f * ( float )cos( m_cnt1 + m_cnt2 ) ); glPrint( ( int )( 280 + 250 * cos( m_cnt1 ) ), ( int )( 235 + 200 * sin( m_cnt2 ) ), (char*)&"NeHe", 0 ); glColor3f( 1.0f * ( float )sin( m_cnt2 ), 1.0f - 0.5f * ( float )cos( m_cnt1 + m_cnt2 ), 1.0f * ( float )cos( m_cnt1 ) ); glPrint( ( int )( 280 + 230 * cos( m_cnt2 ) ), ( int )( 235 + 200 * sin( m_cnt1 ) ), (char*)&"OpenGL", 1 ); /* Set Color to Red */ glColor3f( 0.0f, 0.0f, 1.0f ); /* Draw Text To The Screen */ glPrint( ( int )( 240 + 200 * cos( ( m_cnt2 + m_cnt1 ) / 5 ) ), 2, (char*)&"Giuseppe D'Agata", 0 ); /* Set Color To White */ glColor3f( 1.0f, 1.0f, 1.0f ); /* Draw Offset Text To The Screen */ glPrint( ( int )( 242 + 200 * cos( ( m_cnt2 + m_cnt1 ) / 5 ) ), 2, (char*)&"Giuseppe D'Agata", 0 ); m_cnt1 += 0.01f; /* Increase The First Counter */ m_cnt2 += 0.0081f; /* Increase The Second Counter */ }
void Gource::draw(float t, float dt) { display.mode2D(); drawBackground(dt); if(draw_loading) { loadingScreen(); draw_loading = false; return; } Frustum frustum(camera); trace_time = SDL_GetTicks(); mousetrace(frustum,dt); trace_time = SDL_GetTicks() - trace_time; glMatrixMode(GL_PROJECTION); glLoadIdentity(); camera.focus(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //draw tree drawTree(frustum, dt); glColor4f(1.0, 1.0, 0.0, 1.0); for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) { trace_debug ? it->second->drawSimple(dt) : it->second->draw(dt); } glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); //draw bloom drawBloom(frustum, dt); root->drawNames(font,frustum); if(!(gGourceSettings.hide_usernames || gGourceSettings.hide_users)) { for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) { it->second->drawName(); } } //draw selected item names again so they are over the top if(selectedUser !=0) selectedUser->drawName(); if(selectedFile !=0) { vec2f dirpos = selectedFile->getDir()->getPos(); glPushMatrix(); glTranslatef(dirpos.x, dirpos.y, 0.0); selectedFile->drawName(); glPopMatrix(); } if(debug) { glDisable(GL_TEXTURE_2D); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); track_users ? user_bounds.draw() : dir_bounds.draw(); } if(gGourceQuadTreeDebug) { glDisable(GL_TEXTURE_2D); glColor4f(0.0f, 1.0f, 0.0f, 1.0f); glLineWidth(1.0); dirNodeTree->outline(); glColor4f(0.0f, 1.0f, 1.0f, 1.0f); userTree->outline(); } glColor4f(1.0f, 1.0f, 1.0f, 1.0f); display.mode2D(); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); vec3f campos = camera.getPos(); if(logotex!=0) { glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); glColor4f(1.0, 1.0, 1.0, 1.0); glBindTexture(GL_TEXTURE_2D, logotex->textureid); vec2f logopos = vec2f(display.width, display.height) - vec2f(logotex->w, logotex->h) - gGourceSettings.logo_offset; glPushMatrix(); glTranslatef(logopos.x, logopos.y, 0.0); glBegin(GL_QUADS); glTexCoord2f(0.0f,0.0f); glVertex2i(0, 0); glTexCoord2f(1.0f,0.0f); glVertex2i(logotex->w, 0); glTexCoord2f(1.0f,1.0f); glVertex2i(logotex->w, logotex->h); glTexCoord2f(0.0f,1.0f); glVertex2i(0, logotex->h); glEnd(); glPopMatrix(); } if(splash>0.0f) { int logowidth = fontlarge.getWidth("Gource"); int logoheight = 100; int cwidth = font.getWidth("Software Version Control Visualization"); int awidth = font.getWidth("(C) 2009 Andrew Caudwell"); vec2f corner(display.width/2 - logowidth/2 - 30.0f, display.height/2 - 40); glDisable(GL_TEXTURE_2D); glColor4f(0.0f, 0.5f, 1.0f, splash * 0.015f); glBegin(GL_QUADS); glVertex2f(0.0f, corner.y); glVertex2f(0.0f, corner.y + logoheight); glVertex2f(display.width, corner.y + logoheight); glVertex2f(display.width, corner.y); glEnd(); glEnable(GL_TEXTURE_2D); glColor4f(1.0,1.0,1.0,1.0); fontlarge.draw(display.width/2 - logowidth/2,display.height/2 - 30, "Gource"); font.draw(display.width/2 - cwidth/2,display.height/2 + 10, "Software Version Control Visualization"); font.draw(display.width/2 - awidth/2,display.height/2 + 30, "(C) 2009 Andrew Caudwell"); } // text using the specified font goes here glColor4f(gGourceSettings.font_colour.x, gGourceSettings.font_colour.y, gGourceSettings.font_colour.z, 1.0f); if(!gGourceSettings.hide_date) { fontmedium.draw(display.width/2 - date_x_offset, 20, displaydate); } if(gGourceSettings.title.size()>0) { fontmedium.alignTop(false); fontmedium.draw(10, display.height - 10, gGourceSettings.title); fontmedium.alignTop(true); } if(message_timer>0.0f) { fontmedium.draw(1, 3, message); } // end text glColor4f(1.0f, 1.0f, 1.0f, 1.0f); if(debug) { font.print(1,20, "FPS: %.2f", fps); font.print(1,40,"Days Per Second: %.2f", gGourceSettings.days_per_second); font.print(1,60,"Time Scale: %.2f", time_scale); font.print(1,80,"Users: %d", users.size()); font.print(1,100,"Files: %d", files.size()); font.print(1,120,"Dirs: %d", gGourceDirMap.size()); font.print(1,140,"Log Position: %.4f", commitlog->getPercent()); font.print(1,160,"Camera: (%.2f, %.2f, %.2f)", campos.x, campos.y, campos.z); font.print(1,180,"Gravity: %.2f", gGourceForceGravity); font.print(1,200,"Update Tree: %u ms", update_dir_tree_time); font.print(1,220,"Draw Tree: %u ms", draw_tree_time); font.print(1,240,"Mouse Trace: %u ms", trace_time); font.print(1,260,"Logic Time: %u ms", logic_time); font.print(1,280,"Draw Time: %u ms", SDL_GetTicks() - draw_time); font.print(1,300,"File Inner Loops: %d", gGourceFileInnerLoops); font.print(1,320,"User Inner Loops: %d", gGourceUserInnerLoops); font.print(1,340,"Dir Inner Loops: %d (QTree items = %d, nodes = %d)", gGourceDirNodeInnerLoops, dirNodeTree->item_count, dirNodeTree->node_count); if(selectedUser != 0) { } if(selectedFile != 0) { font.print(1,360,"%s: %d files (%d visible)", selectedFile->getDir()->getPath().c_str(), selectedFile->getDir()->fileCount(), selectedFile->getDir()->visibleFileCount()); } } glDisable(GL_TEXTURE_2D); if(canSeek()) slider.draw(dt); mousemoved=false; mouseclicked=false; }
static void RenderTexture(void) { GLenum status; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0, 0.0, -15.0); /* draw to texture image */ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { printf("Framebuffer incomplete!!!\n"); } glViewport(0, 0, TexWidth, TexHeight); glClearColor(0.5, 0.5, 1.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); CheckError(__LINE__); #if DEPTH glEnable(GL_DEPTH_TEST); #endif #if STENCIL glEnable(GL_STENCIL_TEST); glStencilFunc(GL_NEVER, 1, ~0); glStencilOp(GL_REPLACE, GL_KEEP, GL_REPLACE); #endif CheckError(__LINE__); #if DEPTH || STENCIL /* draw diamond-shaped stencil pattern */ glColor3f(0, 1, 0); glBegin(GL_POLYGON); glVertex2f(-0.2, 0.0); glVertex2f( 0.0, -0.2); glVertex2f( 0.2, 0.0); glVertex2f( 0.0, 0.2); glEnd(); #endif /* draw teapot where stencil != 1 */ #if STENCIL glStencilFunc(GL_NOTEQUAL, 1, ~0); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); #endif CheckError(__LINE__); #if 0 glBegin(GL_POLYGON); glColor3f(1, 0, 0); glVertex2f(-1, -1); glColor3f(0, 1, 0); glVertex2f(1, -1); glColor3f(0, 0, 1); glVertex2f(0, 1); glEnd(); #else glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glPushMatrix(); glRotatef(0.5 * Rot, 1.0, 0.0, 0.0); glutSolidTeapot(0.5); glPopMatrix(); glDisable(GL_LIGHTING); /* PrintStencilHistogram(TexWidth, TexHeight); */ #endif glDisable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST); #if DRAW /* Bind normal framebuffer */ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); #endif CheckError(__LINE__); }
static __inline__ void draw_map(window_info *win,float zoom_multip, float px, float py) { float sx = 0.0f, sy = 0.0f; int i; float x, y; glPushMatrix(); sx = float_minimap_size/2; sy = float_minimap_size/2; glTranslatef(sx, sy, 0.0f); glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); glEnable(GL_STENCIL_TEST); glStencilFunc(GL_ALWAYS, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glDepthMask(GL_FALSE); glColor3f(0.0f,0.0f,0.0f); glBegin(GL_POLYGON); for (i=0; i<=360; i +=10) { x = sin((i)*0.0174532925f)/2*float_minimap_size; y = cos((i)*0.0174532925f)/2*float_minimap_size; glVertex2f(x, y); } glEnd(); glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // re-enable the drawing in the current buffer glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthMask(GL_TRUE); glEnable(GL_TEXTURE_2D); //draw the map #ifdef NEW_TEXTURES bind_texture(minimap_texture); #else /* NEW_TEXTURES */ bind_texture_id(minimap_texture); #endif /* NEW_TEXTURES */ glColor4f(1.0f,1.0f,1.0f,1.0f); rotate_at_player(zoom_multip,px,py); glBegin(GL_QUADS); #ifdef NEW_TEXTURES glTexCoord2f(0.0f, 1.0f); glVertex2f(-float_minimap_size/2, float_minimap_size/2); glTexCoord2f(1.0f, 1.0f); glVertex2f(float_minimap_size/2, float_minimap_size/2); glTexCoord2f(1.0f, 0.0f); glVertex2f(float_minimap_size/2, -float_minimap_size/2); glTexCoord2f(0.0f, 0.0f); glVertex2f(-float_minimap_size/2, -float_minimap_size/2); #else /* NEW_TEXTURES */ glTexCoord2f(0.0f, 0.0f); glVertex2f(-float_minimap_size/2, float_minimap_size/2); glTexCoord2f(1.0f, 0.0f); glVertex2f(float_minimap_size/2, float_minimap_size/2); glTexCoord2f(1.0f, 1.0f); glVertex2f(float_minimap_size/2, -float_minimap_size/2); glTexCoord2f(0.0f, 1.0f); glVertex2f(-float_minimap_size/2, -float_minimap_size/2); #endif /* NEW_TEXTURES */ glEnd(); glDisable(GL_STENCIL_TEST); glPopMatrix(); if (compass_tex) { //draw the compass texture draw_compass(); } }
void display(void) { int i; int j; while(nummines < 20) { minerow = rand() % 20; minecol = rand() % 20; if(mines[minerow][minecol] == 0) { mines[minerow][minecol] = 1; nummines++; } } glClear(GL_COLOR_BUFFER_BIT); for(i = 0; i < 20; i++) { for(j = 0; j < 20; j++) { if(flags[i][j] == 1) { if(mines[i][j] == 1) { glColor3f(1.0, 0.0, 0.0); } else { glColor3f(0.5, 0.8, 0.2); } } else { glColor3f(0.1, 0.1, 0.1); } glTranslatef((float)j * .1, (float)i * .1, 0.0); glBegin(GL_POLYGON); glVertex2f(-1.0, -1.0); glVertex2f(-1.0, -0.9); glVertex2f(-0.9, -0.9); glVertex2f(-0.9, -1.0); glEnd(); glColor3f(0.5, 0.5, 0.5); glBegin(GL_LINE_LOOP); glVertex2f(-1.0, -1.0); glVertex2f(-1.0, -0.9); glVertex2f(-0.9, -0.9); glVertex2f(-0.9, -1.0); glEnd(); glLoadIdentity(); glFlush(); } } }
int display_minimap_handler(window_info *win) { float zoom_multip; float size_x = float_minimap_size / (tile_map_size_x * 6); float size_y = float_minimap_size / (tile_map_size_y * 6); float px = 0.0f, py = 0.0f; actor *me; float x,y; int i; if(win->pos_x > window_width - 50) move_window(minimap_win,win->pos_id,win->pos_loc,window_width-minimap_size,win->pos_y); if(win->pos_y > window_height - 50) move_window(minimap_win,win->pos_id,win->pos_loc,win->pos_x,window_height-minimap_size); if (enable_controls) { draw_minimap_title_bar(win); enable_controls = 0; } zoom_multip = minimap_get_zoom(); if(!minimap_texture) { //there's no minimap for this map :( draw a X glTranslatef(0.0f, 16.0f, 0.0f); glPushMatrix(); glDisable(GL_TEXTURE_2D); //draw black background glColor3f(0.0f,0.0f,0.0f); glBegin(GL_POLYGON); for (i=0; i<=360; i +=10) { x = sin((i)*0.0174532925f)/2*float_minimap_size+float_minimap_size/2; y = cos((i)*0.0174532925f)/2*float_minimap_size+float_minimap_size/2; glVertex2f(x, y); } glEnd(); glPopMatrix(); draw_compass(); return 0; } //draw minimap //get player position in window coordinates if( (me = get_our_actor ()) == NULL) { //Don't know who we are? can't draw then return 0; } px = me->x_tile_pos * size_x; py = float_minimap_size - (me->y_tile_pos * size_y); glTranslatef(0.0f, 16.0f, 0.0f); glDisable(GL_TEXTURE_2D); //draw black background glColor3f(0.0f,0.0f,0.0f); glBegin(GL_POLYGON); for (i=0; i<=360; i +=10) { x = sin((i)*0.0174532925f)/2*float_minimap_size+float_minimap_size/2; y = cos((i)*0.0174532925f)/2*float_minimap_size+float_minimap_size/2; glVertex2f(x, y); } glEnd(); draw_map(win,zoom_multip, px, py); draw_actor_points(zoom_multip, px, py); #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE return 0; }
void RenderObject::renderCall() { //RenderObjectLayer *rlayer = core->getRenderObjectLayer(getTopLayer()); if (positionSnapTo) this->position = *positionSnapTo; position += offset; #ifdef BBGE_BUILD_DIRECTX if (!RENDEROBJECT_FASTTRANSFORM) core->getD3DMatrixStack()->Push(); #endif #ifdef BBGE_BUILD_OPENGL if (!RENDEROBJECT_FASTTRANSFORM) glPushMatrix(); if (!RENDEROBJECT_SHAREATTRIBUTES) { glPushAttrib(GL_ALL_ATTRIB_BITS); } #endif if (!RENDEROBJECT_FASTTRANSFORM) { if (layer != LR_NONE) { RenderObjectLayer *l = &core->renderObjectLayers[layer]; if (l->followCamera != NO_FOLLOW_CAMERA) { followCamera = l->followCamera; } } if (followCamera!=0 && !parent) { if (followCamera == 1) { #ifdef BBGE_BUILD_OPENGL glLoadIdentity(); glScalef(core->globalResolutionScale.x, core->globalResolutionScale.y,0); glTranslatef(position.x, position.y, position.z); if (isfh()) { //glDisable(GL_CULL_FACE); glRotatef(180, 0, 1, 0); } glRotatef(rotation.z+rotationOffset.z, 0, 0, 1); #endif #ifdef BBGE_BUILD_DIRECTX core->getD3DMatrixStack()->LoadIdentity(); core->scaleMatrixStack(core->globalResolutionScale.x, core->globalResolutionScale.y,0); core->translateMatrixStack(position.x, position.y, 0); if (isfh()) { //HACK: disable cull -> core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180)); } core->rotateMatrixStack(rotation.z + rotationOffset.z); #endif } else { Vector pos = getFollowCameraPosition(); #ifdef BBGE_BUILD_OPENGL glTranslatef(pos.x, pos.y, pos.z); if (isfh()) { //glDisable(GL_CULL_FACE); glRotatef(180, 0, 1, 0); } glRotatef(rotation.z+rotationOffset.z, 0, 0, 1); #endif #ifdef BBGE_BUILD_DIRECTX core->translateMatrixStack(pos.x, pos.y, 0); if (isfh()) { //HACK: disable cull -> core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180)); } core->rotateMatrixStack(rotation.z + rotationOffset.z); #endif } } else { #ifdef BBGE_BUILD_OPENGL glTranslatef(position.x, position.y, position.z); #endif #ifdef BBGE_BUILD_DIRECTX core->translateMatrixStack(position.x, position.y, 0); #endif #ifdef BBGE_BUILD_OPENGL if (RenderObject::renderPaths && position.data && position.data->path.getNumPathNodes() > 0) { glLineWidth(4); glEnable(GL_BLEND); int i = 0; glColor4f(1.0f, 1.0f, 1.0f, 0.5f); glBindTexture(GL_TEXTURE_2D, 0); glBegin(GL_LINES); for (i = 0; i < position.data->path.getNumPathNodes()-1; i++) { glVertex2f(position.data->path.getPathNode(i)->value.x-position.x, position.data->path.getPathNode(i)->value.y-position.y); glVertex2f(position.data->path.getPathNode(i+1)->value.x-position.x, position.data->path.getPathNode(i+1)->value.y-position.y); } glEnd(); glPointSize(20); glBegin(GL_POINTS); glColor4f(0.5,0.5,1,1); for (i = 0; i < position.data->path.getNumPathNodes(); i++) { glVertex2f(position.data->path.getPathNode(i)->value.x-position.x, position.data->path.getPathNode(i)->value.y-position.y); } glEnd(); } #endif #ifdef BBGE_BUILD_OPENGL glRotatef(rotation.z+rotationOffset.z, 0, 0, 1); if (isfh()) { //glDisable(GL_CULL_FACE); glRotatef(180, 0, 1, 0); } #endif #ifdef BBGE_BUILD_DIRECTX //core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 0, 1), rotation.z+rotationOffset.z); core->rotateMatrixStack(rotation.z + rotationOffset.z); if (isfh()) { //HACK: disable cull core->getD3DDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); //core->getD3DMatrixStack()->Scale(-1, 1, 1); //core->applyMatrixStackToWorld(); core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180)); //core->applyMatrixStackToWorld(); } #endif } #ifdef BBGE_BUILD_OPENGL glTranslatef(beforeScaleOffset.x, beforeScaleOffset.y, beforeScaleOffset.z); glScalef(scale.x, scale.y, 1); glTranslatef(internalOffset.x, internalOffset.y, internalOffset.z); #endif #ifdef BBGE_BUILD_DIRECTX core->translateMatrixStack(beforeScaleOffset.x, beforeScaleOffset.y, 0); core->scaleMatrixStack(scale.x, scale.y, 1); core->translateMatrixStack(internalOffset.x, internalOffset.y, 0); core->applyMatrixStackToWorld(); #endif //glDisable(GL_CULL_FACE); /* Never set anywhere. --achurch if (renderOrigin) { #ifdef BBGE_BUILD_OPENGL glBegin(GL_TRIANGLES); glColor4f(1.0f, 0.0f, 0.0f, 1.0f); glVertex3f(0.0f, 5.0f, 0.0f); glVertex3f(50.0f, 0.0f, 0.0f); glVertex3f(0.0f, -5.0f, 0.0f); glColor4f(0.0f, 1.0f, 0.0f, 1.0f); glVertex3f(0.0f, 0.0f, 5.0f); glVertex3f(0.0f, 50.0f, 0.0f); glVertex3f(0.0f, 0.0f, -5.0f); glColor4f(0.0f, 0.0f, 1.0f, 1.0f); glVertex3f(5.0f, 0.0f, 0.0f); glVertex3f(0.0f, 0.0f, 50.0f); glVertex3f(-5.0f, 0.0f, 0.0f); glEnd(); #endif } */ } for (Children::iterator i = children.begin(); i != children.end(); i++) { if (!(*i)->isDead() && (*i)->renderBeforeParent) (*i)->render(); } //if (useColor) { #ifdef BBGE_BUILD_OPENGL if (rlayer) glColor4f(color.x * rlayer->color.x, color.y * rlayer->color.y, color.z * rlayer->color.z, alpha.x*alphaMod); else glColor4f(color.x, color.y, color.z, alpha.x*alphaMod); #elif defined(BBGE_BUILD_DIRECTX) core->setColor(color.x, color.y, color.z, alpha.x*alphaMod); #endif } if (texture) { #ifdef BBGE_BUILD_OPENGL if (texture->textures[0] != lastTextureApplied || repeatTexture != lastTextureRepeat) { texture->apply(repeatTexture); lastTextureRepeat = repeatTexture; lastTextureApplied = texture->textures[0]; } #endif #ifdef BBGE_BUILD_DIRECTX texture->apply(repeatTexture); #endif } else { if (lastTextureApplied != 0 || repeatTexture != lastTextureRepeat) { #ifdef BBGE_BUILD_OPENGL glBindTexture(GL_TEXTURE_2D, 0); #endif #ifdef BBGE_BUILD_DIRECTX core->bindTexture(0, 0); #endif lastTextureApplied = 0; lastTextureRepeat = repeatTexture; } } applyBlendType(); bool doRender = true; int pass = renderPass; if (core->currentLayerPass != RENDER_ALL && renderPass != RENDER_ALL) { RenderObject *top = getTopParent(); if (top) { if (top->overrideRenderPass != OVERRIDE_NONE) pass = top->overrideRenderPass; } doRender = (core->currentLayerPass == pass); } if (renderCollisionShape) renderCollision(); if (doRender) onRender(); //collisionShape.render(); if (!RENDEROBJECT_SHAREATTRIBUTES) { glPopAttrib(); } for (Children::iterator i = children.begin(); i != children.end(); i++) { if (!(*i)->isDead() && !(*i)->renderBeforeParent) (*i)->render(); } if (!RENDEROBJECT_FASTTRANSFORM) { #ifdef BBGE_BUILD_OPENGL glPopMatrix(); #endif #ifdef BBGE_BUILD_DIRECTX core->getD3DMatrixStack()->Pop(); core->applyMatrixStackToWorld(); #endif } position -= offset; }
void drawHouse(float angle) { glBegin(GL_QUADS); //первый этаж glColor3ub(240, 220, 130); glVertex2f(-13, 65); glVertex2f(-15, 95); glVertex2f(15, 95); glVertex2f(13, 65); glEnd(); if((angle>=0.0&&angle<=90.0)||(angle>=180.0&&angle<=270)) { glColor3ub(255, 255, 0); } else if(angle>=90.0&&angle<=180.0) { glColor3ub(255, 255, 255); } else { glColor3ub(0, 0, 0); } glBegin(GL_QUADS); //окно glVertex2f(-9, 75 ); glVertex2f(-10, 90); glVertex2f(10, 90); glVertex2f(10, 75); glEnd(); glBegin(GL_LINE_LOOP); //рама glColor3ub(150, 75, 0); glVertex2f(-9, 75 ); glVertex2f(-10, 90); glVertex2f(10, 90); glVertex2f(10, 75); glEnd(); drawLine(0, 75, 0, 90, 0, 0, 0); drawLine(0, 84, 10, 84, 0, 0, 0); glBegin(GL_TRIANGLES); //крыша glColor3ub(150, 75, 0); glVertex2f(-20, 95); glVertex2f(0, 118); glVertex2f(20, 95); glEnd(); }
// draw title void ShellTitle::Render(unsigned int aId, float aTime, const Transform2 &aTransform) { //#define USE_TITLE_VERTEX_ARRAY #ifdef USE_TITLE_VERTEX_ARRAY static Vector2 vertexarray[32768]; static unsigned int colorarray[32768]; Vector2 *vertexptr = vertexarray; unsigned int *colorptr = colorarray; #else glBegin(GL_QUADS); #endif // draw title bar for (int row = 0; row < SDL_arraysize(titlemap); ++row) { float y0 = titley + row * titleh, y1 = y0 + titleh; #ifdef USE_TITLE_VERTEX_ARRAY unsigned int color = (xs_RoundToInt(255*baralpha[row]) << 24) | 0x00505050; *colorptr++ = color; *colorptr++ = color; *colorptr++ = color; *colorptr++ = color; *vertexptr++ = Vector2(0, y0); *vertexptr++ = Vector2(640, y0); *vertexptr++ = Vector2(640, y1); *vertexptr++ = Vector2(0, y1); #else glColor4f(0.3f, 0.3f, 0.3f, baralpha[row]); glVertex2f(0, y0); glVertex2f(640, y0); glVertex2f(640, y1); glVertex2f(0, y1); #endif } // draw title body unsigned short *titlefillptr = titlefill; #if 1 #ifdef USE_TITLE_MIRROR_WATER_EFFECT // starting mirror properties float mirror_y0 = MirrorWaveY(titley - titleh); float mirror_d0 = MirrorWaveX(mirror_y0); float mirror_a0 = mirroralphastart + mirroralphadelta * mirror_y0; #endif for (int row = -1; row < (int)SDL_arraysize(titlemap) + 1; ++row) { float y = titley + row * titleh; #ifdef USE_TITLE_MIRROR_WATER_EFFECT // row mirror properties float mirror_y1 = MirrorWaveY(y + titleh); float mirror_yd = (mirror_y1 - mirror_y0) / titleh; float mirror_d1 = MirrorWaveX(mirror_y1); float mirror_dd = (mirror_d1 - mirror_d0) / titleh; float mirror_a1 = mirroralphastart + mirroralphadelta * mirror_y1; float mirror_ad = (mirror_a1 - mirror_a0) / titleh; #endif for (int col = -1; col < (int)SDL_arraysize(titlemap[0]); ++col) { float x = titlex + col * titlew; if (*titlefillptr != 0) { int phase = *titlefillptr >> 9; int fill = *titlefillptr & 0x1FF; // get block color float R, G, B; float h = BlockHue(col, row); bool border = (fill & ~(1<<4)) != 0; HSV2RGB(h + phase * 0.5f + border * 0.5f, 1.0f, 1.0f - 0.25f * border, R, G, B); // for each block... for (int i = 0; i < 9; ++i) { // if the block is filled if (fill & (1 << i)) { // block borders float x0 = x + block[i][0][0]; float x1 = x + block[i][0][1]; float y0 = y + block[i][1][0]; float y1 = y + block[i][1][1]; // upright #ifdef USE_TITLE_VERTEX_ARRAY unsigned int color = 0xFF000000 | (xs_RoundToInt(B * 255) << 16) | (xs_RoundToInt(G * 255) << 8) | (xs_RoundToInt(R * 255) ); *colorptr++ = color; *colorptr++ = color; *colorptr++ = color; *colorptr++ = color; *vertexptr++ = Vector2(x0, y0); *vertexptr++ = Vector2(x1, y0); *vertexptr++ = Vector2(x1, y1); *vertexptr++ = Vector2(x0, y1); #else glColor4f(R, G, B, 1.0f); glVertex2f(x0, y0); glVertex2f(x1, y0); glVertex2f(x1, y1); glVertex2f(x0, y1); #endif #ifdef USE_TITLE_MIRROR_WATER_EFFECT if (mirror_a0 > 0.0f || mirror_a1 > 0.0f) { // mirrored float m0 = y0 - y; float m1 = y1 - y; float a0 = std::max(mirror_a0 + mirror_ad * m0, 0.0f); float a1 = std::max(mirror_a0 + mirror_ad * m1, 0.0f); float dx0 = mirror_d0 + mirror_dd * m0; float dx1 = mirror_d0 + mirror_dd * m1; float yy0 = mirror_y0 + mirror_yd * m0; float yy1 = mirror_y0 + mirror_yd * m1; #ifdef USE_TITLE_VERTEX_ARRAY color &= 0x00FFFFFF; color |= xs_RoundToInt(a1 * a1 * 255) << 24; *colorptr++ = color; *colorptr++ = color; *vertexptr++ = Vector2(x0 + dx1, yy1); *vertexptr++ = Vector2(x1 + dx1, yy1); color &= 0x00FFFFFF; color |= xs_RoundToInt(a0 * a0 * 255) << 24; *colorptr++ = color; *colorptr++ = color; *vertexptr++ = Vector2(x1 + dx0, yy0); *vertexptr++ = Vector2(x0 + dx0, yy0); #else glColor4f(R, G, B, a1 * a1); glVertex2f(x0 + dx1, yy1); glVertex2f(x1 + dx1, yy1); glColor4f(R, G, B, a0 * a0); glVertex2f(x1 + dx0, yy0); glVertex2f(x0 + dx0, yy0); #endif } #endif } } } ++titlefillptr; } #ifdef USE_TITLE_MIRROR_WATER_EFFECT // mirror shift row mirror_y0 = mirror_y1; mirror_d0 = mirror_d1; mirror_a0 = mirror_a1; #endif }
void MenuUserInterface::render() { if(gClientGame->getConnectionToServer()) { gGameUserInterface.render(); glColor4f(0, 0, 0, 0.6); glEnable(GL_BLEND); glBegin(GL_POLYGON); glVertex2f(0, 0); glVertex2f(canvasWidth, 0); glVertex2f(canvasWidth, canvasHeight); glVertex2f(0, canvasHeight); glEnd(); glDisable(GL_BLEND); } glColor3f(1,1,1); drawCenteredString( vertMargin, 30, menuTitle); drawCenteredString( vertMargin + 35, 18, menuSubTitle); drawCenteredString( canvasHeight - vertMargin - 20, 18, menuFooter); if(selectionIndex >= menuItems.size()) selectionIndex = 0; S32 offset = 0; S32 count = menuItems.size(); if(count > 7) { count = 7; offset = selectionIndex - 3; if(offset < 0) offset = 0; else if(offset + count >= menuItems.size()) offset = menuItems.size() - count; } U32 yStart = (canvasHeight - count * 45) / 2; //glColor3f(0,1,0); for(S32 i = 0; i < count; i++) { U32 y = yStart + i * 45; if(selectionIndex == i + offset) { glColor3f(0,0,0.4); glBegin(GL_POLYGON); glVertex2f(0, y - 2); glVertex2f(800, y - 2); glVertex2f(800, y + 25 + 5); glVertex2f(0, y + 25 + 5); glEnd(); glColor3f(0,0,1); glBegin(GL_LINES); glVertex2f(0, y - 2); glVertex2f(799, y - 2); glVertex2f(799, y + 25 + 5); glVertex2f(0, y + 25 + 5); glEnd(); } glColor3f(1,1,1); drawCenteredString(y, 25, menuItems[i+offset].mText); } }
void Marker::update(bool force) { GLubyte g; bool markerflag = m_MarkerBufferControl.update(); if( markerflag || force ) { double value = m_Value.getPrimaryBuffer(); const GraphState & state = m_Destination->getGraphState(); const QRect & datarect = m_Destination->getDataPos(); const MarkerDirection & type = m_Type.getPrimaryBuffer(); // Remove Marker if out of range if( (type == Marker::M_V && (value <= state.xLow || value >= state.xHigh)) || (type == Marker::M_H && (value <= state.yLow || value >= state.yHigh))) { glNewList( m_ListBase, GL_COMPILE ); glEndList(); return; } // Scale correctly double xRatio = datarect.width()/(double)(state.xHigh-state.xLow); double yRatio = datarect.height()/(double)(state.yHigh-state.yLow); double xOffset = -state.xLow; double yOffset = -state.yLow; glNewList( m_ListBase, GL_COMPILE ); { glPushAttrib( GL_LINE_BIT ); { if( m_LinePatternFactor > 0 ) { glEnable( GL_LINE_STIPPLE ); glLineStipple( m_LinePatternFactor, m_LinePattern ); } g = m_GrayLevel.getPrimaryBuffer(); glColor3ub( g, g, g ); glLineWidth( m_LineWidth ); glBegin( GL_LINES ); { switch(type) { case Marker::M_V: glVertex2f( (value+xOffset)*xRatio, (state.yLow+yOffset)*yRatio ); glVertex2f( (value+xOffset)*xRatio, (state.yHigh+yOffset)*yRatio ); break; case Marker::M_H: glVertex2f( (state.xLow+xOffset)*xRatio, (value+yOffset)*yRatio ); glVertex2f( (state.xHigh+xOffset)*xRatio, (value+yOffset)*yRatio ); break; } } glEnd(); } glPopAttrib(); } glEndList(); } }