Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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] 2
1  Game Development / Newbie & Debugging Questions / Re: Correct way to render thousands of polygons on: 2013-03-20 21:50:45
Yeah I suppose that makes a lot more sense now that I think about it.

However; I may have misled you a little bit in the OP, it's not this program that I'm having FPS issues with, I'm only having issues with it not drawing at all.

Do you see anything important missing? Or anything that might make the objects not be rendered at all?


Oh god I feel dumb.... Lips Sealed

*whispers*forgot to flip the buffers...
2  Game Development / Newbie & Debugging Questions / Re: Correct way to render thousands of polygons on: 2013-03-20 21:33:05
Thanks for the information Cheesy although I believe it's what I already had in my mind. (see Map Class below)

In regards to the 3rd question's answer:

From what I understand, this should draw 1 square (as they're all on top of each other due to the 0L offset), yet nothing is drawn at all.
I'm certain that openGL is set up correctly because I can draw immediate mode just fine. It's something to do with how I'm using the VBOs.

Tile Class: http://pastebin.java-gaming.org/30439348749
Map Class: http://pastebin.java-gaming.org/b3043298447

Edit: lol ignore BufferHelper.reserveData(150000) that was just a hotfix so that I could continue testing
3  Game Development / Newbie & Debugging Questions / Re: Java - LibGDX - Ease Rotation with Speed? on: 2013-03-20 20:36:09
So, if you take out the rotation ease code, it works correctly?

I'm not 100% sure, but it looks like either _rotationSpring or _rotationDamping will affect what you want.  The variables are constant at the moment, and one or both of them need to change according to the speed.  Try messing around with the variables to see which one affects what, and go from there.

I can't tell exactly what's going on with the math because the variable names are so ridiculous..._dr, _ar, _vr...Huh

4  Game Development / Newbie & Debugging Questions / Correct way to render thousands of polygons on: 2013-03-20 20:25:51
I understand that VBOs are currently the best way to render polygons.

Here is what I understand VBO's to be:
(please correct any of the following information if it is wrong)

- Vertex Buffer Objects take an array of data, package it tightly, and send it to the GPU to be rendered.
- The memory must already be reserved on the GPU before the data is sent.
- The goal of using VBOs is to keep the data stored on the GPU for as long as possible (therefore, better for static drawing?)

That being said, I have a couple of questions about them.

1) What parts of the vbo should be done only once, and which need to be called every tick?
2) What parts of the vbo fast and which parts take the most time? (when drawing thousands of polys *wrongly*, it will slow down to about 1fps)


Now, if somebody really feels like helping me:

3) What is the correct way to render a huge amount of polygons with VBOs in the following example:

I'm rendering a 2d environment made up of probably millions of squares (think terraria).  
I have a class for each tile, and a map class that holds 1 list of tiles at the moment.
Should I store the buffer data in the tile class and call it to the map class when needed?
Should I package all of the arrays into one huge array before I send it to a VBO?

Hopefully you've got an idea of what I'm trying to do now.

Any information would be helpful as I'm still a newb! xD

Edit: sorry, forgot to mention that I'm using LWJGL to do this.
5  Game Development / Newbie & Debugging Questions / Re: Widescreen Display without skewing (LWJGL) on: 2013-02-20 09:35:05
Thanks guys.

ra4king: debugging doesn't have much to do with being smart, only with looking in the right places.  I apparently was not.
(you're normally really nice and helpful so I won't hold a grudge Tongue)
6  Game Development / Newbie & Debugging Questions / Re: HD resolution without skewing (LWJGL) on: 2013-02-19 11:36:00
I'm sorry Danny. I wrote the wrong thing.  I meant when the aspect ratio AND the screen dimensions are a 1:1 ratio.  

ps: I know what HD means, please don't be a jerk.
pps: I am well aware of the difference between OpenGL, and LWJGL.

ppps: Your reply was neither constructive nor informative, please reply with a better response next time. But thank you for at least taking the time to read the post I guess...
7  Game Development / Newbie & Debugging Questions / Re: HD resolution without skewing (LWJGL) on: 2013-02-19 06:57:20
The aspect ratio is technically correct, and maybe this is just an issue with OpenGL itself.

When running a game on the source engine (and most other engines), you can look straight down (assuming a 3d environment) and rotate on the y axis extremely fast.

