Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (521)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
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]
1  Java Game APIs & Engines / Xith3D Forums / GLException in Tutorial Code on: 2004-06-11 10:35:37
While running code from the tutorial (Interaction) I get a following exception when I terminate the program.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
net.java.games.jogl.GLException: Error swapping buffers
      at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.swapBuffers(WindowsOnscreenGLContext.java:140)
      at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:241)
      at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:186)
      at net.java.games.jogl.GLCanvas.display(GLCanvas.java:74)
      at com.xith3d.render.jogl.CanvasPeerImpl.render(CanvasPeerImpl.java:1100)
      at com.xith3d.scenegraph.View.renderOnce(View.java:755)
      at com.xith3d.scenegraph.View.renderOnce(View.java:688)
      at tests.Interaction.<init>(Interaction.java:101)
      at tests.Interaction.main(Interaction.java:46)


Otherwise the program works correctly. I have a Radeon 9700 and my processor is AMD 64 Athlon.
What is going wrong in here.
2  Java Game APIs & Engines / Xith3D Forums / Re: Xith3D using SWT on: 2004-06-09 07:25:30
Great.

I think that the userinterface- package will need some work to get it working with SWT. Have you had an look? The reason why I'm asking is that I won't do any duplicate work. I will look at the source later and perhaps I can help (at least in debugging) :-)


Sami.
3  Java Game APIs & Engines / JOGL Development / Re: JOGL with SWT on: 2004-06-07 10:26:09
Where can I get more information about this SWT / Xith porting? Is the source code in the CVS?
4  Java Game APIs & Engines / Xith3D Forums / Xith3D using SWT on: 2004-06-07 08:14:51
Hi,

Is it possible to port Xith3D to use SWT instead of AWT? What are the dependencies with Xith and AWT, and where they are? If I should port Xith3D to SWT, should I try to port JOGL to use SWT or would it be easier to port Xith to use LWGL that can run with SWT? All help and tips are appreciated.

5  Java Game APIs & Engines / JOGL Development / JOGL with SWT on: 2004-06-07 07:36:58
Hi,


Is it possible to port JOGL to use SWT instead of Swing? How much dependencies JOGL have with Swing and where these dependencies are? What I really would like to do is make Xith3D to use SWT instead of Swing...
6  Java Game APIs & Engines / JOGL Development / Selection problems on: 2003-11-27 17:26:00
I populate my 3D-space with spheres that contain smaller spheres. When the spheres doesn't have anything inside of them, my selection routine works fine. But when my spheres contain smaller spheres I don't get any selections. I think that this has to do with glPushName and glPushMatrix but I don't know how.
See pseudocode for the drawing method below.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
for (int i = 0; i < counter; i++) {
// When I comment these lines inside loop everything works
  gl.glPushMatrix();    
     // draw smaller sphere
  gl.glPopMatrix();
}

glPushName(uniqueId)
gl.glPushMatrix()
  // Draw larger sphere
gl.glPopMatrix()
gl.glPopName();


