Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
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  Game Development / Newbie & Debugging Questions / Re: Broken applet - assist please on: 2012-08-31 13:22:42
this one works for me, in index.html file:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
<applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
      width="100%"
      height="100%"
      archive="jar/applet-launcher.jar,
               jar/gluegen-rt.jar,
               jar/jogl.all.jar,
               jar/<your_file>.jar"
>
   <param name="codebase_lookup" value="false">
   <param name="subapplet.classname" value="main.class.here">
   <param name="subapplet.displayname" value="">
   <param name="noddraw.check" value="true">
   <param name="progressbar" value="true">
   <param name="jnlpNumExtensions" value="1">
   <param name="jnlpExtension1"
          value="jar/jogl-all-awt.jnlp">
   <param name="java_arguments" value="-Dsun.java2d.noddraw=true">
   <param name="jnlp_href" value="jar/applet-launcher.jnlp">
</applet>


applet-launcher.jnlp:
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  
<?xml version="1.0" encoding="utf-8"?>
<jnlp href="applet-launcher.jnlp">
  <information>
    <title></title>
    <vendor></vendor>
    <homepage href=""/>
    <description></description>
    <description kind="short"></description>
    <offline-allowed/>
  </information>

    <resources>
      <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
      <property name="sun.java2d.noddraw" value="true"/>
      <jar href="yourfile.jar" main="true"/>
      <extension name="newt-all-awt" href="jogl-all-awt.jnlp" />
    </resources>

  <applet-desc
      name="Applet"
      main-class="main/class.here"
      width="640"
      height="480">
  </applet-desc>
</jnlp>
2  Game Development / Newbie & Debugging Questions / Re: Alpha doesnt work on: 2012-08-31 13:00:33
setting glColor to white, fixes the problem... but the scene is a little brighter.

The following code was causing alpha to fail:
1  
gl.glTexEnvi (GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_DECAL);
3  Game Development / Newbie & Debugging Questions / Re: Alpha doesnt work on: 2012-08-30 18:20:40
ok, found a problem: gl.glTexEnvi (GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_DECAL);

after removing* that transparency works, but everything is red... its red becouse of font rendering.

is there a way to reset opengl color after calling glColor?? and another way to use only texture color no lights?
4  Game Development / Newbie & Debugging Questions / Re: Alpha doesnt work on: 2012-08-30 18:02:48
ok made a progress, removed default color from objects, only texture now.

now on areas where should be transparent, i have red color? Cheesy

EDIT: its not the background, background is blue
5  Game Development / Newbie & Debugging Questions / Re: Alpha doesnt work on: 2012-08-30 17:45:21
still doesn't work, and i see poligons thru walls.
6  Game Development / Newbie & Debugging Questions / Re: Alpha doesnt work on: 2012-08-30 16:34:29
Almost everything i have  Huh  Undecided

7  Game Development / Newbie & Debugging Questions / Alpha doesnt work on: 2012-08-30 16:02:03
Using JOGL, and problem is - there is no alpha. I have a PNG file that shows transparency in photoshop.

Loading texture:

1  
2  
3  
4  
5  
6  
7  
8  
   public void LoadTextureFromResource(String res,String type) throws IOException
   {
     
        InputStream stream = getClass().getResourceAsStream(res);
        TextureData data = TextureIO.newTextureData(GLProfile.getDefault(),stream,GL2.GL_RGBA,GL2.GL_RGBA, false, type);
        this.texture = TextureIO.newTexture(data);
        this.loaded = true;
   }


OpenGL init:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
        GLCapabilities capabilities = new GLCapabilities(GLProfile.getDefault());
        capabilities.setHardwareAccelerated(true);
        capabilities.setNumSamples(0);
        capabilities.setAlphaBits(8);
        capabilities.setSampleBuffers(true);

        ......
       
        gl.glDisable(GL2.GL_LIGHTING);
   gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);  // <--
   gl.glEnable (GL2.GL_BLEND);
        gl.glShadeModel(GLLightingFunc.GL_SMOOTH);
        gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        gl.glClearDepth(1.0f);
        gl.glEnable(GL.GL_DEPTH_TEST);
        gl.glDepthFunc(GL.GL_LEQUAL);
        gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);


Tried changing blend func, some modes make everything transparent, this one renders fine but without alpha.
And ofcourse, im rendering object with that texture last.

Help??
8  Game Development / Newbie & Debugging Questions / Re: Texturing problem on: 2011-12-29 23:16:49
texture coords were wrong,
i needed to use UVW Unwrap modifier in 3DS max.

after that works perfectly Smiley
9  Game Development / Newbie & Debugging Questions / Re: Texturing problem on: 2011-12-29 21:21:37
some things are complicated too much, somewhere used wrong names...
but anyway i have checked parsed data, everything is correct.

tested with simple object, result:
http://img7.imageshack.us/img7/5130/omgwtfqj.jpg

looks like texture is applied on every side, instead of whole object.

here is my CTexture 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  
public class CTexture 
{
   private Texture texture;
   private boolean loaded;
   
