當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。