void TerrainEntity::InitRenderable() { //m_pRenderable = new TerrainRenderable(this); m_pRenderable = (TerrainRenderable*)new TerrainRenderablePlane(this); m_pRenderable->LoadFromFile(); SetPostion(0, 0, 0); }
DWORD CAbstractFileData::Close() { UnmapViewOfFile(m_pByteBuf); CloseHandle(m_hMapFile); SetPostion(0); m_pByteBuf = NULL; m_hMapFile = INVALID_HANDLE_VALUE; return 0; }
DWORD CAbstractFileData::Open(TCHAR *FileName) { HANDLE hFile = CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ ,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(hFile==INVALID_HANDLE_VALUE) { return 0; } m_dwBUFSize = GetFileSize(hFile, NULL); m_hMapFile = CreateFileMapping( hFile, // use paging file NULL, // default security PAGE_READONLY, // read/write access 0, // max. object size m_dwBUFSize, // buffer size NULL); // name of mapping object if (m_hMapFile == NULL || m_hMapFile == INVALID_HANDLE_VALUE) { _tprintf(_T("Could not create file mapping object with %s, error(%d).\n"), FileName, GetLastError()); CloseHandle(hFile); return 0; } m_pByteBuf = (PBYTE) MapViewOfFile( m_hMapFile, // handle to mapping object FILE_MAP_READ, // read/write permission 0, 0, m_dwBUFSize); CloseHandle(hFile); if (m_pByteBuf == NULL) { return 0; } SetPostion(0); return 1; }
CAbstractFileData::CAbstractFileData(void) { m_pByteBuf = NULL; m_hMapFile = INVALID_HANDLE_VALUE; SetPostion(0); }