• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GLFWImage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setShape

import org.lwjgl.glfw.GLFWImage; //导入依赖的package包/类
/**
 * <p>
 * Set the shape of the cursor to a custom image.
 * </p>
 *
 * @param texture The cursor shape.
 * @param hot The hot point of the shape.
 */
public static void setShape(Texture2D texture, Vector2f hot)
{
	if(CursorShape.hasCursor(texture, hot))
	{
		setShape(CursorShape.getCursor(texture, hot));
		LoggerInternal.log("Loaded existing cursor shape");
	}
	else
	{
		GLFWImage image = GLFWImage.malloc().set(texture.getWidth(), texture.getHeight(), texture.getByteBuffer());
		
		long cursor = glfwCreateCursor(image, Math.round(hot.x), Math.round(hot.y));
		CursorShape.addCursor(texture, hot, cursor);
		
		setShape(cursor);
		LoggerInternal.log("Created new cursor shape");
	}
}
 
开发者ID:Snakybo,项目名称:TorchEngine,代码行数:27,代码来源:Cursor.java


示例2: setPointerIcon

import org.lwjgl.glfw.GLFWImage; //导入依赖的package包/类
@Override
public void setPointerIcon(File file, int hotX, int hotY) {
	checkMainThread();
	Long cursor = FILE2CRSR.get(file);
	if(cursor == null) {
		try {
			IHostImage src = Platform.get().getImageSupport().readHost(new FileInputStream(file), ComponentType.BYTE, ComponentFormat.RGBA, AlphaMode.POST_MULTIPLIED);
			GLFWImage image = GLFWImage.malloc();
			image.set(src.getWidth(), src.getHeight(), flip(src.getPixels(), src.getHeight()));			
			cursor = Long.valueOf(GLFW.glfwCreateCursor(image, hotX, hotY));
			FILE2CRSR.put(file, cursor);
			image.free();
		} catch(Throwable t) {
			log.warning(t);
		}
	}
	if(cursor != null)
		GLFW.glfwSetCursor(window, cursor.longValue());
}
 
开发者ID:arisona,项目名称:ether,代码行数:20,代码来源:GLFWWindow.java


示例3: GLIcon

import org.lwjgl.glfw.GLFWImage; //导入依赖的package包/类
protected GLIcon(String imagePath) {
	this.image = GLFWImage.malloc();
	this.buffer = GLFWImage.malloc(1);

	BufferedImage bufferedImage = ImageUtils.readImage(imagePath);
	int imwidth = bufferedImage.getWidth();
	int imheight = bufferedImage.getHeight();
	ByteBuffer pixels = BufferUtils.createByteBuffer(imwidth * imheight * 4);
	for (int y = 0; y < imheight; y++) {
		for (int x = 0; x < imwidth; x++) {
			Color color = new Color(bufferedImage.getRGB(x, y), true);
			pixels.put((byte) color.getRed());
			pixels.put((byte) color.getGreen());
			pixels.put((byte) color.getBlue());
			pixels.put((byte) color.getAlpha());
		}
	}
	pixels.flip();
	this.image.set(imwidth, imheight, pixels);
	this.buffer.put(0, this.image);
}
 
开发者ID:rpereira-dev,项目名称:CubeEngine,代码行数:22,代码来源:GLIcon.java


示例4: create

import org.lwjgl.glfw.GLFWImage; //导入依赖的package包/类
public void create(int width, int height)
{
	setWidth(width);
	setHeight(height);
	
	glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);	
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);	
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);	
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);	
	
	window = glfwCreateWindow(width, height, "OREON ENGINE Programming Tutorial Series", 0, 0);
	
	if(window == 0) {
	    throw new RuntimeException("Failed to create window");
	}
	
	ByteBuffer bufferedImage = ImageLoader.loadImageToByteBuffer("./res/logo/oreon_lwjgl_icon32.png");
	
	GLFWImage image = GLFWImage.malloc();
	
	image.set(32, 32, bufferedImage);
	
	GLFWImage.Buffer images = GLFWImage.malloc(1);
       images.put(0, image);
	
	glfwSetWindowIcon(window, images);
	
	glfwMakeContextCurrent(window);
	GL.createCapabilities();
	glfwShowWindow(window);
}
 
