OGLplus(oglplus)是一个仅包含头文件的C++语言库,用于实现一个瘦面向对象的OpenGL门面操作接口,提供了自动资源和对象管理的封装,让在C++中使用OpenGL更加简单和安全。
示例代码:
#include<oalplus/al.hpp>#include<oalplus/all.hpp>#include<oalplus/alut.hpp>#include<chrono>#include<thread>intmain(intargc,char**argv){//openthedefaultdeviceoalplus::Devicedevice;//createacontextusingthedeviceandmakeitcurrentoalplus::CurrentContextcontext(device);//createaninstanceofALUToalplus::ALUtilityToolkitalut(false,argc,argv);//createalistenerandsetitsposition,velocityandorientationoalplus::Listenerlistener;listener.Position(0.0f,0.0f,0.0f);listener.Velocity(0.0f,0.0f,0.0f);listener.Orientation(0.0f,0.0f,-1.0f,0.0f,1.0f,0.0f);//createaHelloWorldsoundandstoreitintoabufferoalplus::Bufferbuffer=alut.CreateBufferHelloWorld();//createasourcefromthedatainbufferandsetitspositionoalplus::Sourcesource;source.Buffer(buffer);source.Position(0.0f,0.0f,-1.0f);//letthesourceplaythesoundsource.Play();//waitforawhilestd::chrono::secondsduration(2);std::this_thread::sleep_for(duration);//return0;}
评论