Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 / JOGL (GL3) not rendering a single thing on: 2013-07-13 17:19:06
I've spent whole day trying to make this render my triangle. Didn't happen. What am I doing wrong ? Syntax is OK. Screen gets filled with background color of Z-Buffer and no triangle appears. I've been used to old glBegin(), glEnd() style and I have almost no idea what am I doing now.

What I understand:

1. How buffers work,
2. How to reference buffers with IntBuffer
3. How to feed them with data using glBufferData.
4. Binding buffers.

What I do not understand:

1. What gl.glEnableVertexAttribArray(0); does ?
2. How do I change color of those vertices ? Are they drawn the same color as background, so they're invisible ?

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  
package opengltest;

import java.nio.FloatBuffer;
import java.nio.IntBuffer;

import javax.media.opengl.GL2;
import javax.media.opengl.GL3;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;

import jogamp.graph.font.typecast.ot.table.Program;

public class SceneRenderer implements GLEventListener {

   private GLU glu = new GLU();

   private float triangle[] = { 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
         1.0f, 0.0f };
   private FloatBuffer verticesBuffer = FloatBuffer.wrap(triangle);
   private IntBuffer vbos = IntBuffer.allocate(1);

   @Override
   public void init(GLAutoDrawable drawable) {
      GL3 gl = drawable.getGL().getGL3();

      gl.glEnable(GL3.GL_DEPTH_TEST);
      gl.glDepthFunc(GL3.GL_LEQUAL);
      gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

      gl.glGenBuffers(1, vbos);


      gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbos.get(0));

      gl.glBufferData(GL3.GL_ARRAY_BUFFER, 9 * 4, verticesBuffer,
            GL3.GL_STATIC_DRAW);

      gl.glFinish();
     
   }

   @Override
   public void dispose(GLAutoDrawable drawable) {

   }

   @Override
   public void display(GLAutoDrawable drawable) {

      GL3 gl = drawable.getGL().getGL3();
      gl.glClear(GL3.GL_DEPTH_BUFFER_BIT | GL3.GL_COLOR_BUFFER_BIT);

      gl.glEnableVertexAttribArray(0);
      gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbos.get(0));
      gl.glVertexAttribPointer(0, 3, GL3.GL_FLOAT, true, 0, 0);

      gl.glDrawArrays(GL3.GL_TRIANGLES, 0, 3);
      gl.glDisableVertexAttribArray(0);
      gl.glFinish();
      gl.glFlush();

   }

   @Override
   public void reshape(GLAutoDrawable drawable, int x, int y, int width,
         int height) {
      float aspect = (float) width / (float) height;
      glu.gluPerspective(85.0f, aspect, 0.1f, 100.0f);
      drawable.getGL().glViewport(0, 0, width, height);
     

   }

}
2  Game Development / Newbie & Debugging Questions / How BSP and other optimizations work ? on: 2013-03-30 08:49:05
Hello everyone,

I'd like to ask a few questions about BSP trees, or generally about any methods that split the scene into more parts Wink I've studied these methods in theory,but never used. Now I have my own OpenGL engine written in Java and I'd like to use these optimalizations.

1. WHEN is the world split into more areas ? Does this happen when you export your map out of your editor ? Or does the engine load the map and does the splitting ?

2. Is it ok to test an object placed in more BSP logical parts of the scene in every one of them ? Or is there a different approach ?

3. Are there any good tutorials HOW EDITORS work ? I still wonder what's the difference between 3DMax and GTK Radiant. I can import my models to GTK, but game maps seem to be made of much less polygons ...  Is the engine support related ? Is it connected with BSP ?

Thank you for your replies.  Smiley

3  Games Center / Showcase / Re: Modern Shooter - a very modern FPS game on: 2013-03-16 18:42:25
I've tried this game and all I got was two trojan warning by Windows Defender. Is it a Java security problem ? Anyone else has the same issue ?
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.

UprightPath (20 views)
2014-09-20 20:14:06

BurntPizza (26 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (70 views)
2014-09-10 13:57:51

TehJavaDev (95 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29

BurntPizza (52 views)
2014-09-07 01:13:42

Longarmx (39 views)
2014-09-07 01:12:14

Longarmx (45 views)
2014-09-07 01:11:22
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!