Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
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 3
1  Game Development / Newbie & Debugging Questions / Re: Ordering draw calls for alpha blending on: 2014-07-06 17:06:56
Hm, okay. I guess I should abandon this then - I was going to have all of the terrain above a certain height translucent, so that you could not only see a 'cross section' of the terrain but also the full shape of the terrain.
2  Game Development / Newbie & Debugging Questions / Re: Ordering draw calls for alpha blending on: 2014-07-05 19:29:45
But how could you sort it back to front if half the vertices of 1 poly are behind, and the other half are in front?
3  Game Development / Newbie & Debugging Questions / Re: Ordering draw calls for alpha blending on: 2014-07-05 19:17:33
But the point is, do i need to order every draw call, or just the order in which the VBOs are drawn?
4  Game Development / Newbie & Debugging Questions / Re: Ordering draw calls for alpha blending on: 2014-07-05 15:32:01
Just wondering if anyone had any experience with it, before I jump in and do something:P
5  Game Development / Newbie & Debugging Questions / Re: Drawing Graphics on: 2014-07-05 14:18:44
Are you using the basic java graphics libraries? java.awt, JFrames and the like?

I assume you are (as no other library was mentioned).

This is how I used to do it:
Create a class called DrawGame or something. Make this extend Canvas (I can't remember which package this belongs to, but you could google it, or, if using eclipse, use ctrl+shift+O to automatically import it).

The DrawGame class will be where you do all of your drawing.
To prevent tearing, you need to double or triple buffer your graphics. To do this, add a member variable to DrawGame of type 'BufferStrategy'.

In DrawGame's constructor, call 'createBufferStrategy(2);' to create a buffer strategy for the canvas.
next, assign the BufferStrategy member variable to 'getBufferStrategy()'

When you want to draw anything, simply call 'getDrawGraphics()' on the BufferStrategy variable, and store this value in a Graphics object.

After you finish drawing anything, call show() on the strategy and dispose() on the graphics object.

After creating your JFrame, add an instance of DrawGame to it.

To further illustrate this, here is an example class which will draw a square -

http://pastebin.java-gaming.org/e3dee740a0a13

It's pretty dirty code though.
Have fun:)

6  Game Development / Newbie & Debugging Questions / Ordering draw calls for alpha blending on: 2014-07-05 14:01:02
Hey!

I recently ran into a problem where having multiple calls to opengl to draw translucent geometry produced some funky results. I googled it, and I believe the problem has something to do with having to order the draw calls from back to front.

I was curious; how should I go about doing this?

My game features an infinite world, split into chunks. Each chunk is 1 VBO. I can order the VBOs from back to front no problem. But will this fix the problem,? Or do I need to order the draw calls within the VBO too? Wouldn't that be quite awkward to do, especially if you have a face that has 2 vertices behind another face, but 2 vertices in front of that same face?

I'm a little puzzled if I have to be honest. The only thing I know is that the weird alpha drawing only happens between chunks. This leads me to believe I only need to order the separate VBOs rather than the inner calls to openGL to draw the faces...

Anyway, thanks:P
7  Discussions / Miscellaneous Topics / Re: Looking for a good host on: 2014-07-03 17:38:14
Linode is awesome (Y)

In fact I believe this website runs off of linode:P

Not sure how suitable it is for gaming. I like it though - you have full control over everything!
8  Game Development / Newbie & Debugging Questions / Re: How to delay somthing without stopping the gameloop? on: 2014-07-03 17:33:51
replace the while with an if, and place the block inside your game loop -

while(!endFlag)
{
   //Game loop goes here


   if (alive == false)
   {
      timer ++;
      if(timer > 10)
      {
         handler.NextLevel();
         timer = 0;
      }
   }
}

The reason the while loop froze your game loop, is because whilst you were looping around inside the alive==false loop, you never updated anything else of the game. Which means nothing got drawn or updated - causing everything to freeze.Smiley