It will produce what appears to be a perfect circle.  With LWJGL using gluPerspective, it creates an oval (unless the aspect ratio is 1).  It's even an issue in one of the most popular titles of our days (Minecraft)

Some might not consider it an issue, but to me, it creates an unrealistic 3d environment.
8  Game Development / Newbie & Debugging Questions / Widescreen Display without skewing (LWJGL) on: 2013-02-19 03:58:12
When working with LWJGL in a 3d environment using gluPerspective (using HD resolution such as 16x9, or anything larger than 1), there is the same amount of viewable space on the (2d) x and y axes.

Because of this, the screen appears to be stretched on whichever side is larger.

I've read that supposedly, multiplying all of the rendering by the projection matrix will fix this, but cannot find anywhere how I would go about doing so.
sorry, misread that tutorial.

I'm pretty confident most people know what I'm talking about, but I might have worded it weirdly. Let me know if you would like screenshots, or if you would like to test it yourself, make a button binding to toggle between gluPerspective(60, width/height, 0.1f, 1000f), and gluPerspective(60, 1, 0.1f, 1000f)

the latter is what I am trying to achieve while still keeping the same screen size (1600x900)
9  Game Development / Newbie & Debugging Questions / Re: Skybox Rendering on: 2013-02-19 03:14:52
Thank you guys! Cheesy

I've had to re-write how I load in textures, but it was worth it! It's working perfectly now Smiley
10  Game Development / Newbie & Debugging Questions / Re: Skybox Rendering on: 2013-02-17 16:46:25
Ahh thanks!

Im not near my computer atm but ive got one question about that code. Is it a one-time binding? Or do I need to do this every render tick?

Itll be nearly 24 hours before I can test this but ill let you know if it works! Cheesy

Really appreciate the feedback!
(LOVE this forum! And the community)
11  Game Development / Newbie & Debugging Questions / Re: Skybox Rendering on: 2013-02-17 13:44:36
1) It was done on the pixel-by-pixel level in Adobe Photoshop CS5

2) No. I'll research this.  If its simple to explain, feel free to explain it on this topic Cheesy

3) Yes they're on every edge, it's probably the wrapping policy that will fix it.

How would I go about separating the skybox image via an algorithm? PNG decoder?
12  Game Development / Newbie & Debugging Questions / [FIXED]Skybox Rendering on: 2013-02-17 12:42:31
So...I've got a working skybox and I'm trying to figure out how I can make it better/more realistic.

In the following screenshot, you can see that there are dark lines where the planes intersect.



I've made sure that the images themselves do not have any such lines.

Some information on how the skybox is rendered:

The FloatBuffer data fed to openGL:

http://pastebin.java-gaming.org/551a80d3e4a

The rendering method:

http://pastebin.java-gaming.org/51a8d1e3a43


Also, I know that a new trend in games is to have a spherical skybox.  Should I ditch the old cube-style?


Thanks,
QuicK
13  Game Development / Newbie & Debugging Questions / Re: Texture with VBOs and Slick library on: 2013-02-13 01:51:49
I found that client state prior to creating this post and when I tried including it with the code supplied in the OP, it crashed the IDE. Ive never experienced that type of crash before and am not sure how to debug it. I can post the crash log when I get home if that will help?
14  Game Development / Newbie & Debugging Questions / Re: Texture with VBOs and Slick library on: 2013-02-12 14:17:40
I figured it had to do with something like that, I just couldn't get a solid answer out of google as to how much memory a floating point number actually takes up.

Thanks for the reply! Smiley
15  Game Development / Newbie & Debugging Questions / [SOLVED]Texture with VBOs and Slick library on: 2013-02-12 13:31:06
Is it possible to use Textures from the Slick2D library in conjunction with VBOs from GL15?  I've got everything working, the image is loaded etc.  I'm just not quite sure how to bind the image to openGL.

I'm currently using only 1 float buffer with position vertices, colors, and texture coordinates.

My FloatBuffer is as follows:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
FloatBuffer buffer = BufferHelper.reserveData(32);
      buffer.put(new float[]{
         //position vertices
        x - width, y - height, 0,
         x + width, y - height, 0,
         x + width, y + height, 0,
         x - width, y + height, 0,
         //color vertices
        1, 1, 1,
         1, 1, 1,
         1, 1, 1,
         1, 1, 1,
         //texture vertices
        0, 0,
         1, 0,
         1, 1,
         0, 1
      });


