예제 #1
0
    CTexture* CGraphicsDeviceGLES2::CreateTexture(
        IZ_UINT width,
        IZ_UINT height,
        E_GRAPH_PIXEL_FMT fmt,
        void* data)
    {
        CTexture* texture = CreateTexture(
            width, height, 1,
            fmt,
            E_GRAPH_RSC_USAGE_STATIC);
        VRETURN_NULL(texture != IZ_NULL);

        void* dst = IZ_NULL;
        VRETURN_NULL(
            texture->Lock(0, (void**)&dst, IZ_FALSE));

        IZ_UINT bpp = CGraphUtil::GetBPP(fmt);
        IZ_UINT size = width * height * bpp;

        memcpy(dst, data, size);

        texture->Unlock(0);

        return texture;
    }
예제 #2
0
    ObjModel* ObjModel::create(
        izanagi::IMemoryAllocator* allocator,
        izanagi::graph::CGraphicsDevice* device,
        const char* path)
    {
        void* buf = ALLOC(allocator, sizeof(ObjModel));
        VRETURN_NULL(buf);

        IZ_BOOL result = IZ_FALSE;

        ObjModel* instance = new(buf)ObjModel;
        {
            instance->m_Allocator = allocator;
            instance->AddRef();

            result = instance->load(
                allocator,
                device,
                path);
        }

        if (!result) {
            SAFE_RELEASE(instance);
        }

        return instance;
    }
예제 #3
0
    // インスタンス作成
    CWindow* CWindow::Create(
        IMemoryAllocator* allocator,
        HINSTANCE hInst,
        HWND hWnd,
        HDC hDC)
    {
        void* buf = ALLOC_ZERO(allocator, sizeof(CWindow));
        VRETURN_NULL(buf != IZ_NULL);

        CWindow* window = new(buf) CWindow(hInst, hWnd, hDC);
        window->m_Allocator = allocator;

        return window;
    }
예제 #4
0
AnimationStateMachine* AnimationStateMachine::create(IMemoryAllocator* allocator)
{
    void* buf = ALLOC(allocator, sizeof(AnimationStateMachine));
    VRETURN_NULL(buf);

    AnimationStateMachine* ret = new(buf)AnimationStateMachine;
    {
        ret->m_Allocator = allocator;

        //ret->m_blendAnm = izanagi::IAnimationBlender::CreateAnmBlender<izanagi::CAnmLinearBlender>(allocator);
        ret->m_blendAnm = izanagi::CAnimationInterp::CreateAnimationInterp(allocator);
        IZ_ASSERT(ret->m_blendAnm);

        ret->AddRef();
    }

    return ret;
}
예제 #5
0
    CShaderConstTableLite* CShaderConstTableLite::CreateShaderConstTableLite(
        IMemoryAllocator* allocator,
        IZ_PCSTR path)
    {
        void *buf = ALLOC(allocator, sizeof(CShaderConstTableLite));
        VRETURN_NULL(buf != IZ_NULL);

        IZ_BOOL result = IZ_TRUE;

        CShaderConstTableLite* instance = new(buf) CShaderConstTableLite;
        {
            instance->AddRef();
            instance->m_Allocator = allocator;

            izanagi::CFileInputStream input;
            result = input.Open(path);
            VGOTO(result, __EXIT__);

            void* program = ALLOC(allocator, (size_t)input.GetSize());
            result = (program != IZ_NULL);
            VGOTO(result, __EXIT__);

            input.Read(program, 0, (size_t)input.GetSize());

            // シェーダ定数テーブル取得
            HRESULT hr = D3DXGetShaderConstantTable(
                    (const DWORD*)program,
                    &instance->m_ConstTable);
            result = SUCCEEDED(hr);

            result = (instance->m_ConstTable != IZ_NULL);
            IZ_ASSERT(result);

            FREE(allocator, program);
        }

__EXIT__:
        if (!result) {
            SAFE_RELEASE(instance);
        }
        return instance;
    }
예제 #6
0
    IArchive* CArchiveTar::CreateArchive(
        IMemoryAllocator* allocator,
        IInputStream* input)
    {
        void* p = ALLOC(allocator, sizeof(CArchiveTar));
        VRETURN_NULL(p);

        CArchiveTar* instance = new(p) CArchiveTar;
        {
            instance->AddRef();

            instance->m_Allocator = allocator;
            instance->m_Input = input;

            while (input->GetCurPos() < input->GetSize()) {
                CTarHeader* tarHeader = CTarHeader::Create(allocator, input);

                IZ_UINT offset = tarHeader->GetBytes();
                
                if (tarHeader == IZ_NULL) {
                    break;
                }
                else if (tarHeader->typeflag != '0') {
                    FREE(allocator, tarHeader);
                }
                else {
                    instance->m_Headers.Add(tarHeader->GetHashItem());
                }

                IZ_UINT odd = (offset & 511);

                if (odd > 0) {
                    offset += 512 - odd;
                }
                
                input->Seek(offset, E_IO_STREAM_SEEK_POS_CUR);
            }
        }

        return instance;
    }
