Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Java Game APIs & Engines / JOGL Development / Re: How to detect Pixel order RGBA vs ABGR on: 2010-04-26 12:23:09
PRoblem solved in a different way.
2  Java Game APIs & Engines / JOGL Development / How to detect Pixel order RGBA vs ABGR on: 2010-04-26 09: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.

3  Java Game APIs & Engines / JOGL Development / Re: transparency problem since java 1.6.0_20 on: 2010-04-21 13:18:18
Ah now the penny has swapped.. aeh dropped! Thank you.
Currently I am fine with draw pixels. Maybe I change it later.

Ok thank you.

4  Java Game APIs & Engines / JOGL Development / Re: transparency problem since java 1.6.0_20 on: 2010-04-21 13:09:32
I do this with the new BufferedImage.TYPE_4BYTE_ABGR

1  
2  
3  
4  
5  
6  
7  
8  
// get a byte array   
imgRGBA = ((DataBufferByte)interfaceElements.get(i).image.getRaster().getDataBuffer()).getData();

//create bytebuffer            
buffer = ByteBuffer.wrap(imgRGBA);

// draw pixel            
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 13: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 12: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
7  Java Game APIs & Engines / JOGL Development / Re: Overlay Kills Content when resizing on: 2009-09-22 09:57:03
solved, it had something to do with a changed drawable... or something...

good so it must be re-initiated... Lunchtime now!
8  Java Game APIs & Engines / JOGL Development / Overlay Kills Content when resizing on: 2009-09-22 09: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){
   // create the overlay object
  olay = new Overlay(drawable);
         
   // create the java Graphics 2D Object
  g2D = olay.createGraphics();
   rec = new Rectangle();
        rec.x = 0;
        rec.y = 0;
}
     

rec.width = GLController.getInstance().getViewport()[2];
rec.height = GLController.getInstance().getViewport()[3];
     
// Create a new alpha composite
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 21: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 21: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);

// save in list
textureData.add(tData);

// returns the index of the saved texture data.
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 05: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);      // Enable Depth Testing
      // Set Perspective Calculations To Most Accurate
          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); // try setting this to GL_FLAT and see what happens.
     
       gl.glEnable(GL.GL_LIGHTING);
       gl.glEnable(GL.GL_LIGHT0);
       gl.glEnable(GL.GL_COLOR_MATERIAL);

    // Create light components
   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 };

    // Assign created components to GL_LIGHT0
   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) { // avoid a divide by zero error!
       
            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])));
             
             // start drawing in the one row and one column under the gl screen (like a safety buffer zone)
            // then add one floor tile after another till top corner is reached one row above gl screen
            gl.glTranslatef(((0.0f - floorTileSize[0])+(float)(col*floorTileSize[0])),   // x
                        ((0.0f - floorTileSize[1])+(float)(row*floorTileSize[1])),   // y
                        0.0f);                                          // z



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:

1  
2  
3  
   
// just a test check
//gl.glTranslatef((0.0f + (float)(col*2.0f)),0.0f,0.0f);


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 20: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();
             
             
             
             // start drawing in the one row and one column under the gl screen (like a safety buffer zone)
            // then add one floor tile after another till top corner is reached one row above gl screen
            gl.glTranslatef(((0.0f - floorTileSize[0])+(float)(col*floorTileSize[0])),   // x
                        ((0.0f - floorTileSize[1])+(float)(row*floorTileSize[1])),   // y
                        0.0f);                                          // z
            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?


13  Java Game APIs & Engines / J2ME / Re: Overlay Blending with Java ? the How ? on: 2007-06-15 17:30:32
Hi, i just found the solution

thread closed Cheesy
14  Java Game APIs & Engines / J2ME / Overlay Blending with Java ? the How ? on: 2007-06-15 14: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 Smiley

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
15  Java Game APIs & Engines / J2ME / Re: jsr 82 works fine on emulator, but not on real device on: 2007-06-01 09:52:51
Hi,
i just tested the game, and it is running,
i dont know why... i added a debug mode... i changed midlet 1.0.0 to 1.0
and i added ja other jsr82 jar... hmm
yuhuuu

thx for helping !
16  Java Game APIs & Engines / J2ME / Re: jsr 82 works fine on emulator, but not on real device on: 2007-06-01 09:17:52
Hehe, i cant find the Article on jpc.org,  do you meen the bluetooth specifications?

I should use the device debuggin mode, i think it can help
17  Java Game APIs & Engines / J2ME / Re: jsr 82 works fine on emulator, but not on real device on: 2007-06-01 08:33:29
The Server (or Client) and the Canvas are independent...
I just adding a debug mode  to the programm  Grin

