Changeset 1622 for trunk/tools/neercs/video/render.cpp
- Timestamp:
- Jul 10, 2012, 7:28:24 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/neercs/video/render.cpp
r1606 r1622 81 81 float beat_value = 0; // value 82 82 float beat_speed = 2.0f; // speed 83 /* corner variable */84 const int corner_n = 10; // m_polygon number85 int corner_w = 24; // radius86 int corner_vtx[corner_n*6];// vertex array87 83 /* window variable */ 88 84 int window_m; // margin … … 91 87 ivec2 map_size(256,256); // texture map size 92 88 ivec2 font_size(8,8); // font size 93 vec2 car_size(1.0f/map_size.x*font_size.x, 1.0f/map_size.y*font_size.y); 89 ivec2 text_size(80,25); // text size 90 ivec2 blit_top(0,0); // text blit top position 91 ivec2 blit_bottom(0,0); // text blit bottom position 94 92 int shell_vtx[8]; // vertex array 95 93 float shell_tex[] = {1.0f, 0.96875f, 1.0f, 1.0f, 0.78125f, 1.0f, 0.78125f, 0.96875f}; … … 170 168 glVertex2i(x+w, y+h); 171 169 glEnd(); 172 }173 174 void corner()175 {176 float vertex[6+corner_n*2];177 vertex[0] = 0;178 vertex[1] = 0;179 for (int i = 1; i < corner_n + 1; i++)180 {181 int j = i*2;182 float a = PID*90.0f/(corner_n-1)*(i-1);183 vertex[j ] = corner_w-corner_w*cosf(a);184 vertex[j+1] = corner_w-corner_w*sinf(a);185 }186 for (int i = 0; i < corner_n; i++)187 {188 int j = i*6;189 int k = i*2;190 corner_vtx[j ] = (int)vertex[0];191 corner_vtx[j+1] = (int)vertex[1];192 corner_vtx[j+2] = (int)vertex[2+k];193 corner_vtx[j+3] = (int)vertex[3+k];194 corner_vtx[j+4] = (int)vertex[4+k];195 corner_vtx[j+5] = (int)vertex[5+k];196 }197 170 } 198 171 … … 263 236 { 264 237 screen_size = Video::GetSize(); 265 corner_w = 16*ratio_2d.x; 266 corner(); 267 window_m=12*ratio_2d.x; 268 window_vtx[0]=font_size.x*ratio_2d.x/2.0f; 269 window_vtx[1]=font_size.y*ratio_2d.y/2.0f; 270 window_vtx[2]=font_size.x*ratio_2d.x/2.0f; 271 window_vtx[3]=-font_size.y*ratio_2d.y/2.0f; 272 window_vtx[4]=-font_size.x*ratio_2d.x/2.0f; 273 window_vtx[5]=-font_size.y*ratio_2d.y/2.0f; 274 window_vtx[6]=-font_size.x*ratio_2d.x/2.0f; 275 window_vtx[7]=font_size.y*ratio_2d.y/2.0f; 276 shell_vtx[0]=window_m+58*ratio_2d.x; 277 shell_vtx[1]=window_m+(font_size.y+1)*ratio_2d.y; 278 shell_vtx[2]=window_m+58*ratio_2d.x; 279 shell_vtx[3]=window_m+ratio_2d.y; 280 shell_vtx[4]=window_m+2*ratio_2d.x; 281 shell_vtx[5]=window_m+ratio_2d.y; 282 shell_vtx[6]=window_m+2*ratio_2d.x; 283 shell_vtx[7]=window_m+(font_size.y+1)*ratio_2d.y; 238 239 window_m = 12 * ratio_2d.x; 240 window_vtx[0] = font_size.x * ratio_2d.x / 2.0f; 241 window_vtx[1] = font_size.y * ratio_2d.y / 2.0f; 242 window_vtx[2] = font_size.x * ratio_2d.x / 2.0f; 243 window_vtx[3] = -font_size.y * ratio_2d.y / 2.0f; 244 window_vtx[4] = -font_size.x * ratio_2d.x / 2.0f; 245 window_vtx[5] = -font_size.y * ratio_2d.y / 2.0f; 246 window_vtx[6] = -font_size.x * ratio_2d.x / 2.0f; 247 window_vtx[7] = font_size.y * ratio_2d.y / 2.0f; 248 shell_vtx[0] = window_m + 58 * ratio_2d.x; 249 shell_vtx[1] = window_m + (font_size.y + 1) * ratio_2d.y; 250 shell_vtx[2] = window_m + 58 * ratio_2d.x; 251 shell_vtx[3] = window_m + ratio_2d.y; 252 shell_vtx[4] = window_m + 2 * ratio_2d.x; 253 shell_vtx[5] = window_m + ratio_2d.y; 254 shell_vtx[6] = window_m + 2 * ratio_2d.x; 255 shell_vtx[7] = window_m + (font_size.y + 1) * ratio_2d.y; 256 257 blit_top = ivec2(window_m, window_m + font_size.y * ratio_2d.y) + ratio_2d * 2; 258 blit_bottom = screen_size - ivec2(window_m * 2, window_m * 2 + font_size.y * ratio_2d.y) + ratio_2d * 2; 259 260 //caca_set_canvas_size(m_caca,20,10); 261 284 262 InitDraw(); 285 263 return true; … … 407 385 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 408 386 409 ivec2 border_top = ivec2(window_m, window_m + font_size.y * ratio_2d.y) 410 + ratio_2d * 2; 411 ivec2 border_bottom = ivec2(window_m * 2, window_m * 2 + font_size.y * ratio_2d.y) 412 + ratio_2d * 2; 413 text_render->Blit(border_top, screen_size - border_bottom); 387 text_render->Blit(blit_top, blit_bottom); 414 388 415 389 //if(m_polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH); … … 461 435 glTexCoordPointer(2, GL_FLOAT, 0, shell_tex); 462 436 glDrawArrays(GL_QUADS, 0, 4); 463 // draw corner464 glDisable(GL_TEXTURE_2D);465 glDisable(GL_BLEND);466 glVertexPointer(2, GL_INT, 0, corner_vtx);467 glLoadIdentity();468 glColor3f(1.0f, 1.0f, 1.0f);469 glDrawArrays(GL_TRIANGLES, 0, corner_n*3);470 glTranslated(screen_size.x, 0, 0);471 glRotated(90.0f, 0, 0, 1.0f);472 glDrawArrays(GL_TRIANGLES, 0, corner_n*3);473 glTranslated(screen_size.y, 0, 0);474 glRotated(90.0f, 0, 0, 1.0f);475 glDrawArrays(GL_TRIANGLES, 0, corner_n*3);476 glTranslated(screen_size.x, 0, 0);477 glRotated(90.0f, 0, 0, 1.0f);478 glDrawArrays(GL_TRIANGLES, 0, corner_n*3);479 437 glEnable(GL_BLEND); 480 438 }
Note: See TracChangeset
for help on using the changeset viewer.