   public CTexture()
   {
      loaded = false;
   }
   
   public void LoadTextureFromResource(String res,String type) throws IOException
   {
        InputStream stream = getClass().getResourceAsStream(res);
        TextureData data = TextureIO.newTextureData(GLProfile.getDefault(),stream, false, type);
        this.texture = TextureIO.newTexture(data);
        this.loaded = true;
   }
   
   public boolean hasTexture()
   {
      return loaded;
   }
   
   public void apply2Object(GL gl)
   {
      texture.enable(gl);
      texture.bind(gl);
   }
   
}




10  Game Development / Newbie & Debugging Questions / Texturing problem on: 2011-12-29 17:06:35
I am trying to bake texture in 3DS Max and use it in OpenGL, but texture looks weird.
I was looking on google for few hours, but cant find any solution.  Sad


Here is 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  
public void RenderObject(CObject obj)
   {
      CMesh m; MFace f; MVertex v; MNormal n; MTexCords t; CTexture tx;
     
      tx = obj.GetTexture(); m = obj.GetMesh();
     
      if(tx.hasTexture())
      {
         tx.apply2Object(gl.getGL());
      }
     
      gl.glTranslatef(obj.location.x, obj.location.y, obj.location.z);
      gl.glRotatef(obj.rotation.x, 1, 0, 0);
      gl.glRotatef(obj.rotation.y, 0, 1, 0);
      gl.glRotatef(obj.rotation.z, 0, 0, 1);
     
      for(int i = 0; i < m.getFaceList().size();i++)
      {
         f = m.getFaceList().get(i);
         
         gl.glColor3f(0.5f, 0.5f, 0.5f);
         gl.glBegin(GL2.GL_POLYGON);
               
         for(int j = 0;j < f.GetPolygonCount();j++)
         {
            v = m.getVertexList().get(f.GetPolygonByIndex(j).vertexIndex - 1);
            t = m.getTexCordsList().get(f.GetPolygonByIndex(j).texcordIndex - 1);
            n = m.getNormalList().get(f.GetPolygonByIndex(j).normalIndex - 1);
           
            gl.glNormal3f(n.x, n.y, n.z);
            gl.glTexCoord3f(t.u,t.v, t.w);
            gl.glVertex3f(v.x, v.y, v.z);
           
         }

         gl.glEnd();
      }


Code is based on open source OBJ loader in c++.
http://sourceforge.net/projects/objloader/

What i want:
http://img521.imageshack.us/img521/5181/wantp.jpg

What i get:
http://img171.imageshack.us/img171/645/getor.jpg

Baked texture:
http://img205.imageshack.us/img205/8562/bakedi.jpg


help!?
11  Game Development / Newbie & Debugging Questions / Re: Applet resize problem on: 2011-09-24 20:02:14
fixed Smiley

replaced canvas.setPreferedSize() with canvas.reshape().
eclipse doesn't have javadoc for that method, it has 4 parameters so i guessed that would be x,y,width,and height.

1  
canvas.reshape(0, 0, this.getWidth(), this.getHeight());
12  Game Development / Newbie & Debugging Questions / Re: Applet resize problem on: 2011-09-24 11:31:31
Nobody knows where is problem?

Dont know if i have to resize canvas manually or is there some way to tell canvas to resize automatically,
i need to set some layout or??
13  Game Development / Newbie & Debugging Questions / Applet resize problem on: 2011-09-23 16:52:56
Hi, i am new to java and game development.

I just started creating my first java applet using JOGL library.
After few tutorials i managed to draw a triangle, but have problem with GLCanvas and the reshape method.

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  
        public class CMain extends Applet implements GLEventListener
....

   public void init()
   {
      glu = new GLU();
      canvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault()));
      this.add(canvas);
     
      canvas.addGLEventListener(this);
      canvas.setPreferredSize(this.getSize());
     
      final FPSAnimator animator = new FPSAnimator(canvas, 60);
      animator.start();
   }

....

   public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h)
   {
         GL2 gl = glDrawable.getGL().getGL2();
         
         h = (h == 0) ? 1 : h;  // Prevent divide by zero
         float aspect = (float)w / h; // Compute aspect ratio
         
         // Set view port to cover full screen
         gl.glViewport(0, 0, w, h);
         
         // Set up the projection matrix - choose perspective view
         gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);  
         gl.glLoadIdentity();    // reset
         glu.gluPerspective(45.0f, aspect, 0.1f, 100.0f);
         
         // Switch to the model-view transform
         gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
         gl.glLoadIdentity();    
         
         canvas.setPreferredSize(null);
         canvas.setPreferredSize(this.getSize());  // <--- hmmm
   }


I'm using Eclipse and Java applet viewer, and when i resize window/applet
sometimes the Canvas size doesn't update!!  persecutioncomplex

Any suggestions?
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.

Longarmx (49 views)
2014-10-17 03:59:02

Norakomi (38 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (35 views)
2014-10-15 16:18:58

TehJavaDev (65 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (55 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
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!