当前位置: 首页>>代码示例>>Java>>正文


Java BufferUtils类代码示例

本文整理汇总了Java中org.lwjgl.BufferUtils的典型用法代码示例。如果您正苦于以下问题:Java BufferUtils类的具体用法?Java BufferUtils怎么用?Java BufferUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BufferUtils类属于org.lwjgl包,在下文中一共展示了BufferUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setMouseCursor

import org.lwjgl.BufferUtils; //导入依赖的package包/类
/**
  * {@inheritDoc}
  */
 public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
     try {
        Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
        Graphics g = temp.getGraphics();
        
        ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
        g.drawImage(image.getFlippedCopy(false, true), 0, 0);
        g.flush();
        g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
        
        Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
        Mouse.setNativeCursor(cursor);
     } catch (Throwable e) {
        Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
     }
  }
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:21,代码来源:AppletGameContainer.java

示例2: setMouseCursor

import org.lwjgl.BufferUtils; //导入依赖的package包/类
/**
 * @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
 */
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
	try {
		Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
		Graphics g = temp.getGraphics();
		
		ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
		g.drawImage(image.getFlippedCopy(false, true), 0, 0);
		g.flush();
		g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
		
		Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
		Mouse.setNativeCursor(cursor);
	} catch (Throwable e) {
		Log.error("Failed to load and apply cursor.", e);
		throw new SlickException("Failed to set mouse cursor", e);
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:21,代码来源:AppGameContainer.java

示例3: GUILabel

import org.lwjgl.BufferUtils; //导入依赖的package包/类
/**
 * Full constructor of a Label
 * @param text (String) : the text to print
 * @param xC (float) : the x coordonnate of the frame where start printing the Label (upper left corner)
 * @param yC (float) : the y coordonnate of the frame where start printing the Label (upper left corner)
 * @param color (java.awt.Color) : the Color you wish for the text
 * @param font (String) : the font (i.e. "Arial" or "Times new roman")
 * @param size (int) : the font size
 */
public GUILabel(String text, int xC, int yC, Color color, String font, int size){
	super(xC,yC);
	this.font = font;
	this.color = color;
	this.text = text;
	this.size = size;
	if(this.texture != null)this.texture.destroy();
	this.texture = Texture.loadFont(text,color,font,size);
	super.width = this.texture.width;
	super.height = this.texture.height;
	this.vbo = GL15.glGenBuffers();
	float[] a = new float[]{
			0,0,        0.0f,0.0f,
			1,0,         1.0f,0.0f,
			1,1,          1.0f,1.0f,
			0,1,         0.0f,1.0f
	};
	FloatBuffer buff = BufferUtils.createFloatBuffer(a.length);
	buff.put(a).flip();
	this.numberOfVertices = a.length/(2+2);

	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
	GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buff, GL15.GL_STATIC_DRAW);
	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
 
开发者ID:mrdev023,项目名称:Global-Gam-Jam-2017,代码行数:35,代码来源:GUILabel.java

示例4: fetchAttribs

import org.lwjgl.BufferUtils; //导入依赖的package包/类
private Attribute[] fetchAttribs()
{
	int len = GL20.glGetProgrami(this.handle, GL20.GL_ACTIVE_ATTRIBUTES);
	int strlen = GL20.glGetProgrami(this.handle, GL20.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH);

	Attribute[] attribs = new Attribute[len];

	IntBuffer sizeBuffer = BufferUtils.createIntBuffer(1);
	IntBuffer typeBuffer = BufferUtils.createIntBuffer(1);
	for(int i = 0; i < attribs.length; ++i)
	{
		String name = GL20.glGetActiveAttrib(this.handle, i, strlen, sizeBuffer, typeBuffer);
		int location = GL20.glGetAttribLocation(this.handle, name);
		attribs[i] = new Attribute(this, name, typeBuffer.get(), location);

		typeBuffer.flip();
	}

	return attribs;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:21,代码来源:Program.java

示例5: renderGL

import org.lwjgl.BufferUtils; //导入依赖的package包/类
/**
 * Render the GL scene, this isn't efficient and if you know 
 * OpenGL I'm assuming you can see why. If not, you probably
 * don't want to use this feature anyway
 */
public void renderGL() {		
	FloatBuffer pos = BufferUtils.createFloatBuffer(4);
	pos.put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f}).flip();
	FloatBuffer red = BufferUtils.createFloatBuffer(4);
	red.put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f}).flip();

	GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos);
	GL11.glEnable(GL11.GL_LIGHT0);

	GL11.glEnable(GL11.GL_CULL_FACE);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_LIGHTING);
	
	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glLoadIdentity();
	float h = (float) 600 / (float) 800;
	GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glLoadIdentity();	
	GL11.glTranslatef(0.0f, 0.0f, -40.0f);	
	GL11.glRotatef(rot,0,1,1);		
	
	GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red);
	gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:31,代码来源:SlickCallableTest.java

