Changeset 2773


Ignore:
Timestamp:
Jun 23, 2013, 3:39:00 PM (8 years ago)
Author:
sam
Message:

gpu: implement polygon rendering mode in GL and D3D.

Location:
trunk/src
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gpu/rendercontext.cpp

    r2772 r2773  
    6060    TrackedState<BlendFunc> m_blend_src, m_blend_dst;
    6161    TrackedState<DepthFunc> m_depth_func;
    62     TrackedState<CullMode> m_face_culling;
     62    TrackedState<CullMode> m_cull_mode;
     63    TrackedState<PolygonMode> m_polygon_mode;
    6364};
    6465
     
    9495        g_renderer->SetDepthFunc(m_data->m_depth_func.GetValue());
    9596
    96     if (m_data->m_face_culling.HasChanged())
    97         g_renderer->SetFaceCulling(m_data->m_face_culling.GetValue());
     97    if (m_data->m_cull_mode.HasChanged())
     98        g_renderer->SetCullMode(m_data->m_cull_mode.GetValue());
     99
     100    if (m_data->m_polygon_mode.HasChanged())
     101        g_renderer->SetPolygonMode(m_data->m_polygon_mode.GetValue());
    98102
    99103    delete m_data;
     
    152156}
    153157
    154 void RenderContext::SetFaceCulling(CullMode mode)
     158void RenderContext::SetCullMode(CullMode mode)
    155159{
    156     if (!m_data->m_face_culling.HasChanged())
    157         m_data->m_face_culling.TrackValue(g_renderer->GetFaceCulling());
     160    if (!m_data->m_cull_mode.HasChanged())
     161        m_data->m_cull_mode.TrackValue(g_renderer->GetCullMode());
    158162
    159     g_renderer->SetFaceCulling(mode);
     163    g_renderer->SetCullMode(mode);
     164}
     165
     166void RenderContext::SetPolygonMode(PolygonMode mode)
     167{
     168    if (!m_data->m_polygon_mode.HasChanged())
     169        m_data->m_polygon_mode.TrackValue(g_renderer->GetPolygonMode());
     170
     171    g_renderer->SetPolygonMode(mode);
    160172}
    161173
  • trunk/src/gpu/renderer.cpp

    r2772 r2773  
    6464    BlendFunc m_blend_src, m_blend_dst;
    6565    DepthFunc m_depth_func;
    66     CullMode m_face_culling;
     66    CullMode m_cull_mode;
     67    PolygonMode m_polygon_mode;
    6768
    6869private:
     
    156157    SetDepthFunc(DepthFunc::LessOrEqual);
    157158
    158     m_data->m_face_culling = CullMode::Disabled;
    159     SetFaceCulling(CullMode::CounterClockwise);
     159    m_data->m_cull_mode = CullMode::Disabled;
     160    SetCullMode(CullMode::CounterClockwise);
     161
     162    m_data->m_polygon_mode = PolygonMode::Point;
     163    SetPolygonMode(PolygonMode::Fill);
    160164
    161165    /* Add some rendering states that we don't export to the user */
     
    601605 */
    602606
    603 void Renderer::SetFaceCulling(CullMode mode)
    604 {
    605     if (m_data->m_face_culling == mode)
     607void Renderer::SetCullMode(CullMode mode)
     608{
     609    if (m_data->m_cull_mode == mode)
    606610        return;
    607611
     
    638642#endif
    639643
    640     m_data->m_face_culling = mode;
    641 }
    642 
    643 CullMode Renderer::GetFaceCulling() const
    644 {
    645     return m_data->m_face_culling;
     644    m_data->m_cull_mode = mode;
     645}
     646
     647CullMode Renderer::GetCullMode() const
     648{
     649    return m_data->m_cull_mode;
     650}
     651
     652/*
     653 * Polygon rendering mode
     654 */
     655
     656void Renderer::SetPolygonMode(PolygonMode mode)
     657{
     658    if (m_data->m_polygon_mode == mode)
     659        return;
     660
     661#if defined USE_D3D9 || defined _XBOX
     662    switch (mode)
     663    {
     664    case PolygonMode::Point:
     665        m_data->m_d3d_dev->SetRenderState(D3DRS_FILLMODE, D3DFILL_POINT);
     666        break;
     667    case PolygonMode::Line:
     668        m_data->m_d3d_dev->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
     669        break;
     670    case PolygonMode::Fill:
     671        m_data->m_d3d_dev->SetRenderState(D3DRS_FILLMODE, D3DCULL_SOLID);
     672        break;
     673    }
     674#else
     675    switch (mode)
     676    {
     677    case PolygonMode::Point:
     678        glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
     679        break;
     680    case PolygonMode::Line:
     681        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
     682        break;
     683    case PolygonMode::Fill:
     684        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
     685        break;
     686    }
     687#endif
     688
     689    m_data->m_polygon_mode = mode;
     690}
     691
     692PolygonMode Renderer::GetPolygonMode() const
     693{
     694    return m_data->m_polygon_mode;
    646695}
    647696
  • trunk/src/lol/gpu/rendercontext.h

    r2768 r2773  
    3434    void SetBlendFunc(BlendFunc src, BlendFunc dst);
    3535    void SetDepthFunc(DepthFunc func);
    36     void SetFaceCulling(CullMode mode);
     36    void SetCullMode(CullMode mode);
     37    void SetPolygonMode(PolygonMode mode);
    3738
    3839private:
  • trunk/src/lol/gpu/renderer.h

    r2770 r2773  
    8686};
    8787
     88/* A safe enum to indicate the polygon mode. */
     89struct PolygonMode
     90{
     91    enum Value
     92    {
     93        Fill,
     94        Line,
     95        Point,
     96    }
     97    m_value;
     98
     99    inline PolygonMode() : m_value(Fill) {}
     100    inline PolygonMode(Value v) : m_value(v) {}
     101    inline operator Value() { return m_value; }
     102};
     103
    88104/* A safe enum to indicate the depth test mode. */
    89105struct DepthFunc
     
    165181    DepthFunc GetDepthFunc() const;
    166182
    167     void SetFaceCulling(CullMode mode);
    168     CullMode GetFaceCulling() const;
     183    void SetCullMode(CullMode mode);
     184    CullMode GetCullMode() const;
     185
     186    void SetPolygonMode(PolygonMode mode);
     187    PolygonMode GetPolygonMode() const;
    169188
    170189private:
  • trunk/src/video.cpp

    r2772 r2773  
    7676//            else
    7777//                SetFaceCulling(true);
    78             glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
     78//            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    7979#endif
    8080            break;
     
    9999#elif defined HAVE_GLES_2X
    100100#else
    101             glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
     101//            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    102102#endif
    103103            break;
Note: See TracChangeset for help on using the changeset viewer.