List of usage examples for org.lwjgl.opengl GL11 GL_TRUE
int GL_TRUE
To view the source code for org.lwjgl.opengl GL11 GL_TRUE.
Click Source Link
From source file:com.wicpar.sinkingsimulatorclassic.graphics.Shader.java
License:Open Source License
public Shader compile() { if (ID == null) { delete();/*from w ww. j av a2s . c o m*/ ID = GL20.glCreateShader(type); } GL20.glShaderSource(ID, source); GL20.glCompileShader(ID); if (GL20.glGetShaderi(ID, GL20.GL_COMPILE_STATUS) != GL11.GL_TRUE) { logger.error("failed to compile shader: \n" + GL20.glGetShaderInfoLog(ID)); } return this; }
From source file:com.wicpar.sinkingsimulatorclassic.graphics.ShaderProgram.java
License:Open Source License
public ShaderProgram setShaders(Shader... shaders) { if (ID == null) create();/*from w w w . j a v a 2 s .co m*/ if (this.shaders.size() != 0) { for (Shader shader : this.shaders) { GL20.glDetachShader(ID, shader.getID()); } this.shaders.clear(); } for (Shader shader : shaders) { GL20.glAttachShader(ID, shader.getID()); } GL20.glLinkProgram(ID); if (GL20.glGetProgrami(ID, GL20.GL_LINK_STATUS) != GL11.GL_TRUE) { logger.error("failed to link program: \n" + GL20.glGetProgramInfoLog(ID)); } return this; }
From source file:cuchaz.jfxgl.prism.JFXGLContext.java
License:Open Source License
@Override public int createProgram(int vertexShaderId, int[] fragmentShaderIds, String[] attrs, int[] indices) { // build the shader program int id = GL20.glCreateProgram(); GL20.glAttachShader(id, vertexShaderId); for (int fragmentShaderId : fragmentShaderIds) { GL20.glAttachShader(id, fragmentShaderId); }/*www . j a v a 2 s . c o m*/ assert (attrs.length == indices.length); for (int i = 0; i < attrs.length; i++) { GL20.glBindAttribLocation(id, indices[i], attrs[i]); } GL20.glLinkProgram(id); boolean isSuccess = GL20.glGetProgrami(id, GL20.GL_LINK_STATUS) == GL11.GL_TRUE; if (!isSuccess) { throw new RuntimeException("Shader program did not link:\n" + GL20.glGetProgramInfoLog(id, 4096)); } GL20.glValidateProgram(id); isSuccess = GL20.glGetProgrami(id, GL20.GL_VALIDATE_STATUS) == GL11.GL_TRUE; if (!isSuccess) { throw new RuntimeException("Shader program did not validate:\n" + GL20.glGetProgramInfoLog(id, 4096)); } return id; }
From source file:cuchaz.jfxgl.prism.JFXGLContext.java
License:Open Source License
@Override public boolean texImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, Buffer pixels, boolean useMipmap) { // NOTE: null pixels are allowed if (pixels != null && !(pixels instanceof ByteBuffer)) { throw new Error( "buffer should be a " + ByteBuffer.class.getName() + ", not a " + pixels.getClass().getName()); }/*w ww . ja va 2 s.c o m*/ ByteBuffer buf = (ByteBuffer) pixels; if (useMipmap) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE); } // if buf is not direct, copy it to a direct buffer if (buf != null && !buf.isDirect()) { imageBuf = updateBuffer(imageBuf, buf); buf = imageBuf; } clearGLErrors(); GL11.glTexImage2D(translatePrismToGL(target), level, translatePrismToGL(internalFormat), width, height, border, translatePrismToGL(format), translatePrismToGL(type), buf); int glerror = getGLError(); boolean hasError = glerror != GL11.GL_NO_ERROR; if (hasError) { System.err.println(String .format("WARNING: couldn't upload texture. glTexImage2D failed with code: 0x%x", glerror)); } return !hasError; }
From source file:doom.Doom_3_3.java
private void initWindow() { // Setup an error callback. The default implementation // will print the error message in System.err. glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err)); // Initialize GLFW. Most GLFW functions will not work before doing this. if (glfwInit() != GL11.GL_TRUE) { throw new IllegalStateException("Unable to initialize GLFW"); }//from www. ja va 2 s . co m // Configure our window glfwDefaultWindowHints(); // optional, the current window hints are already the default glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // the window will stay hidden after creation glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // the window will be resizable glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Create the window window = glfwCreateWindow(width, height, "Hello World!", NULL, NULL); if (window == NULL) { throw new RuntimeException("Failed to create the GLFW window"); } // Setup a key callback. It will be called every time a key is pressed, repeated or released. glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback() { @Override public void invoke(long window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) { glfwSetWindowShouldClose(window, GL_TRUE); // We will detect this in our rendering loop } if (action == GLFW_PRESS || action == GLFW_REPEAT) { switch (key) { case GLFW_KEY_W: //UP game.board.player.forward(); break; case GLFW_KEY_S: //Down game.board.player.backward(); break; case GLFW_KEY_D: //RIGHT game.board.player.right(); break; case GLFW_KEY_A: //left game.board.player.left(); break; } } } }); //mouse button callback glfwSetMouseButtonCallback(window, mouseCallback = new GLFWMouseButtonCallback() { @Override public void invoke(long window, int button, int action, int mods) { } }); //set resize callback glfwSetWindowSizeCallback(window, windowSizeCallback = new GLFWWindowSizeCallback() { @Override public void invoke(long window, int width, int height) { game.resolutionChanged(); } }); // Get the resolution of the primary monitor ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); // Center our window glfwSetWindowPos(window, (GLFWvidmode.width(vidmode) - width) / 2, (GLFWvidmode.height(vidmode) - height) / 2); //mouse position callback glfwSetCursorPosCallback(window, posCallback = new GLFWCursorPosCallback() { private float mouseSensitivy = 0.1f; @Override public void invoke(long window, double xpos, double ypos) { //yaw and pitch are zero at center of window game.board.player.getCamera().setYaw((width / 2 - (float) xpos) * mouseSensitivy); game.board.player.getCamera().setPitch((height / 2 - (float) ypos) * mouseSensitivy); } }); // Make the OpenGL context current glfwMakeContextCurrent(window); // Enable v-sync glfwSwapInterval(1); // Make the window visible glfwShowWindow(window); }
From source file:espresso3d.engine.renderer.particle.E3DParticleRendererARBPointSprite.java
License:Open Source License
private void setupPointSpriteParameters(double spriteSize) { particleDistanceScalarBuffer.clear(); // particleDistanceScalarBuffer.put(0.0f);//1.0f); particleDistanceScalarBuffer.put(0.0f);//1.0f); particleDistanceScalarBuffer.put(0.0f); particleDistanceScalarBuffer.put((float) (1.0 / (getEngine().getCurrentViewport().getWidth() * getEngine().getCurrentViewport().getHeight())));//0.1f); particleDistanceScalarBuffer.rewind(); ARBPointParameters.glPointParameterARB(ARBPointParameters.GL_POINT_DISTANCE_ATTENUATION_ARB, particleDistanceScalarBuffer); ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_SIZE_MIN_ARB, 1f);//(float)particle.getSize());//1f ); ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_SIZE_MAX_ARB, maxPointSpriteSize); ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_FADE_THRESHOLD_SIZE_ARB, 100f); /* GL14.glPointParameter(GL14.GL_POINT_DISTANCE_ATTENUATION, particleDistanceScalarBuffer); GL14.glPointParameterf( GL14.GL_POINT_SIZE_MIN, 1f);//(float)particle.getSize());//1f ); GL14.glPointParameterf( GL14.GL_POINT_SIZE_MAX, maxPointSpriteSize); GL14.glPointParameterf(GL14.GL_POINT_FADE_THRESHOLD_SIZE, 100f); *//*w w w . j a v a 2 s .c o m*/ GL14.glPointParameterf(GL20.GL_POINT_SPRITE_COORD_ORIGIN, GL20.GL_LOWER_LEFT); GL11.glTexEnvf(ARBPointSprite.GL_POINT_SPRITE_ARB, ARBPointSprite.GL_COORD_REPLACE_ARB, GL11.GL_TRUE); // GL11.glTexEnvf( GL20.GL_POINT_SPRITE, GL20.GL_COORD_REPLACE, GL11.GL_TRUE ); GL11.glPointSize((float) spriteSize); //POINT_SIZE_WORLD_COORD_SCALAR); }
From source file:illarion.graphics.lwjgl.TextureAtlasLWJGL.java
License:Open Source License
/** * Activate the texture and prepare it for usage by OpenGL. * // w w w . j av a 2 s .c o m * @param resizeable true in case the texture shall be loaded with advanced * rescaling methods, that are more calculation intensive but * look better then the normal ones * @param allowCompression true if the texture is compressed at default * settings, false if not. Best disallow compression for static * images such as tiles, since the effects of the compression * will be quite visible there */ @Override @SuppressWarnings("nls") public void activateTexture(final boolean resizeable, final boolean allowCompression) { if (!hasTextureData()) { throw new IllegalStateException("No texturedata loaded"); } final int quality = Graphics.getInstance().getQuality(); if (getTextureID() != 0) { removeTexture(); } // generate new texture ID final int texID = getNewTextureID(); setTextureID(texID); // bind texture ID DriverSettingsLWJGL.getInstance().enableTexture(texID); // prepare texture data if (resizeable) { // Textures will be resized -> smoothing would be good if (quality <= Graphics.QUALITY_LOW) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } else if ((quality <= Graphics.QUALITY_NORMAL) || isNoMipMaps()) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); } else { if (GLContext.getCapabilities().OpenGL14) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE); } else { setNoMipMaps(true); } if (!isNoMipMaps()) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); } } } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); if (GLContext.getCapabilities().OpenGL13) { GL11.glHint(GL13.GL_TEXTURE_COMPRESSION_HINT, GL11.GL_NICEST); } // setup texture compression final boolean activateCompression = GLContext.getCapabilities().OpenGL13 && ((allowCompression && (quality < Graphics.QUALITY_MAX)) || (quality <= Graphics.QUALITY_LOW)); if (isTextureRGBA()) { internalFormat = GL11.GL_RGBA; sourceFormat = GL11.GL_RGBA; if (activateCompression) { internalFormat = GL13.GL_COMPRESSED_RGBA; } } else if (isTextureRGB()) { internalFormat = GL11.GL_RGB; sourceFormat = GL11.GL_RGB; if (activateCompression) { internalFormat = GL13.GL_COMPRESSED_RGB; } } else if (isTextureGrey()) { internalFormat = GL11.GL_LUMINANCE; sourceFormat = GL11.GL_LUMINANCE; if (activateCompression) { internalFormat = GL13.GL_COMPRESSED_LUMINANCE; } } else if (isTextureGreyAlpha()) { internalFormat = GL11.GL_LUMINANCE_ALPHA; sourceFormat = GL11.GL_LUMINANCE_ALPHA; if (activateCompression) { internalFormat = GL13.GL_COMPRESSED_LUMINANCE_ALPHA; } } final ByteBuffer texData = getTextureData(); final int texWidth = getTextureWidth(); final int texHeight = getTextureHeight(); // produce a texture from the byte buffer GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, internalFormat, texWidth, texHeight, 0, sourceFormat, GL11.GL_UNSIGNED_BYTE, texData); if (quality < Graphics.QUALITY_MAX) { texIDBuffer.rewind(); GL11.glGetTexLevelParameter(GL11.GL_TEXTURE_2D, 0, GL13.GL_TEXTURE_COMPRESSED, texIDBuffer); texData.rewind(); if (texIDBuffer.get(0) == GL11.GL_FALSE) { int newInternalFormat = internalFormat; if (internalFormat == GL13.GL_COMPRESSED_LUMINANCE_ALPHA) { newInternalFormat = GL13.GL_COMPRESSED_RGBA; } else if (internalFormat == GL13.GL_COMPRESSED_LUMINANCE) { newInternalFormat = GL13.GL_COMPRESSED_RGB; } final int orgSize = texData.remaining(); if (newInternalFormat != internalFormat) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, newInternalFormat, texWidth, texHeight, 0, sourceFormat, GL11.GL_UNSIGNED_BYTE, texData); GL11.glGetTexLevelParameter(GL11.GL_TEXTURE_2D, 0, GL13.GL_TEXTURE_COMPRESSED_IMAGE_SIZE, texIDBuffer); final int newSize = texIDBuffer.get(0); if (newSize > orgSize) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, internalFormat, texWidth, texHeight, 0, sourceFormat, GL11.GL_UNSIGNED_BYTE, texData); } } } } texIDBuffer.rewind(); GL11.glGetTexLevelParameter(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_INTERNAL_FORMAT, texIDBuffer); internalFormat = texIDBuffer.get(); discardImageData(); }
From source file:ion2d.INTexture2D.java
License:Open Source License
/** * Can only generate mipmap with opengl 1.4 or greater *///from w w w . j a v a 2 s .c o m public void glGenerateMipMap() { this.bind(); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE); }
From source file:jacobgc.grafx.grafxngine.display.Display.java
License:Open Source License
public static void init() { if (GLFW.glfwInit() != GL11.GL_TRUE) { System.err.println("GLFW initialziation failed!"); }/* ww w .j a v a 2 s . co m*/ GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GL11.GL_TRUE); window = GLFW.glfwCreateWindow(width, height, title, NULL, NULL); if (window == NULL) { System.err.println("Could not create the window!"); } GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor()); GLFW.glfwSetWindowPos(window, (vidmode.width() - width) / 2, (vidmode.height() - height) / 2); GLFW.glfwMakeContextCurrent(window); GL.createCapabilities(); GLFW.glfwShowWindow(window); }
From source file:jacobgc.grafx.grafxngine.display.Display.java
License:Open Source License
@Override public void run() { init();//ww w.j a v a 2s . c o m double frame_cap = 1.0 / fps; double time = Timer.getTime(); double unprocessed = 0; double frame_time = 0; int frames = 0; while (running) { boolean can_render = false; double time_2 = Timer.getTime(); double passed = time_2 - time; unprocessed += passed; frame_time += passed; time = time_2; while (unprocessed >= frame_cap) { can_render = true; unprocessed -= frame_cap; if (frame_time >= 1.0) { frame_time = 0; System.out.print(frames + "\n"); frames = 0; } } if (can_render) { render(); frames++; } update(); if (GLFW.glfwWindowShouldClose(window) == GL11.GL_TRUE) { running = false; loader.cleanUP(); } } }