Show Posts
|
|
Pages: [1] 2
|
|
2
|
Java Game APIs & Engines / JOGL Development / How to detect Pixel order RGBA vs ABGR
|
on: 2010-04-26 11:40:42
|
Hi, the new java version 1.6.0_20 is coursing some troubles with my transparent images. The transparency is swapped and the pixels of a buffered image are in the order ABGR. Before it was RGBA. How can I determine the order? Since I want to have the correct colors in all of the versions (at least the newer java versions) I tried this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| public void findPixelChannelOrder(){ BufferedImage image = FileController.getInstance().getImage("rsc/red.gif"); int firstpixel = image.getRGB(0,0); int r = (firstpixel & 0xff000000) >> 16; int g = (firstpixel & 0x00ff0000) >> 16; int b = (firstpixel & 0x0000ff00) >> 16; int a = (firstpixel & 0x000000ff) >> 16;
GUIController.getInstance().getConsole().print("r: "+r+" g: "+g+" b: "+b+" a: "+a); if (r == 255){ EnvironmentController.getInstance().setRGBA(true); }else{ if (a == 255){ EnvironmentController.getInstance().setRGBA(false); } } } |
but it is useless, had also some other configurations shifting in different direction etc but its not working. I am stucked here.
|
|
|
|
|
4
|
Java Game APIs & Engines / JOGL Development / Re: transparency problem since java 1.6.0_20
|
on: 2010-04-21 15:09:32
|
I do this with the new BufferedImage.TYPE_4BYTE_ABGR 1 2 3 4 5 6 7 8
| imgRGBA = ((DataBufferByte)interfaceElements.get(i).image.getRaster().getDataBuffer()).getData();
buffer = ByteBuffer.wrap(imgRGBA);
gl.glDrawPixels(width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer); |
Do I have to set up different parameters? Is there something wrong with the commands I used?
|
|
|
|
|
5
|
Java Game APIs & Engines / JOGL Development / Re: transparency problem since java 1.6.0_20
|
on: 2010-04-21 15:01:21
|
I have done it like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
| int width = image.getWidth(); int height = image.getHeight(); BufferedImage newImage = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); for(int i = 0; i < width; i++){ for(int j = 0; j < height; j++){ int k = image.getRGB(i, j); newImage.setRGB(i, j, k); } } } |
then used the newImage, but there was no difference. What do you exactly mean with accessing the pixels ?
|
|
|
|
|
6
|
Java Game APIs & Engines / JOGL Development / transparency problem since java 1.6.0_20
|
on: 2010-04-21 14:47:00
|
Hello, I am loading some transparent pngs: 1
| BufferedImage image = ImageIO.read(url); |
then I want to draw them on the gl canvas surface: 1 2 3 4 5 6 7 8 9 10
| width = image.getWidth(); height = image.getHeight(); gl.glWindowPos2i(win_x + 5, (win_y - height - 5)); byte[] imgRGBA = ((DataBufferByte)interfaceElements.get(i).image.getRaster().getDataBuffer()).getData(); ByteBuffer buffer = ByteBuffer.wrap(imgRGBA); gl.glDrawPixels(width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer); |
This was working fine until I installed the new java version 1.6.0_20, earlier I was using 1.6.0_14, which was workign nicely! Now Instead of transparency I got these blueish looking colors. I read somewhere here, that it has something to do with indexed colors? Does somebody know how to fix these problem? I was searching for it here, there was an solution from NexusOne, which was not working for me. kind regards Knut
|
|
|
|
|
8
|
Java Game APIs & Engines / JOGL Development / Overlay Kills Content when resizing
|
on: 2009-09-22 11:26:37
|
Hi, I am using an GLJPanel to draw my scene. And I use an overlay that draws and alpha rectangle to darken the screen sometimes (the panel). Rest is swing. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| if(olay == null){ olay = new Overlay(drawable); g2D = olay.createGraphics(); rec = new Rectangle(); rec.x = 0; rec.y = 0; }
rec.width = GLController.getInstance().getViewport()[2]; rec.height = GLController.getInstance().getViewport()[3]; AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.75f);
g2D.setComposite(ac); g2D.setColor(Color.BLACK); g2D.fill(rec); g2D.draw(rec); g2D.dispose();
olay.beginRendering(); olay.draw(0,0, rec.width, rec.height); olay.endRendering(); |
this looks fine until i dont resize it, then the gl panel shows white content... until the overlay is killed -> then the 3d scene is rendered again. so what to do what to do? kind regards knut
|
|
|
|
|
9
|
Java Game APIs & Engines / JOGL Development / Perspective scaling
|
on: 2009-08-04 23:07:01
|
|
Hi,
When the Frame of the GLJPanel is resizing, then the objects are drawn bigger. Is it possible that the objects are drawn in the same size as before, but more objects are visible?
And If so, is it just a alignment of the camera depending on the frame size. For example Z axis++, when the camera is set down the z axis?
Or is it done else?
Imagine a field of quaders, like a chess field, but more quaders. When the window is resizing, the quaders have the same size, but they are more.
kind regards
Knut
|
|
|
|
|
10
|
Java Game APIs & Engines / JOGL Development / Texture mapping problem
|
on: 2009-07-30 23:31:33
|
Hi there, I have a problem with texture mapping on a cube mesh. I load a texture (not in the opengl thread): 1 2 3 4 5 6 7 8
| BufferedImage image = ImageIO.read(new File(texture)); tData = TextureIO.newTextureData(image, false);
textureData.add(tData);
return textureData.size()-1; |
In my Cube Mesh I call: 1 2 3 4 5 6
| if(texture != -1){ gl.glBindTexture(GL.GL_TEXTURE_2D, texture); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, 64, 64, 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, TextureController.getInstance().getTextureDataBufferAt(texture)); gl.glBindTexture(GL.GL_TEXTURE_2D, texture); } |
At the gl.glTexImage2D Command I got the following exception: java.lang.IllegalArgumentException: Illegally formatted version identifier: "null" What am I doing wrong here? I initiate the texturing like this: 1 2 3 4 5 6 7 8 9
| gl.glEnable(GL.GL_TEXTURE_2D); gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE); gl.glTexEnvf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); |
kind regards Knut
|
|
|
|
|
11
|
Java Game APIs & Engines / JOGL Development / Re: Modelview Matrix outside GLEventListener Always 0 ?
|
on: 2009-07-07 07:41:39
|
Hi again, this is my init and reshape method, respectively: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| public void init(GLAutoDrawable drawable) { gl = drawable.getGL(); gl.glEnable(GL.GL_DEPTH_TEST); gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); gl.glShadeModel(GL.GL_SMOOTH); gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT0); gl.glEnable(GL.GL_COLOR_MATERIAL);
float ambientLight[] = { 0.2f, 0.2f, 0.2f, 1.0f }; float diffuseLight[] = { 0.8f, 0.8f, 0.8f, 1.0f }; float specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f }; float position[] = { -1.5f, 1.0f, -4.0f, 1.0f };
gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambientLight, 0); gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuseLight, 0); gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, specularLight, 0); gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, position, 0); }
@Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL gl = drawable.getGL(); GLU glu = new GLU();
if (height <= 0) { height = 1; } final float h = (float) width / (float) height; gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45.0f, h, 1.0, 50.0); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0); GLController.getInstance().setViewport(viewport); } |
I also added a System.out to show some values in the scene.draw() function to show, that the TileSize has values: 1 2 3 4 5 6 7
| System.out.println("pos x = "+((0.0f - floorTileSize[0])+(float)(col*floorTileSize[0]))+"pos y = "+((0.0f - floorTileSize[1])+(float)(row*floorTileSize[1]))); gl.glTranslatef(((0.0f - floorTileSize[0])+(float)(col*floorTileSize[0])), ((0.0f - floorTileSize[1])+(float)(row*floorTileSize[1])), 0.0f); |
This is some of the output: pos x = 0.0pos y = 0.0 mod x = 0.0mod y = 0.0 pos x = 0.0pos y = 54.018032 mod x = 0.0mod y = 0.0 pos x = 0.0pos y = 108.03606 mod x = 0.0mod y = 0.0 pos x = 0.0pos y = 162.0541 mod x = 0.0mod y = 0.0 -> is still the not changing modelview matrix And to make sure, that the distances are maybe not just too big I testet the gl.Translatef with the following values: So I commented it out, after seeing that the result is the same and every cube is drawn to the center of the window. Could that be a windows vista 64 problem? But what the hell, Its just running in eclipse, and I put the gl directly during the display function of the gleventlistener in the scene draw method and in the end the drawing is finished be gl.glflush() in the display method it self. Actually, I had the same problem with another programm, that the modmatrix projmatrix and the viewport is only filled correctly in the GLEvent Listener methods, thus I had to change the hole drawing structur. Is it me or is it JOGL? With kind regards, Knut
|
|
|
|
|
12
|
Java Game APIs & Engines / JOGL Development / Modelview Matrix outside GLEventListener Always 0 ?
|
on: 2009-07-06 22:32:28
|
Hi there, I have a Scene and want to draw its elements to the display. What I am doing is, I call the scene draw methon in the GLEventlisteners display method and give it the gl object as parameter like this: 1 2 3 4 5
| public void display(GLAutoDrawable drawable) { this.gl = drawable.getGL(); GLController.getInstance().getScene().draw(gl); gl.glFlush(); } |
this is my drawing setup in the scene draw method: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
| public void draw(GL gl){ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT ); gl.glLoadIdentity();
gl.glTranslatef(0.0f, 0.0f, -25.0f); gl.glColor3f(1.0f,0.0f,0.0f); gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, modMatrix, 0); gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, projMatrix, 0); gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
... |
the the drawing method, I just want to draw some cubes on different positions. SO I change the values for gl.glTranslatef in two loops and draw the cube object in the next step: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| gl.glBegin(GL.GL_TRIANGLES); for(int col = 0; col < (int)(floorDimension[0]+2); col++){ for(int row = 0; row < (int)(floorDimension[1]+2) ; row++){ gl.glPushMatrix(); gl.glTranslatef(((0.0f - floorTileSize[0])+(float)(col*floorTileSize[0])), ((0.0f - floorTileSize[1])+(float)(row*floorTileSize[1])), 0.0f); gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, modMatrix, 0); System.out.println("mod x = " + modMatrix[12] + "mod y = " + modMatrix[13] ); floor.draw(gl); gl.glPopMatrix(); } } gl.glEnd(); |
Since I was wandering, why the cubes are always drawn in the center of the window, I loaded the modMatrix and printed the x,y coordinates, which are always 0. Why is it not possible to load them outside the event listener? When I have to draw everything in the event listener, the code is getting messy. Or have I done a mistake?
|
|
|
|
|
14
|
Java Game APIs & Engines / J2ME / Overlay Blending with Java ? the How ?
|
on: 2007-06-15 16:08:30
|
Hi, do you know the overlay blending funktion in adobe's photoshop. I want to use this for my mobile app. , to decrease the memory wasting. Does anybody know the calculations between it for the corresponding pixels? I first thought it would be R G B*Alpha ) + (R G B * Alpha), but i was wrong  example: a black line 0, 0, 0 freshes up a green line 73, 255,97 to a 0, 255, 0 i want to use a kind of watermark in a menu and scrollable lines.... so ... i can not store the photoshop result to an imagefile. sincerly me
|
|
|
|
|
19
|
Java Game APIs & Engines / J2ME / Re: jsr 82 works fine on emulator, but not on real device
|
on: 2007-05-31 19:06:05
|
this for the server: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
| package network;
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.DataOutputStream; import java.io.DataInputStream;
import javax.bluetooth.DataElement; import javax.bluetooth.DiscoveryAgent; import javax.bluetooth.LocalDevice; import javax.bluetooth.ServiceRecord; import javax.bluetooth.UUID; import javax.microedition.io.Connection; import javax.microedition.io.Connector; import javax.microedition.io.StreamConnection; import javax.microedition.io.StreamConnectionNotifier;
import controller.GameController; import controller.NetworkController;
public class Server implements Runnable{ private LocalDevice localDevice; ServiceRecord serviceRecord; StreamConnection connection; OutputStream os; private static final UUID VERSUS_SERVER_UUID = new UUID("F0E0D0C0B0A000908070605040302010", false);
boolean connected = false; ServerReceiverThread receiver; public Server(){ receiver = new ServerReceiverThread(); } public void start(){ Thread t = new Thread( this ); t.start(); } public void cancel(){ Thread t = new Thread(this); try{ t.sleep(1000); t.interrupt(); System.out.println("server active: "+ t.isAlive()); }catch(Exception e){ e.printStackTrace(); } }
public void run(){ try{ localDevice = LocalDevice.getLocalDevice(); if (!localDevice.setDiscoverable(DiscoveryAgent.GIAC)) { System.out.println("not discoverable"); } } catch (Exception e) { System.err.println("Can't initialize bluetooth: " + e); } StringBuffer url = new StringBuffer("btspp://"); url.append("localhost").append(':');
url.append(VERSUS_SERVER_UUID.toString());
url.append(";name=Versus Server");
url.append(";authorize=false"); createConnection(url.toString()); }
public void createConnection(String url){ try{ StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector.open(url.toString()); serviceRecord = localDevice.getRecord(notifier); serviceRecord.setAttributeValue(0x0100, new DataElement(DataElement.STRING, "vssrvnm")); serviceRecord.setAttributeValue(0x0101, new DataElement(DataElement.STRING, "test")); localDevice.updateRecord(serviceRecord); connection = notifier.acceptAndOpen(); localDevice.setDiscoverable(DiscoveryAgent.NOT_DISCOVERABLE); receiver.start(connection); connected = true; os = connection.openOutputStream(); String msg = "1hello there Client"; startNetworkGame(); }catch(IOException e){ e.printStackTrace(); } } public void closeConnection(){ try{ connected = false; connection.close(); }catch(IOException ioe){ } } public void startNetworkGame(){ sendCommand(GameController.getInstance().STARTGAME); GameController.getInstance().startGame(); } public void sendCommand(int i){ try{ os.write(i); }catch(IOException e){} System.out.println("da geht was nicht"); } public void sendCommand(byte[] b){ try{ os.write(b); }catch(IOException e){} }
public void getBTProperties(){ System.out.println(NetworkController.getInstance().getConnectionManager().getLocalDevice().getProperty("bluetooth.api.version")); System.out.println(NetworkController.getInstance().getConnectionManager().getLocalDevice().getProperty("bluetooth.sd.attr.retrievable.max")); System.out.println(NetworkController.getInstance().getConnectionManager().getLocalDevice().getProperty("bluetooth.connected.devices.max")); System.out.println(NetworkController.getInstance().getConnectionManager().getLocalDevice().getProperty("bluetooth.connected.inquiry.scan")); System.out.println(NetworkController.getInstance().getConnectionManager().getLocalDevice().getProperty("bluetooth.api.version")); System.out.println(NetworkController.getInstance().getConnectionManager().getLocalDevice().getProperty("bluetooth.connected.inquiry")); }
}
class ServerReceiverThread implements Runnable{ boolean connected; StreamConnection connection; public ServerReceiverThread(){} public void start(StreamConnection c) { this.connection = c; this.connected = true; Thread t = new Thread(this); t.start(); }
public void run() { try { InputStream is = connection.openInputStream(); byte[]buffer = new byte[100]; while (connected) { is.read(buffer); NetworkController.getInstance().seh.handleIncomingBytes(buffer); } } catch (IOException ioe) {
}
}
} |
|
|
|
|
|
20
|
Java Game APIs & Engines / J2ME / Re: jsr 82 works fine on emulator, but not on real device
|
on: 2007-05-31 19:05:37
|
Yes i get the Popup when i am starting a server (asking to allow creating bt server) I am using the Sony Ericsson SDK 2.2.4 libaries this is the source for client: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
| package network;
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.util.Vector;
import javax.bluetooth.BluetoothStateException; import javax.bluetooth.DeviceClass; import javax.bluetooth.DiscoveryAgent; import javax.bluetooth.DiscoveryListener; import javax.bluetooth.LocalDevice; import javax.bluetooth.RemoteDevice; import javax.bluetooth.ServiceRecord; import javax.bluetooth.UUID; import javax.microedition.io.Connector; import javax.microedition.io.StreamConnection; import javax.microedition.io.StreamConnectionNotifier;
import controller.GameController; import controller.NetworkController;
public class Client implements Runnable, DiscoveryListener{ Vector remoteDevices = new Vector(); private static final UUID VERSUS_SERVER_UUID = new UUID("F0E0D0C0B0A000908070605040302010", false); private UUID[] uuidSet; int[] attributes = {0x0100, 0x0101, 0x0003, 0x0004, 0x0000}; Thread clientThread;
LocalDevice localDevice; DiscoveryAgent discoveryAgent; boolean testBT;
private int discType; String connectionURL; StreamConnection connection; OutputStream os; InputStream is; ClientReceiverThread receiver; boolean connected = false; public Client(){ receiver = new ClientReceiverThread(); } public void start(){ NetworkController.getInstance().setClientBusy(true); clientThread = new Thread( this ); clientThread.start(); } public void run(){ try{ localDevice = LocalDevice.getLocalDevice(); discoveryAgent = localDevice.getDiscoveryAgent(); }catch(BluetoothStateException e){} uuidSet = new UUID[2]; uuidSet[0] = new UUID(0x1101);
uuidSet[1] = VERSUS_SERVER_UUID; remoteDevices.removeAllElements(); searchDevices(); if(remoteDevices.size() > 0){ searchServices(); }else { System.out.println("no Device found"); } try{ synchronized(this){ wait(); } } catch(InterruptedException e){ } connectionURL = (String)NetworkController.getInstance().getRemoteConnectionURLs().firstElement(); System.out.println("url: "+connectionURL.toString()); enterConnection(connectionURL); }
public void searchDevices() { try { discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this); System.out.println("searching for Devices..."); } catch (BluetoothStateException e) { e.printStackTrace(); } try { synchronized(this){ wait(); } } catch (InterruptedException e) { System.err.println("Unexpected interuption: " + e); } System.out.println("search Device komplett");
} public void deviceDiscovered(RemoteDevice remoteDevice, DeviceClass cod) { System.out.println("device discoverd..."); try { remoteDevices.addElement(remoteDevice); } catch (Exception e) { e.printStackTrace(); } } public void inquiryCompleted(int discType) { this.discType = discType; synchronized(this){ notify(); System.out.println("search Device notify"); } } public void searchServices(){ try { for ( int i = 0; i < remoteDevices.size(); i++) { discoveryAgent.searchServices(attributes, uuidSet, (RemoteDevice) remoteDevices.elementAt(i), this); } } catch (BluetoothStateException e) { e.printStackTrace(); } } public void servicesDiscovered(int transID, ServiceRecord[] serviceRecord) { try {
if (serviceRecord[0].getAttributeValue(0x100).getValue().toString() .equals("vssrvnm")) { System.out.println("Versus Server gefunden..."); NetworkController.getInstance().addServiceRecords(serviceRecord[0]); NetworkController.getInstance().setServiceDiscovered(true); } } catch (Exception e) { e.printStackTrace(); } } public void serviceSearchCompleted(int arg0, int arg1) { NetworkController.getInstance().setClientBusy(false); NetworkController.getInstance().updateServerList(); NetworkController.getInstance().drawServerList(); System.out.println("service search completed: list updated...");
}
public void enterConnection(String URL){ try { connection = (StreamConnection)Connector.open(URL); System.out.println(connection.toString()); } catch (IOException e) { System.err.println("Note: can't connect to: " + URL); } try{ connected = true; byte[]buffer = new byte[100]; System.out.println("bevore method receive bytes client"); receiver.start(connection); os = connection.openOutputStream(); String msg = "1hello there"; os.write(msg.getBytes()); } catch(Exception e) { e.printStackTrace(); } } public void sendCommand(int i){ try{ os.write(i); }catch(IOException e){ } } public void sendCommand(byte[] b){ try{ os.write(b); }catch(IOException e){ } } public void receiveBytes(StreamConnection connection){ byte buffer[] = new byte[100]; try{ InputStream is = connection.openInputStream(); while(connected){ is.read(buffer); NetworkController.getInstance().ceh.handleIncomingBytes(buffer); System.out.println("received"); } }catch(IOException e){ e.printStackTrace(); } } public void closeConnection(){ try{ connected = false; connection.close(); }catch(IOException ioe){ } }
public LocalDevice getLocalDevice() { return localDevice; } public void notifyConnection(){ synchronized(this){ notify(); } }
}
class ClientReceiverThread implements Runnable{ boolean connected; StreamConnection connection;
public ClientReceiverThread(){} public void start(StreamConnection c) { this.connection = c; this.connected = true; Thread t = new Thread(this); t.start(); }
public void run() { try { InputStream is = connection.openInputStream(); byte[]buffer = new byte[100]; while (connected) { is.read(buffer); NetworkController.getInstance().ceh.handleIncomingBytes(buffer); } } catch (IOException ioe) {
}
} } |
|
|
|
|
|
21
|
Java Game APIs & Engines / J2ME / jsr 82 works fine on emulator, but not on real device
|
on: 2007-05-31 17:22:46
|
|
Hi, I am currently working on a project, where i am using the bluetooth jsr 82 lib. On the emulator the device discovery and service discovery are working -> the dicsovered service are listed on the display -> i can choose a server -> and connect to it. Like the topic says its working on the emulator but not on the phones i tested (k750, v610i, another k750i and a other sony ericsson i think k600.... something like that) .
I dont not know where to find the error, i checked the jad file... and the manifest file, which includes this entries:
Manifest-Version: 1.0 MicroEdition-Configuration: CLDC-1.1 MIDlet-Name: TestforMIDlet Suite MIDlet-Permissions: javax.microedition.io.Connector.bluetooth.client,j avax.microedition.io.Connector.bluetooth.server MIDlet-Vendor: Midlet Suite Vendor MIDlet-1: StartMIDlet,,StartMIDlet MIDlet-Version: 1.0.0 MicroEdition-Profile: MIDP-2.0
is the linebreak a problem?
I installed the BluetoothDemo from wtk2 on my k750i and on my roommates v610i ... it works... moreless the same code like mine, some other variables names etc...
i am using eclipse me for developing, are there any known problems with that IDE ?
please help, if you need any more informations, ask me I am going to post them here.
with best regards
|
|
|
|
|
24
|
Java Game APIs & Engines / J2ME / Problem with Canvas
|
on: 2006-08-15 16:13:53
|
Hi, i have a problem running the canvas, one week ago the same application was running on my k750, but this week (without changing the code, only the Image name from bg.png to grassland.png) there is an error in the application. Please take a look at my Code and maybe you can tell my whats wrong. (Its running on the emulator the Images are in the res folder and the src folder). Midlet Class 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| import javax.microedition.midlet.*; import javax.microedition.lcdui.*;
public class HelloMIDlet extends MIDlet implements CommandListener { private Display display;
private MyCanvas mycanvas; public HelloMIDlet() { display = Display.getDisplay(this); mycanvas = new MyCanvas(); }
public void startApp() { display.setCurrent(mycanvas); mycanvas.repaint(); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable s) { notifyDestroyed(); } } |
Canvas Class 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Graphics; import javax.microedition.lcdui.Image;
public class MyCanvas extends Canvas{ Image bgImage; public MyCanvas(){ } protected void paint(Graphics g) { try{ bgImage = Image.createImage("/grassland.png"); }catch (Exception e){ e.printStackTrace(); g.drawString(e.toString(),0,0,0); }; g.drawImage(bgImage, 0, 0, 0); }
} |
it is moreless the Code from examples at diffrent websites.
|
|
|
|
|
25
|
Java Game APIs & Engines / JOGL Development / Selection Buffer Identifier always 0 problem
|
on: 2006-01-10 22:27:55
|
|
Hi, the Problem is: i am pushing the namestacl with incremented id, then i "draw" the object, then in pop the stack, like i have done a 100 times before or like every one of you does as well... but in this time. the value of the selectionbuffer identifier is always 0? anybody knows the problem? i dont think i have to paste code, its the same as every where to see.. i just want to know, if somebody of you ever had the same problem and a solution
|
|
|
|
|
26
|
Java Game APIs & Engines / JOGL Development / Re: gluUnproject not working
|
on: 2005-11-15 09:02:56
|
|
HI, i clear the buffer in the beginning think that its right... when draw the cube infront of the unproject method, the values are 0.0 too i just want to transform the mouse windowcoordinates to object coordinates (is this possible at all?) the coordinates from the object are not important to me, i return them with a feedback mode
|
|
|
|
|
29
|
Java Game APIs & Engines / JOGL Development / gluUnproject not working
|
on: 2005-11-13 19:04:42
|
Hi, the gluUnproject funktion does not create the right values, only 0.0. i dont know why. Can somebody take a look at my code pls. this is the part of the draw funktion: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| public void draw(GLDrawable drawable){ GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); double[] mvMatrix = new double[16]; double[] projection = new double[16]; int[] viewport = new int[4]; double[] objx = new double[1]; double[] objy = new double[1]; double[] objz = new double[1]; int realY; gl.glGetDoublev(GL.GL_MODELVIEW, mvMatrix); for (int i = 0; i < mvMatrix.length; i++){ System.out.println("mvmatrix: "+mvMatrix[i]); } gl.glGetDoublev(GL.GL_PROJECTION, projection); gl.glGetIntegerv(GL.GL_VIEWPORT, viewport); realY = viewport[3] - mouseY - 1 ; glu.gluUnProject((double)mouseX, (double)realY, 0.0, mvMatrix, projection, viewport, objx, objy, objz); System.out.println("this is it: "+objx[0]+","+objy[0]+","+objz[0]); this.geoobj.drawFromPrimitives(); gl.glFlush(); } |
the Mousevalues comes from the mouselistener...
|
|
|
|
|
30
|
Java Game APIs & Engines / JOGL Development / Again Feedback Problem
|
on: 2005-10-12 12:51:47
|
Hi, i am still working on feedback.. my problem is, when i am using glortho, i dont get the vertex- values only by using glPerspective()... can somebody pls take look at my code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| public void vertexFeedbackMode(Vertex v){ FloatBuffer feedbackBuffer = BufferUtils.newFloatBuffer(1024); int size; Vertex vertex = v; gl.glFeedbackBuffer(1024, GL.GL_3D, feedbackBuffer); gl.glMatrixMode(GL.GL_PROJECTION); gl.glPushMatrix(); gl.glRenderMode(GL.GL_FEEDBACK); gl.glLoadIdentity();
gl.glOrtho(0.0,(double)screenwidth,0.0,(double)screenheight,-1.0, 1.0);
gl.glPassThrough(1.0f); gl.glBegin(GL.GL_POINTS); gl.glVertex3f(vertex.data[0],vertex.data[1], vertex.data[2]); gl.glEnd(); size = gl.glRenderMode(GL.GL_RENDER); printOutFeedback(size, feedbackBuffer); gl.glMatrixMode(GL.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); } |
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|