开发者ID:oreonengine,项目名称:Lwjgl3-Game-Engine-Programming-Series,代码行数:32,代码来源:Window.java


示例5: setIcon

import org.lwjgl.glfw.GLFWImage; //导入依赖的package包/类
public void setIcon(String icon16Path, String icon32Path){
	//setup buffers to work with stb
	IntBuffer w = BufferUtils.createIntBuffer(1);
	IntBuffer h = BufferUtils.createIntBuffer(1);
	IntBuffer comp = BufferUtils.createIntBuffer(1);
	
	//these will be the data buffers for the textures
	ByteBuffer icon16,icon32;
	try{
		//populate the buffers with the raw image data
		icon16 = ResourceLoader.getBytes(icon16Path);
		icon32 = ResourceLoader.getBytes(icon32Path);
		
		//setup image buffers for the images to be processed
		try(GLFWImage.Buffer icons = GLFWImage.malloc(2)){
			//process both images with stb
			//16x16 icon
			ByteBuffer p16 = STBImage.stbi_load_from_memory(icon16, w, h, comp, 4);
			icons.position(0).width(w.get(0)).height(h.get(0)).pixels(p16);
			
			//32x32 icon
			ByteBuffer p32 = STBImage.stbi_load_from_memory(icon32, w, h, comp, 4);
			icons.position(1).width(w.get(0)).height(h.get(0)).pixels(p32);
			
			//reset the icons buffer position
			icons.position(0);
			GLFW.glfwSetWindowIcon(handle, icons);
			
			//free the stb resources
			STBImage.stbi_image_free(p16);
			STBImage.stbi_image_free(p32);
		}
	}catch(Exception e){
		e.printStackTrace();
	}
}
 
开发者ID:tek256,项目名称:LD38,代码行数:37,代码来源:Window.java


示例6: setWindowIcon

import org.lwjgl.glfw.GLFWImage; //导入依赖的package包/类
/**
 * Sets the taskbar and window icon for the game
 */
private void setWindowIcon() {
	GLFWImage image = GLFWImage.malloc();
	image.set(32, 32, loadIcon("/icon.png"));
	GLFWImage.Buffer images = GLFWImage.malloc(1);
	images.put(0, image);

	glfwSetWindowIcon(window, images);

	images.free();
	image.free();
}
 
开发者ID:mattgd,项目名称:Laser-Amazer,代码行数:15,代码来源:Window.java


示例7: JglfwCursor

import org.lwjgl.glfw.GLFWImage; //导入依赖的package包/类
public JglfwCursor(JglfwGraphics graphics, Pixmap pixmap, int xHotspot, int yHotspot) {
	this.graphics = graphics;

	if (pixmap == null) {
		glfwCursor = 0;
		return;
	}

	if (pixmap.getFormat() != Pixmap.Format.RGBA8888) {
		throw new GdxRuntimeException("Cursor image pixmap is not in RGBA8888 format.");
	}

	if ((pixmap.getWidth() & (pixmap.getWidth() - 1)) != 0) {
		throw new GdxRuntimeException("Cursor image pixmap width of " + pixmap.getWidth()
				+ " is not a power-of-two greater than zero.");
	}

	if ((pixmap.getHeight() & (pixmap.getHeight() - 1)) != 0) {
		throw new GdxRuntimeException("Cursor image pixmap height of " + pixmap.getHeight()
				+ " is not a power-of-two greater than zero.");
	}

	if (xHotspot < 0 || xHotspot >= pixmap.getWidth()) {
		throw new GdxRuntimeException("xHotspot coordinate of " + xHotspot + " is not within image width bounds: [0, "
				+ pixmap.getWidth() + ").");
	}

	if (yHotspot < 0 || yHotspot >= pixmap.getHeight()) {
		throw new GdxRuntimeException("yHotspot coordinate of " + yHotspot + " is not within image height bounds: [0, "
				+ pixmap.getHeight() + ").");
	}

	final GLFWImage img = GLFWImage.malloc();
	img.width(pixmap.getWidth());
	img.height(pixmap.getHeight());
	img.pixels(pixmap.getPixels());

	glfwCursor = glfwCreateCursor(img, xHotspot, yHotspot);
	if (glfwCursor == 0) {
		throw new GdxRuntimeException("Could not create cursor image.");
	}
}
 