My drawing method is as follows:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public void draw() {
      texture.bind();
      glBindBuffer(GL_ARRAY_BUFFER, vboHandle);
        glVertexPointer(3, GL_FLOAT, 0, 0L);
        glColorPointer(3, GL_FLOAT, 0, 48L);
        glTexCoordPointer(2, GL_FLOAT, 0, 96L);
        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);
        glDrawArrays(GL_QUADS, 0, 4);
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_COLOR_ARRAY);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
   }



Is there a client state that needs to be enabled?
Am I binding the texture correctly?
Should I be using GL_TEXTURE_2D instead of slick?

Any input would be appreciated, even pointing out bad coding practices! (please do!)

P.S. - if anybody could explain to me why 48L is the correct offset for the colors, that would be great! Smiley



Edit: Sorry, guess I should have brushed up on basic openGL texturing first.  Fixed it by enabling GL_TEXTURE_2D and GL_BLEND. (using a .png)
16  Game Development / Newbie & Debugging Questions / Re: Is a drop of 60 fps to 57 noticeable? on: 2012-10-31 10:10:43
...in 3D they won't, no. But in 2D it is like a GIANT BALL OF PUS RUINING YOUR LIFE.

Cas Smiley

Right you are, haha I've been working in 3D so much, I actually forgot about 2D..... Cry
17  Games Center / Cube World Projects / Re: VBO order of operations on: 2012-10-31 04:44:34
Thanks for the replies guys! That really clears up some things that I didn't know about VBOs!

@ra4king the reason I'm now using FloatBuffer vertexData = BufferUtils.createFloatBuffer(294912); is because I had tried what you suggested prior to posting this, and couldn't get it to work.

I'll take what you guys said, and try to fix my chunk code! I'll update this post after I've attempted it! Smiley

Edit:

Okay, so...I've tried many things to no avail.

Let me make sure I have things right in my mind. (Note: this is to create a VBO for 16x16x16 cubes)

1) create the chunk-specific FloatBuffer (vertexData) with enough space to hold all indices of all vertices (294912)
2) generate the ID for the buffer (glGenBuffers()) -- there should be only one of these right?
3) run through 3 nested loops (x, y, z) to create the indices
4) put the indices in vertexData
5) after the nested loops, flip vertexData
6) bind the ID generated in step 2, provide the VBO with the vertex data, and unbind the ID generated in step 2
7) after all of the above steps have been completed, run this every draw tick:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public void draw() {
     
      glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
      glVertexPointer(3, GL_FLOAT, 0, 0L);
     
      glBindBuffer(GL_ARRAY_BUFFER, vboColorHandle);
      glColorPointer(3, GL_FLOAT, 0, 0L);
     
     
      glTranslatef(curx, cury, curz);
     
      glEnable(GL_CULL_FACE);
      glCullFace(GL_BACK);
      glEnableClientState(GL_VERTEX_ARRAY);
      glEnableClientState(GL_COLOR_ARRAY);
      glDrawArrays(GL_QUADS, 0, 98304); //98304 derived from 4 vertices per face and 6 faces (4*6) * (16*16*16)
     glDisableClientState(GL_COLOR_ARRAY);
      glDisableClientState(GL_VERTEX_ARRAY);
      glDisable(GL_CULL_FACE);
     
   }




And....as usual I feel extremely dumb because I found out my problem as I was writing this out.
M issue was in glDrawArrays()...I was only allowing enough indices for 1 cube.

I decided to go ahead and post this in case anybody else finds it useful Smiley thanks for the help guys! I still learned a good bit about VBOs from this Smiley
18  Game Development / Newbie & Debugging Questions / Re: Is a drop of 60 fps to 57 noticeable? on: 2012-10-31 03:06:13
Nope, from my experience with gaming (particularly with Counter-Strike: 1.6 and Counter-Strike: Source), fps was only noticeably low once it dropped below about 40 fps.

There is a slight difference between 40 and 60, but most gamers will be used to this, and won't notice it Smiley
19  Games Center / Cube World Projects / VBO order of operations on: 2012-10-31 02:58:42
Okay...so like everybody else, I'm trying to create a "simple" voxel engine.

