本文整理汇总了Java中org.lwjgl.glfw.GLFWFramebufferSizeCallback类的典型用法代码示例。如果您正苦于以下问题:Java GLFWFramebufferSizeCallback类的具体用法?Java GLFWFramebufferSizeCallback怎么用?Java GLFWFramebufferSizeCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GLFWFramebufferSizeCallback类属于org.lwjgl.glfw包,在下文中一共展示了GLFWFramebufferSizeCallback类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.lwjgl.glfw.GLFWFramebufferSizeCallback; //导入依赖的package包/类
/**
* Initialize the renderer.
*/
public void init() {
// Show a status message
System.out.println("Initializing " + VoxelTex.ENGINE_NAME + " renderer...");
// Create and configure the error callback, make sure it was created successfully
glfwSetErrorCallback(errorCallback = GLFWErrorCallback.createPrint(System.err));
if(glfwInit() != GL11.GL_TRUE)
throw new IllegalStateException("Unable to initialize GLFW");
// Set the default window hints
this.window.glDefaultWindowHints();
// Set the visibility and resizability of the window
this.window.setHintVisible(false);
this.window.setHintResizable(true);
// Create the window
this.window.glCreateWindow();
// Initialize the input manager for this window
Input.init(this.window);
// Create the framebuffer size callback
glfwSetFramebufferSizeCallback(this.window.getWindowId(), fbCallback = new GLFWFramebufferSizeCallback() {
@Override
public void invoke(long windowId, int width, int height) {
// Update the window size
if(width > 0 && height > 0)
window.setSize(width, height);
}
});
// Center the window
this.window.centerWindow();
// Create an int buffer for the window
IntBuffer framebufferSize = BufferUtils.createIntBuffer(2);
nglfwGetFramebufferSize(this.window.getWindowId(), memAddress(framebufferSize), memAddress(framebufferSize) + 4);
// Set the window size
this.window.setSize(framebufferSize.get(0), framebufferSize.get(1));
// Make the window context
this.window.glMakeContextCurrent();
// Set the swap interval (V-sync)
glfwSwapInterval(0);
// Show the window
this.window.glShowWindow();
// Center the cursor
Input.centerMouseCursor();
// Create the rendering capabilities, required by LWJGL
GL.createCapabilities();
// Print the OpenGL version
System.out.println("OpenGL " + GL11.glGetString(GL11.GL_VERSION));
// Set the clear color
glClearColor(0.9f, 0.9f, 0.9f, 1.0f);
// Enable depth testing
glEnable(GL_DEPTH_TEST);
// Load the engine shaders
ShaderManager.load();
// Initialize the Time object
Time.init();
// Show a status message
System.out.println(VoxelTex.ENGINE_NAME + " renderer initialized successfully!");
}
示例2: onModuleCreate
import org.lwjgl.glfw.GLFWFramebufferSizeCallback; //导入依赖的package包/类
/**
* <p>Handle when the module create</p>
*/
private void onModuleCreate(Display.Preference preference) {
//!
//! Create display module.
//!
final GLFWFramebufferSizeCallback resize = GLFWFramebufferSizeCallback.create((window, width, height) ->
{
mLifecycle.onResize(width, height);
//!
//! NOTE: This is required due to GLFW3 limitation.
//!
onModuleRender(GLFW.glfwGetTime());
});
final GLFWWindowIconifyCallback iconify = GLFWWindowIconifyCallback.create((window, iconified) ->
{
if (iconified) {
mLifecycle.onPause();
} else {
mLifecycle.onResume();
}
});
mDisplay.onModuleCreate(preference, resize, iconify);
//!
//! Create audio module.
//!
mAudio.onModuleCreate(new DesktopALES10());
mAudioThread.schedule(new TimerTask() {
@Override
public void run() {
mAudio.onModuleUpdate();
}
}, 0L, THREAD_AUDIO_DELAY);
//!
//! Create input module.
//!
mInput.onModuleCreate(new DesktopInputKeyboard(mDisplay.getHandle()), new DesktopInputMouse(mDisplay.getHandle()));
mInputThread.schedule(new TimerTask() {
@Override
public void run() {
mInput.onModuleUpdate();
}
}, 0L, THREAD_INPUT_DELAY);
//!
//! Create render module.
//!
mRender.onModuleCreate(new DesktopGLES32());
//!
//! Create resource module.
//!
mResources.registerAssetLocator("INTERNAL", new ClassAssetLocator());
mResources.registerAssetLocator("EXTERNAL", new FilesAssetLocator());
mResources.registerAssetLoader(new TexturePNGAssetLoader(), "png");
mResources.registerAssetLoader(new TextureDDSAssetLoader(), "dds", "s3tc");
mResources.registerAssetLoader(new AudioWAVAssetLoader(), "wav");
mResources.registerAssetLoader(new AudioOGGAssetLoader(), "ogg");
mResources.registerAssetLoader(new FontBinaryAssetLoader(), "fnt");
mResources.registerAssetLoader(new ShaderBinaryAssetLoader(QKRender.getCapabilities()), "shader");
//!
//! Handle the create notification.
//!
mLifecycle.onCreate();
mLifecycle.onResize(mDisplay.getWidth(), mDisplay.getHeight());
}
示例3: DisplayLayer
import org.lwjgl.glfw.GLFWFramebufferSizeCallback; //导入依赖的package包/类
private DisplayLayer(long fullscreenMonitor, int width, int height, String title, boolean resizable, boolean vsync,
String[] args, KMain main) {
LUtils.print("Using LWJGL v" + org.lwjgl.Version.getVersion());
if (!GLFW.glfwInit()) {
throw new IllegalStateException("glfwInit failed!");
}
GLFW.glfwDefaultWindowHints();
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, resizable ? GLFW.GLFW_TRUE : GLFW.GLFW_FALSE);
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3);
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 2);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GLFW.GLFW_TRUE);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);
this.window = GLFW.glfwCreateWindow(width, height, title, fullscreenMonitor, 0);
if (this.window == 0) {
// uh oh.
throw new IllegalStateException("window creation failed.");
}
GLFW.glfwMakeContextCurrent(this.window);
GL.createCapabilities(true);
createdMap.put(this.window, this);
GLFW.glfwSwapInterval(vsync ? 1 : 0);
this.sizeCallback = GLFWFramebufferSizeCallback.create((win, w, h) -> GLData.resizedRefresh(win));
GLFW.glfwSetFramebufferSizeCallback(this.window, this.sizeCallback);
this.mouseHelp = MouseHelp.getHelper(this.window);
this.keys = Keys.getHelper(this.window);
String currentMethodName = StackTraceInfo.getCurrentMethodName();
GLData.notifyOnGLError(currentMethodName);
KMain.setDisplayThread(Thread.currentThread());
GLData.notifyOnGLError(currentMethodName);
KMain.setInst(main);
GLData.notifyOnGLError(currentMethodName);
Mods.findAndLoad();
GLData.notifyOnGLError(currentMethodName);
GLData.initOpenGL(this.window);
this.displayFPSTracker = new FPS(title);
GLData.notifyOnGLError(currentMethodName);
// Bind VAO around NVG init
GLData.bindVAO();
int flags = NVG_ANTIALIAS | NVG_STENCIL_STROKES;
if (Boolean.getBoolean(LUtils.SHORT_LIB_NAME + ".nvg.debug")) {
flags |= NVG_DEBUG;
}
this.nvgHandle = nvgCreateGL3(flags);
GLData.notifyOnGLError(currentMethodName);
GLData.unbindVAO();
main.init(this, args);
GLData.notifyOnGLError(currentMethodName);
LUtils.print("Using OpenGL v" + LUtils.getGLVer());
// Initialize NFD here to prevent slow times later
NativeFileDialog.NFD_GetError();
}
示例4: getFramebufferCallback
import org.lwjgl.glfw.GLFWFramebufferSizeCallback; //导入依赖的package包/类
/**
* Gets the GLFWWindow's Framebuffer Size Callback
*
* @return Framebuffer Size Callback of the GLFW Instance
*/
public GLFWFramebufferSizeCallback getFramebufferCallback() {
return framebufferCallback;
}
示例5: setFramebufferCallback
import org.lwjgl.glfw.GLFWFramebufferSizeCallback; //导入依赖的package包/类
/**
* Sets the GLFWWindow's Framebuffer Size Callback
*
* @param framebufferCallback GLFWFramebufferSizeCallback to be used by the GLFW Instance
*/
public void setFramebufferCallback(GLFWFramebufferSizeCallback framebufferCallback) {
this.framebufferCallback = framebufferCallback;
}