Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (753)
Games in Android Showcase (228)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  jogl texture wrapping of complex shape  (Read 962 times)
0 Members and 1 Guest are viewing this topic.
Offline nkl

Innocent Bystander

« Posted 2011-08-05 10:27:42 »

Hi, I've been batting my head against a wall for some time on this topic and am curious if anyone out there can spot a mistake I have made. Essentially, what I am trying to do is construct a 3d asteroid field. I wanted to use 'interesting' shapes and so have generated some items in a 3D program...which I exported as .obj files. I have read these into my program, storing them as vertices and can generate the shape in a jogl display. Happy days. The next stap was to wrap a suitable texture around the object and this is where i have been stuck for some time- i have searched numerous forums yet can't seem to crack it.

This is how i'm loading the texture image:

  gl.glGenTextures(1, retVal,0);   
  //do stuff for the bound texture
  //-get input stream and bind to image integer place-holder
  InputStream stream1 = AsteroidListener.class.getResourceAsStream("textures/asteroid_texture.png");
  BufferedInputStream bis = new BufferedInputStream(stream1);
  //-create buffered image
  BufferedImage bi=;
  Raster r =bi.getRaster();
  DataBufferByte dbi= (DataBufferByte) r.getDataBuffer();
  byte b[]=dbi.getData();
  //-create final byte buffer to use as the texture
  int texSize =b.length;
  //System.out.println("tex size is:" +texSize);
  ByteBuffer texture= ByteBuffer.allocateDirect(texSize);
  ByteOrder newOrder= ByteOrder.nativeOrder();
  //-fill texture that is in byte array
  gl.glBindTexture(GL.GL_TEXTURE_2D, asteroidTex);   
  glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, GL.GL_RGB, bi.getWidth(), bi.getHeight(), GL.GL_RGB, GL.GL_UNSIGNED_BYTE,texture);

And i'm (trying) to wrap the generated shape with:

  gl.glBindTexture(GL.GL_TEXTURE_2D, asteroidTex);

Yet all I seem to be getting is the desired shape textured with something that is 'not quite right'. The texture appears to be getting overlaid, yet it is not the right colour and there seem to be some very odd 'flourescing' effects on the surface of the object.

Has anyone come across this before?
Pages: [1]
  ignore  |  Print  

ivj94 (584 views)
2018-03-24 14:47:39

ivj94 (48 views)
2018-03-24 14:46:31

ivj94 (382 views)
2018-03-24 14:43:53

Solater (62 views)
2018-03-17 05:04:08

nelsongames (109 views)
2018-03-05 17:56:34

Gornova (159 views)
2018-03-02 22:15:33

buddyBro (702 views)
2018-02-28 16:59:18

buddyBro (92 views)
2018-02-28 16:45:17

xxMrPHDxx (493 views)
2017-12-31 17:17:51

xxMrPHDxx (733 views)
2017-12-31 17:15:51
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!