I'm trying to create a VBO that will draw the entire chunk of 16x16x16 cubes.

My questions are:

1) FloatBuffer vertexData = BufferUtils.createFloatBuffer(294912);
    Is the above code bad? it's got 16*16*16*72 slots available for the vertex buffer which means it can store every vertex of every cube.
    Should I be storing this many floats in the same buffer? (it's my understanding that VBO's are to Immediate mode as the GPU is to the CPU) which would mean that
    what I'm doing is correct.

2) what does glGenBuffers() actually do, and when should it be called?
    before the vertices are stored in the float buffer? while they're being stored? after they're stored? etc.

3) what actually happens to the FloatBuffer when it is flipped?
    should it only be flipped once (always)?

4) what does the following code do?
1  
2  
3  
4  
int vboVertexHandle = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
glBufferData(GL_ARRAY_BUFFER, vertexData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);



Any information on any of the above questions would be much appreciated!
*as always, any source code will be supplied upon request Smiley



Thanks!

QuicK
20  Game Development / Newbie & Debugging Questions / Re: Having trouble with delta. on: 2012-10-11 05:37:28
Thanks to everyone who replied, I now have a working delta (I used System.nanoTime())!!

21  Games Center / Showcase / Re: Clouds: simple jumping on moving platforms on: 2012-10-09 13:17:01
please please please please please add the cloud's x velocity to the player's x velocity.

This is my only complaint about the game Smiley
It's a nice challenging game. Update the graphics, add sounds, add high scores, and publish! haha
22  Games Center / Showcase / Re: Polygon Skirmish on: 2012-10-09 13:10:50
I played one game of this. I like the mechanics and the particle effects!

The only complaint I have for a version 1 is that the enemies can spawn on you! This makes for a very unfair death IMO.

A Tip that might make the bullets look better.
It's very late and I'm not thinking clearly any more but I think this is right...

Calculate the forward velocity by running Math.atan2(yvel, xvel) * 180/Math.PI and add this to the bullet's velocity.