thx for the hint  on jcp.org, i will try that now.
thx so far
18  Java Game APIs & Engines / J2ME / Re: jsr 82 works fine on emulator, but not on real device on: 2007-06-01 08:01:53
Ok i am going to fix that, but i think that is not the problem, because the programm is not running till this "codeline" ... because the Service Record or the Device (or both) of the Server is not found by the client...  that suxx.. Tongue
19  Java Game APIs & Engines / J2ME / Re: jsr 82 works fine on emulator, but not on real device on: 2007-05-31 17: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;
   
   /** Describes this server */
    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 );
       // this.activeThread = t;
     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();
      }
   
      //System.out.println(activeThread.isAlive());
  }

   
   public void run(){
       try{
        localDevice = LocalDevice.getLocalDevice();
       
        // set we are discoverable
       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://");
      //createService();
      // indicate this is a server
       url.append("localhost").append(':');

        // add the UUID to identify this service
       url.append(VERSUS_SERVER_UUID.toString());

        // add the name for our service
       url.append(";name=Versus Server");

        // request all of the client not to be authorized
       // some devices fail on authorize=true
       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);
   
        // getBTProperties();
         // accept client connections
       
          connection = notifier.acceptAndOpen();
         
         
          localDevice.setDiscoverable(DiscoveryAgent.NOT_DISCOVERABLE);
          receiver.start(connection);
          connected = true;
          os = connection.openOutputStream();
         
          String msg = "1hello there Client";
        //  os.write(msg.getBytes());
             /*
             * Here is where the gaming starts
             */

   
          startNetworkGame();
        //     connection.close();
 
      }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 17: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{
   
   
   /**save the discoveres Devices*/
   Vector remoteDevices = new Vector();
   
   
    /** Describes this server */
    private static final UUID VERSUS_SERVER_UUID =
        new UUID("F0E0D0C0B0A000908070605040302010", false);
   
   /** Optimization: keeps service search patern. */
    private UUID[] uuidSet;
   
   //UUID[] uuidSet = {new UUID(0x0003) };
  int[] attributes = {0x0100, 0x0101, 0x0003, 0x0004, 0x0000};
   
   Thread clientThread;

   
   LocalDevice localDevice;
   DiscoveryAgent discoveryAgent;
   
   boolean testBT;

    /** Keeps the device discovery return code. */
    private int discType;
   
   
    /**
     * Connection spezified stuff
     */

   String connectionURL;
   
   /** connection*/
   StreamConnection connection;
   
   /**write*/
   OutputStream os;
   
   /**read*/
   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{
         
          // initialize bluetooth first
       
         
         // create/get a local device and discovery agent
        localDevice = LocalDevice.getLocalDevice();
         discoveryAgent = localDevice.getDiscoveryAgent();
         
          // remember we've reached this point.
   
           
      }catch(BluetoothStateException e){}
     
      //initialize some optional variables
     uuidSet = new UUID[2];
        // ok, we are interesting in btspp services only
      uuidSet[0] = new UUID(0x1101);

       // and only known ones, that allows pictures
      uuidSet[1] = VERSUS_SERVER_UUID;
     
     
       remoteDevices.removeAllElements();
       //Ok now we can search for Devices..
 
       searchDevices();
   
      if(remoteDevices.size() > 0){
         
          searchServices();
      }else {
          System.out.println("no Device found");
      }
       
    try{
       // notified by notifyConnection() when trying to connect to Server..
        synchronized(this){
            wait();
         }
       
      } catch(InterruptedException e){
         
      }
      connectionURL = (String)NetworkController.getInstance().getRemoteConnectionURLs().firstElement();
      System.out.println("url: "+connectionURL.toString());
      enterConnection(connectionURL);
   }

   public void searchDevices() {
   
      try {
     
         
     
         // To start searching for Bluetooth-enabled phones, use the DiscoveryAgent
        discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this);
         System.out.println("searching for Devices...");
      } catch (BluetoothStateException e) {
         e.printStackTrace();
      }
     
       try {
          synchronized(this){
          // until devices are found
           wait();
          }
           
           } catch (InterruptedException e) {
               System.err.println("Unexpected interuption: " + e);
           }
           
           System.out.println("search Device komplett");

   }
   
   
    /**
     * Invoked by system when a new remote device is found -
     * remember the found device.
     */

   public void deviceDiscovered(RemoteDevice remoteDevice, DeviceClass cod) {
      System.out.println("device discoverd...");
      try {
         
         remoteDevices.addElement(remoteDevice);
     
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
   
   
   
   /**
     * Invoked by system when device discovery is done.
     * <p>
     * Use a trick here - just remember the discType
     * and process its evaluation in another thread.
     */

    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 {

         /*
          * Wenn das Versus aktiv ist versendet bluetooth die Versus ID:
          * vssrvnm dadurch werden nur entsprächende ServiceRecords
          * gefiltert, die auf die man zugreifen soll
          */

     
         // TODO:else anweisung für DEBUG nachher rausnehmen
        if (serviceRecord[0].getAttributeValue(0x100).getValue().toString()
               .equals("vssrvnm")) {
            /*
             * Gefundene Versus Services werden dem Networkcontroller
             * übergeben.
             */

            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) {
      // TODO Auto-generated method stub
     NetworkController.getInstance().setClientBusy(false);
      NetworkController.getInstance().updateServerList();
      NetworkController.getInstance().drawServerList();
      System.out.println("service search completed: list updated...");

   }

   
   public void enterConnection(String URL){
     
     
     
      try {
//          open a connection to the server
        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;
         //          Send/receive data
        byte[]buffer = new byte[100];
         System.out.println("bevore method receive bytes client");
         
         
         receiver.start(connection);
         os = connection.openOutputStream();
     
          String msg = "1hello there";
        //  InputStream is = connection.openInputStream();
       
         
           
          // send data to the server
         os.write(msg.getBytes());
         
          // read data from the server
     
          /*
           *     is.read(buffer);
     
            String text = new String(buffer);
           System.out.println(text);
           */

     
         
             /*
             * Here is where the game starts
             */

           
           
         
           
           //closeConnection();
         
      } 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){
         
      }
   }
   /*
    * falls man die funktion als thread laufen lassen kann receiveBytes verwenden anstatt classe receiver
    */

   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();
      }
   }

}


