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 DrawBloomTex(int winW,int winH) { glBindTexture(GL_TEXTURE_2D, bloomTexId2); glDisable(GL_BLEND); 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(-winW/2,winW/2,-winH/2,winH/2,-1,1); // Set Up An Ortho Screen glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glPushMatrix(); // Store The Modelview Matrix glLoadIdentity(); DrawBloomMap(winW,winH); glBegin(GL_QUADS); glTexCoord2f(0.0f,0.0f);glVertex2i(-DrawbloomTexSize/2,-DrawbloomTexSize/2); glTexCoord2f(1.0f,0.0f);glVertex2i( DrawbloomTexSize/2,-DrawbloomTexSize/2); glTexCoord2f(1.0f,1.0f);glVertex2i( DrawbloomTexSize/2, DrawbloomTexSize/2); glTexCoord2f(0.0f,1.0f);glVertex2i(-DrawbloomTexSize/2, DrawbloomTexSize/2); glEnd(); CGDisableProfilePixel(); glBindTexture(GL_TEXTURE_2D, bloomTexId1); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, -(DrawbloomTexSize-winW)/2, -(DrawbloomTexSize-winH)/2, DrawbloomTexSize, DrawbloomTexSize, 0); //glClear (GL_COLOR_BUFFER_BIT ); DrawBloomW(winW); glBegin(GL_QUADS); glTexCoord2f(0.0f,0.0f);glVertex2i(-DrawbloomTexSize/2,-DrawbloomTexSize/2); glTexCoord2f(1.0f,0.0f);glVertex2i( DrawbloomTexSize/2,-DrawbloomTexSize/2); glTexCoord2f(1.0f,1.0f);glVertex2i( DrawbloomTexSize/2, DrawbloomTexSize/2); glTexCoord2f(0.0f,1.0f);glVertex2i(-DrawbloomTexSize/2, DrawbloomTexSize/2); glEnd(); CGDisableProfilePixel(); glBindTexture(GL_TEXTURE_2D, bloomTexId1); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, -(DrawbloomTexSize-winW)/2, -(DrawbloomTexSize-winH)/2, DrawbloomTexSize, DrawbloomTexSize, 0); //glClear (GL_COLOR_BUFFER_BIT ); DrawBloomH(winH); glBegin(GL_QUADS); glTexCoord2f(0.0f,0.0f);glVertex2i(-DrawbloomTexSize/2,-DrawbloomTexSize/2); glTexCoord2f(1.0f,0.0f);glVertex2i( DrawbloomTexSize/2,-DrawbloomTexSize/2); glTexCoord2f(1.0f,1.0f);glVertex2i( DrawbloomTexSize/2, DrawbloomTexSize/2); glTexCoord2f(0.0f,1.0f);glVertex2i(-DrawbloomTexSize/2, DrawbloomTexSize/2); glEnd(); CGDisableProfilePixel(); glBindTexture(GL_TEXTURE_2D, bloomTexId1); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, -(DrawbloomTexSize-winW)/2, -(DrawbloomTexSize-winH)/2, DrawbloomTexSize, DrawbloomTexSize, 0); //glClear (GL_COLOR_BUFFER_BIT ); 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 glEnable(GL_BLEND); }
void Blur_apply(){ if(multiSamples!=1 && blur==Blur_glsl_depth){ consoleLog("Blur_apply: Blur_glsl_depth can't be used with multisample, disabling\n"); blur=Blur_glsl_simple; } if(blur==Blur_none) return; float lastMatrix[16]; glGetFloatv(GL_MODELVIEW_MATRIX, lastMatrix); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glScalef(2.f/screen->w, -2.f/screen->h, 1.f); glTranslatef(-screen->w*.5f, -screen->h*.5f, 0.f); glDisable(GL_DEPTH_TEST); glDisable(GL_FOG); glDisable(GL_LIGHTING); glDepthMask(GL_FALSE); if(blur==Blur_basic){ glColor4f(1.f, 1.f, 1.f, powf(.3f, blurdt*60.f)); glBindTexture(GL_TEXTURE_2D, tex_screen); glBegin(GL_QUADS); glTexCoord2f(0.f, (float)screen->h/sh); glVertex2i(0, 0); glTexCoord2f(0.f, 0.f); glVertex2i(0, screen->h); glTexCoord2f((float)screen->w/sw, 0.f); glVertex2i(screen->w, screen->h); glTexCoord2f((float)screen->w/sw, (float)screen->h/sh); glVertex2i(screen->w, 0); glEnd(); totalPolys+=2; glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, screen->w, screen->h); } #if GL_ARB_shader_objects else if(blur==Blur_glsl_simple){ glUseProgramObjectARB(prg_blurSimple); glUniform1iARB(glGetUniformLocationARB(prg_blurSimple, "screen"), 0); glUniform2fARB(glGetUniformLocationARB(prg_blurSimple, "texSize"), (float)screen->w/sw, (float)screen->h/sh); float imat[16]; float mat2[16]; memcpy(imat, mx_old, sizeof(imat)); inverseMatrix4(imat); glUniformMatrix4fvARB(glGetUniformLocationARB(prg_blurSimple, "curMatrix"), 1, GL_FALSE, lastMatrix); glUniformMatrix4fvARB(glGetUniformLocationARB(prg_blurSimple, "oldMatrix"), 1, GL_FALSE, mx_old); inverseMatrix4(lastMatrix); glUniformMatrix4fvARB(glGetUniformLocationARB(prg_blurSimple, "oldMatrixInverse"), 1, GL_FALSE, imat); glUniformMatrix4fvARB(glGetUniformLocationARB(prg_blurSimple, "curMatrixInverse"), 1, GL_FALSE, lastMatrix); glColor4f(1,1,1,1); glBindTexture(GL_TEXTURE_2D, tex_screen); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, screen->w, screen->h); glBegin(GL_QUADS); glTexCoord2f(-1.f, 1.f); glVertex2i(0, 0); glTexCoord2f(-1.f, -1.f); glVertex2i(0, screen->h); glTexCoord2f(1.f, -1.f); glVertex2i(screen->w, screen->h); glTexCoord2f(1.f, 1.f); glVertex2i(screen->w, 0); glEnd(); totalPolys+=2; glUseProgramObjectARB(0); } #if GL_ARB_depth_texture else if(blur==Blur_glsl_depth){ glActiveTexture(GL_TEXTURE1_ARB); glBindTexture(GL_TEXTURE_2D, tex_depth); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, screen->w, screen->h); glActiveTexture(GL_TEXTURE0_ARB); glUseProgramObjectARB(prg_blurDepth); glUniform1iARB(glGetUniformLocationARB(prg_blurDepth, "screen"), 0); glUniform1iARB(glGetUniformLocationARB(prg_blurDepth, "depthTex"), 1); glUniform2fARB(glGetUniformLocationARB(prg_blurDepth, "texSize"), (float)screen->w/sw, (float)screen->h/sh); float imat[16]; float mat2[16]; memcpy(imat, mx_old, sizeof(imat)); inverseMatrix4(imat); glUniformMatrix4fvARB(glGetUniformLocationARB(prg_blurDepth, "curMatrix"), 1, GL_FALSE, lastMatrix); glUniformMatrix4fvARB(glGetUniformLocationARB(prg_blurDepth, "oldMatrix"), 1, GL_FALSE, mx_old); inverseMatrix4(lastMatrix); glUniformMatrix4fvARB(glGetUniformLocationARB(prg_blurDepth, "oldMatrixInverse"), 1, GL_FALSE, imat); glUniformMatrix4fvARB(glGetUniformLocationARB(prg_blurDepth, "curMatrixInverse"), 1, GL_FALSE, lastMatrix); glColor4f(1,1,1,1); glBindTexture(GL_TEXTURE_2D, tex_screen); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, screen->w, screen->h); glBegin(GL_QUADS); glTexCoord2f(-1.f, 1.f); glVertex2i(0, 0); glTexCoord2f(-1.f, -1.f); glVertex2i(0, screen->h); glTexCoord2f(1.f, -1.f); glVertex2i(screen->w, screen->h); glTexCoord2f(1.f, 1.f); glVertex2i(screen->w, 0); glEnd(); totalPolys+=2; glUseProgramObjectARB(0); } #endif #endif glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_LIGHTING); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glEnable(GL_DEPTH_TEST); glEnable(GL_FOG); glDepthMask(GL_TRUE); }
static void hw_draw_extra_shape(struct TileWindow *win, struct ExtraShape *shape) { int sx, sy, sw, sh; int size; sw = win->scale_w; sh = win->scale_h; sx = win->scr_x - win->pan_x + shape->x * sw + shape->y * win->scale_skew; sy = win->scr_y - win->pan_y + shape->y * sh; /* trivial clipping */ if (sx + sw <= win->scr_x || sx >= win->scr_x + win->scr_w) return; if (sy + sh * 2 <= win->scr_y || sy >= win->scr_y + win->scr_h) return; switch (shape->type) { case SHAPE_None: break; case SHAPE_Heart: case SHAPE_Ridden: /* * par1: 0 is normal, 1 puts it on the left. */ sx += win->scale_full_w * (shape->par1 ? 1 : 3) / 4; size = (win->scale_h <= 10) ? 6 : 8; if (win->scale_h > 24) size += (win->scale_h - 24) / 4; sy += (win->scale_full_h - sh) * 3 / 5; if (win->scale_h < 16) sy += 4; sx -= size / 2; glEnable(GL_TEXTURE_2D); if (shape->type == SHAPE_Ridden) glBindTexture(GL_TEXTURE_2D, ridden_mark_id); else glBindTexture(GL_TEXTURE_2D, pet_mark_id); glColor3f(1.0, 1.0, 1.0); glEnable(GL_BLEND); glBegin(GL_QUADS); glTexCoord2f(0.01, 0.01); glVertex2i(sx, sy+sh-size); glTexCoord2f(0.01, 0.99); glVertex2i(sx, sy+sh); glTexCoord2f(0.99, 0.99); glVertex2i(sx+size, sy+sh); glTexCoord2f(0.99, 0.01); glVertex2i(sx+size, sy+sh-size); glEnd(); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); break; } }
void render(Game *game) { float w, h; Rect r; glClear(GL_COLOR_BUFFER_BIT); r.bot = WINDOW_HEIGHT - 20; r.left = 10; r.center = 0; ggprint8b(&r, 16, 0x00FFFFFF, "Waterfall Model"); //Draw shapes... const int n=40; static int firsttime = 1; static Vec vert[n]; if (firsttime) { float ang = 0.0, inc = (3.14159 * 2.0) / (float)n; for (int i = 0; i<n; i++) { vert[i].x = cos(ang) * game->circle.radius; vert[i].y = sin(ang) * game->circle.radius; ang += inc; } firsttime = 0; glColor3ub(90,140,90); } //draw circle glColor3ub(90,140,90); glBegin(GL_LINE_LOOP); glColor3ub(90,140,90); for (int i = 0; i < n; i++) { glVertex2i(game->circle.center.x + vert[i].x, game->circle.center.y + vert[i].y); } glEnd(); //draw box Shape *s; glColor3ub(90,140,90); const char* text[5] = {"Requirements", "Design", "Coding", "Testing", "Maintenance"}; for (int i = 0; i < 5; i++) { glColor3ub(90,140,90); r.bot = WINDOW_HEIGHT - (110 + (i * 60)); r.left = (60 + (i * 70)); r.center = 0; s = &game->box[i]; glPushMatrix(); glTranslatef(s->center.x, s->center.y, s->center.z); w = s->width; h = s->height; glBegin(GL_QUADS); glVertex2i(-w,-h); glVertex2i(-w, h); glVertex2i( w, h); glVertex2i( w,-h); glEnd(); glPopMatrix(); ggprint8b(&r, 16, 0x00F3FF00, text[i]); //0x00ff0000 } //draw all particles here glPushMatrix(); glColor3ub(150,160,220); for (int i = 0; i < game->n; i++) { Vec *c = &game->particle[i].s.center; w = 2; h = 2; glBegin(GL_QUADS); glVertex2i(c->x-w, c->y-h); glVertex2i(c->x-w, c->y+h); glVertex2i(c->x+w, c->y+h); glVertex2i(c->x+w, c->y-h); glEnd(); } glPopMatrix(); }
void Timer::draw() { glBegin( GL_QUADS ); // top Color(0.333).scaleValue( 0.75 ).withAlpha( 0.75 ).set(); glVertex2i( 0, 0 ); glVertex2i( bounds.w, 0 ); // bottom Color(0.333).scaleValue( 0.25 ).withAlpha( 0.5 ).set(); glVertex2i( bounds.w, bounds.h ); glVertex2i( 0, bounds.h ); glEnd(); if ( enabled()) { // draw pulsing Pause symbol Color(0.333).scaleValue( m_ticks & 1 ? 0.8 : 1.0 ).withAlpha(0.5).set(); glBegin( GL_QUADS ); glVertex2i( 7, 7 ); glVertex2i( 13, 7 ); glVertex2i( 13, 23 ); glVertex2i( 7, 23 ); // prime numbers are good! glVertex2i( 17, 7 ); glVertex2i( 23, 7 ); glVertex2i( 23, 23 ); glVertex2i( 17, 23 ); glEnd(); } else { // draw Run symbol Color(0.333).withAlpha(0.5).set(); glBegin( GL_TRIANGLES ); glVertex2i( 8, 5 ); glVertex2i( 23, 15 ); glVertex2i( 8, 24 ); glEnd(); Color(0.333).set(); glEnable( GL_LINE_SMOOTH ); glBegin( GL_LINE_LOOP ); glVertex2i( 8, 5 ); glVertex2i( 23, 15 ); glVertex2i( 8, 24 ); glEnd(); glDisable( GL_LINE_SMOOTH ); } glColor4f( 0, 0, 0, 0.5 ); localRect().stroke(); }
void render(void) { Rect r; //Clear the screen glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); // // //draw a quad with texture float wid = 120.0f; glColor3f(1.0, 1.0, 1.0); if (forest) { glBindTexture(GL_TEXTURE_2D, forestTexture); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex2i(0, 0); glTexCoord2f(0.0f, 0.0f); glVertex2i(0, yres); glTexCoord2f(1.0f, 0.0f); glVertex2i(xres, yres); glTexCoord2f(1.0f, 1.0f); glVertex2i(xres, 0); glEnd(); } if (show_bigfoot) { glPushMatrix(); glTranslatef(bigfoot.pos[0], bigfoot.pos[1], bigfoot.pos[2]); if (!silhouette) { glBindTexture(GL_TEXTURE_2D, bigfootTexture); } else { glBindTexture(GL_TEXTURE_2D, silhouetteTexture); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.0f); glColor4ub(255,255,255,255); } glBegin(GL_QUADS); if (bigfoot.vel[0] > 0.0) { glTexCoord2f(0.0f, 1.0f); glVertex2i(-wid,-wid); glTexCoord2f(0.0f, 0.0f); glVertex2i(-wid, wid); glTexCoord2f(1.0f, 0.0f); glVertex2i( wid, wid); glTexCoord2f(1.0f, 1.0f); glVertex2i( wid,-wid); } else { glTexCoord2f(1.0f, 1.0f); glVertex2i(-wid,-wid); glTexCoord2f(1.0f, 0.0f); glVertex2i(-wid, wid); glTexCoord2f(0.0f, 0.0f); glVertex2i( wid, wid); glTexCoord2f(0.0f, 1.0f); glVertex2i( wid,-wid); } glEnd(); glPopMatrix(); // if (trees && silhouette) { glBindTexture(GL_TEXTURE_2D, forestTransTexture); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex2i(0, 0); glTexCoord2f(0.0f, 0.0f); glVertex2i(0, yres); glTexCoord2f(1.0f, 0.0f); glVertex2i(xres, yres); glTexCoord2f(1.0f, 1.0f); glVertex2i(xres, 0); glEnd(); } glDisable(GL_ALPHA_TEST); } glDisable(GL_TEXTURE_2D); //glColor3f(1.0f, 0.0f, 0.0f); //glBegin(GL_QUADS); // glVertex2i(10,10); // glVertex2i(10,60); // glVertex2i(60,60); // glVertex2i(60,10); //glEnd(); //return; glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); if (show_rain) draw_raindrops(); glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); // #ifdef USE_UMBRELLA if (show_umbrella) draw_umbrella(); #endif //USE_UMBRELLA glBindTexture(GL_TEXTURE_2D, 0); // // r.bot = yres - 20; r.left = 10; r.center = 0; unsigned int cref = 0x00ffffff; ggprint8b(&r, 16, cref, "B - Bigfoot"); ggprint8b(&r, 16, cref, "F - Forest"); ggprint8b(&r, 16, cref, "S - Silhouette"); ggprint8b(&r, 16, cref, "T - Trees"); ggprint8b(&r, 16, cref, "U - Umbrella"); ggprint8b(&r, 16, cref, "R - Rain"); ggprint8b(&r, 16, cref, "D - Deflection"); ggprint8b(&r, 16, cref, "N - Sounds"); }
void Route::DrawGL( ViewPort &VP ) { #ifdef ocpnUSE_GL if( m_nPoints < 1 || !m_bVisible ) return; // Hiliting first // Being special case to draw something for a 1 point route.... ocpnDC dc; if(m_hiliteWidth) { wxColour y = GetGlobalColor( _T ( "YELO1" ) ); wxColour hilt( y.Red(), y.Green(), y.Blue(), 128 ); wxPen HiPen( hilt, m_hiliteWidth, wxPENSTYLE_SOLID ); ocpnDC dc; dc.SetPen( HiPen ); wxRoutePointListNode *node = pRoutePointList->GetFirst(); RoutePoint *prp0 = node->GetData(); wxPoint r0; bool r0valid = cc1->GetCanvasPointPix( prp0->m_lat, prp0->m_lon, &r0); int lines = 0; node = node->GetNext(); while( node ) { RoutePoint *prp = node->GetData(); wxPoint r1; bool r1valid = cc1->GetCanvasPointPix( prp->m_lat, prp->m_lon, &r1); if(r0valid && r1valid) { dc.StrokeLine( r0.x, r0.y, r1.x, r1.y ); lines++; } r0valid = r1valid; r0 = r1; node = node->GetNext(); } if(lines == 0 && cc1->GetCanvasPointPix( prp0->m_lat, prp0->m_lon, &r0)) { dc.StrokeLine( r0.x, r0.y, r0.x + 2, r0.y + 2 ); return; } } // if( m_nPoints < 2 ) // return; /* determine color and width */ wxColour col; int width = g_pRouteMan->GetRoutePen()->GetWidth(); //g_route_line_width; if( m_width != wxPENSTYLE_INVALID ) width = m_width; if(m_bIsTrack) width = g_pRouteMan->GetTrackPen()->GetWidth(); if( m_bRtIsActive ) { col = g_pRouteMan->GetActiveRoutePen()->GetColour(); } else if( m_bRtIsSelected ) { col = g_pRouteMan->GetSelectedRoutePen()->GetColour(); } else { if( m_Colour == wxEmptyString ) { col = g_pRouteMan->GetRoutePen()->GetColour(); // For tracks, establish colour based on first icon name if(m_bIsTrack) { wxRoutePointListNode *node = pRoutePointList->GetFirst(); RoutePoint *prp = node->GetData(); if( prp->GetIconName().StartsWith( _T("xmred") ) ) col = GetGlobalColor( _T ( "URED" ) ); else if( prp->GetIconName().StartsWith( _T("xmblue") ) ) col = GetGlobalColor( _T ( "BLUE3" ) ); else if( prp->GetIconName().StartsWith( _T("xmgreen") ) ) col = GetGlobalColor( _T ( "UGREN" ) ); else col = GetGlobalColor( _T ( "CHMGD" ) ); } } else { for( unsigned int i = 0; i < sizeof( ::GpxxColorNames ) / sizeof(wxString); i++ ) { if( m_Colour == ::GpxxColorNames[i] ) { col = ::GpxxColors[i]; break; } } } } int style = wxSOLID; if( m_style != wxPENSTYLE_INVALID ) style = m_style; dc.SetPen( *wxThePenList->FindOrCreatePen( col, width, style ) ); glColor3ub(col.Red(), col.Green(), col.Blue()); glLineWidth( wxMax( g_GLMinSymbolLineWidth, width ) ); dc.SetGLStipple(); glBegin(GL_LINE_STRIP); float lastlon = 0; float lastlat = 0; unsigned short int FromSegNo = 1; for(wxRoutePointListNode *node = pRoutePointList->GetFirst(); node; node = node->GetNext()) { RoutePoint *prp = node->GetData(); unsigned short int ToSegNo = prp->m_GPXTrkSegNo; /* crosses IDL? if so break up into two segments */ int dir = 0; if(prp->m_lon > 150 && lastlon < -150) dir = -1; else if(prp->m_lon < -150 && lastlon > 150) dir = 1; wxPoint r; if (FromSegNo != ToSegNo) { glEnd(); FromSegNo = ToSegNo; glBegin(GL_LINE_STRIP); } if(dir) { double crosslat = lat_rl_crosses_meridian(lastlat, lastlon, prp->m_lat, prp->m_lon, 180.0); if(cc1->GetCanvasPointPix( crosslat, dir*180, &r)) glVertex2i(r.x, r.y); glEnd(); glBegin(GL_LINE_STRIP); if(cc1->GetCanvasPointPix( crosslat, -dir*180, &r)) glVertex2i(r.x, r.y); } lastlat=prp->m_lat; lastlon=prp->m_lon; if(cc1->GetCanvasPointPix( prp->m_lat, prp->m_lon, &r)) glVertex2i(r.x, r.y); else { glEnd(); glBegin(GL_LINE_STRIP); } } glEnd(); glDisable (GL_LINE_STIPPLE); /* direction arrows.. could probably be further optimized for opengl */ if( !m_bIsTrack ) { wxRoutePointListNode *node = pRoutePointList->GetFirst(); wxPoint rpt1, rpt2; while(node) { RoutePoint *prp = node->GetData(); cc1->GetCanvasPointPix( prp->m_lat, prp->m_lon, &rpt2 ); if(node != pRoutePointList->GetFirst()) RenderSegmentArrowsGL( rpt1.x, rpt1.y, rpt2.x, rpt2.y, cc1->GetVP() ); rpt1 = rpt2; node = node->GetNext(); } } /* Route points */ for(wxRoutePointListNode *node = pRoutePointList->GetFirst(); node; node = node->GetNext()) { RoutePoint *prp = node->GetData(); if ( !m_bVisible && prp->m_bKeepXRoute ) prp->DrawGL( VP ); else if (m_bVisible) prp->DrawGL( VP ); } #endif }
/* CTextureCanvas::drawTexture * Draws the currently opened composite texture *******************************************************************/ void CTextureCanvas::drawTexture() { // Push matrix glPushMatrix(); // Translate to middle of the canvas glTranslated(GetSize().x * 0.5, GetSize().y * 0.5, 0); // Zoom double yscale = (tx_arc ? scale * 1.2 : scale); glScaled(scale, yscale, 1); // Draw offset guides if needed drawOffsetLines(); // Apply texture scale double tscalex = 1; double tscaley = 1; if (tex_scale) { tscalex = texture->getScaleX(); if (tscalex == 0) tscalex = 1; tscaley = texture->getScaleY(); if (tscaley == 0) tscaley = 1; glScaled(1.0 / tscalex, 1.0 / tscaley, 1); } // Calculate top-left position of texture (for glScissor, since it ignores the current translation/scale) point2_t screen_tl = texToScreenPosition(0, 0); int left = screen_tl.x; int top = screen_tl.y; // Translate by offsets if needed if (view_type == 0) // No offsets glTranslated(texture->getWidth() * -0.5, texture->getHeight() * -0.5, 0); if (view_type >= 1) // Sprite offsets glTranslated(-texture->getOffsetX(), -texture->getOffsetY(), 0); if (view_type == 2) // HUD offsets glTranslated(-160 * tscalex, -100 * tscaley, 0); // Draw the texture border drawTextureBorder(); // Enable textures glEnable(GL_TEXTURE_2D); // First, draw patches semitransparently (for anything outside the texture) // But only if we are drawing stuff outside the texture area if (draw_outside) { for (uint32_t a = 0; a < texture->nPatches(); a++) drawPatch(a, true); } // Reset colouring OpenGL::setColour(COL_WHITE); // If we're currently dragging, draw a 'basic' preview of the texture using opengl if (dragging) { glEnable(GL_SCISSOR_TEST); glScissor(left, top, texture->getWidth() * scale * (1.0 / tscalex), texture->getHeight() * yscale * (1.0 / tscaley)); for (uint32_t a = 0; a < texture->nPatches(); a++) drawPatch(a); glDisable(GL_SCISSOR_TEST); } // Otherwise, draw the fully generated texture else { // Generate if needed if (!tex_preview.isLoaded()) { // Determine image type SIType type = PALMASK; if (blend_rgba) type = RGBA; // CTexture -> temp Image -> GLTexture SImage temp(type); texture->toImage(temp, parent, &palette, blend_rgba); tex_preview.loadImage(&temp, &palette); } // Draw it tex_preview.draw2d(); } // Disable textures glDisable(GL_TEXTURE_2D); // Now loop through selected patches and draw selection outlines OpenGL::setColour(70, 210, 220, 255, BLEND_NORMAL); glEnable(GL_LINE_SMOOTH); glLineWidth(1.5f); for (size_t a = 0; a < selected_patches.size(); a++) { // Skip if not selected if (!selected_patches[a]) continue; // Get patch CTPatch* patch = texture->getPatch(a); CTPatchEx* epatch = (CTPatchEx*)patch; // Check for rotation if (texture->isExtended() && (epatch->getRotation() == 90 || epatch->getRotation() == -90)) { // Draw outline, width/height swapped glBegin(GL_LINE_LOOP); glVertex2i(patch->xOffset(), patch->yOffset()); glVertex2i(patch->xOffset(), patch->yOffset() + (int)patch_textures[a]->getWidth()); glVertex2i(patch->xOffset() + (int)patch_textures[a]->getHeight(), patch->yOffset() + (int)patch_textures[a]->getWidth()); glVertex2i(patch->xOffset() + (int)patch_textures[a]->getHeight(), patch->yOffset()); glEnd(); } else { // Draw outline glBegin(GL_LINE_LOOP); glVertex2i(patch->xOffset(), patch->yOffset()); glVertex2i(patch->xOffset(), patch->yOffset() + (int)patch_textures[a]->getHeight()); glVertex2i(patch->xOffset() + (int)patch_textures[a]->getWidth(), patch->yOffset() + (int)patch_textures[a]->getHeight()); glVertex2i(patch->xOffset() + (int)patch_textures[a]->getWidth(), patch->yOffset()); glEnd(); } } // Finally, draw a hilight outline if anything is hilighted if (hilight_patch >= 0 && hilight_patch < (int)texture->nPatches()) { // Set colour OpenGL::setColour(255, 255, 255, 150, BLEND_ADDITIVE); // Get patch CTPatch* patch = texture->getPatch(hilight_patch); CTPatchEx* epatch = (CTPatchEx*)patch; GLTexture* patch_texture = patch_textures[hilight_patch]; // Check for rotation if (texture->isExtended() && (epatch->getRotation() == 90 || epatch->getRotation() == -90)) { // Draw outline, width/height swapped glBegin(GL_LINE_LOOP); glVertex2i(patch->xOffset(), patch->yOffset()); glVertex2i(patch->xOffset(), patch->yOffset() + (int)patch_texture->getWidth()); glVertex2i(patch->xOffset() + (int)patch_texture->getHeight(), patch->yOffset() + (int)patch_texture->getWidth()); glVertex2i(patch->xOffset() + (int)patch_texture->getHeight(), patch->yOffset()); glEnd(); } else { // Draw outline glBegin(GL_LINE_LOOP); glVertex2i(patch->xOffset(), patch->yOffset()); glVertex2i(patch->xOffset(), patch->yOffset() + (int)patch_texture->getHeight()); glVertex2i(patch->xOffset() + (int)patch_texture->getWidth(), patch->yOffset() + (int)patch_texture->getHeight()); glVertex2i(patch->xOffset() + (int)patch_texture->getWidth(), patch->yOffset()); glEnd(); } } glDisable(GL_LINE_SMOOTH); glLineWidth(1.0f); // Pop matrix glPopMatrix(); }
/* CTextureCanvas::drawTextureBorder * Draws a black border around the texture *******************************************************************/ void CTextureCanvas::drawTextureBorder() { // Draw the texture border double ext = 0.11; glLineWidth(2.0f); OpenGL::setColour(COL_BLACK); glBegin(GL_LINE_LOOP); glVertex2d(-ext, -ext); glVertex2d(-ext, texture->getHeight()+ext); glVertex2d(texture->getWidth()+ext, texture->getHeight()+ext); glVertex2d(texture->getWidth()+ext, -ext); glEnd(); glLineWidth(1.0f); // Draw vertical ticks int y = 0; glColor4f(0.0f, 0.0f, 0.0f, 0.6f); while (y <= texture->getHeight()) { glBegin(GL_LINES); glVertex2i(-4, y); glVertex2i(0, y); glVertex2i(texture->getWidth(), y); glVertex2i(texture->getWidth() + 4, y); glEnd(); y += 8; } // Draw horizontal ticks int x = 0; while (x <= texture->getWidth()) { glBegin(GL_LINES); glVertex2i(x, -4); glVertex2i(x, 0); glVertex2i(x, texture->getHeight()); glVertex2i(x, texture->getHeight() + 4); glEnd(); x += 8; } // Draw grid if (show_grid) { // Draw inverted grid lines glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // Vertical y = 8; while (y <= texture->getHeight() - 8) { glBegin(GL_LINES); glVertex2i(0, y); glVertex2i(texture->getWidth(), y); glEnd(); y += 8; } // Horizontal x = 8; while (x <= texture->getWidth() - 8) { glBegin(GL_LINES); glVertex2i(x, 0); glVertex2i(x, texture->getHeight()); glEnd(); x += 8; } // Darken grid lines glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.0f, 0.0f, 0.0f, 0.5f); // Vertical y = 8; while (y <= texture->getHeight() - 8) { glBegin(GL_LINES); glVertex2i(0, y); glVertex2i(texture->getWidth(), y); glEnd(); y += 8; } // Horizontal x = 8; while (x <= texture->getWidth() - 8) { glBegin(GL_LINES); glVertex2i(x, 0); glVertex2i(x, texture->getHeight()); glEnd(); x += 8; } } }
void cc2DLabel::drawMeOnly2D(CC_DRAW_CONTEXT& context) { if (!m_dispIn2D) return; assert(!m_points.empty()); //standard case: list names pushing bool pushName = MACRO_DrawEntityNames(context); if (pushName) glPushName(getUniqueID()); //we should already be in orthoprojective & centered omde //glOrtho(-halfW,halfW,-halfH,halfH,-maxS,maxS); int strHeight = 0; int titleHeight = 0; QString title(getName()); QStringList body; GLdouble arrowDestX=-1.0,arrowDestY=-1.0; QFont bodyFont,titleFont; if (!pushName) { /*** line from 2D point to label ***/ //compute arrow head position CCVector3 arrowDest; m_points[0].cloud->getPoint(m_points[0].index,arrowDest); for (unsigned i=1;i<m_points.size();++i) arrowDest += *m_points[i].cloud->getPointPersistentPtr(m_points[i].index); arrowDest /= (PointCoordinateType)m_points.size(); //project it in 2D screen coordinates int VP[4]; context._win->getViewportArray(VP); const double* MM = context._win->getModelViewMatd(); //viewMat const double* MP = context._win->getProjectionMatd(); //projMat GLdouble zp; gluProject(arrowDest.x,arrowDest.y,arrowDest.z,MM,MP,VP,&arrowDestX,&arrowDestY,&zp); /*** label border ***/ bodyFont = context._win->getTextDisplayFont(); //takes rendering zoom into account! titleFont = QFont(context._win->getTextDisplayFont()); //takes rendering zoom into account! titleFont.setBold(true); QFontMetrics titleFontMetrics(titleFont); QFontMetrics bodyFontMetrics(bodyFont); strHeight = bodyFontMetrics.height(); titleHeight = titleFontMetrics.height(); if (m_showFullBody) body = getLabelContent(context.dispNumberPrecision); //base box dimension int dx = 150; dx = std::max(dx,titleFontMetrics.width(title)); int dy = c_margin; //top vertical margin dy += titleHeight; //title if (!body.empty()) { dy += c_margin; //vertical margin above separator for (int j=0; j<body.size(); ++j) { dx = std::max(dx,bodyFontMetrics.width(body[j])); dy += strHeight; //body line height } dy += c_margin; //vertical margin below text } else { dy += c_margin; // vertical margin (purely for aesthetics) } dy += c_margin; // bottom vertical margin dx += c_margin*2; // horizontal margins //main rectangle m_labelROI[0]=0; m_labelROI[1]=0; m_labelROI[2]=dx; m_labelROI[3]=dy; //close button /*m_closeButtonROI[2]=dx-c_margin; m_closeButtonROI[0]=m_closeButtonROI[2]-c_buttonSize; m_closeButtonROI[3]=c_margin; m_closeButtonROI[1]=m_closeButtonROI[3]+c_buttonSize; //*/ //automatically elide the title //title = titleFontMetrics.elidedText(title,Qt::ElideRight,m_closeButtonROI[0]-2*c_margin); } int halfW = (context.glW>>1); int halfH = (context.glH>>1); //draw label rectangle int xStart = m_lastScreenPos[0] = (int)((float)context.glW * m_screenPos[0]); int yStart = m_lastScreenPos[1] = (int)((float)context.glH * (1.0f-m_screenPos[1])); //colors bool highlighted = (!pushName && isSelected()); //default background color colorType defaultBkgColor[4]; memcpy(defaultBkgColor,context.labelDefaultCol,sizeof(colorType)*3); defaultBkgColor[3] = (colorType)((float)context.labelsTransparency*(float)MAX_COLOR_COMP/100.0f); //default border color (mustn't be totally transparent!) colorType defaultBorderColor[4]; if (highlighted) memcpy(defaultBorderColor,ccColor::red,sizeof(colorType)*3); else memcpy(defaultBorderColor,context.labelDefaultCol,sizeof(colorType)*3); defaultBorderColor[3] = (colorType)((float)(50+context.labelsTransparency/2)*(float)MAX_COLOR_COMP/100.0f); glPushAttrib(GL_COLOR_BUFFER_BIT); glEnable(GL_BLEND); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef(static_cast<GLfloat>(-halfW+xStart),static_cast<GLfloat>(-halfH+yStart),0); if (!pushName) { //compute arrow base position relatively to the label rectangle (for 0 to 8) int arrowBaseConfig = 0; int iArrowDestX = (int)arrowDestX-xStart; int iArrowDestY = (int)arrowDestY-yStart; { if (iArrowDestX < m_labelROI[0]) //left arrowBaseConfig += 0; else if (iArrowDestX > m_labelROI[2]) //Right arrowBaseConfig += 2; else //Middle arrowBaseConfig += 1; if (iArrowDestY > -m_labelROI[1]) //Top arrowBaseConfig += 0; else if (iArrowDestY < -m_labelROI[3]) //Bottom arrowBaseConfig += 6; else //Middle arrowBaseConfig += 3; } //we make the arrow base start from the nearest corner if (arrowBaseConfig != 4) //4 = label above point! { glColor4ubv(defaultBorderColor); glBegin(GL_TRIANGLE_FAN); glVertex2d(arrowDestX-xStart,arrowDestY-yStart); switch(arrowBaseConfig) { case 0: //top-left corner glVertex2i(m_labelROI[0], -m_labelROI[1]-2*c_arrowBaseSize); glVertex2i(m_labelROI[0], -m_labelROI[1]); glVertex2i(m_labelROI[0]+2*c_arrowBaseSize, -m_labelROI[1]); break; case 1: //top-middle edge glVertex2i(std::max(m_labelROI[0],iArrowDestX-c_arrowBaseSize), -m_labelROI[1]); glVertex2i(std::min(m_labelROI[2],iArrowDestX+c_arrowBaseSize), -m_labelROI[1]); break; case 2: //top-right corner glVertex2i(m_labelROI[2], -m_labelROI[1]-2*c_arrowBaseSize); glVertex2i(m_labelROI[2], -m_labelROI[1]); glVertex2i(m_labelROI[2]-2*c_arrowBaseSize, -m_labelROI[1]); break; case 3: //middle-left edge glVertex2i(m_labelROI[0], std::min(-m_labelROI[1],iArrowDestY+c_arrowBaseSize)); glVertex2i(m_labelROI[0], std::max(-m_labelROI[3],iArrowDestY-c_arrowBaseSize)); break; case 4: //middle of rectangle! break; case 5: //middle-right edge glVertex2i(m_labelROI[2], std::min(-m_labelROI[1],iArrowDestY+c_arrowBaseSize)); glVertex2i(m_labelROI[2], std::max(-m_labelROI[3],iArrowDestY-c_arrowBaseSize)); break; case 6: //bottom-left corner glVertex2i(m_labelROI[0], -m_labelROI[3]+2*c_arrowBaseSize); glVertex2i(m_labelROI[0], -m_labelROI[3]); glVertex2i(m_labelROI[0]+2*c_arrowBaseSize, -m_labelROI[3]); break; case 7: //bottom-middle edge glVertex2i(std::max(m_labelROI[0],iArrowDestX-c_arrowBaseSize), -m_labelROI[3]); glVertex2i(std::min(m_labelROI[2],iArrowDestX+c_arrowBaseSize), -m_labelROI[3]); break; case 8: //bottom-right corner glVertex2i(m_labelROI[2], -m_labelROI[3]+2*c_arrowBaseSize); glVertex2i(m_labelROI[2], -m_labelROI[3]); glVertex2i(m_labelROI[2]-2*c_arrowBaseSize, -m_labelROI[3]); break; } glEnd(); } } //main rectangle glColor4ubv(defaultBkgColor); glBegin(GL_QUADS); glVertex2i(m_labelROI[0], -m_labelROI[1]); glVertex2i(m_labelROI[0], -m_labelROI[3]); glVertex2i(m_labelROI[2], -m_labelROI[3]); glVertex2i(m_labelROI[2], -m_labelROI[1]); glEnd(); //if (highlighted) { glPushAttrib(GL_LINE_BIT); glLineWidth(3.0f); glColor4ubv(defaultBorderColor); glBegin(GL_LINE_LOOP); glVertex2i(m_labelROI[0], -m_labelROI[1]); glVertex2i(m_labelROI[0], -m_labelROI[3]); glVertex2i(m_labelROI[2], -m_labelROI[3]); glVertex2i(m_labelROI[2], -m_labelROI[1]); glEnd(); glPopAttrib(); } //draw close button /*glColor3ubv(ccColor::black); glBegin(GL_LINE_LOOP); glVertex2i(m_closeButtonROI[0],-m_closeButtonROI[1]); glVertex2i(m_closeButtonROI[0],-m_closeButtonROI[3]); glVertex2i(m_closeButtonROI[2],-m_closeButtonROI[3]); glVertex2i(m_closeButtonROI[2],-m_closeButtonROI[1]); glEnd(); glBegin(GL_LINES); glVertex2i(m_closeButtonROI[0]+2,-m_closeButtonROI[1]+2); glVertex2i(m_closeButtonROI[2]-2,-m_closeButtonROI[3]-2); glVertex2i(m_closeButtonROI[2]-2,-m_closeButtonROI[1]+2); glVertex2i(m_closeButtonROI[0]+2,-m_closeButtonROI[3]-2); glEnd(); //*/ //display text if (!pushName) { int xStartRel = c_margin; int yStartRel = -c_margin; yStartRel -= titleHeight; const colorType* defaultTextColor = (context.labelsTransparency<40 ? context.textDefaultCol : ccColor::darkBlue); context._win->displayText(title,xStart+xStartRel,yStart+yStartRel,ccGenericGLDisplay::ALIGN_DEFAULT,0,defaultTextColor,&titleFont); yStartRel -= c_margin; if (!body.empty()) { //line separation glColor4ubv(defaultBorderColor); glBegin(GL_LINES); glVertex2i(xStartRel,yStartRel); glVertex2i(xStartRel+m_labelROI[2]-m_labelROI[0]-2*c_margin,yStartRel); glEnd(); //display body yStartRel -= c_margin; for (int i=0; i<body.size(); ++i) { yStartRel -= strHeight; context._win->displayText(body[i],xStart+xStartRel,yStart+yStartRel,ccGenericGLDisplay::ALIGN_DEFAULT,0,defaultTextColor,&bodyFont); } } } glPopAttrib(); glPopMatrix(); if (pushName) glPopName(); }
void renderString(int x, int y, string glstring){ unsigned int i = 0; int uc; double tx, ty, span = 0; //Textures::TEXTURE_RGBA Tex; TextureID ftex; wchar_t* wstr = nullptr; MBToWC(glstring.c_str(), wstr, 128); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, ww, wh, 0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glEnable(GL_TEXTURE_2D); for (unsigned int k = 0; k < wstrlen(wstr); k++){ glLoadIdentity(); glColor4f(r, g, b, a); glTranslated(x + 1 + span, y + 1, 0); uc = wstr[k]; if (!useUnicodeASCIIFont && glstring[i]>=0 && glstring[i] <= 127){ glprint(x + 1 + (int)span, y + 1, string() + glstring[i]); } else{ if (!unicodeTexAval[uc / 256]) { //printf("[Console][Event]"); //printf("Loading unicode font texture #%d\n", uc / 256); std::stringstream ss; ss << "Textures\\Fonts\\unicode\\unicode_glyph_" << uc / 256 << ".bmp"; ftex = Textures::LoadFontTexture(ss.str()); unicodeTex[uc / 256] = ftex; unicodeTexAval[uc / 256] = true; } else{ ftex = unicodeTex[uc / 256]; } tx = ((uc % 256) % 16) / 16.0; ty = 1 - ((uc % 256) / 16) / 16.0; glBindTexture(GL_TEXTURE_2D, ftex); glBegin(GL_QUADS); glColor4f(0.5, 0.5, 0.5, a); glTexCoord2d(tx, ty); glVertex2i(1, 1); glTexCoord2d(tx + 0.0625, ty); glVertex2i(17, 1); glTexCoord2d(tx + 0.0625, ty - 0.0625); glVertex2i(17, 17); glTexCoord2d(tx, ty - 0.0625); glVertex2i(1, 17); glColor4f(r, g, b, a); glTexCoord2d(tx, ty); glVertex2i(0, 0); glTexCoord2d(tx + 0.0625, ty); glVertex2i(16, 0); glTexCoord2d(tx + 0.0625, ty - 0.0625); glVertex2i(16, 16); glTexCoord2d(tx, ty - 0.0625); glVertex2i(0, 16); glEnd(); } if (glstring[i] >= 0 && glstring[i] <= 127){ i += 1; span += 10; } else{ i += 2; span += 16; } } glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glColor4f(1.0, 1.0, 1.0, 1.0); free(wstr); }
void SpaceShip::draw() { Point abc[4]; // Right & Left Carriers glLineWidth(2); glColor3f(0.799, 0.1098, 0.0588); glBegin(GL_TRIANGLE_STRIP); glVertex2i(startX + 10, (startY + 0)); glVertex2i(startX + 20, (startY + 10)); glVertex2i(startX + 7, (startY + 23)); glVertex2i(startX + 17, (startY + 30)); glEnd(); glBegin(GL_TRIANGLE_STRIP); glVertex2i(startX + 68, (startY + 0)); glVertex2i(startX + 58, (startY + 10)); glVertex2i(startX + 72, (startY + 23)); glVertex2i(startX + 62, (startY + 30)); glEnd(); // Main Body glLineWidth(4); glColor3f(0.925, 0.925, 0.925); abc[0].setxy(startX + 22, (startY + 9)); abc[1].setxy(startX + 14, (startY + 28)); abc[2].setxy(startX + 16, (startY + 86)); abc[3].setxy(startX + 39, (startY + 97)); basicShapes.drawCurve(abc[0], abc[1], abc[2], abc[3]); abc[0].setxy(startX + 56, (startY + 9)); abc[1].setxy(startX + 66, (startY + 28)); abc[2].setxy(startX + 62, (startY + 86)); abc[3].setxy(startX + 39, (startY + 97)); basicShapes.drawCurve(abc[0], abc[1], abc[2], abc[3]); abc[0].setxy(startX + 22, (startY + 9)); abc[1].setxy(startX + 34, (startY + 16)); abc[2].setxy(startX + 44, (startY + 16)); abc[3].setxy(startX + 56, (startY + 9)); basicShapes.drawCurve(abc[0], abc[1], abc[2], abc[3]); basicShapes.solidCircle(startX + 39, (startY + 82), 13); basicShapes.solidCircle(startX + 39, (startY + 65), 20); basicShapes.solidCircle(startX + 39, (startY + 53), 22); basicShapes.solidCircle(startX + 39, (startY + 35), 23); basicShapes.solidCircle(startX + 27, (startY + 20), 9); basicShapes.solidCircle(startX + 52, (startY + 20), 9); // Glass Window glColor3f(0.827, 0.96, 1); basicShapes.solidCircle(startX + 39, (startY + 60), 10); // Middle Carrier glLineWidth(2.8); glColor3f(0.799, 0.1098, 0.0588); glBegin(GL_LINES); glVertex2i(startX + 39, (startY + 0)); glVertex2i(startX + 39, (startY + 30)); glEnd(); // Glass Frame glLineWidth(2); basicShapes.hallowCircle(startX + 39, (startY + 60), 10); }
void GLUI_EditText::draw( int x, int y ) { int orig; int name_x; if ( NOT can_draw() ) return; orig = set_to_glut_window(); name_x = MAX(text_x_offset - string_width(this->name) - 3,0); draw_name( name_x , 13); glBegin( GL_LINES ); glColor3f( .5, .5, .5 ); glVertex2i( text_x_offset, 0 ); glVertex2i( w, 0 ); glVertex2i( text_x_offset, 0 ); glVertex2i( text_x_offset, h ); glColor3f( 1., 1., 1. ); glVertex2i( text_x_offset, h ); glVertex2i( w, h ); glVertex2i( w, h ); glVertex2i( w, 0 ); if ( enabled ) glColor3f( 0., 0., 0. ); else glColor3f( .25, .25, .25 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( w-1, 1 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( text_x_offset+1, h-1 ); glColor3f( .75, .75, .75 ); glVertex2i( text_x_offset+1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, 1 ); glEnd(); /** Find where to draw the text **/ update_substring_bounds(); draw_text(0,0); draw_insertion_pt(); restore_window(orig); }
bool cScene::LoadLevel(int level) { bool res; FILE *fd; char file[16]; int i,j,px,py; int tile; float coordx_tile, coordy_tile; res=true; if(level<10) sprintf(file,"%s0%d%s",(char *)FILENAME,level,(char *)FILENAME_EXT); else sprintf(file,"%s%d%s",(char *)FILENAME,level,(char *)FILENAME_EXT); fd=fopen(file,"r"); if(fd==NULL) return false; int width = (level == 1) ? SCENE_WIDTH : SCENE_WIDTH_2; id_DL=glGenLists(1); glNewList(id_DL,GL_COMPILE); glBegin(GL_QUADS); for(j=SCENE_HEIGHT-1;j>=0;j--) { px=SCENE_Xo; py=SCENE_Yo+(j*TILE_SIZE); for(i=0;i<width;i++) { fscanf(fd,"%d",&tile); if (tile == 0) { if (level == 1) map[(j*width)+i]=0; else map2[(j*width) + i] = 0; } else { //PODRIAMOS COMPROBAR ALGUNA TILE EN CONCRETO SI QUEREMOS QUE CIERTOS ID TENGAN ANIMACION //TODO //Tiles = 1,2,3,... float divY = (level == 1) ? 0.25f : 0.125f; if (level == 1) map[(j*width)+i] = tile; else map2[(j*width) + i] = tile; coordy_tile = (tile - 1) / tilesFila * divY; coordx_tile = ((tile-1) % (tilesFila)) * (float)(1.0f / (float)tilesFila); glTexCoord2f(coordx_tile ,coordy_tile+ divY); glVertex2i(px ,py ); glTexCoord2f(coordx_tile+ (1.0f/(float)tilesFila),coordy_tile+ divY); glVertex2i(px+BLOCK_SIZE,py ); glTexCoord2f(coordx_tile+ (1.0f / (float)tilesFila),coordy_tile ); glVertex2i(px+BLOCK_SIZE,py+BLOCK_SIZE); glTexCoord2f(coordx_tile ,coordy_tile ); glVertex2i(px ,py+BLOCK_SIZE); } px+=TILE_SIZE; } } glEnd(); glEndList(); fclose(fd); return res; }
void GLUI_EditText::draw_text( int x, int y ) { int text_x, i, sel_lo, sel_hi; int orig; if ( NOT can_draw() ) return; if ( debug ) dump( stdout, "-> DRAW_TEXT" ); orig = set_to_glut_window(); if ( NOT draw_text_only ) { if ( enabled ) glColor3f( 1., 1., 1. ); else set_to_bkgd_color(); glDisable( GL_CULL_FACE ); glBegin( GL_QUADS ); glVertex2i( text_x_offset+2, 2 ); glVertex2i( w-2, 2 ); glVertex2i( w-2, h-2 ); glVertex2i( text_x_offset+2, h-2 ); glEnd(); } /** Find where to draw the text **/ text_x = text_x_offset + 2 + GLUI_EDITTEXT_BOXINNERMARGINX; /*printf( "text_x: %d substr_width: %d start/end: %d/%d\n", text_x, substring_width( substring_start, substring_end ), substring_start, substring_end ); */ /** Find lower and upper selection bounds **/ sel_lo = MIN(sel_start, sel_end ); sel_hi = MAX(sel_start, sel_end ); int sel_x_start, sel_x_end, delta; /** Draw selection area dark **/ if ( sel_start != sel_end ) { sel_x_start = text_x; sel_x_end = text_x; for( i=substring_start; i<=substring_end; i++ ) { delta = char_width( text[i] ); if ( i < sel_lo ) { sel_x_start += delta; sel_x_end += delta; } else if ( i < sel_hi ) { sel_x_end += delta; } } glColor3f( 0.0f, 0.0f, .6f ); glBegin( GL_QUADS ); glVertex2i( sel_x_start, 2 ); glVertex2i( sel_x_end, 2 ); glVertex2i( sel_x_end, h-2 ); glVertex2i( sel_x_start, h-2 ); glEnd(); } if ( sel_start == sel_end ) { /* No current selection */ if ( enabled ) glColor3b( 0, 0, 0 ); else glColor3b( 32, 32, 32 ); glRasterPos2i( text_x, 13); for( i=substring_start; i<=substring_end; i++ ) { glutBitmapCharacter( get_font(), this->text[i] ); } } else { /* There is a selection */ int x = text_x; for( i=substring_start; i<=substring_end; i++ ) { if ( IN_BOUNDS( i, sel_lo, sel_hi-1)) { /* This character is selected */ glColor3f( 1., 1., 1. ); glRasterPos2i( x, 13); glutBitmapCharacter( get_font(), this->text[i] ); } else { glColor3f( 0., 0., 0. ); glRasterPos2i( x, 13); glutBitmapCharacter( get_font(), this->text[i] ); } x += char_width( text[i] ); } } restore_window( orig ); if ( debug ) dump( stdout, "<- DRAW_TEXT" ); }
void buttonList::buttonDraw(){ int fontx; int fonty; current = start; while(current != NULL){ if(current->display){ if (current->highlighted) { glColor3f(0.0f,0.0f,0.0f); } else { glColor3f(0.0f,0.0f,0.0f); } glBegin(GL_QUADS); glVertex2i( current->x, current->y ); glVertex2i( current->x, current->y+current->h ); glVertex2i( current->x+current->w, current->y+current->h ); glVertex2i( current->x+current->w, current->y ); glEnd(); glLineWidth(3); if (current->pressed) { glColor3f(0.0f,0.0f,0.0f); } else { glColor3f(0.0f,0.0f,0.0f); } glBegin(GL_LINE_STRIP); glVertex2i( current->x+current->w, current->y ); glVertex2i( current->x , current->y ); glVertex2i( current->x , current->y+current->h ); glEnd(); if (current->pressed) { glColor3f(0.0f,0.0f,0.0f); } else { glColor3f(0.0f,0.0f,0.0f); } glBegin(GL_LINE_STRIP); glVertex2i( current->x, current->y+current->h ); glVertex2i( current->x+current->w, current->y+current->h ); glVertex2i( current->x+current->w, current->y ); glEnd(); glLineWidth(1); const unsigned char* tempLabel = (const unsigned char*) current->label; fontx = current->x + (current->w - glutBitmapLength(GLUT_BITMAP_HELVETICA_10,tempLabel)) / 2 ; fonty = current->y + (current->h+10)/2; if (current->pressed) { fontx+=2; fonty+=2; } if(current->highlighted) { glColor3f(0,0,0); displayText(GLUT_BITMAP_HELVETICA_10,current->label,fontx,fonty); fontx--; fonty--; } glColor3f(0,0,0); displayText(GLUT_BITMAP_HELVETICA_10,current->label,fontx,fonty); } current = current->next; } }