package com.aincc.lib.util;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
/**
*
* <h3><b>OpenGLUtil</b></h3></br>
*
* @author aincc@barusoft.com
* @version 1.0.0
* @since 1.0.0
*/
public class OpenGLUtil
{
/**
* degree to radian 변환
*
* @since 1.0.0
* @param degree
* @return the radian
*/
public static float d2r(float degree)
{
return degree * (float) Math.PI / 180f;
}
/**
*
* @since 1.0.0
* @param v
* @return the FloatBuffer
*/
public static FloatBuffer toFloatBuffer(float[] v)
{
ByteBuffer buf = ByteBuffer.allocateDirect(v.length * 4);
buf.order(ByteOrder.nativeOrder());
FloatBuffer buffer = buf.asFloatBuffer();
buffer.put(v);
buffer.position(0);
return buffer;
}
/**
*
* @since 1.0.0
* @param v
* @return the ShortBuffer
*/
public static ShortBuffer toShortBuffer(short[] v)
{
ByteBuffer buf = ByteBuffer.allocateDirect(v.length * 2);
buf.order(ByteOrder.nativeOrder());
ShortBuffer buffer = buf.asShortBuffer();
buffer.put(v);
buffer.position(0);
return buffer;
}
}