Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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: how i can limit game loop time on: 2011-03-10 12:38:26
thanks for article - by some reason don't saw it previously, but
>Display.sync(60); // cap fps to 60fps
i'm trying to find way without cap. But it is also helpfull.
2  Game Development / Newbie & Debugging Questions / how i can limit game loop time on: 2011-03-10 12:17:54
Hi all!)
I have a problem. My game loop gives all available fps from processor - how i can limit it, that i had non constant fps and not 100% of processor used same time?
3  Game Development / Newbie & Debugging Questions / Re: Out of memory while drawing VBOs on: 2011-01-24 13:48:42
Forget to rewind buffers before sending them to OpenGL..
4  Game Development / Newbie & Debugging Questions / Minor drawing question on: 2011-01-24 13:36:57
Guys, i just cannot get it...
If gl_Vertex is deprecated in #version 130, how i can draw?
so, i need to draw VBO with indices as usual (glVertexPointer(3, GL_FLOAT, 0, 0)) and if i need to transfere vertex in shader i need to use vertex attributes, right?
5  Game Development / Newbie & Debugging Questions / Re: Out of memory while drawing VBOs on: 2011-01-21 19:08:22
Problem solved.. But i don't know how - i did it pretty the same way...Wink
6  Game Development / Newbie & Debugging Questions / Re: Out of memory while drawing VBOs on: 2011-01-21 17:09:31
Rewrited VBOHelper as in tutorial - still do not work...........((
http://www.lwjgl.org/wiki/index.php?title=Using_Vertex_Buffer_Objects_(VBO)
7  Game Development / Newbie & Debugging Questions / Re: Out of memory while drawing VBOs on: 2011-01-21 16:53:38
thanks, i'l try..
And by the way - why they always use methods like ARBVertexBufferObject.glGenBuffersARB(buffer); instead of methods used in most of tutorials/literature like glGenBuffers()
8  Game Development / Newbie & Debugging Questions / Re: Out of memory while drawing VBOs on: 2011-01-21 16:39:54
First one is a tutorial from oficial site - but i'm pretty sure it it outdated - second and third (same) are outdated too. VBOs now is in core i think...
P.S. i just cannot get into version system - what means org.lwjgl.opengl.GL15? why it does'n include for example org.lwjgl.opengl.GL11? Every time i found any tutorial it looks like OpenGL was rewrited complitedly..;((
9  Game Development / Newbie & Debugging Questions / Re: Out of memory while drawing VBOs on: 2011-01-21 16:08:30
Maybe someone can just add some working code snippet?
10  Game Development / Newbie & Debugging Questions / Out of memory while drawing VBOs on: 2011-01-21 15:56:18
Guys, i really stuck with this..(( Want to draw two simple triangles as a quad through VBO, but can see only triangle rendered through immediate mode((

App 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  
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  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
package vbo;

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

import org.lwjgl.BufferUtils;
import org.lwjgl.input.Keyboard;

import lwjgl.VBOHelper;
import app.IKeyListener;
import app.LWJGLApp;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;

public class VBOApp extends LWJGLApp implements IKeyListener {

   boolean end = false;
   
   VBOApp(String title, int width, int height) {
      super(title, width, height);
   }

   /**
    * @param args
    */

   public static void main(String[] args) {
      VBOApp app = new VBOApp("VBO example", 800, 600);
      app.start();
   }

   int vertBuf = 0;
   int colBuf = 0;
   int indBuf = 0;  

   @Override
   public boolean onInit() {
      addKeyListener(this);
     
      if(!VBOHelper.checkHardwareVBOSupport()){
         return false;
      }
     
      // Buffers
      FloatBuffer vBuf = BufferUtils.createFloatBuffer(12);
      FloatBuffer cBuf = BufferUtils.createFloatBuffer(16);
      IntBuffer iBuf = BufferUtils.createIntBuffer(6);
       
      float color[] = {1, 0, 1, 0};
     
      // First
      float first[] = {-1, -1, 0};
      vBuf.put(first);      
      cBuf.put(color);
           
      // Second
      float second[] = {-1, 1, 0};
      vBuf.put(second);            
      cBuf.put(color);
     
      // Third
      float third[] = {1, 1, 0};
      vBuf.put(third);            
      cBuf.put(color);
     
      // Fourth
      float fourth[] = {1, -1, 0};
      vBuf.put(fourth);      
      cBuf.put(color);
     
      // Indices
      int indices[] = {0, 1, 2, 0, 2, 3};
      iBuf.put(indices);
     
      // Creating buffers and filling data
      vertBuf = VBOHelper.createVBOID();
      VBOHelper.bufferData(vertBuf, vBuf, GL_STATIC_DRAW);
     
      colBuf = VBOHelper.createVBOID();
      VBOHelper.bufferData(colBuf, cBuf, GL_STATIC_DRAW);
     
      indBuf = VBOHelper.createVBOID();
      VBOHelper.bufferElementData(indBuf, iBuf, GL_STATIC_DRAW);
     
      return true;
   }
   
   @Override
   public boolean prepareFrame(long msecElapsed) {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
     
      glTranslatef(0, 0, -6.0f);

      glBegin(GL_TRIANGLES);                  // Drawing Using Triangles
      glVertex3f( 0.0f, 1.0f, 0.0f);            // Top
      glVertex3f(-1.0f,-1.0f, 0.0f);            // Bottom Left
      glVertex3f( 1.0f,-1.0f, 0.0f);            // Bottom Right
      glEnd();
     
      VBOHelper.bindVBO(vertBuf, indBuf, colBuf);
      VBOHelper.drawTriangles(6);
     
      return !end;
   }

   @Override
   public void onDestroy() {
      // Destroying buffers
      VBOHelper.destroyBuffer(vertBuf);
      VBOHelper.destroyBuffer(colBuf);
      VBOHelper.destroyBuffer(indBuf);
   }

   @Override
   public void keyboardEvent(int key, boolean pressed) {
      if(key == Keyboard.KEY_ESCAPE){
         end = true;
      }      
   }

}


VBO helper 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  
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  
package lwjgl;

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

import org.lwjgl.opengl.GLContext;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;

import utils.Log;

public class VBOHelper {
   
   /**
    * Checking CAPs
    */

   public static boolean checkHardwareVBOSupport(){
      if(!GLContext.getCapabilities().GL_ARB_vertex_buffer_object){
         Log.hardwareNotSupport("GL_ARB_vertex_buffer_object");
      }
      return GLContext.getCapabilities().GL_ARB_vertex_buffer_object;
   }

   /**
    * Creating, filling, destroying
    */

   // Creating id for our VBO
   public static int createVBOID() {
      return glGenBuffers();
   }

   // Float data for our VBO (vertex, color, normal)(default usage = GL_STATIC_DRAW)
   public static void bufferData(int id, FloatBuffer data, int usage) {      
      glBindBuffer(GL_ARRAY_BUFFER, id);
      glBufferData(GL_ARRAY_BUFFER, data, usage);
   }

   // Int data for our VBO (indices)(default usage = GL_STATIC_DRAW)
   public static void bufferElementData(int id, IntBuffer data, int usage) {
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);
      glBufferData(GL_ELEMENT_ARRAY_BUFFER, data, usage);
   }
   
   public static void destroyBuffer(int id){
      glDeleteBuffers(id);
   }
   
   /**
    * Binding, drawing
    */

   // Preparing OpenGL for drawing and binding buffers
   public static void bindVBO(int vertexBufferID, int indexBufferID, int colourBufferID) {
      glEnableClientState(GL_VERTEX_ARRAY);
      glBindBuffer(GL_ARRAY_BUFFER, vertexBufferID);
      glVertexPointer(3, GL_FLOAT, 0, 0);
             
      glEnableClientState(GL_COLOR_ARRAY);
      glBindBuffer(GL_ARRAY_BUFFER, colourBufferID);
      glColorPointer(4, GL_FLOAT, 0, 0);
       
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferID);
   }
   
   
   public static void drawTriangles(int indexBufferSize){
      glDrawElements(GL_TRIANGLES, indexBufferSize, GL_UNSIGNED_INT, 0);
   }  
}
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.

rwatson462 (35 views)
2014-12-15 09:26:44

Mr.CodeIt (26 views)
2014-12-14 19:50:38

BurntPizza (60 views)
2014-12-09 22:41:13

BurntPizza (95 views)
2014-12-08 04:46:31

JscottyBieshaar (55 views)
2014-12-05 12:39:02

SHC (71 views)
2014-12-03 16:27:13

CopyableCougar4 (73 views)
2014-11-29 21:32:03

toopeicgaming1999 (133 views)
2014-11-26 15:22:04

toopeicgaming1999 (124 views)
2014-11-26 15:20:36

toopeicgaming1999 (34 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

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
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!