Changeset 1484
- Timestamp:
- Jun 16, 2012, 7:19:17 PM (11 years ago)
- Location:
- trunk/neercs/video
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/neercs/video/render.cpp
r1483 r1484 164 164 shader_postfx_sync; 165 165 166 FrameBuffer *fbo_ text, *fbo_back, *fbo_front;166 FrameBuffer *fbo_back, *fbo_front; 167 167 FrameBuffer *fbo_blur_h, *fbo_blur_v, *fbo_ping, *fbo_pong; 168 168 #endif … … 183 183 } 184 184 185 void Init( )185 void Init(ivec2 screen_size, ivec2 font_size) 186 186 { 187 187 m_shader = Shader::Create(lolfx_text); … … 206 206 m_vbo2 = new VertexBuffer(m_width * m_height * sizeof(int32_t)); 207 207 m_vbo3 = new VertexBuffer(m_width * m_height * sizeof(int32_t)); 208 } 209 210 void Blit(ivec2 screen_size, ivec2 font_size) 208 209 m_fbo = new FrameBuffer(screen_size); 210 } 211 212 void Render(ivec2 screen_size, ivec2 font_size) 211 213 { 212 214 /* Transform matrix for the scene: … … 241 243 m_vbo3->Unlock(); 242 244 245 m_fbo->Bind(); 243 246 glEnable(GL_POINT_SPRITE); 244 247 //glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); … … 258 261 m_shader->Unbind(); 259 262 glDisable(GL_POINT_SPRITE); 263 m_fbo->Unbind(); 264 } 265 266 void Blit() 267 { 268 /* FIXME: scaling is wrong */ 269 glDisable(GL_BLEND); 270 glEnable(GL_TEXTURE_2D); 271 glBindTexture(GL_TEXTURE_2D, m_fbo->GetTexture()); 272 glColor3f(1.0f,1.0f,1.0f); 273 274 int x = dos_m; 275 int y = dos_m + (font_size.y + 2) * ratio_2d.y; 276 int w = screen_size.x - dos_m * 2; 277 int h = screen_size.y - dos_m * 2 - (font_size.y + 2) * ratio_2d.y; 278 279 glLoadIdentity(); 280 glBegin(GL_QUADS); 281 glTexCoord2f(1.0f, 1.0f); 282 glVertex2i(x+w, y ); 283 glTexCoord2f(0.0f, 1.0f); 284 glVertex2i(x , y ); 285 glTexCoord2f(0.0f, 0.0f); 286 glVertex2i(x , y+h); 287 glTexCoord2f(1.0f, 0.0f); 288 glVertex2i(x+w, y+h); 289 glEnd(); 260 290 } 261 291 … … 270 300 VertexDeclaration *m_vdecl; 271 301 VertexBuffer *m_vbo1, *m_vbo2, *m_vbo3; 302 FrameBuffer *m_fbo; 272 303 }; 273 304 … … 387 418 // initialize some variable 388 419 screen(); 420 389 421 #if SHADER 390 422 if (shader_flag) 391 423 { 392 fbo_text = new FrameBuffer(screen_size);424 /* Initialise framebuffer objects */ 393 425 fbo_back = new FrameBuffer(screen_size); 394 426 fbo_front = new FrameBuffer(screen_size); … … 472 504 473 505 Render::Render(caca_canvas_t *caca) 474 : m_caca(caca) 506 : m_caca(caca), 507 m_ready(false) 475 508 { 476 509 text_render = new TextRender(m_caca); … … 486 519 Entity::TickDraw(seconds); 487 520 488 static int todo = 1; 489 if (todo) 521 if (!m_ready) 490 522 { 491 523 CreateGLWindow("LOL"); 492 todo = 0; 493 text_render->Init(); 524 text_render->Init(screen_size, ivec2(8, 8)); 525 526 m_ready = true; 494 527 } 495 528 … … 544 577 void Render::Draw2D() 545 578 { 546 #if SHADER547 579 /* Draw text in an offline buffer */ 548 fbo_text->Bind(); 549 text_render->Blit(screen_size, ivec2(8, 8)); 550 fbo_text->Unbind(); 551 #endif 580 text_render->Render(screen_size, ivec2(8, 8)); 552 581 553 582 /* Clear the back buffer */ … … 566 595 #endif 567 596 568 /* FIXME: when SHADER is true, we should blit the offline 569 * buffer instead, but for some reason it doesn't work yet. */ 570 text_render->Blit(screen_size, ivec2(8, 8)); 597 text_render->Blit(); 571 598 572 599 glEnableClientState(GL_VERTEX_ARRAY); … … 580 607 581 608 init_viewport(1); 582 583 #if 0584 /* Render text buffer to the current buffer */585 glEnable(GL_BLEND);586 glEnable(GL_TEXTURE_2D);587 glBlendFunc(GL_ONE, GL_ONE);588 glVertexPointer(2, GL_INT, 0, shell_vtx);589 glTexCoordPointer(2, GL_FLOAT, 0, shell_tex);590 shader_simple->Bind();591 shader_simple->SetTexture(shader_simple_texture, fbo_text->GetTexture(), 0);592 fs_quad();593 shader_simple->Unbind();594 #endif595 609 596 610 tex_map->Bind(); -
trunk/neercs/video/render.h
r1462 r1484 22 22 private: 23 23 caca_canvas_t *m_caca; 24 bool m_ready; 24 25 }; 25 26
Note: See TracChangeset
for help on using the changeset viewer.