Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (727)
Games in Android Showcase (217)
games submitted by our members
Games in WIP (796)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 5 6 [7] 8 9 10
 61 
 on: 2017-05-17 14:59:54 
Started by buddyBro - Last post by buddyBro
@abcdef, per your suggestion, I've moved the floatBuffer creation to once per execution instead of once per frame, and just do .clear each frame. Likewise moved the int vboID = glGenBuffers(); line to once per execution instead of per frame.


        // once per execution
   FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(1000 * 100 * 10);
   int vboID = -1;

   public void oncePerFrame() {
         x = new LinkedList<>();
         
         glClear(GL_COLOR_BUFFER_BIT);

               // here i loop over polygons and add vertices to x.
         
         float[] y = new float[x.size()];
         for (int i = 0; i < y.length; i++)
            y = x.get(i);
         
         if (vboID == -1) {  // once per execution
            vboID = glGenBuffers();
            glBindBuffer(GL_ARRAY_BUFFER, vboID);
         }

         verticesBuffer.clear();
         verticesBuffer.put(y).flip();
         glEnableVertexAttribArray(0);
         glBufferData(GL_ARRAY_BUFFER, verticesBuffer, GL_DYNAMIC_DRAW);
         glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);
         glDrawArrays(GL_QUADS, 0, y.length);
         
         glfwSwapBuffers(window);
      }

And did not see any improvements.

I feel bad for posting prior to having a chance to reading Riven your link, but just wanted to try and provide update on the suggestions. I'll be reading that as my next step.

 62 
 on: 2017-05-17 04:47:58 
Started by buddyBro - Last post by abcdef
You are creating a brand new vbo every frame, create the vbo once and update that vbo only if the data changes. By creating a new vbo every frame you are creating new memory blocks on the GPU every frame.

You are also creating a new FloatBuffer every frame. Don't. Create it once and reuse it.

Remember a vbo is just a pointer to memory on the gpu that holds vertex data and the FloatBuffer is the memory the CPU uses to hold the data locally and update the GPU when necessary.

 63 
 on: 2017-05-17 03:56:48 
Started by buddyBro - Last post by buddyBro
Thank you both. I'll look at that intro and see what happens.

@Elect, just to clarify, you mean something like the following?

float[] accumulatedVerticies; // reset empty at beginning of each frame

void oncePerPolygon(float[] verticies) {
  glEnableVertexAttribArray(0);
  glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);
  glDrawArrays(GL_QUADS, 0, vertices.length);
  // accumulatedVerticies = accumulatedVerticies . append . verticies;
}


void oncePerFrame() {
  FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(accumulatedVerticies.length);
  verticesBuffer.put(vertices).flip();
  int vboID = glGenBuffers();
  glBindBuffer(GL_ARRAY_BUFFER, vboID);
  glBufferData(GL_ARRAY_BUFFER, verticesBuffer, GL_DYNAMIC_DRAW);
}

If that's what you mean (though I have a feeling I misunderstood you), I could just move all but the last line of the oncePerPolygon into the oncePerFrame, and just have the oncePerPolygon create append to the accumulatedVerticies, right?

Well, I just tried that, having the following execute once per frame:

         x = new LinkedList<>();
         
         // here i loop over polygons and add vertices to x.

         float[] y = new float[x.size()];
         for (int i = 0; i < y.length; i++)
            y = x.get(i);
         
         FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(y.length);
         verticesBuffer.put(y).flip();
         int vboID = glGenBuffers();
         glEnableVertexAttribArray(0);
         glBindBuffer(GL_ARRAY_BUFFER, vboID);
         glBufferData(GL_ARRAY_BUFFER, verticesBuffer, GL_DYNAMIC_DRAW);
         glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);
         glDrawArrays(GL_QUADS, 0, y.length);
         
         glfwSwapBuffers(window);

And the result was the same 1-3 fps at just a 1000 polygon count.
Yes vertices change every frame, since these are not 3d world coordinates, but the 2d screen-projected coordinates.

 64 
 on: 2017-05-16 23:24:23 
Started by NuclearPixels - Last post by NuclearPixels
Thanks for you feedback Smiley!

First of all, since you mentioned the assets I must say that the credit must be going to Reiner's Tilesets (http://www.reinerstilesets.de/). Since we do not have yet the credits section it is important to identify the people who actually provided the graphical components (I will try to compile the whole list tomorrow), the real heroes Tongue!

Secondly, regarding the arrows. I agree, at some point the trajectory is so damn weird Cheesy! You suggestion is interesting as it would force the player to recruit additional melee troops or even place some obstacles/traps in the path of the enemies, so they could be slowed down and still hit by the range units. On another hand, for archers, we were thinking to experiment with dynamic hitbox, so deployed on the tower units, instead of receiving the same obstacle location as all other units, would ignore the tower where they are deployed at and simply shoot down. I am not sure how it will look though, we will definitely experiment with proposed by you solution Smiley!

 65 
 on: 2017-05-16 20:40:57 
Started by NuclearPixels - Last post by meva
Hi,
I played your game and found it very good. I love graphics, it's awesome:).
I like the way units are moving, very realistic. Great job.

