Changeset 2752


Ignore:
Timestamp:
Jun 19, 2013, 2:18:17 AM (8 years ago)
Author:
sam
Message:

gpu: use the RenderContext class in a few friendly places.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scene.cpp

    r2613 r2752  
    192192void Scene::Render() // XXX: rename to Blit()
    193193{
     194    RenderContext rc;
     195    rc.SetDepthTest(true);
     196    rc.SetAlphaBlend(true);
     197
    194198#if defined USE_D3D9 || defined _XBOX
    195199#else
    196     glEnable(GL_DEPTH_TEST);
    197200    glDepthFunc(GL_LEQUAL);
    198201#if defined HAVE_GL_2X && !defined __APPLE__
     
    200203    glAlphaFunc(GL_GEQUAL, 0.01f);
    201204#endif
    202     glEnable(GL_BLEND);
    203205    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    204206#endif
     
    348350    /* TODO */
    349351#else
    350     glDisable(GL_DEPTH_TEST);
    351352#   if defined HAVE_GL_2X && !defined __APPLE__
    352353    glDisable(GL_ALPHA_TEST);
    353354#   endif
    354     glDisable(GL_BLEND);
    355355#endif
    356356}
  • trunk/tools/neercs/video/render.cpp

    r2593 r2752  
    14511451
    14521452    /* Clear the back buffer */
     1453
     1454    RenderContext rc;
     1455    rc.SetAlphaBlend(true);
     1456
    14531457    glEnable(GL_TEXTURE_2D);
    1454     glEnable(GL_BLEND);
    14551458    glBlendFunc(GL_SRC_COLOR, GL_DST_ALPHA);
    14561459
     
    14761479        return;
    14771480
    1478     glDisable(GL_DEPTH_TEST);
    1479     glDisable(GL_BLEND);
     1481    RenderContext rc;
     1482    rc.SetAlphaBlend(false);
     1483    rc.SetDepthTest(false);
    14801484
    14811485    glEnableClientState(GL_VERTEX_ARRAY);
  • trunk/tools/neercs/video/text-render.cpp

    r2593 r2752  
    144144
    145145    m_fbo->Bind();
    146     glViewport(0, 0, m_fbo_size.x, m_fbo_size.y);
    147     glDisable(GL_DEPTH_TEST);
     146    {
     147        RenderContext rc;
     148        rc.SetDepthTest(false);
     149
     150        glViewport(0, 0, m_fbo_size.x, m_fbo_size.y);
    148151#if !defined HAVE_GLES_2X
    149     glEnable(GL_POINT_SPRITE);
    150     //glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
    151     glDisable(GL_POINT_SMOOTH);
    152     glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
    153     glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
    154 #endif
    155     m_shader->Bind();
    156     m_font->Bind();
    157     m_shader->SetUniform(m_texture, 0);
    158     m_shader->SetUniform(m_transform, xform);
    159     m_shader->SetUniform(m_datasize, vec2(m_canvas_size.x,
     152        glEnable(GL_POINT_SPRITE);
     153        //glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
     154        glDisable(GL_POINT_SMOOTH);
     155        glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
     156        glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
     157#endif
     158        m_shader->Bind();
     159        m_font->Bind();
     160        m_shader->SetUniform(m_texture, 0);
     161        m_shader->SetUniform(m_transform, xform);
     162        m_shader->SetUniform(m_datasize, vec2(m_canvas_size.x,
    160163                                          max(m_font_size.x, m_font_size.y)));
    161     m_vdecl->SetStream(m_vbo1, m_color);
    162     m_vdecl->SetStream(m_vbo2, m_char);
     164        m_vdecl->SetStream(m_vbo1, m_color);
     165        m_vdecl->SetStream(m_vbo2, m_char);
    163166#if !HAVE_SHADER_4
    164     m_vdecl->SetStream(m_vbo3, m_vertexid);
    165 #endif
    166     m_vdecl->Bind();
    167     m_vdecl->DrawElements(MeshPrimitive::Points, 0, m_cells);
    168     m_vdecl->Unbind();
    169     m_font->Unbind();
    170     m_shader->Unbind();
     167        m_vdecl->SetStream(m_vbo3, m_vertexid);
     168#endif
     169        m_vdecl->Bind();
     170        m_vdecl->DrawElements(MeshPrimitive::Points, 0, m_cells);
     171        m_vdecl->Unbind();
     172        m_font->Unbind();
     173        m_shader->Unbind();
    171174#if !defined HAVE_GLES_2X
    172     glDisable(GL_POINT_SPRITE);
    173 #endif
     175        glDisable(GL_POINT_SPRITE);
     176#endif
     177    }
    174178    m_fbo->Unbind();
    175179}
     
    182186    uint64_t const &x = *(uint64_t const *)&t;
    183187
    184     glDisable(GL_BLEND);
     188    RenderContext rc;
     189    rc.SetAlphaBlend(false);
     190
    185191    glEnable(GL_TEXTURE_2D);
    186192    glBindTexture(GL_TEXTURE_2D, (int)x);
  • trunk/tutorial/08_fbo.cpp

    r2748 r2752  
    8484        }
    8585
     86        /* FIXME: we should just disable depth test in the shader */
     87        RenderContext rc;
     88        rc.SetDepthTest(false);
     89
    8690        m_fbo->Bind();
    87         /* FIXME: we should just disable depth test in the shader */
    88         Video::Clear(ClearMask::Depth);
    8991        m_shader->Bind();
    9092
Note: See TracChangeset for help on using the changeset viewer.