Engineevebeberb.rar

  • vadimka
    了解作者
  • Visual C++
    开发工具
  • 614KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2021-04-06 05:06
    上传日期
ry5659p[]\\=0-0898765y4tnm,.=-76,.0i
Engineevebeberb.rar
  • Engine
  • bin
  • Engine.exe
    436.5KB
  • Engine.ipdb
    62KB
  • Engine.pdb
    860KB
  • Engine.iobj
    155.1KB
  • Device.cpp
    1.8KB
  • main.cpp
    1.8KB
  • input.hpp
    794B
  • Engine.vcxproj.filters
    4.4KB
  • app.hpp
    763B
  • vector4.hpp
    2.2KB
  • bitmap.bmp
    392.6KB
  • input.cpp
    2KB
  • color.hpp
    1.1KB
  • app.cpp
    1.7KB
  • Engine.aps
    420.8KB
  • vertex_declaration.hpp
    427B
  • sound.hpp
    1KB
  • Engine.vcxproj
    8.7KB
  • resource.hpp
    489B
  • icon.ico
    25KB
  • vertex_buffer.hpp
    603B
  • index_buffer.cpp
    530B
  • buffer.hpp
    877B
  • Device.hpp
    586B
  • vertex_buffer.cpp
    574B
  • splash.hpp
    268B
  • delegate.hpp
    224B
  • vector2.hpp
    5.3KB
  • vertex_declaration.cpp
    0B
  • define_type.hpp
    292B
  • sound.cpp
    3.2KB
  • splash.cpp
    626B
  • additional.hpp
    488B
  • main.hpp
    754B
  • Engine.sln
    1.4KB
  • timer.hpp
    1.7KB
  • index_buffer.hpp
    480B
  • Engine.vcxproj.user
    168B
  • matrix.hpp
    13.1KB
  • vector3.hpp
    4.7KB
  • Engine.rc
    2.5KB
内容介绍
#include "sound.hpp" Sound::Sound(void) { device = nullptr; primary = nullptr; } Sound::~Sound(void) { if (playlist.size()>null) { for (unsigned int i = null; i < playlist.size(); i++) { RELEASE(playlist[i].buffer); } } RELEASE(primary); RELEASE(device); } void Sound::initialization(HWND hwnd) { DSBUFFERDESC bd; WAVEFORMATEX wfx; DirectSoundCreate8(nullptr, &device, nullptr); device->SetCooperativeLevel(hwnd, DSSCL_PRIORITY); bd.dwSize = sizeof(DSBUFFERDESC); bd.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME; bd.dwBufferBytes = null; bd.dwReserved = null; bd.lpwfxFormat = null; bd.guid3DAlgorithm = GUID_NULL; device->CreateSoundBuffer(&bd, &primary, nullptr); wfx.wFormatTag = WAVE_FORMAT_PCM; wfx.nSamplesPerSec = 44100; wfx.wBitsPerSample = 16; wfx.nChannels = 2; wfx.nBlockAlign = (wfx.wBitsPerSample / 8) * wfx.nChannels; wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; wfx.cbSize = null; primary->SetFormat(&wfx); } void Sound::destroy(void) { delete this; } void Sound::add(string filename) { FILE * ptr_file; uchar * buffer_data; uchar * buffer_ptr; ulong buffer_size; WavFileFormat wav; WAVEFORMATEX wfx; DSBUFFERDESC bd; IDirectSoundBuffer * temp = nullptr; IDirectSoundBuffer8 * SoundBuffer = nullptr; fopen_s(&ptr_file, filename, "rb"); fread(&wav, sizeof(wav), 1, ptr_file); wfx.wFormatTag = WAVE_FORMAT_PCM; wfx.nSamplesPerSec = 44100; wfx.wBitsPerSample = 16; wfx.nChannels = 2; wfx.nBlockAlign = (wfx.wBitsPerSample / 8) * wfx.nChannels; wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; wfx.cbSize = null; bd.dwSize = sizeof(DSBUFFERDESC); bd.dwFlags = DSBCAPS_CTRLVOLUME; bd.dwBufferBytes = wav.dataSize; bd.dwReserved = null; bd.lpwfxFormat = &wfx; bd.guid3DAlgorithm = GUID_NULL; device->CreateSoundBuffer(&bd, &temp, NULL); temp->QueryInterface(IID_IDirectSoundBuffer8, (void**)&SoundBuffer); temp->Release(); temp = nullptr; fseek(ptr_file, sizeof(WavFileFormat), SEEK_SET); buffer_data = new unsigned char[wav.dataSize]; fread(buffer_data, 1, wav.dataSize, ptr_file); fclose(ptr_file); SoundBuffer->Lock(0, wav.dataSize, (void**)&buffer_ptr, (DWORD*)&buffer_size, nullptr, null, null); memcpy(buffer_ptr, buffer_data, wav.dataSize); SoundBuffer->Unlock((void*)buffer_ptr, buffer_size, nullptr, null); BufferSound track; track.buffer = SoundBuffer; track.id = filename; playlist.push_back(track); delete[] buffer_data; buffer_data = nullptr; } void Sound::release(string filename) { for (uint i = null; i < playlist.size(); i++) { if (playlist[i].id == filename) { RELEASE(playlist[i].buffer); } } } void Sound::play(string filename) { for (uint i = null; i < playlist.size(); i++) { if (playlist[i].id == filename) { playlist[i].buffer->SetCurrentPosition(null); playlist[i].buffer->SetVolume(DSBVOLUME_MAX); playlist[i].buffer->Play(null, null, null); } } } void Sound::stop(string filename) { for (uint i = null; i < playlist.size(); i++) { if (playlist[i].id == filename) { playlist[i].buffer->Stop(); } } }
评论
    相关推荐
    • 3D Game Engine Design
      Now considered an essential reference in the game industry, 3D Game Engine Design is the first book to go beyond basic descriptions of algorithms and accurately demonstrate the complex engineering ...
    • java game engine
      sgs-client-src-0.9.5.1-r3730.zip
    • GameEngine
      游戏引擎 一个简单的游戏引擎,用于在3D球形上创建受Snake启发的游戏。 该引擎使用OpenGL和SDL并依赖于Assimp和stb进行模型加载。
    • GameEngine-SuperMarioBros
      开发智能界面和游戏 超级马里奥的实施 团队 Antonis Pantelakis Giorgos Stavros Raptakis Michail 关于实施 这项工作的实现是在Microsoft Visual Studio 2019的环境中完成的。 对于图形,使用了Allegro5库,...
    • GameEngine2DWithJavaScript
      GameEngine2DWithJavaScript 该项目旨在开发基本的GameEngine并仅使用JavaScript轻松创建,并且其中制作的游戏将直接由浏览器执行 开发始于02/26/2021,当时我的目标是了解仅使用纯JavaScript可以走多远,并且有...
    • GameEngine_App
      GameEngine_App Direct3D VC++ 視窗原碼
    • Game Engine Gems
      Game Engine Gems 游戏引擎精粹
    • GameEngine
      游戏引擎
    • GameEngine_Timer
      GameEngine_Timer VC++ 時間計算原碼
    • Game Engine Architecture.zip
      Game Engine Architecture Second edition 2014