Ignore:
Timestamp:
Feb 5, 2013, 5:07:09 PM (7 years ago)
Author:
touky
Message:

render : Added DebugRenderMode & corresponding shaders. naive (VERY) implementation in MeshViewer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/video.cpp

    r2216 r2370  
    5252    static mat4 proj_matrix;
    5353    static ivec2 saved_viewport;
     54    static DebugRenderMode render_mode;
    5455#if defined USE_D3D9 || defined _XBOX
    5556#   if defined USE_D3D9
     
    6768mat4 VideoData::proj_matrix;
    6869ivec2 VideoData::saved_viewport(0, 0);
     70DebugRenderMode VideoData::render_mode = DebugRenderMode::Default;
    6971
    7072#if defined USE_D3D9 || defined _XBOX
     
    154156    SetClearColor(vec4(0.1f, 0.2f, 0.3f, 1.0f));
    155157    SetClearDepth(1.f);
     158    SetDebugRenderMode(DebugRenderMode::Default);
    156159}
    157160
     
    231234    glClearDepth(f);
    232235#endif
     236}
     237
     238void Video::SetDebugRenderMode(DebugRenderMode d)
     239{
     240    if (d == DebugRenderMode::Max)
     241        return;
     242
     243    switch(d)
     244    {
     245        //All these modes are handled in the shaders.
     246        case DebugRenderMode::Default:
     247        case DebugRenderMode::Lighting:
     248        case DebugRenderMode::Normal:
     249        case DebugRenderMode::UV:
     250        {
     251#if defined USE_D3D9 || defined _XBOX
     252#else
     253            glEnable(GL_CULL_FACE);
     254            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
     255#endif
     256            break;
     257        }
     258        case DebugRenderMode::Wireframe:
     259        {
     260            if (VideoData::render_mode == DebugRenderMode::Wireframe)
     261            {
     262#if defined USE_D3D9 || defined _XBOX
     263#else
     264                if (glIsEnabled(GL_CULL_FACE) == GL_TRUE)
     265                    glDisable(GL_CULL_FACE);
     266                else
     267                    glEnable(GL_CULL_FACE);
     268#endif
     269            }
     270            else
     271            {
     272#if defined USE_D3D9 || defined _XBOX
     273#else
     274                glDisable(GL_CULL_FACE);
     275#endif
     276            }
     277#if defined USE_D3D9 || defined _XBOX
     278#else
     279            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
     280#endif
     281            break;
     282        }
     283    }
     284    VideoData::render_mode = d;
     285}
     286
     287DebugRenderMode Video::GetDebugRenderMode()
     288{
     289    return VideoData::render_mode;
    233290}
    234291
Note: See TracChangeset for help on using the changeset viewer.