示例6: ShaderUniform

import org.lwjgl.BufferUtils; //导入依赖的package包/类
public ShaderUniform(String name, int type, int count, ShaderManager manager)
{
    this.shaderName = name;
    this.uniformCount = count;
    this.uniformType = type;
    this.shaderManager = manager;

    if (type <= 3)
    {
        this.uniformIntBuffer = BufferUtils.createIntBuffer(count);
        this.uniformFloatBuffer = null;
    }
    else
    {
        this.uniformIntBuffer = null;
        this.uniformFloatBuffer = BufferUtils.createFloatBuffer(count);
    }

    this.uniformLocation = -1;
    this.markDirty();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:ShaderUniform.java

示例7: Texture

import org.lwjgl.BufferUtils; //导入依赖的package包/类
public Texture(String string) throws IOException {
BufferedImage bi;
bi = ImageIO.read(new File(string));
this.width = bi.getWidth();
this.height = bi.getHeight();
int[] pixels_raw = bi.getRGB(0, 0, this.width, this.height, null, 0, this.width);
ByteBuffer pixels = BufferUtils.createByteBuffer(width * height * 4);
for (int i = 0; i < width; i++) {
    for (int j = 0; j < height; j++) {
	int pixel = pixels_raw[i*width + j];
	pixels.put((byte) ((pixel >> 16) & 0xFF));
	pixels.put((byte) ((pixel >> 8) & 0xFF));
	pixels.put((byte) (pixel & 0xFF));
	pixels.put((byte) ((pixel >> 24) & 0xFF));
	
    }
}
pixels.flip();
id = glGenTextures();
glBindTexture(GL_TEXTURE_2D, id);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
   }
 
开发者ID:markd315,项目名称:Devpro,代码行数:25,代码来源:Texture.java

示例8: cleanUpSource

import org.lwjgl.BufferUtils; //导入依赖的package包/类
/**
 * Clean up the buffers applied to the sound source
 */
private void cleanUpSource() {
	SoundStore store = SoundStore.get();
	
	AL10.alSourceStop(store.getSource(0));
	IntBuffer buffer = BufferUtils.createIntBuffer(1);
	int queued = AL10.alGetSourcei(store.getSource(0), AL10.AL_BUFFERS_QUEUED);
	
	while (queued > 0)
	{
		AL10.alSourceUnqueueBuffers(store.getSource(0), buffer);
		queued--;
	}
	
	AL10.alSourcei(store.getSource(0), AL10.AL_BUFFER, 0);
}
 
开发者ID:imaTowan,项目名称:Towan,代码行数:19,代码来源:StreamSound.java

示例9: Model

import org.lwjgl.BufferUtils; //导入依赖的package包/类
/**
 * Creates the buffers and puts the data inside
 *
 * @param vertices the edges of the pinball
 */
Model(double[] vertices) {
    draw_count = vertices.length / 3;
  
    buffer = BufferUtils.createDoubleBuffer(vertices.length);
    buffer.put(vertices);
    buffer.flip();

    vao_id = glGenVertexArrays();
    glBindVertexArray(vao_id);

    vbo_id = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
    glBufferData(GL_ARRAY_BUFFER, buffer, GL_DYNAMIC_DRAW);

    glVertexAttribPointer(0, 3, GL_DOUBLE, false, 0, 0);
    glEnableVertexAttribArray(0);

    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindVertexArray(0);
}
 
开发者ID:TauOmicronMu,项目名称:TeamProject,代码行数:26,代码来源:Model.java

示例10: Track

import org.lwjgl.BufferUtils; //导入依赖的package包/类
/**
 * (Use this as the default!)
 * Creates a new Track from the wav file at filepath, with a static source at the default location (0,0,0)
 * and default gain (1.0f) and pitch (1.0f).
 * @param filepath The path to the wav file to load in.
 */
public Track(String filepath) {
    buffer = BufferUtils.createIntBuffer(1);
    source = BufferUtils.createIntBuffer(1);

    /**
     * Set default values for the source, gain and pitch:
     *     sourcePos : 0.0f, 0.0f, 0.0f
     *     sourceVel : 0.0f, 0.0f, 0.0f
     *     gain      : 1.0f
     *     pitch     : 1.0f
     */
    sourcePos = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f}).rewind();
    sourceVel = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f}).rewind();
    gain = 1.0f;
    pitch = 1.0f;

    loadALData(filepath);
}
 