예제 #7
0
izanagi::threadmodel::CJob* TextureLoader::EnqueueLoadingRequest(
    izanagi::graph::CGraphicsDevice* device,
    const char* path,
    Item* target)
{
    IZ_ASSERT(m_Allocator != IZ_NULL);

    // Create loading texture job.
    LoadTextureJob* job = (LoadTextureJob*)izanagi::threadmodel::CJob::CreateJob<LoadTextureJob>(m_Allocator);
    VRETURN_NULL(job != IZ_NULL);

    job->Init(
        &m_JobSafeAllocator,
        device,
        path,
        target);

    m_JobQueue.Enqueue(job, IZ_TRUE);

    return job;
}
예제 #8
0
    CArchiveTar::CTarHeader* CArchiveTar::CTarHeader::Create(
        IMemoryAllocator* allocator,
        IInputStream* in)
    {
        void* p = ALLOC(allocator, sizeof(CTarHeader));
        VRETURN_NULL(p);

        CTarHeader* instance = new(p) CTarHeader;
        {
            IZ_INPUT_READ(in, instance, 0, sizeof(TarHeader));

            CKey key(instance->name);
            instance->m_HashItem.Init(key, instance);

            instance->m_Bytes = _OctalStringToInt(instance->size, COUNTOF(instance->size));

            instance->m_Pos = (IZ_UINT)in->GetCurPos();
        }

        return instance;
    }
예제 #9
0
    // ウインドウ作成.
    WindowHandle CSysWindow::Create(
        IMemoryAllocator* allocator,
        const WindowParams& param)
    {
        IZ_ASSERT(allocator != IZ_NULL);

        HINSTANCE hInst = (HINSTANCE)param.platformParam;
        IZ_ASSERT(hInst != IZ_NULL);

        WNDCLASSEX wcex;
        {
            wcex.cbSize         = sizeof(WNDCLASSEX);
            wcex.style          = CS_HREDRAW | CS_VREDRAW;
            wcex.lpfnWndProc    = WndProc;
            wcex.cbClsExtra     = 0;
            wcex.cbWndExtra     = 0;
            wcex.hInstance      = hInst;
            wcex.hIcon          = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
            wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
            //wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW + 1); // システムカラー(白色)
            wcex.hbrBackground  = (HBRUSH)::GetStockObject(BLACK_BRUSH);
            wcex.lpszMenuName   = NULL;
            wcex.lpszClassName  = (param.title != IZ_NULL ? param.title : registerName);
            wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));

            VRETURN_NULL(RegisterClassEx(&wcex));
        }

        DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
        DWORD exStyle = 0;

        RECT rect = {
            0, 0,
            param.width,
            param.height
        };

        if (param.isWindowed) {
            style |= WS_OVERLAPPEDWINDOW;

            // TODO
            // 最大化、最小化ボタンは無し
            //style &= ~WS_MINIMIZEBOX;
            style &= ~WS_MAXIMIZEBOX;

            // TODO
            // サイズ変更無効化
            style &= ~WS_THICKFRAME;

            exStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;

            // ウインドウモード
            VRETURN_NULL(
                ::AdjustWindowRect(
                    &rect,
                    style,
                    FALSE));

            rect.right = rect.right - rect.left;
            rect.bottom = rect.bottom - rect.top;
            rect.left = CW_USEDEFAULT;
            rect.top = CW_USEDEFAULT;
        }
        else {
            // フルスクリーンモード
            style |= WS_POPUP;
            exStyle = WS_EX_APPWINDOW;
        }

        // ウインドウ作成
        HWND hWnd = ::CreateWindowExA(
                        exStyle,
                        wcex.lpszClassName,
                        param.title,
                        style,
                        rect.left, rect.top,
                        rect.right, rect.bottom,
                        NULL,
                        NULL,
                        hInst,
                        NULL);
        VRETURN_NULL(hWnd != NULL);

        // ウインドウ表示
        ::ShowWindow(hWnd, SW_SHOWNORMAL);
        ::SetFocus(hWnd);
        ::SetForegroundWindow(hWnd);

        ::UpdateWindow(hWnd);

        HDC hDC = ::GetDC(hWnd);
        VRETURN_NULL(hDC != NULL);

        CWindow* window = CWindow::Create(
                            allocator,
                            hInst,
                            hWnd,
                            hDC);
        IZ_ASSERT(window != IZ_NULL);

        // メッセージハンドラを保持
        if (param.handler) {
            sMsgHandlerMgr.Register(param.handler, hWnd);
        }

        return window;
    }