Also: I got a random crash after about 40 kills...it seems to be a recurring crash (I'm not getting any kind of error log)
23  Game Development / Newbie & Debugging Questions / Re: Having trouble with delta. on: 2012-10-09 12:59:44
With a fresh head next day, some problems will almost solve by itself Wink

Tongue however true that may be, this has been a problem for almost a week now...It's got to be just one little thing I'm doing in all of my programs. but I don't know what it could be, because the code seems very linear for getDelta();
24  Game Development / Newbie & Debugging Questions / Re: Scrolling tile game help on: 2012-10-09 12:58:04
The way I would do this is:

Create a Map class with a 2d array of Tiles.

if the player has free movement rather than tile movment, I would find the nearest tile.

I would then take that tile and center the camera on it. (basically translate the matrix to that position)

I would only render tiles that are within the camera position.x +/- Display.getWidth()/2 and camera position.y +/- Display.getHeight()/2

You might need to play with the render distance to make sure tiles that are half on the screen and half off are still drawn.

If you still need help tomorrow, I might be able to throw something simple together for you Smiley
25  Game Development / Newbie & Debugging Questions / Re: How to get the angle from 1 point to another on: 2012-10-09 12:50:42
Have any of you ever had an issue with this returning bad angles?

I was messing around with an L-System algorithm, and all of my angles when calculating (angle%45) should be 0.
Some of them return 44.99999 or 90.00001...all of my numbers are floating decimal numbers, and there is no rounding :/

is this just some fault with computers? (I understand its not that big of a deal, I just found it interesting)
26  Game Development / Newbie & Debugging Questions / Re: Having trouble with delta. on: 2012-10-09 12:45:31
Maybe you can try one of them and see if they work better than the timer that you are using?

I'll give it a try! I don't think the deficiencies in the resolution would cause stuttering as long as vsync is enabled...but for now I need to sleep haha. I've been up all night implementing an L-system and trying (but failing) to implement ground made from midpoint displacement :/

The only thing I don't get, is I literally copied a project that has a working delta, changed the name, ran it, and the delta was not working properly. (WTF java...)
27  Game Development / Newbie & Debugging Questions / Re: Having trouble with delta. on: 2012-10-09 12:36:51
First of all, thank you for taking the time to look over this and try to help me Smiley

Second...
What is the getTime() function using as it's means of determining time? Do you know if it uses System.currentTimeMillis()? or System.nanoTime()?

Sorry, I forgot to include my getTime() method which is the following:

1  
2  
3  
public long getTime() { 
      return (Sys.getTime() * 1000) / Sys.getTimerResolution();
   }


I can't find whether Sys.getTime() uses System.currentTimeMillis() or System.nanoTime() or maybe it's own methods?

Where is "lastframe" declared? Is it in the same class? In the same thread? Is there anything being done with it outside of this loop? Is it being altered by the Display functions?

"lastframe" is initialized as an instance variable in the Game class (which contains my game loop and there is only one instance of this running in the program).
the only modifier I have for "lastframe" is in the Game.getDelta() class:
1  
2  
3  
4  
5  
6  
7  
public int getDelta() {
      long time = getTime();
      int delta = (int) (time - lastframe);
      lastframe = time;
     
      return delta;
   }

These are the only two spots lastframe is even used in my entire program.

Quote
I should learn some LWJGL.

I agree! It was pretty easy to learn the basics, and I've been progressing pretty steadily even in 3d rendering.
(It helps that http://www.youtube.com/user/TheCodingUniverse made a great tutorial series on it)
It's also the only java game library I've learned/used. I'm considering giving JMonkeyEngine a go as well!
28  Game Development / Newbie & Debugging Questions / Re: Texturing a cube with multiple textures (slick) on: 2012-10-08 22:58:30
I'd also highly recommend using an object-oriented approach instead of endless if-else statements. Right now you have lots of repeated code.

Could you give me an example of how how would do it? (pseudo-code is fine)

From this statement: this comes to mind.
1  
2  
create a "Face" class for each face with a texture variable (with texture coordinates) and a draw method. (this will contain texture.bind())
create a "Cube" class that has an array of 6 faces that each call the Face.draw() method.


If you can think of a better way to do it, please let me know! Smiley

P.S. - thank you sproingie, I've been looking for those docs...
29  Game Development / Game Play & Game Design / Re: Game Threading on: 2012-10-08 06:45:15
What you can do is do not render anything that you can not see, so reducing the 64x64 cube to something that maybe only shows the front side of the cube or something, this will reduce the time.

edit: im assuming you mean a 64x64x64 or something of cubes, so you can render just the outside, but dont render the inside this will reduce it massively from

262144 cubes completely rendered
to
24576 cubes rendering the entire outer of the cube, where you can remove the rendering from the back (as the player cant see the back, that will just reduce it to like 20576 cubes. which should definitely be under 1 second

It is only a 64x64 space (4096 cubes...I assume this adds up to 49152 faces...12 for each cube (front and back?)) but every face of every cube is being drawn (front, and back).  It was just for testing, I wasn't trying to optimize the rendering. I  just wasn't sure if threading would be involved as part of the optimization or not, but they have answered my question Smiley

Thank you everyone for the replies! Smiley If only I could get this many on my other questions >.>
30  Game Development / Game Play & Game Design / Re: Game Threading on: 2012-10-08 06:25:32
And maybe a thread for music and sound as well.

@ra4king - Do you second this? (I imagine it would be mainly for the loading of sounds which I would generally pre-cache)

Also. When you say 1 thread for logic and rendering, you mean 1 thread total? as in I can just use the main thread?

or do you mean 1 thread for each? Because with my non-optimized rendering of a skybox and a 64x64 grid of cubes, it takes about 2 seconds to finish defining all of the vertices and to initialize the drawing of each. (after this, my fps is fine) and that is what brought me to asking this question.
Pages: [1] 2
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (57 views)
2014-04-15 18:08:23

BurntPizza (55 views)
2014-04-15 03:46:01

UprightPath (68 views)
2014-04-14 17:39:50

UprightPath (51 views)
2014-04-14 17:35:47

Porlus (68 views)
2014-04-14 15:48:38

tom_mai78101 (93 views)
2014-04-10 04:04:31

BurntPizza (153 views)
2014-04-08 23:06:04

tom_mai78101 (249 views)
2014-04-05 13:34:39

trollwarrior1 (205 views)
2014-04-04 12:06:45

CJLetsGame (213 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!