/**
 *
 * @author Admin
 *   ClientReceiverThread: Class for listening to incoming Events
 */


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 15: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
22  Java Game APIs & Engines / J2ME / Re: Problem with Canvas on: 2006-08-16 14:49:44
hmmm i found out, that only the obfuscated version is not running... arghl
23  Java Game APIs & Engines / J2ME / Re: Problem with Canvas on: 2006-08-16 14:18:57
Hi,
 i noticed, that the midlet is running on nokia mobiles and on other k750i but mine (testing with friends). So does anybody have a clue?
24  Java Game APIs & Engines / J2ME / Problem with Canvas on: 2006-08-15 14: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 {
 
  // The display for this MIDlet
  private Display display;    
   


  //private VSGameCanvas canvas;
 private MyCanvas mycanvas;
  public HelloMIDlet() {
     
     display = Display.getDisplay(this);
     mycanvas = new MyCanvas();
   //  canvas = new VSGameCanvas(true);
 }

  public void startApp() {
   
  //  Display.getDisplay(this).setCurrent(mMainForm);
    display.setCurrent(mycanvas);
   //  display.setCurrent(mMainForm);
  // mycanvas.setFullScreenMode(true);
   mycanvas.repaint();
   
  }
  public void pauseApp() { }
  public void destroyApp(boolean unconditional) { }
  public void commandAction(Command c, Displayable s) {
   // if (c == exitCommand) {
   //  destroyApp(false);
     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 21: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 08: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
27  Java Game APIs & Engines / JOGL Development / Re: gluUnproject not working on: 2005-11-14 18:57:37
yes, i copied it,hehehe but i it is not working... since 2 weeks
do you have any other idea?
28  Java Game APIs & Engines / JOGL Development / Re: gluUnproject not working on: 2005-11-14 09:10:38
Hi, still not working. thats argh

29  Java Game APIs & Engines / JOGL Development / gluUnproject not working on: 2005-11-13 18: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]);
         
      // drawing just a cube
           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 10: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){
      //System.out.println("start vertexFeedbackMode()");
     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();
     

               // glu.gluPerspective(45.0,this.h, 1.0, 20.0);
     
      gl.glOrtho(0.0,(double)screenwidth,0.0,(double)screenheight,-1.0, 1.0);

      //
  //   gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  //   gl.glClear(GL.GL_COLOR_BUFFER_BIT);
 
       

      //gl.glTranslatef(0.0f, 0.0f, -6.0f);
 
     
      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();
      //System.out.println("end vertexFeedbackMode()");
   }
Pages: [1] 2
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (16 views)
2014-08-28 18:26:30

CopyableCougar4 (25 views)
2014-08-22 19:31:30

atombrot (38 views)
2014-08-19 09:29:53

Tekkerue (34 views)
2014-08-16 06:45:27

Tekkerue (32 views)
2014-08-16 06:22:17

Tekkerue (20 views)
2014-08-16 06:20:21

Tekkerue (30 views)
2014-08-16 06:12:11

Rayexar (66 views)
2014-08-11 02:49:23

BurntPizza (44 views)
2014-08-09 21:09:32

BurntPizza (34 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!