开发者ID:Arcnor,项目名称:gdx-backend-jglfw,代码行数:43,代码来源:JglfwCursor.java


示例8: getGLFWImage

import org.lwjgl.glfw.GLFWImage; //导入依赖的package包/类
public final GLFWImage getGLFWImage() {
	return (this.image);
}
 
开发者ID:rpereira-dev,项目名称:CubeEngine,代码行数:4,代码来源:GLIcon.java


示例9: Cursor

import org.lwjgl.glfw.GLFWImage; //导入依赖的package包/类
/**
 * Constructs a cursor object using the pixels from an Image object and also the location of the pointer hot point
 * in the image pixels retrieved from the OpenGL Texture.
 *
 * @param image The Image object to retrieve the image data from.
 * @param xHot  The x-coordinate of the cursor hotspot in pixels.
 * @param yHot  The y-coordinate of the cursor hotspot in pixels.
 */
public Cursor(Image image, int xHot, int yHot)
{
    int width = image.getWidth();
    int height = image.getHeight();

    GLFWImage glfwImage = GLFWImage.calloc();
    glfwImage.width(width);
    glfwImage.height(height);

    ByteBuffer data = BufferUtils.createByteBuffer(width * height * 4);

    Color color = Color.REUSABLE_STACK.pop();

    for (int y = 0; y < height; y++)
    {
        for (int x = 0; x < width; x++)
        {
            image.getPixel(x, y, color);

            float r = (color.r * 255f);
            float g = (color.g * 255f);
            float b = (color.b * 255f);
            float a = ((1 - color.a) * 255f);

            data.put((byte) r)
                    .put((byte) g)
                    .put((byte) b)
                    .put((byte) a);
        }
    }

    Color.REUSABLE_STACK.push(color);

    data.flip();
    glfwImage.pixels(data);

    handle = glfwCreateCursor(glfwImage, xHot, yHot);

    if (handle == NULL)
        throw new SilenceException("Unable to load cursor from texture");

    glfwImage.free();
}
 
开发者ID:sriharshachilakapati,项目名称:SilenceEngine,代码行数:52,代码来源:Cursor.java


示例10: convertToGLFWImage

import org.lwjgl.glfw.GLFWImage; //导入依赖的package包/类
public GLFWImage convertToGLFWImage() {
    return GLFWImage.create().set(this.dim.getX(), this.dim.getY(), this.buf);
}
 
开发者ID:TechShroom,项目名称:EmergencyLanding,代码行数:4,代码来源:ELTexture.java


示例11: setIcon

import org.lwjgl.glfw.GLFWImage; //导入依赖的package包/类
public void setIcon(String path){
	
	ByteBuffer bufferedImage = ResourceLoader.loadImageToByteBuffer(path);
	
	GLFWImage image = GLFWImage.malloc();
	
	image.set(32, 32, bufferedImage);
	
	GLFWImage.Buffer images = GLFWImage.malloc(1);
       images.put(0, image);
	
	glfwSetWindowIcon(getId(), images);
}
 
开发者ID:oreonengine,项目名称:oreon-engine,代码行数:14,代码来源:Window.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EnumJvmMemManagerState类代码示例发布时间:2022-05-22
下一篇:
Java RegistrationRequest类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap