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


Java GL类代码示例

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


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

示例1: run

import org.lwjgl.opengl.GL; //导入依赖的package包/类
@Override
public void run() {
	init();
	glfwMakeContextCurrent(window);
	GL.createCapabilities();

	// Set the clear color
	glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
	while (!glfwWindowShouldClose(window)) {
		loop();
	}

	// Free the window callbacks and destroy the window
	glfwFreeCallbacks(window);
	glfwDestroyWindow(window);

	// Terminate GLFW and free the error callback
	glfwTerminate();
	glfwSetErrorCallback(errorCallback).free();
}
 
开发者ID:HuajiStudio,项目名称:ChessMaster,代码行数:21,代码来源:RenderLoop.java

示例2: init

import org.lwjgl.opengl.GL; //导入依赖的package包/类
/**
 * Initialize default state.
 */
private void init() {
    if (glfwInit() != GL_TRUE) {
        throw new IllegalStateException("GLFW failed to initialize!");
    }

    win = glfwCreateWindow(SCREEN_WIDTH, SCREEN_HEIGHT, TITLE, 0, 0);
    glfwShowWindow(win);
    glfwMakeContextCurrent(win);

    GLContext.createFromCurrent();
    GL.createCapabilities(true);
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
 
开发者ID:DeadRunningOnTray,项目名称:Prepare4LudumDare,代码行数:19,代码来源:Game.java

示例3: OpenGLEngine

import org.lwjgl.opengl.GL; //导入依赖的package包/类
public OpenGLEngine() {
	// Set OpenGL context
	GL.createCapabilities();
 
	// Set the clear color
	glClearColor(0.0f, 0.4f, 0.8f, 0.0f);
	
	// Enable transparent textures
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND); 
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	renderQueue = new RenderQueue();
       
	// TODO shader support
       shader = new ShaderProgram(
		new Shader("shaders/vertex.glsl", GL20.GL_VERTEX_SHADER),
		new Shader("shaders/fragment.glsl", GL20.GL_FRAGMENT_SHADER)
	);
}
 
开发者ID:tacocat,项目名称:lambda,代码行数:21,代码来源:OpenGLEngine.java

示例4: initGL

import org.lwjgl.opengl.GL; //导入依赖的package包/类
/**
 * Initializes the GL parameters
 */
private void initGL() {
	GL.createCapabilities();

       for (int flag : GL_FLAGS) {
       	glEnable(flag);
       }

       glClearColor(Colour.BACKDROP[0], Colour.BACKDROP[1], Colour.BACKDROP[2], Colour.BACKDROP[3]);

	// Matrix Initialization
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();

       // Define frustum
       float yTop  = (float) (VIEW_Z_NEAR * Math.tan(Math.toRadians(VIEW_FOV / 2)));
    float xLeft = yTop * VIEW_ASPECT;
    glFrustum(xLeft, -xLeft, -yTop, yTop, VIEW_Z_NEAR, VIEW_Z_FAR);

       glMatrixMode(GL_MODELVIEW);
       glLoadIdentity();
}
 
开发者ID:Mandrenkov,项目名称:Geoscape,代码行数:25,代码来源:Window.java

示例5: loop

import org.lwjgl.opengl.GL; //导入依赖的package包/类
public void loop(){
	GL.createCapabilities();

	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glClearColor(0, 0, 0, 1);

	screen = new MainScreen(w);
	w.navigate(screen);

	while(!w.shouldClose()){
		w.loop();
	}
}
 
开发者ID:jason-yang31415,项目名称:gl3DGE,代码行数:19,代码来源:LightingDemo.java

示例6: create

import org.lwjgl.opengl.GL; //导入依赖的package包/类
/**
 * Initializes the GLFW display and GL capabilities.
 */
public void create()
{
	if (glfwInit() != GLFW_TRUE)
		throw new RuntimeException("Could not init GLFW.");
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
	window = glfwCreateWindow(width, height, title, 0, 0);

	if (window == 0)
	{
		glfwTerminate();
		throw new RuntimeException("Window pointer is NULL.");
	}

	glfwMakeContextCurrent(window);
	glfwSwapInterval(vSync ? 1 : 0);
	GL.createCapabilities(true);
	glfwSetInputMode(window, GLFW_STICKY_KEYS, GLFW_TRUE);
	isCreated = true;
}
 
开发者ID:jibini-media,项目名称:lwjgl-utils,代码行数:26,代码来源:Display.java

示例7: Window

import org.lwjgl.opengl.GL; //导入依赖的package包/类
/**
 * Create a window
 *
 * @param title               The window title
 * @param width               The window width
 * @param height              The window height
 * @param fullscreen          Wether it should be a fullscreen window
 * @param fullscreenVideoMode The video mode (ignored if fullscreen is <code>false</code>)
 * @param monitor             The monitor to put the window on (ignored if fullscreen is <code>false</code>)
 */
public Window(String title, int width, int height, boolean fullscreen, @Nullable GLFWVidMode fullscreenVideoMode, long monitor) {
	this.width = width;
	this.height = height;
	this.title = title;
	this.fullscreen = fullscreen;

	if (fullscreen) {
		GLFW.glfwWindowHint(GLFW.GLFW_RED_BITS, fullscreenVideoMode.redBits());
		GLFW.glfwWindowHint(GLFW.GLFW_GREEN_BITS, fullscreenVideoMode.greenBits());
		GLFW.glfwWindowHint(GLFW.GLFW_BLUE_BITS, fullscreenVideoMode.blueBits());
		GLFW.glfwWindowHint(GLFW.GLFW_REFRESH_RATE, fullscreenVideoMode.refreshRate());
		width = fullscreenVideoMode.width();
		height = fullscreenVideoMode.height();
	}

	window = GLFW.glfwCreateWindow(width, height, title, fullscreen ? monitor : MemoryUtil.NULL, MemoryUtil.NULL
	);
	GLFW.glfwMakeContextCurrent(window);
	GLFW.glfwSwapInterval(0);
	glCapabilities = GL.createCapabilities();
	initCallbacks();
	setCursorEnabled(cursorEnabled);
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:34,代码来源:Window.java

示例8: getGLVersion

import org.lwjgl.opengl.GL; //导入依赖的package包/类
@UIEffect
private String getGLVersion(boolean es) {
	String fullVersion;
	String renderer;
	
	if (es) {
		GLES.createCapabilities();
		fullVersion = GLES20.glGetString(GLES20.GL_VERSION);
		renderer = GLES20.glGetString(GLES20.GL_RENDERER);
	} else {
		GL.createCapabilities();
		fullVersion = GL11.glGetString(GL11.GL_VERSION);
		renderer = GL11.glGetString(GL11.GL_RENDERER);
	}
	
	log.info("{}", fullVersion);
	log.info("{}", renderer);
	
	String version = fullVersion.split(" ", 2)[0];
	return version;
}
 
开发者ID:mav-assistant,项目名称:Mavkit,代码行数:22,代码来源:Display.java

示例9: setUp

import org.lwjgl.opengl.GL; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    window = new Window();
    window.setup();

    GLFW.glfwMakeContextCurrent(window.getWindowHandler());
    GL.createCapabilities();
    final String VERTEX_SHADER_STRING = "#version 100\n" +
            "\n" +
            "uniform mat4 projTrans;\n" +
            "\n" +
            "attribute vec2 Position;\n" +
            "attribute vec2 TexCoord;\n" +
            "\n" +
            "varying vec2 vTexCoord;\n" +
            "\n" +
            "void main() {\n" +
            "    vTexCoord = TexCoord;\n" +
            "    gl_Position = 80.0 * vec4(Position, 0.0, 1.0);\n" +
            "}";
    shader = new Shader(ShaderUtil.VERTEX_SHADER, VERTEX_SHADER_STRING);
}
 
开发者ID:agent6262,项目名称:Abstract-Java-Game-Library,代码行数:23,代码来源:ShaderProgramTest.java

示例10: create

import org.lwjgl.opengl.GL; //导入依赖的package包/类
public void create()
{
	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);	
	
	setId(glfwCreateWindow(getWidth(), getHeight(), "OE3", 0, 0));
	
	if(getId() == 0) {
	    throw new RuntimeException("Failed to create window");
	}
	
	setIcon("textures/logo/oreon_lwjgl_icon32.png");
	
	glfwMakeContextCurrent(getId());
	glfwSwapInterval(0);
	glfwShowWindow(getId());
	capabilities = GL.createCapabilities();
}
 