Bear in mind though, that code will make the timer wait for 10 frames. Which is about a 6th of a second, assuming your game is running at 60fps - you probably won't notice the delay. Consider setting it to something higher, like 60.
9  Game Development / Newbie & Debugging Questions / Re: Transparency in LWJGL on: 2014-06-24 22:56:20
Oh, I didn't understand your answer. I wasn't asking about textures; rather coloured vertices with an alpha value. I do believe in this case, blending is the answer.Smiley
10  Game Development / Newbie & Debugging Questions / Re: Transparency in LWJGL on: 2014-06-24 21:01:42
I didn't find a solution, I realised that I didn't actually need an answer in the first place, I could get by without:P (for now)
11  Game Development / Newbie & Debugging Questions / Re: Transparency in LWJGL on: 2014-06-24 19:31:49
Hm, thanks:) I don't think I need it after all, actually:P I found a way around it:)
12  Game Development / Newbie & Debugging Questions / Transparency in LWJGL on: 2014-06-24 14:43:02
Hello, again!._.

So, I've been playing with transparency in my geometry, and what I *want* is for a face to be transparent at a value of about 0.2 or something. However, if I set multiple faces to 0.2, sometimes they overlap, and create a 0.4 alpha value (or something like that, I'm not sure how they add together).

I need the first face to be 0.2 alpha, and any other non opaque face after that to be completely invisible. Is that possible?
13  Game Development / Performance Tuning / Re: Yet another voxel engine on: 2014-06-24 14:40:07
Pretty darn sure that fps count is broken;)
14  Game Development / Game Mechanics / Re: Vector4f on: 2014-06-24 00:09:17
Sweet, thanks. I always wondered:P
15  Game Development / Game Mechanics / Vector4f on: 2014-06-23 22:58:24
Hey

In LWJGL, You have Vector2f (or others for doubles, ints etc),  Vector3f, then Vector4f

For the life of me, I can't fathom what you'd need the 4th value for?
16  Discussions / General Discussions / Re: What's with unorganized code? on: 2014-06-23 20:25:20
Also, in your 'troint' class, why is there public member variables but also functions for encapsulation? Isn't the point of encapsulation to make sure that values are only set in a certain way? Maybe I'm wrong.
17  Game Development / Newbie & Debugging Questions / Re: When and when not to use VBOs on: 2014-06-23 19:53:18
Ah, I didn't realise you could just update them 0.0

Thanks.
18  Game Development / Newbie & Debugging Questions / When and when not to use VBOs on: 2014-06-23 19:42:30
Hey

I feel like I'm asking questions in excess at this point, so sorry in advance, but:

When drawing dynamic entities, like models loaded from an external file with animations, is it still best to create a VBO every frame?? I would have thought the overhead to be greater than the overhead for immediate rendering.

What if I'm just rendering a simple cube which moves quickly around the scene? That would involve creating a VBO almost every frame just for 24 vertices. It just doesn't seem worth it.

Performance wise, what should I use and when?
19  Game Development / Newbie & Debugging Questions / Re: RTS Selecting units on: 2014-06-23 19:13:49
^Yes, whilst reading through I became aware of that problem. Instead of using glUnProject, then checking which units were selected in that rectangle, I am now just using glProject, as you suggested.  Thanks:)
20  Discussions / General Discussions / Re: What's with unorganized code? on: 2014-06-23 19:04:39
^I know, I'm aware it's more widely done on the same line, was really just wondering why.

It's interesting to read how many code conventions there are though, it's quite surprising
21  Game Development / Newbie & Debugging Questions / Re: RTS Selecting units on: 2014-06-23 18:32:14
<3

Thank you so much, this is exactly what I needed!
22  Discussions / General Discussions / Re: What's with unorganized code? on: 2014-06-23 18:19:43
On a partially related topic
How do you all do your curly braces? I prefer

for (int i = 0; i < 10; i ++)
{
}

