本文整理汇总了Java中org.lwjgl.openal.AL.create方法的典型用法代码示例。如果您正苦于以下问题:Java AL.create方法的具体用法?Java AL.create怎么用?Java AL.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.openal.AL
的用法示例。
在下文中一共展示了AL.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
/**
* Initialise OpenAL LWJGL styley
*/
public void init() {
try {
AL.create();
soundWorks = true;
} catch (LWJGLException e) {
System.err.println("Failed to initialise LWJGL OpenAL");
soundWorks = false;
return;
}
if (soundWorks) {
IntBuffer sources = BufferUtils.createIntBuffer(1);
AL10.alGenSources(sources);
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
System.err.println("Failed to create sources");
soundWorks = false;
} else {
source = sources.get(0);
}
}
}
示例2: init
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
@Override
public void init() {
if (!AL.isCreated()) {
try {
AL.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
allSources = new IntArray(SIMULTANEOUS_SOURCES_COUNT);
for (int i = 0; i < SIMULTANEOUS_SOURCES_COUNT; i++) {
int sourceID = AL10.alGenSources();
if (AL10.alGetError() == AL10.AL_NO_ERROR) {
allSources.add(sourceID);
}
}
idleSources = new IntArray(allSources);
recentSounds = new SoundPoolImpl[SIMULTANEOUS_SOURCES_COUNT];
AL10.alListener(AL10.AL_ORIENTATION, orientation);
AL10.alListener(AL10.AL_VELOCITY, velocity);
AL10.alListener(AL10.AL_POSITION, position);
}
}
示例3: initialize
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
/**
* Initializes the SoundManager
*
* @param channels Number of channels to create
*/
public void initialize(int channels) {
try {
AL.create();
// allocate sources
scratchBuffer.limit(channels);
AL10.alGenSources(scratchBuffer);
scratchBuffer.rewind();
scratchBuffer.get(sources = new int[channels]);
// could we allocate all channels?
if(AL10.alGetError() != AL10.AL_NO_ERROR) {
throw new LWJGLException("Unable to allocate " + channels + " sources");
}
// we have sound
soundOutput = true;
} catch (LWJGLException le) {
le.printStackTrace();
System.out.println("Sound disabled");
}
}
示例4: BasicTest
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
/**
* Creates an instance of PlayTest
*/
protected BasicTest() {
try {
AL.create();
System.out.println("Default device: " + ALC10.alcGetString(null, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));
if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
String[] devices = ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER).split("\0");
System.out.println("Available devices: ");
for(int i=0; i<devices.length; i++) {
System.out.println(i +": " + devices[i]);
}
}
} catch (Exception e) {
System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
return;
}
}
示例5: execute
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
/**
* Runs the actual test, using supplied arguments
*/
protected void execute(String[] args) {
try {
AL.create(null, -1, 60, false);
checkForErrors();
} catch (LWJGLException le) {
die("Init", le.getMessage());
}
printALCInfo();
printALInfo();
printEFXInfo();
checkForErrors();
AL.destroy();
}
示例6: OpenAL
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
public OpenAL() throws LWJGLException {
try {
AL.create();
} catch (Exception e) {
System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
return;
}
Thread t = new Thread() {
public void run() {
while (true) {
if (isVisible())
repaint();
Display.sync(60);
}
}
};
t.setDaemon(true);
t.start();
}
示例7: init
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
public static final void init() throws InstantiationException {
if (init) {
throw new InstantiationException("[WARNING] Jumbo Audio Player was already initialized!"); //$NON-NLS-1$
}
try {
AL.create();
} catch (LWJGLException le) {
le.printStackTrace();
return;
}
buffer = BufferUtils.createIntBuffer(SOUND_NUM);
AL10.alGenSources(source);
AL10.alGenBuffers(buffer);
buffer.limit(1);
AL10.alDopplerFactor(1.0f);
AL10.alDopplerVelocity(1.0f);
check();
init = true;
}
示例8: Sound
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
public Sound()
{
System.out.print("SFX initialisation");
try
{
AL.create();
IntSource = alGenSources();
}
catch (LWJGLException e)
{
e.printStackTrace();
}
System.out.println(".");
}
示例9: create
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
@Override
public void create(String title) {
setTitle(title);
enableResize(true);
PixelFormat pixelFormat = new PixelFormat();
ContextAttribs contextAtrributes = new ContextAttribs(3, 2)
.withForwardCompatible(true)
.withProfileCore(true);
try {
Display.setDisplayMode(new DisplayMode(getWidth(), getHeight()));
Display.create(pixelFormat, contextAtrributes);
Keyboard.create();
Mouse.create();
AL.create();
drawBuffer = glGetInteger(GL_DRAW_BUFFER);
readBuffer = glGetInteger(GL_READ_BUFFER);
} catch (LWJGLException e) {
LOGGER.error("Error setting up input and window", e);
}
}
示例10: main
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
public static void main(String[] args) throws FileNotFoundException {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.setTitle("OpenAL Demo");
Display.create();
AL.create();
} catch (LWJGLException e) {
e.printStackTrace();
Display.destroy();
AL.destroy();
System.exit(1);
}
WaveData data = WaveData.create(new BufferedInputStream(new FileInputStream("res" + File.separatorChar +
"sounds" + File.separatorChar + "thump.wav")));
int buffer = alGenBuffers();
alBufferData(buffer, data.format, data.data, data.samplerate);
data.dispose();
int source = alGenSources();
alSourcei(source, AL_BUFFER, buffer);
while (!Display.isCloseRequested()) {
while (Keyboard.next()) {
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
alSourcePlay(source);
}
}
Display.update();
Display.sync(60);
}
alDeleteBuffers(buffer);
AL.destroy();
Display.destroy();
System.exit(0);
}
示例11: init
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
/**
* Initialise the game
* @throws Exception if init fails
*/
private static void init() throws Exception {
// Create a fullscreen window with 1:1 orthographic 2D projection, and with
// mouse, keyboard, and gamepad inputs.
Display.setTitle(GAME_TITLE);
Display.setFullscreen(true);
// Enable vsync if we can
Display.setVSyncEnabled(true);
Display.create();
// Start up the sound system
AL.create();
// TODO: Load in your textures etc here
// Put the window into orthographic projection mode with 1:1 pixel ratio.
// We haven't used GLU here to do this to avoid an unnecessary dependency.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, Display.getDisplayMode().getWidth(), 0.0, Display.getDisplayMode().getHeight(), -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
}
示例12: alInitialize
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
public void alInitialize() {
try {
AL.create();
} catch (Exception e) {
e.printStackTrace();
return;
}
}
示例13: setupEfx
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
/**
* Loads OpenAL and makes sure ALC_EXT_EFX is supported.
*/
private static void setupEfx() throws Exception {
// Load and create OpenAL
if (!AL.isCreated()) {
AL.create();
}
// Query for Effect Extension
if (!ALC10.alcIsExtensionPresent(AL.getDevice(), EFX10.ALC_EXT_EFX_NAME)) {
throw new Exception("No ALC_EXT_EFX supported by driver.");
}
System.out.println("ALC_EXT_EFX found.");
}
示例14: Sonics
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
public Sonics()
{
// Initialize OpenAL and clear the error bit.
try
{
AL.create();
}
catch (LWJGLException e)
{
e.printStackTrace();
return;
}
AL10.alGetError();
}
示例15: OpenALAudio
import org.lwjgl.openal.AL; //导入方法依赖的package包/类
public OpenALAudio (int simultaneousSources, int deviceBufferCount, int deviceBufferSize) {
this.deviceBufferSize = deviceBufferSize;
this.deviceBufferCount = deviceBufferCount;
registerSound("ogg", Ogg.Sound.class);
registerMusic("ogg", Ogg.Music.class);
registerSound("wav", Wav.Sound.class);
registerMusic("wav", Wav.Music.class);
registerSound("mp3", Mp3.Sound.class);
registerMusic("mp3", Mp3.Music.class);
try {
AL.create();
} catch (LWJGLException ex) {
noDevice = true;
ex.printStackTrace();
return;
}
allSources = new IntArray(false, simultaneousSources);
for (int i = 0; i < simultaneousSources; i++) {
int sourceID = alGenSources();
if (alGetError() != AL_NO_ERROR) break;
allSources.add(sourceID);
}
idleSources = new IntArray(allSources);
soundIdToSource = new LongMap<Integer>();
sourceToSoundId = new IntMap<Long>();
FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6)
.put(new float[] {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).flip();
alListener(AL_ORIENTATION, orientation);
FloatBuffer velocity = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
alListener(AL_VELOCITY, velocity);
FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
alListener(AL_POSITION, position);
recentSounds = new OpenALSound[simultaneousSources];
}