开发者ID:oreonengine,项目名称:oreon-engine,代码行数:21,代码来源:GLWindow.java

示例11: glhSetContext

import org.lwjgl.opengl.GL; //导入依赖的package包/类
/** set the opengl context to the given window */
public static void glhSetContext(GLFWContext context) {
	Logger.get().log(Level.FINE, "OpenGL context set: " + context);
	// set current context
	GLFW.glfwMakeContextCurrent(context.getWindow().getPointer());
	// create context capa
	context.createCapabilities();
	// set current capa to use
	GL.setCapabilities(context.getCapabilities());

	// singleton update
	theContext = context;

	// add the window to GLH objects so it is clean properly on program
	// termination
	GLH.glhAddObject(context.getWindow());
}
 
开发者ID:rpereira-dev,项目名称:CubeEngine,代码行数:18,代码来源:GLH.java

示例12: loop

import org.lwjgl.opengl.GL; //导入依赖的package包/类
void loop() {
    glfwMakeContextCurrent(window);
    GL.createCapabilities();
    glClearColor(0.97f, 0.97f, 0.97f, 1.0f);
    while (!glfwWindowShouldClose(window)) {
        glfwPollEvents();
        glViewport(0, 0, fbWidth, fbHeight);
        viewport[2] = fbWidth; viewport[3] = fbHeight;
        glClear(GL_COLOR_BUFFER_BIT);
        computeVisibleExtents();
        glMatrixMode(GL_PROJECTION);
        glLoadMatrixf(cam.viewproj().get(fb));
        renderGrid();
        renderTickLabels();
        //renderMouseCursorCoordinates();
        glfwSwapBuffers(window);
    }
}
 
开发者ID:JOML-CI,项目名称:joml-lwjgl3-demos,代码行数:19,代码来源:CoordinateSystemDemo.java

示例13: loop

import org.lwjgl.opengl.GL; //导入依赖的package包/类
void loop() {
    GL.createCapabilities();

    glClearColor(0.99f, 0.99f, 0.99f, 1.0f);
    glLineWidth(1.8f);

    while (!glfwWindowShouldClose(window)) {
        glViewport(0, 0, fbWidth, fbHeight);
        glClear(GL_COLOR_BUFFER_BIT);

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, fbWidth, fbHeight, 0, -1, 1);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        renderPolygon();

        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    // autosave current polygon
    // store("autopoly.gon");
}
 
开发者ID:JOML-CI,项目名称:joml-lwjgl3-demos,代码行数:26,代码来源:PolygonDrawer.java

示例14: drawScene

import org.lwjgl.opengl.GL; //导入依赖的package包/类
@Override
public void drawScene(float mouseX, float mouseY) {
    final GLCanvas canvas = cp.getCanvas();

    if (!canvas.isCurrent()) {
        canvas.setCurrent();
        GL.setCapabilities(cp.getCapabilities());
    }
    
    GL11.glColorMask(true, true, true, true);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
    
    Rectangle bounds = cp.getBounds();
    GL11.glViewport(0, 0, bounds.width, bounds.height);
    
    shaderProgram.use();
    GL30.glBindVertexArray(VAO);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);
    GL30.glBindVertexArray(0);
    
    canvas.swapBuffers();
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:24,代码来源:vboWithRGBA.java

示例15: drawScene

import org.lwjgl.opengl.GL; //导入依赖的package包/类
@Override
public void drawScene(float mouseX, float mouseY) {
    final GLCanvas canvas = cp.getCanvas();

    if (!canvas.isCurrent()) {
        canvas.setCurrent();
        GL.setCapabilities(cp.getCapabilities());
    }
    
    GL11.glColorMask(true, true, true, true);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
    
    Rectangle bounds = cp.getBounds();
    GL11.glViewport(0, 0, bounds.width, bounds.height);
    
    shaderProgram.use();
    GL30.glBindVertexArray(VAO);
    // GL20.glEnableVertexAttribArray(POSITION_SHADER_LOCATION); // <-- Not necessary!
    GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_INT, 0);
    // GL20.glDisableVertexAttribArray(POSITION_SHADER_LOCATION); // <-- Not necessary!
    GL30.glBindVertexArray(0);
    
    canvas.swapBuffers();
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:26,代码来源:vboWithIndices.java


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