本文整理汇总了Java中org.lwjgl.glfw.GLFWvidmode类的典型用法代码示例。如果您正苦于以下问题:Java GLFWvidmode类的具体用法?Java GLFWvidmode怎么用?Java GLFWvidmode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GLFWvidmode类属于org.lwjgl.glfw包,在下文中一共展示了GLFWvidmode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createWindow
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
public void createWindow(String title) {
window = glfwCreateWindow(
width,
height,
title,
fullscreen ? glfwGetPrimaryMonitor() : 0,
0);
if (window == 0) {
throw new IllegalStateException("GLFW failed to create window!");
}
if (!fullscreen) {
GLFWVidMode vid = glfwGetVideoMode(glfwGetPrimaryMonitor());
glfwSetWindowPos(window, (vid.width() - width) / 2, (vid.height() - height) / 2);
glfwShowWindow(window);
}
glfwMakeContextCurrent(window);
input = new Input(window);
}
示例2: start
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
private void start(){
if(!glfwInit()){
throw new IllegalStateException("Not enable GLFW Init");
}
glfwDefaultWindowHints();
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
window = glfwCreateWindow(Width, Height, "Light! Weight! Test!", NULL, NULL);
if(window == NULL){
throw new RuntimeException("ウィンドウの生成に失敗しました");
}
glfwSetWindowAspectRatio(window,1,1);
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
glfwSetWindowPos(window, (vidmode.width()-Width)/ 2, (vidmode.height()-Height)/ 2);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwShowWindow(window);
}
示例3: makeWindowCentered
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
public void makeWindowCentered()
{
// Get the thread stack and push a new frame
try (MemoryStack stack = MemoryStack.stackPush())
{
IntBuffer pWidth = stack.mallocInt(1); // int*
IntBuffer pHeight = stack.mallocInt(1); // int*
// Get the window size passed to glfwCreateWindow
GLFW.glfwGetWindowSize(this.handle, pWidth, pHeight);
this.width = pWidth.get(0);
this.height = pHeight.get(0);
// Get the resolution of the primary monitor
GLFWVidMode vidmode = getCurrentVideoMode();
// Center the window
GLFW.glfwSetWindowPos(
this.handle,
this.x = ((vidmode.width() - this.width) / 2),
this.y = ((vidmode.height() - this.height) / 2)
);
} // the stack frame is popped automatically
}
示例4: glfwGetVideoModes
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
Display(long id)
{
this.id = id;
GLFWVidMode.Buffer modes = glfwGetVideoModes(id);
displayModes = new HashSet<>();
for(int i = 0; i < modes.limit(); i++)
{
GLFWVidMode vm = modes.get();
DisplayMode wm = new DisplayMode(
this,
vm.width(),
vm.height(),
vm.redBits(),
vm.refreshRate());
displayModes.add(wm);
}
}
示例5: getNativeDisplayMode
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
/**
* <p>
* Get the native window mode of the display.
* </p>
*
* @return The native window mode.
*/
public final DisplayMode getNativeDisplayMode()
{
GLFWVidMode nvm = glfwGetVideoMode(id);
for(DisplayMode mode : displayModes)
{
if(mode.getWidth() == nvm.width()
&& mode.getHeight() == nvm.height()
&& mode.getBitsPerPixel() == nvm.redBits()
&& mode.getFrequency() == nvm.refreshRate())
{
return mode;
}
}
return null;
}
示例6: Application
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
/**
* Create a new application
* @param width The width
* @param height The height
* @param fullscreen Wether the window should be fullscreen
* @param title The title
* @throws InitializationException If the application fails to initialize
*/
public Application(int width, int height, boolean fullscreen, String title) throws InitializationException {
Logs.setApplication(this);
GLFWVidMode displayMode = null;
if (fullscreen) {
displayMode = Window.getBestFullscreenVideoMode(Window.getFullscreenVideoModes(GLFW.glfwGetPrimaryMonitor()));
}
window = new Window(title, width, height, fullscreen, displayMode, GLFW.glfwGetPrimaryMonitor());
GLFW.glfwShowWindow(window.getWindow());
window.setVsync(false);
loader = new Loader(this);
renderer = new MasterRenderer();
renderer.viewport(0, 0, window.getWidth(), window.getHeight());
renderer.init();
Quad.setup(loader);
}
示例7: getDensity
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
public float getDensity () {
intBuffer.clear();
intBuffer2.clear();
glfwGetMonitorPhysicalSize(getWindowMonitor(), intBuffer, intBuffer2);
float mmWidth = intBuffer.get();
float mmHeight = intBuffer2.get();
float inches = (float) Math.sqrt(mmWidth * mmWidth + mmHeight * mmHeight) * 0.03937f; // mm to inches
final GLFWVidMode vidMode = glfwGetVideoMode(getWindowMonitor());
float pixelWidth = vidMode.width();
float pixelHeight = vidMode.height();
float pixels = (float) Math.sqrt(pixelWidth * pixelWidth + pixelHeight * pixelHeight);
float diagonalPpi = pixels / inches;
return diagonalPpi / 160f;
}
示例8: setSize
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
@Override public void setSize (int width, int height, boolean fullscreen) {
if (plat.config.fullscreen != fullscreen) {
plat.log().warn("fullscreen cannot be changed via setSize, use config.fullscreen instead");
return;
}
GLFWVidMode vidMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
if (width > vidMode.width()) {
plat.log().debug("Capping window width at desktop width: " + width + " -> " +
vidMode.width());
width = vidMode.width();
}
if (height > vidMode.height()) {
plat.log().debug("Capping window height at desktop height: " + height + " -> " +
vidMode.height());
height = vidMode.height();
}
glfwSetWindowSize(window, width, height);
// plat.log().info("setSize: " + width + "x" + height);
viewSizeM.setSize(width, height);
IntBuffer fbSize = BufferUtils.createIntBuffer(2);
long addr = MemoryUtil.memAddress(fbSize);
nglfwGetFramebufferSize(window, addr, addr + 4);
viewportAndScaleChanged(fbSize.get(0), fbSize.get(1));
}
示例9: initialize
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
public void initialize() throws LWJGLLibraryException {
glfwDefaultWindowHints();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, OpenGL.CONTEXT_VERSION_MAJOR);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, OpenGL.CONTEXT_VERSION_MINOR);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, (OpenGL.FORWARD_COMPATIBILITY ? GL_TRUE : GL_FALSE));
glfwWindowHint(GLFW_OPENGL_PROFILE, OpenGL.PROFILE);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
glfwWindowHint(GLFW_RESIZABLE, (resizable ? GL_TRUE : GL_FALSE));
if (fullScreen) {
windowID = glfwCreateWindow(width, height, title, glfwGetPrimaryMonitor(), NULL);
} else {
windowID = glfwCreateWindow(width, height, title, NULL, NULL);
}
if (windowID == NULL)
throw new LWJGLLibraryException("Failed to create a GLFW window");
final ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
glfwSetWindowPos(windowID, (GLFWvidmode.width(vidmode) - width) / 2, (GLFWvidmode.height(vidmode) - height) / 2);
glfwMakeContextCurrent(windowID);
glfwShowWindow(windowID);
}
示例10: findRift
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
public boolean findRift() {
PointerBuffer monitors = GLFW.glfwGetMonitors();
IntBuffer modeCount = BufferUtils.createIntBuffer(1);
for (int i = 0; i < monitors.limit(); i++) {
long monitorId = monitors.get(i);
System.out.println("monitor: " + monitorId);
ByteBuffer modes = GLFW.glfwGetVideoModes(monitorId, modeCount);
System.out.println("mode count=" + modeCount.get(0));
for (int j = 0; j < modeCount.get(0); j++) {
modes.position(j * GLFWvidmode.SIZEOF);
int width = GLFWvidmode.width(modes);
int height = GLFWvidmode.height(modes);
// System.out.println(width + "," + height + "," + monitorId);
if (width == riftWidth && height == riftHeight) {
System.out.println("found dimensions match: " + width + "," + height + "," + monitorId);
riftMonitorId = monitorId;
if (i == RIFT_MONITOR) {
return true;
}
}
}
System.out.println("-----------------");
}
return (riftMonitorId != 0);
}
示例11: init
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
/**
* Create window and OpenGL context
* @param title Window title
* @param width Window width
* @param height Window height
* @param resizable Should the window be resizable
* @param game CoreGame instance
*/
public static void init(String title, int width, int height, boolean resizable, CoreGame game) {
if (!glfwInit()) {
System.err.println("Could not initialize window system!");
System.exit(1);
}
if (!resizable)
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
if (anti_alias)
glfwWindowHint(GLFW_SAMPLES, 4);
window = glfwCreateWindow(width, height, title, 0, 0);
if (window == 0) {
glfwTerminate();
System.err.println("Could not create window!");
System.exit(1);
}
glfwMakeContextCurrent(window);
GL.createCapabilities();
GLFWVidMode vidMode = glfwGetVideoMode(window);
glfwSetWindowPos(window, (vidMode.width() / 2) - (width / 2), (vidMode.height() / 2) - (height / 2));
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, height, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
if (anti_alias) glEnable(GL_MULTISAMPLE);
Window.game = game;
Window.render = new Render();
AudioPlayer.init();
start();
}
示例12: init
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
/**
* Initializes the GLFW library, creating a window and any necessary shaders.
*/
void init(GameState gameState, Main client) {
if (!glfwInit()) {
System.err.println("Failed to initialise GLFW");
System.exit(1);
}
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
window = glfwCreateWindow(windowWidth, windowHeight, Constants.TITLE, 0, 0);
if (window == 0) {
System.err.println("Failed to create window.");
System.exit(1);
}
GLFWVidMode videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
int windowXPosition = (videoMode.width() - windowWidth) / 2;
int windowYPosition = (videoMode.height() - windowHeight) / 2;
glfwSetWindowPos(window, windowXPosition, windowYPosition);
glfwShowWindow(window);
glfwMakeContextCurrent(window);
GL.createCapabilities();
cshader = new ShaderProgram("shaders/cshader.vs","shaders/shader.fs");
rshader = new ShaderProgram("shaders/rshader.vs","shaders/shader.fs");
pshader1 = new ShaderProgram("shaders/pshader.vs","shaders/shader.fs");
pshader2 = new ShaderProgram("shaders/pshader2.vs","shaders/shader.fs");
pshader3 = new ShaderProgram("shaders/pshader3.vs","shaders/shader.fs");
starshader = new ShaderProgram("shaders/starshader.vs","shaders/shader.fs");
registerInputCallbacks(gameState, client);
}
示例13: glfwSwapInterval
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
public static void glfwSwapInterval(int interval, Void ret, MethodCall mc) {
Context ctx = CURRENT_CONTEXT.get();
if (ctx != null && interval != 0) { // != 0 for EXT_swap_control_tear
long monitor = org.lwjgl.glfw.GLFW.glfwGetWindowMonitor(ctx.window);
if (monitor == 0L) {
monitor = org.lwjgl.glfw.GLFW.glfwGetPrimaryMonitor();
}
GLFWVidMode mode = org.lwjgl.glfw.GLFW.glfwGetVideoMode(monitor);
int refreshRate = mode.refreshRate();
mc.comment(refreshRate / Math.abs(interval) + " Hz");
}
mc.param(interval);
}
示例14: createBackground
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
private void createBackground() {
Variables.X = 0;
Variables.Y = 0;
GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
WindowHandle handle = WindowManager.generateHandle(vidmode.width(), vidmode.height(), "");
handle.isDecorated(false);
handle.isVisible(false);
PixelBufferHandle pb = new PixelBufferHandle();
pb.setSrgbCapable(1);
pb.setSamples(4);
handle.setPixelBuffer(pb);
Window backWindow = WindowManager.generate(handle);
Thread backThr = new Thread(() -> {
backgroundWindow = new Background(backWindow, handle);
backgroundWindow.init();
float delta = 0;
float accumulator = 0f;
float interval = 1f / 5;
float alpha = 0;
int fps = 5;
Window window = backgroundWindow.getWindow();
while (running) {
delta = window.getDelta();
accumulator += delta;
while (accumulator >= interval) {
backgroundWindow.update(interval);
accumulator -= interval;
}
alpha = accumulator / interval;
if (window.isVisible())
backgroundWindow.render(alpha);
window.updateDisplay(fps);
}
backgroundWindow.dispose();
window.dispose();
});
backThr.start();
}
示例15: main
import org.lwjgl.glfw.GLFWvidmode; //导入依赖的package包/类
public static void main(String[] args) {
new Bootstrap(args);
GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
Variables.WIDTH = vidmode.width();
Variables.HEIGHT = 40;
Variables.X = 0;
Variables.Y = vidmode.height() - 40;
Variables.ALWAYS_ON_TOP = true;
Variables.DECORATED = false;
Variables.TITLE = "Shell_TrayWnd";
new App(new TaskBar());
}