Selection routines
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  
private int[] setupSelection() {
      int objectsFound = 0;                              // This will hold the amount of objects clicked
            int viewportCoords[] = new int [4];            // We need an array to hold view port coordinates
            int selectBuffer[] = new int [32];
           
            gl.glSelectBuffer(32, selectBuffer);      // Setup selection buffer to accept object ID's
            gl.glGetIntegerv(GL.GL_VIEWPORT, viewportCoords); // Get the current view port coordinates
            gl.glMatrixMode(GL.GL_PROJECTION);            // We want to now effect projection matrix
           
            gl.glPushMatrix();                  // We push on a new matrix so we don't effect our 3D projection

            // This makes it so it doesn't change the frame buffer if we render into it, instead,
            // a record of the names of primitives that would have been drawn if the render mode was
            // GL_RENDER are now stored in the selection array (selectBuffer).

            gl.glRenderMode(GL.GL_SELECT);                        // Allows us to render the objects, but not change the frame buffer
            gl.glLoadIdentity();                                    // Reset our projection matrix

            // gluPickMatrix allows us to create a projection matrix that is around our
            // cursor.  This basically only allows rendering in the region that we specify.
            // If an object is rendered into that region, then it saves that objects ID for us            
            // The first 2 parameters are the X and Y position to start from, then the next 2
            // are the width and height of the region from the starting point.  The last parameter is
            // of course our view port coordinates.  You will notice we subtract "y" from the
            // BOTTOM view port coordinate.  We do this to flip the Y coordinates around.  The 0 y
            // coordinate starts from the bottom, which is opposite to window's coordinates.
            // We also give a 2 by 2 region to look for an object in. This can be changed to preference.

            glu.gluPickMatrix(selectedPoint.getX(), viewportCoords[3] - selectedPoint.getY(),
                  2, 2, viewportCoords);

            // Next, we just call our normal gluPerspective() function, exactly as we did on startup.
            // This is to multiply the perspective matrix by the pick matrix we created up above.

            glu.gluPerspective(45.0f,(float)HEIGTH/(float)WIDTH,0.1f,150.0f);            
            gl.glMatrixMode(GL.GL_MODELVIEW);                        // Go back into our model view matrix            

            return selectBuffer;

}

      private int getSelection(int[] selectBuffer) {
            int objectsFound;
            // If we return to our normal render mode from select mode, glRenderMode returns
            // the number of objects that were found in our specified region (specified in gluPickMatrix())
           
            //      Return to render mode and get the number of objects found
            objectsFound = gl.glRenderMode(GL.GL_RENDER);      
           
            gl.glMatrixMode(GL.GL_PROJECTION);                  // Put our projection matrix back to normal.            
            gl.glPopMatrix();                                          // Stop effecting our projection matrix
           
            gl.glMatrixMode(GL.GL_MODELVIEW);                  // Go back to our normal model view matrix
           
            // PHEW!  That was some stuff confusing stuff.  Now we are out of the clear and should have
            // an ID of the object we clicked on.  objectsFound should be at least 1 if we found an object.
           
            System.out.println("Objects found : "+objectsFound);
            if (objectsFound > 0) {            
                  // If we found more than one object, we need to check the depth values
                  // of all the objects found.  The object with the LEAST depth value is
                  // the closest object that we clicked on.  Depending on what you are doing,
                  // you might want ALL the objects that you clicked on (if some objects were
                  // behind the closest one), but for this tutorial we just care about the one
                  // in front.  So, how do we get the depth value?  Well, The selectionBuffer
                  // holds it.  For every object there is 4 values.  The first value is
                  // "the number of names in the name stack at the time of the event, followed
                  // by the minimum and maximum depth values of all vertices that hit since the
                  // previous event, then followed by the name stack contents, bottom name first." - MSDN
                  // The only ones we care about are the minimum depth value (the second value) and
                  // the object ID that was passed into glLoadName() (This is the fourth value).
                  // So, [0 - 3] is the first object's data, [4 - 7] is the second object's data, etc...
                  // Be carefull though, because if you are displaying 2D text in front, it will
                  // always find that as the lowest object.  So make sure you disable text when
                  // rendering the screen for the object test.  I use a flag for RenderScene().
                  // So, lets get the object with the lowest depth!            
           
                  // Set the lowest depth to the first object to start it off.
                  // 1 is the first object's minimum Z value.
                  // We use an unsigned int so we don't get a warning with selectBuffer below.
                  int lowestDepth = selectBuffer[1];
           
                  // Set the selected object to the first object to start it off.
                  // 3 is the first object's object ID we passed into glLoadName().
                  int selectedObject = selectBuffer[3];                  
           
                  // Go through all of the objects found, but start at the second one
                  for (int i = 1; i < objectsFound; i++) {
                        // Check if the current objects depth is lower than the current lowest
                        // Notice we times i by 4 (4 values for each object) and add 1 for the depth.
                        if (selectBuffer[(i * 4) + 1] < lowestDepth) {
                              // Set the current lowest depth
                              lowestDepth = selectBuffer[(i * 4) + 1];
           
                              // Set the current object ID
                              selectedObject = selectBuffer[(i * 4) + 3];
                        }
                  }
                  System.out.println("Selected object : "+selectedObject);
                 
                  return selectedObject;                  
            }
           
            return 0;      
      }


Best Regards,

Sami
7  Java Game APIs & Engines / JOGL Development / Quadrics and Translucency on: 2003-11-22 12:25:19
Hi,


how do I make my quadrics translucent? I'm using glutSolidSphere to draw
my quadrics, and I color them with glColor3f. I tried to change glColor3f to
glColor4f and specify alpha-value but it didn't have any effect. My quadrics'
materials are:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
private float no_mat[] = {0.0f,0.0f,0.0f,1.0f}; // Materials

private float mat_diffuse[] = {0.1f,0.5f,0.8f,1.0f};

private float mat_specular[] = {1.0f,1.0f,1.0f,1.0f};

private float no_shininess[] = {3.0f};

glMaterialfv (GL.GL_FRONT, GL.GL_AMBIENT, no_mat);

gl.glMaterialfv (GL.GL_FRONT, GL.GL_DIFFUSE, mat_diffuse);

gl.glMaterialfv (GL.GL_FRONT, GL.GL_SPECULAR, no_mat);

gl.glMaterialfv (GL.GL_FRONT, GL.GL_SHININESS, no_shininess);

