Changeset 1236


Ignore:
Timestamp:
Apr 18, 2012, 8:20:30 PM (8 years ago)
Author:
sam
Message:

gpu: replace exit(0) in D3D error checks with lol::Abort().

Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r1224 r1236  
    33
    44liblol_a_SOURCES = \
    5     core.h tiler.cpp tiler.h dict.cpp dict.h \
     5    core.h tiler.cpp tiler.h dict.cpp dict.h debug/debug.h \
    66    audio.cpp audio.h scene.cpp scene.h font.cpp font.h layer.cpp layer.h \
    77    map.cpp map.h entity.cpp entity.h ticker.cpp ticker.h lolgl.h \
  • trunk/src/core.h

    r1227 r1236  
    7272
    7373// Static classes
     74#include "debug/debug.h"
    7475#include "log.h"
    7576#include "platform.h"
  • trunk/src/gpu/vertexbuffer.cpp

    r1234 r1236  
    9898#   endif
    9999
    100     vdecl->Release();
     100    if (FAILED(vdecl->Release()))
     101        Abort();
    101102#else
    102103
     
    113114#   endif
    114115
    115     g_d3ddevice->SetVertexDeclaration(vdecl);
     116    if (FAILED(g_d3ddevice->SetVertexDeclaration(vdecl)))
     117        Abort();
    116118#else
    117119    /* FIXME: Nothing to do? */
     
    122124{
    123125#if defined _XBOX || defined USE_D3D9
    124     g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
     126    if (FAILED(g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW)))
     127        Abort();
    125128    switch (type)
    126129    {
    127130    case MeshPrimitive::Triangles:
    128         g_d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST, skip, count);
     131        if (FAILED(g_d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST, skip, count)))
     132            Abort();
    129133        break;
    130134    }
     
    194198    /* FIXME: precompute most of the crap above! */
    195199    if (stream >= 0)
    196         g_d3ddevice->SetStreamSource(stream, vb->m_data->m_vbo, 0, stride);
     200    {
     201        if (FAILED(g_d3ddevice->SetStreamSource(stream, vb->m_data->m_vbo, 0, stride)))
     202            Abort();
     203    }
    197204#else
    198205    glBindBuffer(GL_ARRAY_BUFFER, vb->m_data->m_vbo);
     
    335342#   endif
    336343
    337     g_d3ddevice->CreateVertexDeclaration(elements, &vdecl);
     344    if (FAILED(g_d3ddevice->CreateVertexDeclaration(elements, &vdecl)))
     345        Abort();
    338346
    339347    m_data = vdecl;
     
    366374{
    367375#if defined USE_D3D9 || defined _XBOX
    368     g_d3ddevice->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, NULL,
    369                                     D3DPOOL_MANAGED, &m_data->m_vbo, NULL);
     376    if (FAILED(g_d3ddevice->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, NULL,
     377                                               D3DPOOL_MANAGED, &m_data->m_vbo, NULL)))
     378        Abort();
    370379    new uint8_t[size];
    371380#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
     
    379388{
    380389#if defined USE_D3D9 || defined _XBOX
    381     m_data->m_vbo->Release();
     390    if (FAILED(m_data->m_vbo->Release()))
     391        Abort();
    382392#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
    383393    glDeleteBuffers(1, &m_data->m_vbo);
     
    391401    void *ret;
    392402    if (FAILED(m_data->m_vbo->Lock(offset, size, (void **)&ret, 0)))
    393         exit(0);
     403        Abort();
    394404    return ret;
    395405#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
     
    401411{
    402412#if defined USE_D3D9 || defined _XBOX
    403     m_data->m_vbo->Unlock();
     413    if (FAILED(m_data->m_vbo->Unlock()))
     414        Abort();
    404415#elif !defined __CELLOS_LV2__ && !defined __ANDROID__
    405416    glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vbo);
  • trunk/src/platform/sdl/sdlapp.cpp

    r1212 r1236  
    103103    {
    104104#if defined USE_SDL && defined USE_D3D9
    105         g_d3ddevice->BeginScene();
     105        if (FAILED(g_d3ddevice->BeginScene()))
     106            Abort();
    106107#endif
    107108        /* Tick the renderer, show the frame and clamp to desired framerate. */
     
    109110#if defined USE_SDL
    110111#   if defined USE_D3D9
    111         g_d3ddevice->EndScene();
    112         g_d3ddevice->Present(NULL, NULL, NULL, NULL);
     112        if (FAILED(g_d3ddevice->EndScene()))
     113            Abort();
     114        if (FAILED(g_d3ddevice->Present(NULL, NULL, NULL, NULL)))
     115            Abort();
    113116#   else
    114117        SDL_GL_SwapBuffers();
  • trunk/src/scene.cpp

    r1234 r1236  
    1919#   define WIN32_LEAN_AND_MEAN
    2020#   include <windows.h>
    21 #   if defined USE_D3D9
    22 #       define FAR
    23 #       define NEAR
    24 #       include <d3d9.h>
    25 #   endif
    2621#endif
    2722
    2823#include "core.h"
    2924#include "lolgl.h"
    30 
    31 #if defined USE_D3D9
    32 extern IDirect3DDevice9 *g_d3ddevice;
    33 #elif defined _XBOX
    34 extern D3DDevice *g_d3ddevice;
    35 #endif
    3625
    3726namespace lol
     
    10796        delete data->bufs[i];
    10897    free(data->bufs);
     98
    10999    delete data->m_vdecl;
    110100    delete data;
  • trunk/src/video.cpp

    r1233 r1236  
    229229    ivec2 size = GetSize();
    230230#if defined USE_D3D9 || defined _XBOX
    231     VideoData::d3d_dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER
     231    if (FAILED(VideoData::d3d_dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER
    232232                                        | D3DCLEAR_STENCIL,
    233                               VideoData::clear_color, 1.0f, 0);
     233                              VideoData::clear_color, 1.0f, 0)))
     234        Abort();
    234235#else
    235236    glViewport(0, 0, size.x, size.y);
  • trunk/test/tutorial/tut01.cpp

    r1231 r1236  
    8787
    8888        m_shader->Bind();
     89        m_vdecl->SetStream(m_vbo, m_coord);
    8990        m_vdecl->Bind();
    90         m_vdecl->SetStream(m_vbo, m_coord);
    9191        m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 1);
    9292        m_vdecl->Unbind();
  • trunk/test/tutorial/tut02.cpp

    r1233 r1236  
    168168            int16_t *indices;
    169169            if (FAILED(g_d3ddevice->CreateIndexBuffer(sizeof(m_indices), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_ibo, NULL)))
    170                 exit(0);
     170                Abort();
    171171            if (FAILED(m_ibo->Lock(0, 0, (void **)&indices, 0)))
    172                 exit(0);
     172                Abort();
    173173            memcpy(indices, m_indices, sizeof(m_indices));
    174174            m_ibo->Unlock();
     
    181181        }
    182182
     183    Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
     184
    183185        m_shader->Bind();
    184186        m_shader->SetUniform(m_mvp, m_matrix);
    185         m_vdecl->Bind();
    186187        m_vdecl->SetStream(m_vbo, m_coord);
    187188        m_vdecl->SetStream(m_cbo, m_color);
     189        m_vdecl->Bind();
    188190
    189191#if defined _XBOX || defined USE_D3D9
    190         g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
    191         g_d3ddevice->SetIndices(m_ibo);
    192         g_d3ddevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 0, 0, sizeof(m_indices) / sizeof(*m_indices));
     192        if (FAILED(g_d3ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW)))
     193            Abort();
     194        if (FAILED(g_d3ddevice->SetIndices(m_ibo)))
     195            Abort();
     196        if (FAILED(g_d3ddevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 0, 0, sizeof(m_indices) / sizeof(*m_indices))))
     197            Abort();
    193198#elif !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
    194199        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ibo);
  • trunk/win32/lolcore.vcxproj

    r1224 r1236  
    134134    <ClInclude Include="..\src\debug\sphere.h" />
    135135    <ClInclude Include="..\src\debug\stats.h" />
     136    <ClInclude Include="..\src\debug\debug.h" />
    136137    <ClInclude Include="..\src\dict.h" />
    137138    <ClInclude Include="..\src\eglapp.h" />
Note: See TracChangeset for help on using the changeset viewer.