Skip to content

Commit

Permalink
[added] Graphics.hasExtensions() to check for GL extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogicgames committed Jul 7, 2011
1 parent 9133880 commit ab1bd3f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public final class AndroidGraphics implements Graphics, Renderer {
GL11 gl11;
GL20 gl20;
GLU glu;
String extensions;

private long lastFrameTime = System.nanoTime();
private float deltaTime = 0;
Expand Down Expand Up @@ -544,4 +545,9 @@ protected AndroidDisplayMode (int width, int height, int refreshRate, int bitsPe

@Override public void setVSync (boolean vsync) {
}

@Override public boolean hasExtension (String extension) {
if(extensions == null) extensions = Gdx.gl.glGetString(GL10.GL_EXTENSIONS);
return extensions.contains(extension);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.backends.openal.OpenALAudio;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.utils.GdxRuntimeException;

Expand All @@ -52,6 +53,7 @@ public class JoglGraphics extends JoglGraphicsBase implements GLEventListener {
boolean exclusiveMode = false;
final JoglDisplayMode desktopMode;
final JoglApplicationConfiguration config;
String extensions;

public JoglGraphics (ApplicationListener listener, JoglApplicationConfiguration config) {
initialize(config);
Expand Down Expand Up @@ -329,4 +331,9 @@ protected static JFrame findJFrame(Component component) {
GLCapabilities caps = canvas.getChosenGLCapabilities();
return new BufferFormat(caps.getRedBits(), caps.getGreenBits(), caps.getBlueBits(), caps.getAlphaBits(), caps.getDepthBits(), caps.getStencilBits(), caps.getNumSamples(), false);
}

@Override public boolean hasExtension (String extension) {
if(extensions == null) extensions = Gdx.gl.glGetString(GL10.GL_EXTENSIONS);
return extensions.contains(extension);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;

import com.badlogic.gdx.Application;
import com.badlogic.gdx.ApplicationListener;
Expand All @@ -33,6 +34,7 @@
import com.badlogic.gdx.Input;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.backends.openal.OpenALAudio;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.utils.GdxRuntimeException;

/**
Expand Down Expand Up @@ -130,6 +132,8 @@ private void mainLoop () {
int lastWidth = graphics.getWidth();
int lastHeight = graphics.getHeight();

Gdx.app.log("LwjglApplication", "extension: " + Gdx.gl.glGetString(GL10.GL_EXTENSIONS));

graphics.lastTime = System.nanoTime();
while (running && !Display.isCloseRequested()) {
graphics.updateTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public final class LwjglGraphics implements Graphics {
boolean resize = false;
LwjglApplicationConfiguration config;
BufferFormat bufferFormat = new BufferFormat(8, 8, 8, 8, 16, 8, 0, false);
String extensions;

LwjglGraphics (LwjglApplicationConfiguration config) {
this.config = config;
Expand Down Expand Up @@ -359,4 +360,9 @@ public LwjglDisplayMode (int width, int height, int refreshRate, int bitsPerPixe
if(vsync && !config.useCPUSynch) Display.setVSyncEnabled(true);
if(!vsync && !config.useCPUSynch) Display.setVSyncEnabled(false);
}

@Override public boolean hasExtension (String extension) {
if(extensions == null) extensions = Gdx.gl.glGetString(GL10.GL_EXTENSIONS);
return extensions.contains(extension);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.awt.Toolkit;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.Graphics.DisplayMode;
import com.badlogic.gdx.graphics.GL10;
Expand All @@ -36,6 +37,7 @@ public class AngleGraphics implements Graphics {
int fps;
int frames;
float deltaTime = 0;
String extensions;

AngleGraphics (int width, int height) {
gl = new AngleGLES20();
Expand Down Expand Up @@ -155,4 +157,9 @@ void updateTime () {
@Override public BufferFormat getBufferFormat () {
return null;
}

@Override public boolean hasExtension (String extension) {
if(extensions == null) extensions = Gdx.gl.glGetString(GL10.GL_EXTENSIONS);
return extensions.contains(extension);
}
}
6 changes: 6 additions & 0 deletions gdx/src/com/badlogic/gdx/Graphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ public String toString() {
*/
public BufferFormat getBufferFormat();

/**
* @param extension the extension name
* @return whether the extension is supported
*/
public boolean hasExtension(String extension);

// /**
// * Opens the first back facing video camera. Only one camera
// * can be opened at any given time.
Expand Down

0 comments on commit ab1bd3f

Please sign in to comment.