gl.glMaterialfv (GL.GL_FRONT, GL.GL_EMISSION, no_mat);




Regards,

- Sami


8  Java Game APIs & Engines / JOGL Development / Text Drawing on: 2003-11-22 11:10:49
Hello,

I'm using GLUT to draw 2D text to screen (glutBitmapString).
Anyhow,  I would like to have a yellow box where this black text is
printed so that the user can see it more clearly (like the popup
screens in some programming editors). Is there any easy way to do
this? My program is in 3D so if I use glVertex3f to draw the box, I
propably should do complex transformations so that the box faces
user directly. And I don't know how I draw the text so that it seems
that it is inside the box.


Regards,
- Sami
9  Java Game APIs & Engines / JOGL Development / Re: Coordinate Trouble on: 2003-11-19 15:23:24
Hello,

found the error myself. I didn't push the matrix
in the display-method.
10  Java Game APIs & Engines / JOGL Development / Coordinate Trouble on: 2003-11-19 13:07:24
Hello,

I'm having trouble at drawing lines so that they start
from the center of spheres that I have just drawn. Here
is the 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  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
public void display(GLDrawable arg0) {
           
            gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
            gl.glLoadIdentity();                                     // Reset The View
            gl.glInitNames();                                          // Initialize object names
           
            int selectBuffer[] = null;
           
            if (isClicked)
                  selectBuffer = setupSelection();
           
            float xtrans = -xpos;
            float ytrans = -ypos;
            float ztrans = -zpos;            
            float sceneroty = 360.0f - yrot;                  

            gl.glRotatef(lookupdown,1.0f,0,0);
            gl.glRotatef(sceneroty,0,1.0f,0);      
            gl.glTranslatef(xtrans, ytrans, ztrans);            
           
            // Draws the spheres                  
            for (Iterator iter = graphClassModels.iterator(); iter.hasNext();) {                  
                  GraphicalClassModel model = (GraphicalClassModel) iter.next();            
                  Integer classId = (Integer) classModelIds.get(model);
                                   
                  Point centerPoint = model.getCoord();                  
                  RGB color = model.getRgb();
                 
                  gl.glPushName(classId.intValue());                  
                        gl.glTranslatef(centerPoint.getX(), centerPoint.getY(), centerPoint.getZ());
                        gl.glColor3f(color.getRed(),color.getGreen(),color.getBlue());
                        glut.glutSolidSphere(glu,1.3f, 32, 32);                              
                  gl.glPopName();      
                       
     
// PROBLEM IN HERE!! Why these lines doesn't start from the center of the sphere !?


                  gl.glBegin(GL.GL_LINES);
                        gl.glVertex3f(centerPoint.getX(),centerPoint.getY(),centerPoint.getZ());
                        gl.glVertex3f(centerPoint.getX() +3,centerPoint.getY()+3,centerPoint.getZ()+3);                  
                  gl.glEnd();
                 
                  gl.glRasterPos3f(centerPoint.getX() +3,centerPoint.getY()+3,centerPoint.getZ()+3);
                  glut.glutBitmapString(gl, GLUT.BITMAP_TIMES_ROMAN_24, "Some text");                  
            }            
           
            if (isClicked) {
                  selection = getSelection(selectBuffer);                                          
                  isClicked = false;
            }
           
            if (selection != 0)
                  printObjectsClass(selection);                  
           
                 
            processKeyboard();            
      }
11  Java Game APIs & Engines / JOGL Development / Fonts and GLUT on: 2003-11-05 14:37:49
Hello again,

