Java Code Examples for org.lwjgl.glfw.GLFWImage#malloc()

The following examples show how to use org.lwjgl.glfw.GLFWImage#malloc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Window.java    From Lwjgl3-Game-Engine-Programming-Series with MIT License 5 votes vote down vote up
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);
}
 
Example 2
Source File: Lwjgl3Mini2DxCursor.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
Lwjgl3Mini2DxCursor(Lwjgl3Mini2DxWindow window, Pixmap pixmap, int xHotspot, int yHotspot) {
	this.window = window;
	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() + ").");
	}

	this.pixmapCopy = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), Pixmap.Format.RGBA8888);
	this.pixmapCopy.setBlending(Pixmap.Blending.None);
	this.pixmapCopy.drawPixmap(pixmap, 0, 0);

	glfwImage = GLFWImage.malloc();
	glfwImage.width(pixmapCopy.getWidth());
	glfwImage.height(pixmapCopy.getHeight());
	glfwImage.pixels(pixmapCopy.getPixels());
	glfwCursor = GLFW.glfwCreateCursor(glfwImage, xHotspot, yHotspot);
	cursors.add(this);
}
 
Example 3
Source File: Window.java    From oreon-engine with GNU General Public License v3.0 3 votes vote down vote up
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);
}