微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

OGLplus OpenGL的C++封装库

程序名称:OGLplus

授权协议: Boost

操作系统: Linux

开发语言: C/C++

OGLplus 介绍

OGLplus (oglplus) 是一个仅包含头文件的 C 语言库,用于实现一个瘦面向对象的 OpenGL
门面操作接口,提供了自动资源和对象管理的封装,让在 C
中使用 OpenGL 更加简单和安全。

示例代码

#include <oalplus/al.hpp>
#include <oalplus/all.hpp>
#include <oalplus/alut.hpp>

#include <chrono>
#include <thread>

int main(int argc, char** argv)
{
    // open the default device
    oalplus::Device device;
    // create a context using the device and make it current
    oalplus::CurrentContext context(device);
    // create an instance of ALUT
    oalplus::ALUtilityToolkit alut(false, argc, argv);
    // create a listener and set its position, veLocity and orientation
    oalplus::Listener listener;
    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);
    // create a Hello World sound and store it into a buffer
    oalplus::Buffer buffer = alut.CreateBufferHelloWorld();
    // create a source from the data in buffer and set its position
    oalplus::Source source;
    source.Buffer(buffer);
    source.Position(0.0f, 0.0f,-1.0f);
    // let the source play the sound
    source.Play();
    // wait for a while
    std::chrono::seconds duration(2);
    std::this_thread::sleep_for(duration);
    //
    return 0;
}

OGLplus 官网

http://oglplus.org/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