Permalink
Browse files

RaspberryPi mouse pointer

Signed-off-by: Xerxes Rånby <xerxes@zafena.se>
  • Loading branch information...
xranby committed Jan 18, 2013
1 parent 2b97e83 commit f66a3ae4fb268bb717530e6ad7744eb693ecd693
@@ -31,7 +31,13 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.backends.joal.OpenALAudio;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.g2d.Gdx2DPixmap;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.GdxRuntimeException;
import com.jogamp.newt.Screen;
import com.jogamp.newt.ScreenMode;
@@ -83,6 +89,14 @@ public void resume () {
super.resume();
}
Texture textureFromPixmap (Gdx2DPixmap pixmap) {
Texture texture = new Texture(pixmap.getWidth(), pixmap.getHeight(), Format.RGB565);
texture.bind();
Gdx.gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0,
pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
return texture;
}
@Override
public void init (GLAutoDrawable drawable) {
initializeGLInstances(drawable);
@@ -95,6 +109,15 @@ public void init (GLAutoDrawable drawable) {
}
created = true;
}
// Fake pointer
Gdx2DPixmap pixmap = new Gdx2DPixmap(16, 16, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888);
pixmap.clear(Color.rgba8888(0, 0, 0, 0.0f));
pixmap.drawLine(0, 0, 10, 16, Color.rgba8888(0, 1, 1, 0.5f));
pixmap.drawLine(0, 0, 8, 0, Color.rgba8888(0, 1, 1, 0.5f));
pixmap.drawLine(0, 0, 0, 8, Color.rgba8888(0, 1, 1, 0.5f));
pointer = new Sprite(textureFromPixmap (pixmap));
batch = new SpriteBatch();
}
@Override
@@ -123,11 +146,20 @@ public void display (GLAutoDrawable arg0) {
}
((JoglInput)(Gdx.input)).processEvents();
listener.render();
// Fake mouse pointer
pointer.setPosition(((JoglInput)(Gdx.input)).getX(), canvas.getHeight()-((JoglInput)(Gdx.input)).getY()-16);
batch.begin();
pointer.draw(batch);
batch.end();
((OpenALAudio)Gdx.audio).update();
}
}
}
SpriteBatch batch;
Sprite pointer;
public void destroy () {
if (!canvas.getContext().isCurrent()) {
canvas.getContext().makeCurrent();
@@ -3,8 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="assets"/>
<classpathentry combineaccessrules="false" kind="src" path="/gdx"/>
<classpathentry combineaccessrules="false" kind="src" path="/gdx-backend-lwjgl"/>
<classpathentry combineaccessrules="false" kind="src" path="/gdx-openal"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/gdx-backend-jogl"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -1,10 +1,12 @@
package de.swagner.paxbritannica;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.jogl.JoglApplication;
public class PaxBritannicaDesktop {
public static void main(String[] args) {
new LwjglApplication(new PaxBritannica(),
"Pax Britannica", 1024, 550,false);
// new JoglApplication(new PaxBritannica(),
// "Pax Britannica", 1024, 550,false);
new JoglApplication(new PaxBritannica(),
"Pax Britannica", 1920, 1080,false);
}
}

0 comments on commit f66a3ae

Please sign in to comment.