what would be the easiest way to print 2D-text to screen? I have tried code from NeHe's tutorial but it doesn't print anything to screen (possibly because I fail to init the font, but I don't know how to do it).

1  
2  
3  
4  
5  
6  
private void printText(String text) {
            byte[] textBytes = text.getBytes();
            gl.glPushAttrib(GL.GL_LIST_BIT);                              // Pushes The Display List Bits
            gl.glListBase(base - 32);                                          // Sets The Base Character to 32            
            gl.glCallLists(text.length(), GL.GL_UNSIGNED_BYTE, textBytes);      // Draws The Display List Text
            gl.glPopAttrib();                                                                  // Pops The Display List Bits

I have created the base by using "base=gl.glGenList(256). Should I init somehow the font?

Thank you.
12  Java Game APIs & Engines / JOGL Development / Object Selection problems on: 2003-11-04 15:07:17
Hi,

does anyone have an idea why my program crashes when I try to make glSelectBuffer - call. I'm trying to find out what object user has clicked on and the code uses glSelectBuffer to achieve this.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
/* (non-Javadoc)
       * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
       */

      public void mousePressed(MouseEvent e) {
            System.out.println("MousePressed");
            int x = e.getX();
            int y = e.getY();
           
            int objectsFound = 0;                              // This will hold the amount of objects clicked
            int viewportCoords[] = new int [4];            // We need an array to hold view port coordinates
            int selectBuffer[] = new int [32];
           
            gl.glSelectBuffer(32, selectBuffer);      // Setup selection buffer to accept object ID's. PROGRAM CRASHES IN HERE!
            gl.glGetIntegerv(GL.GL_VIEWPORT, viewportCoords); // Get the current view port coordinates
            gl.glMatrixMode(GL.GL_PROJECTION);            // We want to now effect projection matrix

...
13  Java Game APIs & Engines / JOGL Development / Re: Nice Looking 3D Spheres on: 2003-10-29 15:22:34
Ok, I did it (thanks)  but now all the spheres have same colours.

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  
private float lightAmb[] = {0.7f, 0.7f, 0.7f, 1.0f};      // Ambient Light
      private float lightPos[] = {4.0f, 4.0f, 6.0f, 1.0f};      // Light Position
      private float lightDif[] = {1.0f, 1.0f, 1.0f, 1.0f};      // Diffuse Light


public void init(GLDrawable drawable) {            
            gl.glShadeModel(GL.GL_SMOOTH);                         // Enable Smooth Shading
            gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);       // Black Background
            gl.glClearDepth(1.0f);                                     // Depth Buffer Setup
            gl.glEnable(GL.GL_DEPTH_TEST);                         // Enables Depth Testing
            gl.glDepthFunc(GL.GL_LEQUAL);                         // The Type Of Depth Testing To Do
            gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);

            gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, lightAmb);      // Set The Ambient Lighting
            gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, lightDif);      // Set The Diffuse Lighting
            gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPos);      // Set The Position For Light0

            gl.glEnable(GL.GL_LIGHT0);                                          // Enable Light 0
            gl.glEnable(GL.GL_LIGHTING);                                    // Enable Lighting
...
}


public void display(GLDrawable arg0) {            
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
            gl.glLoadIdentity();                                     // Reset The View
RGB color = model.getRgb();
                  gl.glTranslatef(centerPoint.getX(), centerPoint.getY(), -5.0f);
                  gl.glColor3f(color.getRed(),color.getGreen(),color.getBlue());                              
                  glu.gluSphere(quadric, 1.3f, 32, 32);                  
}      


14  Java Game APIs & Engines / JOGL Development / Nice Looking 3D Spheres on: 2003-10-29 14:48:50
Hi,

I'm beginner in OpenGL and I was wondering how to create 3D spheres that actually look like that they are in 3D. I'm able to create spheres with gluSphere but these spheres look like 2D objects in 3D world. Using texture mapping I can create nice looking spheres that actually look like 3D objects, but is there any other way?
15  Java Game APIs & Engines / JOGL Development / Multiple Spheres in JOGL on: 2003-10-21 16:41:51
Hi,

I'm learning to use JOGL in my programs and I have a following question. Do I have to create a new GLUquadric object for every sphere that I wish to draw? That is, if I want to draw three spheres using texture mapping do I have to create three GLUquadrics also?

And could someone tell me what is wrong in the following code (it draws only white spheres, not texture mapped):

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public void display(GLDrawable arg0) {
           
            gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
            gl.glLoadIdentity();                         // Reset The View
            gl.glTranslatef(0.0f, 0.0f, -5.0f);
                             
            // Draws a sphere
            Set coords = sphereCoords.keySet();
           
            for (Iterator iter = coords.iterator(); iter.hasNext();) {                  
                  Point centerPoint = (Point) iter.next();
                  GLUquadric quadric = (GLUquadric) sphereCoords.get(centerPoint);
                 
                  gl.glBindTexture(GL.GL_TEXTURE_2D, texture[0]);            
                  gl.glTranslatef(centerPoint.getX(), centerPoint.getY(), -5.0f);
                  glu.gluSphere(quadric, 1.3f, 32, 32);
            }
      }


I have created GLUquadric for every sphere so the problem isn't there.
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

xFryIx (55 views)
2014-11-13 12:34:49

digdugdiggy (34 views)
2014-11-12 21:11:50

digdugdiggy (29 views)
2014-11-12 21:10:15

digdugdiggy (23 views)
2014-11-12 21:09:33

kovacsa (46 views)
2014-11-07 19:57:14

TehJavaDev (50 views)
2014-11-03 22:04:50

BurntPizza (49 views)
2014-11-03 18:54:52

moogie (65 views)
2014-11-03 06:22:04

CopyableCougar4 (63 views)
2014-11-01 23:36:41

DarkCart (148 views)
2014-11-01 14:51:03
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!