开发者ID:TauOmicronMu,项目名称:TeamProject,代码行数:25,代码来源:AudioEngine.java

示例11: ioResourceToByteBuffer

import org.lwjgl.BufferUtils; //导入依赖的package包/类
public static ByteBuffer ioResourceToByteBuffer(String resource, int bufferSize) throws IOException {
    ByteBuffer buffer;

    Path path = Paths.get(resource);
    if(Files.isReadable(path)) {
        try(SeekableByteChannel fc = Files.newByteChannel(path)){
            buffer = BufferUtils.createByteBuffer((int)fc.size() + 1);
            while(fc.read(buffer) != -1);
        }
    }else{
        try(InputStream source = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
            ReadableByteChannel rbc = Channels.newChannel(source)){
            buffer = BufferUtils.createByteBuffer(bufferSize);
            while(true){
                int bytes = rbc.read(buffer);
                if(bytes == -1)
                    break;
                if (buffer.remaining() == 0)
                    buffer = resizeBuffer(buffer, buffer.capacity() * 2);
            }
        }
    }
    
    buffer.flip();
    return buffer;
}
 
开发者ID:tek256,项目名称:LD38,代码行数:27,代码来源:Util.java

示例12: printLogInfo

import org.lwjgl.BufferUtils; //导入依赖的package包/类
private static boolean printLogInfo(int obj, String name)
{
    IntBuffer intbuffer = BufferUtils.createIntBuffer(1);
    ARBShaderObjects.glGetObjectParameterARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB, (IntBuffer)intbuffer);
    int i = intbuffer.get();

    if (i > 1)
    {
        ByteBuffer bytebuffer = BufferUtils.createByteBuffer(i);
        intbuffer.flip();
        ARBShaderObjects.glGetInfoLogARB(obj, intbuffer, bytebuffer);
        byte[] abyte = new byte[i];
        bytebuffer.get(abyte);

        if (abyte[i - 1] == 0)
        {
            abyte[i - 1] = 10;
        }

        String s = new String(abyte);
        SMCLog.info("Info log: " + name + "\n" + s);
        return false;
    }
    else
    {
        return true;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:29,代码来源:Shaders.java

示例13: glGetClipPlanef

import org.lwjgl.BufferUtils; //导入依赖的package包/类
@Override
public void glGetClipPlanef(int pname, FloatBuffer eqn) {
    DoubleBuffer buffer = BufferUtils.createDoubleBuffer(eqn.capacity());
    for (float f : eqn.array()) {
        buffer.put(f);
    }
    GL11.glGetClipPlane(pname, buffer);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:9,代码来源:OpenGLImpl.java

示例14: removeBuffers

import org.lwjgl.BufferUtils; //导入依赖的package包/类
/**
 * Clean up the buffers applied to the sound source
 */
private void removeBuffers() {
	IntBuffer buffer = BufferUtils.createIntBuffer(1);
	int queued = AL10.alGetSourcei(source, AL10.AL_BUFFERS_QUEUED);
	
	while (queued > 0)
	{
		AL10.alSourceUnqueueBuffers(source, buffer);
		queued--;
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:14,代码来源:OpenALStreamPlayer.java

示例15: init

import org.lwjgl.BufferUtils; //导入依赖的package包/类
/**
 * Initialise the FBO that will be used to render to
 * 
 * @throws SlickException
 */
private void init() throws SlickException {
	IntBuffer buffer = BufferUtils.createIntBuffer(1);
	EXTFramebufferObject.glGenFramebuffersEXT(buffer); 
	FBO = buffer.get();

	// for some reason FBOs won't work on textures unless you've absolutely just
	// created them.
	try {
		Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());
		
		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, FBO);
		EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 
													   EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT,
													   GL11.GL_TEXTURE_2D, tex.getTextureID(), 0);
		
		completeCheck();
		unbind();
		
		// Clear our destination area before using it
		clear();
		flush();
		
		// keep hold of the original content
		drawImage(image, 0, 0);
		image.setTexture(tex);
		
	} catch (Exception e) {
		throw new SlickException("Failed to create new texture for FBO");
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:36,代码来源:FBOGraphics.java


注:本文中的org.lwjgl.BufferUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。