我在 pendrive 上运行 ubuntu 12.04。我已经安装了 openAL 和 alut我的主要是:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <al.h>
#include <alc.h>
// Buffers hold sound data.
ALuint Buffer;
using namespace std;
string ErrorCheck(ALenum error)
{
if(error == AL_INVALID_NAME)
{
return "Invalid name";
}
else if(error == AL_INVALID_ENUM)
{
return " Invalid enum ";
}
else if(error == AL_INVALID_VALUE)
{
return " Invalid value ";
}
else if(error == AL_INVALID_OPERATION)
{
return " Invalid operation ";
}
else if(error == AL_OUT_OF_MEMORY)
{
return " Out of memory like! ";
}
return " Don't know ";
}
int main(int argc, char **argv)
{
ALenum error;
error = alGetError();
cout << "\n\tInitial error at start of program - " << ErrorCheck(error);
error = alGetError();
cout << "\n\tError persists - " << ErrorCheck(error);
cout << "\n\tGenerating buffer...";
alGenBuffers(1, &Buffer);
error = alGetError();
if(error != AL_NO_ERROR)
{
cout << "\n\tError generating buffer - "<< ErrorCheck(error) << "\n\n";
return 0;
}
return 0;
}
使用该行编译没有错误
g++ main.cpp -I/usr/include/AL -lopenal -lalut
但是当程序运行时,每次调用 alGetError() 都会返回 AL_INVALID_OPERATION我认为调用 alGetError() 是为了重置错误标志,所以我在开始时调用它两次,第二个至少应该不返回错误。我真的卡住了!
我是一名优秀的程序员,十分优秀!