1 Reply Latest reply: Nov 4, 2009 2:40 AM by gimbal2 RSS

    A few JOGL questions

      Im sorry for asking these questions, i have tried google and i have been looking at javadocs and also i have an OpenGL book but it dosn't really explain what i need as such.

      Question 1:

      For my simple 3d game i draw a set of tiles, the tiles are rendered using 4 vertex points enabling me to change the height of certain parts of landscape rather than it just being flat.

      But anyway, i can render the "tiles" using gl.glVertex3f(x, y, z), but now i need to know how i can apply a texture to these tiles, at the moment this is my rendering method;
      public void renderWorld(GL gl)
                for (Tile t : tileMap)
                     gl.glColor3f(t.getRed(), t.getGreen(), t.getBlue());
                     for (TileVertex v : t.getVertices())
                          gl.glVertex3f(v.getX(), v.getY() - 1, v.getZ());
      The TileVertex class just holds a float for x, y, z and also red, green and blue for normal colouring.

      I wish to be able to apply a texture to them easily, but im not sure how, ive read the examples, tutorials etc but whatever i try it dosn't seem to render a texture.

      Question 2:

      Is there a way to blend colours, for example with my above tiling system the colours are flat coloured tiles and it dosn't give a very realistic effect, i was looking into bump mapping etc but i really want to know if there is a way to append a sort of gradient to the tile so for example a muddy path wouldn't be all the same colour.

      Question 3:

      Does JOGL give any simple way of getting x, y, z from a mouse click when the view is changed?

      For example, if i done the following;
      glu.gluLookAt(xPlayer, yPlayer, zPlayer, xLookAt, yLookAt, zLookAt, 0, 1, 0);
      gl.glRotatef(zAxisOffset, 0.0f, 0.0f, 1.0f);
      And then used MouseEvent and a mouse listener to get the x and y of my click, is there any simple way to convert that to where for example a tile would be drawn on the map?

      Question 4:

      What are the scales of units in OpenGL in general.

      Basically, the models i have are ones which were ment for me to implement into a java.awt.Graphics 3d engine i wrote, so all the values are in pixel size, however, in JOGL i dont understand how the actual sizes work, for example if you have;

      gl.glVertex3f(1.0f, 0.0f, 1.0f);

      That draws a relitivly big square for putting the value 1.0 in, so when my models have values of like 400 because of pixel length is there any way to convert that to the scale of units JOGL uses?
        • 1. Re: A few JOGL questions
          What are the scales of units in OpenGL in general.
          You almost nailed the answer to your question here. You are focusing way too much on doing something in jogl, while this is a simple wrapper library around opengl. All questions you have are not that easy to answer because they originate from a lack of knowledge. I suggest you get yourself a good OpenGL book and learn this stuff, in stead of trying to do it the hard way. Most books have simple C++ code examples which you can easily read and translate to Java. Check out Amazon.com for the user reviews to know which book is a good one.