Infantry when is in tower is useless and exposed to enemy fire. Maybe by clicking on the yellow arrow the unit should go to fight with enemy soldiers through some gate. My tactic based mostly on archers.

When archers are in tower and enemies are cutting the tower, arrows have strange/funny path. Maybe consider case when archers must keep foe units at distance and when they are close to a tower the archers cant shoot them and you need to send knights. Would be more fun:).

 66 
 on: 2017-05-16 16:34:26 
Started by homac - Last post by homac
@ gouessej: had a look at their repository but didn't find anything related to GLSL parsing. Also, I couldn't find a contact address.

Ported the grammar from Khronos' reference impl to ANTLR4 and extended it by the rules for preprocessing according to ISO C standard (also added #include directive while I'm at it - doesn't hurt to have it).

The grammar is written. Test coverage is currently at 30%, roughly.

 67 
 on: 2017-05-16 16:08:48 
Started by buddyBro - Last post by Riven
http://www.java-gaming.org/topics/introduction-to-vertex-arrays-and-vertex-buffer-objects-opengl/24272/msg/203739/view.html

It's showing its age somewhat, but should be enough to get you started Pointing

 68 
 on: 2017-05-16 15:43:22 
Started by buddyBro - Last post by elect
forget glColor3fv, it's deprecated

this should be executed only once:

FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertices.length);
verticesBuffer.put(vertices).flip();
int vboID = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBufferData(GL_ARRAY_BUFFER, verticesBuffer, GL_DYNAMIC_DRAW);


and then in the loop

glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);
glDrawArrays(GL_QUADS, 0, vertices.length);


If you need to change the vertices all together with the same transformation, you need to use matrices, otherwise bind again vboID and call glbufferSubData

 69 
 on: 2017-05-16 15:31:44 
Started by buddyBro - Last post by buddyBro
Intro, so I've spent a couple days trying to figure out the lwjgl 3 way of doing things with vbo's. This being the first time I'm hearing a lot of the terminology isn't making the resources/tutorials easy to understand. Nor do I want to begin at the very beginning, since I have a solid understanding of 3d rendering (though not of opengl or gpu's). Also, though I would like to take the time to learn opengl thoroughly eventually, at the moment, I just want to get my little experiment working.

Previously, I had been using Java graphics2D to draw polygons; e.g.,  brush.drawPolygon(xy[0], xy[1], xy[0].length);

However, I was not happy with the 15fps it was dipping too when polygon count would reach 15-20k. So I decided to try out lwjgl. Here's some code snippet I copied from a previous project before lwjgl 3 had come about, and was very happy with performance,
            glColor3fv(color);
            GL11.glBegin(GL11.GL_POLYGON);
            for (byte i = 0; i < vertices.length; i += 2)
               GL11.glVertex2d(vertices, vertices[i + 1]);
            GL11.glEnd();

But for learning's sake, I wanted to get a little familiar with the newer way of drawing in opengl. So I tried figuring out from tutorials and the online reference and eventually arrived at this working snippet (not included in the snippet is a glclear and glfwSwapBuffers that each happens once per frame):
            glColor3fv(color);
            FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertices.length);
            verticesBuffer.put(vertices).flip();
            int vboID = glGenBuffers();
            glEnableVertexAttribArray(0);
            glBindBuffer(GL_ARRAY_BUFFER, vboID);
            glBufferData(GL_ARRAY_BUFFER, verticesBuffer, GL_DYNAMIC_DRAW);
            glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);
            glDrawArrays(GL_QUADS, 0, vertices.length);

Unfortunately, this last snippet, was dropping painfully slow even at 1000 polygon count, which was disappointing, but also indicated that must not be the correct way of doing things.
I'm not sure if I can group up all my draw's into 1 giant array and only call glDrawArrays once, since I think only the last glColor would then be applied to all the quads. Nor do I want to include the color per vertex, since doing so seems to require writing a shader or something, and that seems like overkill for my requirement.
Additionally, if it matters, vertexes are in 2D coordinates. I do the 3d -> 2d transformation and lighting -> color calculations with java+math rather than opengl. Hence my reluctance to write shaders or anything too complicated.

Thanks,

 70 
 on: 2017-05-16 13:08:04 
Started by Chennorris - Last post by elect
Wow, feeling impressed by the speed at which you spotted the point Shocked

Got the same error of your somewhere in the past, it took me a while.. and I learnt that

Pages: 1 ... 5 6 [7] 8 9 10
 
Archive (293 views)
2017-04-27 17:45:51

buddyBro (482 views)
2017-04-05 03:38:00

CopyableCougar4 (926 views)
2017-03-24 15:39:42

theagentd (940 views)
2017-03-24 15:32:08

Rule (951 views)
2017-03-19 12:43:22

Rule (919 views)
2017-03-19 12:42:17

Rule (921 views)
2017-03-19 12:36:21

theagentd (982 views)
2017-03-16 05:07:07

theagentd (893 views)
2017-03-15 22:37:06

theagentd (691 views)
2017-03-15 22:32:18
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

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!