but some people have the { brace afterwards:

for (int i = 0; i < 10; i ++){

}

23  Game Development / Newbie & Debugging Questions / Re: RTS Selecting units on: 2014-06-23 14:25:22
But how do I get that rectangle if the world is 3D but the input is 2D?

Also, what if I could rotate the view? I'd quite like to include this.
24  Game Development / Newbie & Debugging Questions / RTS Selecting units on: 2014-06-23 13:36:39
Hey:)

So, I'm working on an RTS, and I'm currently thinking about how to go about boxing units. I think the idea is that I get the point on the screen where the mouse has clicked, then create a ray into the 3D world from that, and intersect it with the terrain.

I do this 4 times with each corner of the box, to get an area on the terrain that I'm selecting.

The problem is, where do I go from here? Do I check which units fall within this area? That would be quite messy, especially if a corner of the box lands over on the other side of a hill and another corner hits the hill...

Doing my own research, I've come across 2 methods I could use - gluUnproject and 'picking'
using gluUnproject I can create a ray from my mouse position.
'picking' converts everything on the screen into a 2d image, with different colours used for different things. You then check which colours are inside the box, and select those units.

I'm thinking that picking would be the best way to go about this, but I've heard it's quite slow. Does anyone have any experience with the two? Implementing one of these is going to be more than a few hours of work, as this is completely new territory for me, so I'd rather not have to redo it:P

I hope I've explained this well enough, thanks:)
25  Discussions / Jobs and Resumes / Re: Skill set for an average Java Job on: 2014-06-23 11:39:01
I don't know about any of the things you listed, but sqlite (similar to mysql I believe, but stored in 1 file) was incredibly easy for me to pick up.
My point being that you could probably pick these other things up relatively easily, but it's gonna mean nothing to nobody because you haven't had like 20 years experience with it or whateverD:
26  Game Development / Performance Tuning / Re: Yet another voxel engine on: 2014-06-22 23:21:31
Mm, thanks riven, I'll pop that in when I get chance - I wondered why the results I was getting were incredibly high.

And sorry, I was playing about with the text rendering and I think I added an unecessary GL30 method. I'll remove it later, but I'm a little busy currently:P
27  Game Development / Performance Tuning / Re: Yet another voxel engine on: 2014-06-22 22:08:54
A rather stupid mistake was that I didn't include the Display.update() function in the FPS calculations. I've updated the link to do that - it still stays at a steady 2.5k fps for me though.

Are you on mac?
28  Game Development / Performance Tuning / Re: Yet another voxel engine on: 2014-06-22 22:03:33
Oh sweet, thanks. I'll put that in^^

@Screem
Yeah I got quite a high numbeer too. I'm dubious  of the method I used to calculate it.

I can explain it here:
Because I cap the framerate to 60 every loop, I needed a way to calculate the framerate you would have if you didn't cap it.
Each frame, I get the amount of nanoseconds/1000 it takes to perform all the calculations (without the bit where I cap the framerate). I add this to a value.
Every 60 frames, I take that value and divide by 60 to give the average nanoseconds/1000 it takes to do all the calculations. Then I divide 1000000 by this value, to get the amount of frames that can elapse in 1 second. Then I update the count.

I've been over this and it seems fine - but I was incredibly surprised with the result I got too:s
29  Game Development / Performance Tuning / Re: Yet another voxel engine on: 2014-06-22 21:21:26
Oh, the rendering code is much smaller

http://pastebin.java-gaming.org/c32278a8293

vertexCount, contrary to its name, is the amount of faces there are to render in the buffer.
Why would not dividing it by 7 cause it to explode? 0.0 In case you can't already tell, I'm a COMPLETE newbie to the whole 3D thing:P
30  Game Development / Performance Tuning / Re: Yet another voxel engine on: 2014-06-22 21:05:42
I added a more accurate FPS counter.

However, I had to very quickly find a way to display text in LWJGL - previously, I'd only done it in 2D. So you all have the privilege of witnessing what could possible be THE MOST ugly display of text in anything ever.

To emphasise my point, you'll have to move the camera around a bit to find the number. It should be floating in the sky on a giant billboard. Good luck:P
Pages: [1] 2 3
 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

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

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
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!