• Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About jarod83

  • Rank
  1. I have a GLPanel added to a JFrame. The JFrame has a JMenuBar to. The problem is that when the menu is dropped down it is hiden behind the added GLPane. It is like the GLPane is drawen over the JMenuBar. What seems to be the problem ?
  2. I have this strange problem. I'm doing some OpenGL in Java(JOGL), and I have bproblems with texture loading. What happens is that I load two textures, and then i map each texture to their corresponding quad, but the two squads get two same textures, they get the last loaded texture both. Could there be something wrong with the way I load the textures ? Here is the code for texture loading: public static int[] getTextures(GL gl, String[] paths) { BufferedImage buff = null; File imageFile = null; Raster rst; ByteBuffer texture; int[] pi; int[] tempTextures = new int[paths.length]; gl.glGenTextures(paths.length, tempTextures); for (int i = 0; i < paths.length; i++) { try { imageFile = new File(paths[i]); buff = ImageIO.read( imageFile ); } catch (IOException e) { e.printStackTrace(); } rst = buff.getRaster(); pi = null; pi = rst.getPixels(0, 0, 128, 128, pi); texture = ByteBuffer.allocateDirect(buff.getWidth()*buff.getHeight()*3); for (int y = 0; y < 128; y++) { for (int x = 0; x < 128; x++) { texture.put((byte) pi[(y * 128 + x) * 3]); texture.put((byte) pi[(y * 128 + x) * 3 + 1]); texture.put((byte) pi[(y * 128 + x) * 3 + 2]); } } int width = 128; int height = 128; gl.glBindTexture(GL.GL_TEXTURE_2D, tempTextures[i]); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, 3, width, height, 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, texture); } return tempTextures; }
  3. Texture binding

    Quote:Original post by Zipster Hard to say what's wrong, because that's quite a small section of code to work with. But it's possible that the condition u != 1 is necessary for either textures[0] or gl to be valid. Other than that, all I can do is shrug [dead] When I map textures in some order then all of them are mapped correctly, but if I map them in som other order then some textures are mapped and som are not(i get white texture)... WTF ???
  4. Hello! I'm doing some texture binding but I have a strange problem. The program is written in java, using JOGL for OpenGL. When I initialize the textures in a for loop, I do the following, an it works fine: if (u == 1) { gl.glBindTexture(GL.GL_TEXTURE_2D, textures[1]); } else { gl.glBindTexture(GL.GL_TEXTURE_2D, textures[0]); } but... If I do the following, only textures[1] is working: if (u == 1) { gl.glBindTexture(GL.GL_TEXTURE_2D, textures[0]); } else { gl.glBindTexture(GL.GL_TEXTURE_2D, textures[1]); } Notice that textures[0] and textures[1] are exchanged in if and else blocks... What is wrong ?!?
  5. I'm doing a simulator in Java with floating numbers. I want to know how to convert a single-precision IEEE 754 format to double-precision IEEE 754 format. I've tried google but can't find anything on Floating Point Arithmetic... Can anyone help ?
  6. Catching polygons

    Thanks alot man! Merry Christmas ! ! !
  7. I am doing som OpenGL programming in java with JOGL. How can I figure out which polygon the mouse is pointing at ? Is there an easy way out for this in java with the mouse listener ?
  8. Strange OpenGL blending ?!?

    I still have'nt figured this out... Does anyone have a solution to this ?!?
  9. Strange OpenGL blending ?!?

    I use gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA) but i still get the error.
  10. Strange OpenGL blending ?!?

    Anyone know what's wrong ?
  11. Intersection between a plane and a point

    Quote:Original post by VolkerG You have the equation of the plane (p is any point on that plane): p = v1 + s (v2-v1) + t (v3 - v1). By inserting your point you could solve for s, t and y. Othe possibility: Take the plane equation of the form (p - v1).n = 0, where n is the normal vector of your plane. by inserting (x, y, z) of your point for p you can solve for y. Thanks alot dude, I'll try that! Btw. Mary christmas and happy new year!!!
  12. Hello guys! I'm working with a 3D game,and I need to solve the following problem: I have a plane in the 3D space, actualæy it is a triangle... So what i know is the three points of the triangle, lets say I have the points v1 = (1,2,3), v2 = (4,5,6) and v3 = (7,8,9). If I now pick a point within the triangle, and we call the point u = (x,y,z). Now i know the coordinates x and z of the u point, how can I find the coordinate y ?!?
  13. Strange OpenGL blending ?!?

    Quote:Original post by Khaosifix Post your source code in a pastebin and I'll get back to you[seriously]. Hi again! Here is my code: ... gl.glEnable(GL.GL_TEXTURE_2D); gl.glEnable(GL.GL_DEPTH_TEST); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); gl.glBindTexture(GL.GL_TEXTURE_2D, grassTex[0]); gl.glColor4f(1,1,1,0.4f); ...drawing the landscape here... gl.glDisable(GL.GL_TEXTURE_2D); ... gl.glEnable(GL.GL_BLEND); gl.glDisable(GL.GL_DEPTH_TEST); gl.glEnable(GL.GL_TEXTURE_2D); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); gl.glBindTexture(GL.GL_TEXTURE_2D, waterTex[0]); ...drawing the water... gl.glDisable(GL.GL_BLEND); gl.glEnable(GL.GL_DEPTH_TEST); gl.glDisable(GL.GL_TEXTURE_2D);
  14. Strange OpenGL blending ?!?

    I get strange results when enabling blending. Only the blue border surounded texture is transparent. The grass textures are not transparent. If u take a lok at the following link u'll see what i mean: I'm new to OpenGL. What can I do to fix this problem ?
  15. Hello guys! I'm doing some OpenGL in java. I load some textures in, it works just fine... But when I'm in the display(GLDrawable glDrawable) (draw method for GL), i get strange results... Consider the code below i have in that method: gl.glEnable(GL.GL_TEXTURE_2D); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); gl.glBindTexture(GL.GL_TEXTURE_2D, textures[1]); gl.glBegin(GL.GL_TRIANGLES); gl.glTexCoord2f(0, 0); gl.glVertex3f(-1, 1, 1); gl.glTexCoord2f(0, 1); gl.glVertex3f(-1, -1, 1); gl.glTexCoord2f(1, 1); gl.glVertex3f(1, -1, 1); gl.glEnd(); gl.glBindTexture(GL.GL_TEXTURE_2D, textures[1]); gl.glBegin(GL.GL_TRIANGLES); gl.glTexCoord2f(1, 1); gl.glVertex3f(1, -1, 1); gl.glTexCoord2f(1, 0); gl.glVertex3f(1, 1, 1); gl.glTexCoord2f(0, 0); gl.glVertex3f(-1, 1, 1); gl.glEnd(); gl.glDisable(GL.GL_TEXTURE_2D); This code works fine for both triangles. Bu when I have the following: gl.glBindTexture(GL.GL_TEXTURE_2D, textures[0]); ... gl.glBindTexture(GL.GL_TEXTURE_2D, textures[1]); then it is not working!!! It's strange because the two last combinations are also working, that is: gl.glBindTexture(GL.GL_TEXTURE_2D, textures[1]); ... gl.glBindTexture(GL.GL_TEXTURE_2D, textures[0]); and gl.glBindTexture(GL.GL_TEXTURE_2D, textures[0]); ... gl.glBindTexture(GL.GL_TEXTURE_2D, textures[0]); anyone know what's wrong here ?