Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
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 ... 8
1  Game Development / Newbie & Debugging Questions / Re: [LibGdx/LWJGL] What does this do? on: 2015-08-04 12:01:22
I'd honestly like clarification on exactly what that method does, since reading the lwjgl documentation doesn't make it very clear.

The LWJGL documentation probably won't be of much help with respect to OpenGL functions, since LWJGL just provides a binding. For details, you'll probably want to refer to an OpenGL-specific reference, such as this.

In short, glBufferData() allocates storage for an OpenGL buffer (releasing any previous storage), and optionally initializes the buffer with user-supplied data. Since the source of the call is presumably in LibGDX code, I'm not sure how much can be gleaned from the screenshot you posted. I will say though that the number of invocations (> 2000) is a bit suspicious. Because memory allocation/deallocation can be costly, it's typical to create buffers and reuse them rather than create them repeatedly as seems to be happening here.

Here are some things you could check:

- Do all those invocations happen early on? Or does the number of invocations increase steadily, more or less, the longer the program runs?
- Can you isolate the part(s) of your rendering code that are responsible for the invocations?

Keep in mind that if your application is performing adequately, it's not necessarily a problem for there to be hot spots. However, I do think it might be worth tracking down where those invocations are coming from.
2  Game Development / Newbie & Debugging Questions / Re: Best way to handle multiple references to a resource on: 2015-08-03 02:13:50
If I have a "Content" class which stores a static sprite image, and then I create 100 sprites which all take this image as a parameter, will I have 100 instances of this image in RAM or just 100 pointers to the static image?

You'll have 100 'pointers' (references, generally speaking) to a single instance. That's assuming this is Java you're talking about, and that there's no cloning or deep copying going on that you haven't mentioned.
3  Game Development / Newbie & Debugging Questions / Re: World architecture and internal construction? on: 2015-08-03 02:09:26
I don't really have an answer, but since you haven't gotten any replies yet I'll go ahead and mention a couple things.

People may be slow to respond because it would probably take more of an 'inside' view of the problem (which only you have at the moment) to know what solution would be optimal. But, I'll go ahead and put in my usual plug for data-driven design.

I guess the question I'd ask is if there's anything about the 'region' concept that really needs to be represented at the code level. Would it be sufficient for that distinction only to exist at the data level? For example, the idea of per-region styles sounds like something that could be handled at the data level with proper support. Rooms could just have string tags ('castle', 'dungeon'), and these could be used along with abstract material tags ('wall', 'floor') to choose specific materials ('castle wall', 'dungeon floor'). And so on for other aspects of the design. Adding a scripting system (if you don't already have one) might further reduce the need for hard-coding aspects of the world design.

Anyway, that may or may not be helpful, but that's what comes to mind.
4  Game Development / Performance Tuning / Re: 2D Collision Engine - Performance Test on: 2015-08-02 09:16:04
( Wikipedia link with illustrations:

Sure, I understand that. I was just asking because you mentioned projecting the polygon onto a point, but maybe you meant line.

Quote
Currently the 'Polygon' class is for convex polygons only.

Ok, I'll just mention one thing I noticed. Although I haven't examined it carefully, it looks like your contains() function for polygons uses some form of the generalized 'edge crossing' algorithm for point-polygon containment. Is that correct? If so, it seems like for convex polygons you'd want to instead use a simple hyperplane test (that is, check to see if the point is 'inside' all the bounding hyperplanes for the polygon), as that's likely to be simpler and more robust.

Also, are you sure this loop:

1  
2  
3  
4  
        for (int index = vertexes.size() - 1; index-- > 0;)
        {
            final Point cur = getVertex(index);
            final Point next = getVertex(index + 1);

Is correct? It seems like this would always miss one of the polygon edges.
5  Games Center / WIP games, tools & toy projects / Re: [Android] Blu’s Travel (Testers wanted!) on: 2015-08-02 03:30:33
I don't have a device to test on, but just wanted to say that I like the art and the concept Smiley
6  Game Development / Performance Tuning / Re: 2D Collision Engine - Performance Test on: 2015-08-01 23:37:56
Writing general collision libraries is certainly tempting, but it's kind of a deep rabbit hole. For one thing, collision detection problems are often highly context-dependent, and bespoke implementations can sometimes exploit context in a way that generic solutions can't. Also, numerical issues can make implementing robust collision code difficult, and it's really easy to miss corner cases even if you know what you're doing. I'm sure you already know all that, but I guess I'm just saying it's all pretty non-trivial.

Anyway, I looked through the code a bit and was wondering, is the 'Polygon' class supposed to be convex-only? Or is it intended to represent non-convex polygons as well?

Also, can you clarify what you mean by projecting a polygon onto a specified point?
7  Game Development / Newbie & Debugging Questions / Re: Slick Utils and the Modern OpenGL 3+ on: 2015-08-01 23:17:48
Slick was the Go-To library for pre-OpenGL 3.0.  If it isn't being updated anymore, is there a better/newer library that uses the newer OpenGL 3+ features?

I remember reading that Slick is no longer maintained, but I could be wrong (I'm not sure where I read it). It does sound though like it doesn't use modern techniques consistently under the hood. As for alternatives, the only thing I can think of is the oft-mentioned LibGDX, but maybe you've already considered that and decided not to use it for one reason or another.

Quote
(and Yes, I am sure the line mentioned is the problematic code and it is pre-compiled so I can't see the code - Slick uses Immediate Mode to render text, that's why I had to rewrite this class to begin with)

Isn't Slick open source? It seems like you should be able to find out what's going on in that line of code. Also, are you sure the 'invalid enum' error isn't being generated by your own code somewhere and just happens to be being caught by the Slick code? (Apologies if I'm misunderstanding anything.)

Lastly, it might be worth considering whether whatever functionality Slick is providing is something you could just replicate yourself, which would free you from the dependency and might make debugging easier. Maybe you have a reason for not wanting to do that though.
8  Game Development / Newbie & Debugging Questions / Re: Slick Utils and the Modern OpenGL 3+ on: 2015-08-01 05:43:31
I don't know much about Slick, but I seem to remember reading that it's not being updated anymore. Assuming that's actually the case, have you considered just writing the needed functionality yourself? It'd be additional work of course, but it might be easier than trying to combine your own code with whatever Slick is doing.

In any case, I assume Slick is open-source and that you can take a look at the problematic function. Can you see what's going on in the glEnable() call that seems to be causing the error? (You also might double-check to make sure the error is actually occurring there, rather than occurring in your own code somewhere and just being reported there.)
9  Game Development / Newbie & Debugging Questions / Re: Check to see if Triangle intersects Rectangle on: 2015-07-31 03:54:28
The part were I'm extending the point to a circle is Minkowski addition.

I'm familiar with these methods and with Minkowski sums. I've used them in a variety of contexts myself and in fact just recently provided a solution based on Minkowski sums to someone here on the forums. The material you're presenting is familiar to me.

I think I'll just hold to my previous objections. What you seem to be saying is that if an algorithm can be simplified for a special case, it's no longer the same algorithm. You also seem to be saying that if a newly developed theorem covers cases for which the solutions were already trivially obvious, then it doesn't 'really' apply to those cases. Both of these claims seem illogical to me, but perhaps I'm misunderstanding you.

In any case, as I said before I'm happy to leave it as a semantic disagreement. I think at this point trying to determine whether the separating axis test 'really' applies to trivial cases would require more discourse than would be appropriate for this thread. To me it's obvious that it does, based on both principle and voluminous practical evidence, but obviously your view differs.
10  Game Development / Newbie & Debugging Questions / Re: Check to see if Triangle intersects Rectangle on: 2015-07-31 01:56:41
@Roquen: It sounds like the disagreement here is basically over what 'separating axis test' means.

I'm sure you'd agree that the SAT for arbitrary convex polytopes is really the SAT. The SAT for oriented boxes is of course just a special case of the convex polytope case, with the regularity of the shapes exploited to simplify the test. Adding the further constraint that the boxes be axis-aligned causes most of the remaining complexity to drop out, and you're left with the canonical axis-aligned box test.

What you seem to be saying is that somewhere in this process of simplification, the SAT stops being the SAT. I can't really follow the logic on this, as it would seem to suggest that simplifying an algorithm for a special case causes that algorithm not to be that algorithm anymore.

In any case, it does indeed seem that you're using the term 'SAT' to mean 'non-trivial SAT', so I guess we should probably just leave it at that.

As for Minkowski-based approaches, thank you for suggesting an alternative Smiley It'd be interesting to compare a Minkowski-based approach with the SAT for relatively simple shapes (such as boxes and triangles) in 2-d in terms of efficiency, robustness, and ease of implementation. Based on my past experience working with Minkowski-based algorithms I'm a little skeptical that they'd be preferable over the SAT for simple 2-d cases, but I think some formal investigation would be needed to really weigh the two against each other.

Anyway, this has obviously wandered a bit far afield as far as the OP's case is concerned. Not having done any software-rendering work as of late, I don't really feel confident in making any suggestions there, so I'll leave that to others.
11  Game Development / Newbie & Debugging Questions / Re: Check to see if Triangle intersects Rectangle on: 2015-07-31 00:34:40
If you guys don't know why I need this, basically that rectangle in the image in the main post is the application screen and the triangle is a triangle that was 3D originally but is now 2D because it was projected. I'm just too lazy to implement triangle-only clipping and I'm trying to think of different ways to get the effect.

What's the context exactly? (I'm just curious because this suggests you're doing something fairly low-level.)

Also, do you just need a boolean result? Or do you need to clip the triangle to the screen? If boolean only, is a conservative test ok, or do you need an exact test?
12  Game Development / Newbie & Debugging Questions / Re: Check to see if Triangle intersects Rectangle on: 2015-07-31 00:13:33
Quote
I've covered "why not SAT" before.

I did a quick search, but couldn't find anything. Could you provide a link?

Quote
It's silly to say that AABB is SAT.

The standard intersection test for axis-aligned boxes is absolutely an application of the SAT. I can provide support for this if needed.

Now, maybe by 'SAT' what you really mean is non-trivial SAT, but if so I think that probably needs to be specified.

I really don't mean to be contrary or difficult, but I can't help but question your claims here. What I'm seeing is that you're saying the axis-aligned box test is not an application of the SAT, but haven't explained why, and that the SAT should seldom or never be used, but haven't given any reasons for this or suggested any alternatives.

I realize you say you've discussed this before and evidently are reluctant to repeat yourself, but I think even something like the following would really help clarify things:

1. The SAT should not be used because it's <inefficient/unstable/etc.>.
2. Instead, you should use <recommend a better algorithm here>.


I'm sure this would only take a couple minutes, and I think would be helpful to a lot of people (me included!).
13  Game Development / Newbie & Debugging Questions / Re: Check to see if Triangle intersects Rectangle on: 2015-07-30 21:24:12
SAT is almost never a good idea.

Roquen, could you explain why SAT would be a poor choice in this case, and what method or methods you think should be preferred? I think that information would be very useful to the OP (and to anyone else, like me, who's interested in these topics and always looking to expand their knowledge).

@The OP: Just in case Roquen doesn't get around to elaborating, let me offer some counterpoint here. Although I'm always happy to be shown to be wrong, I'm not entirely sure Roquen is correct here, and in absence of supporting explanation I'd recommend not jumping to the conclusion that the SAT is a poor choice.

First of all, the bog-standard canonical axis-aligned box test that we all know and have seen implemented countless times is in fact the separating axis test, so obviously the SAT has valid applications.

Now, maybe this is why Roquen said 'almost'. However, the question then becomes, if the SAT is good for axis-aligned boxes, why is it not applicable elsewhere, and at what point do other options start to look better?

In 3-d the SAT can be problematic in some cases due to numerical issues or excessive number of axes. However, these concerns don't apply in the given context. If your triangles are axis-aligned like in your image, the SAT here is only a bit more involved than the axis-aligned box case, so it's a little difficult for me to imagine why the SAT would suddenly become unsuitable in this case. Even if your triangles are arbitrary, you're still only talking about 5 axes to test total.

Additionally, the discrete SAT for simple 2-d tests has the advantages of being entirely stable and robust (given good input), of handling all cases correctly (no concerns about containment or other special cases), and of being easily extended to return a minimum translational vector that can be used to resolve the intersection.

I do think this:

Quote
It's only upsides is that it works and it's simple to implement.

Is kind of interesting Smiley What strikes me as amusing about this is that 'it works and is simple to implement' is really quite an endorsement! I mean really, as long as it's also reasonably efficient (which it is in this case), what more could you ask for? Wink Anyway Roquen, I'm sure you have reasons for discouraging its use, but I think some elaboration would be helpful here.
14  Game Development / Newbie & Debugging Questions / Re: Simple Stupid Funnel Algorithm on: 2015-07-30 13:11:13
If you have any good links for the non-simplified algorithm you could recommend, it'd be much appreciated.

I just looked around a bit, but couldn't find the reference I used, unfortunately. It was a really good paper though. The general topic was pathfinding in a Delaunay triangulation environment for agents with arbitrary radii. The specific version of the funnel algorithm used ensured that the agent stayed radius units away from all obstacles, and included curved sections in the path to go around corners.

This isn't the paper in question:

Link

But it does have pseudocode for the funnel algorithm at the end, which might be helpful.
15  Game Development / Newbie & Debugging Questions / Re: Check to see if Triangle intersects Rectangle on: 2015-07-30 12:50:31
In addition to the previous posters' recommendations, I'd suggest looking into the separating axis test if all you need is a boolean result (or a boolean result and a separation vector). The SAT for the shapes in question is fairly straightforward and will handle all cases correctly (including containment).

If you need the actual area of intersection as shown in your diagram, then that's a CSG problem, more or less, which is a little more involved.
16  Game Development / Newbie & Debugging Questions / Re: Ball loses speed when it bounces straight up on: 2015-07-30 05:53:43
Are 'xa' and 'ya' the x and y velocities of the ball? If so, if xa is non-zero before the bounce, the speed of the ball will always be slower after the bounce. The larger |xa| is before the bounce, the more pronounced the difference will be.

If you want the speed to remain the same, set ya to whatever the length of (xa, ya) was before the bounce (+ or -, as appropriate).
17  Game Development / Game Mechanics / Re: Rendering Text on: 2015-07-30 00:32:54
I don't even know why each character has a different color rectangle when drawn.

Me neither (not at the moment at least). It'd probably be good to confirm the problem with the image though.

What image editor did you use to check the image? (The image is all white in the RGB channels with the glyphs in the alpha channel, so if the viewer doesn't handle alpha or displays the image against a white background, you may not be able to see the glyphs.)
18  Game Development / Newbie & Debugging Questions / Re: Simple Stupid Funnel Algorithm on: 2015-07-29 22:54:06
I've implemented the 'un-simplified' version of the funnel algorithm before, with good results. Unfortunately, it's been a while and the details aren't fresh in my mind at the moment, so I'd probably have to sit down and draw some diagrams to figure out whether the simplified version should be expected to handle all cases correctly.

However, just in case you haven't seen it, there's a comment on the blog post you linked to (fourth from the end) where someone questions whether the simplified version will guarantee correct results. I can't say off hand whether his observation is correct, but it does at least suggest that the simplified version might be flawed. Also, my first impression is that the incorrect results you're getting in the second example may be due to some other problem, as it doesn't really match what the commenter described.

One thing I notice about the second example is that because there's no 'next portal' at the end, the step where the right edge crosses over the left may not occur. If this is where the extra path vertex would be added, it makes sense it would be missed. So, that would appear to be a flaw either in the algorithm or in the implementation. (I imagine you've already tried stepping through in the debugger, but it seems the reason for the missing step could probably be determined that way.)

Sorry I can't be of more help, but maybe something there will point you in the right direction.
19  Game Development / Game Mechanics / Re: Rendering Text on: 2015-07-29 21:12:36
You might double-check and make sure the PNG image has the correct content. The glyphs may be there and not showing up in the preview because the background is white, but to be sure, you could open it in an image editor such as GIMP. With a non-white background, you should be able to see the glyphs.

Your last image is kind of small, so it's difficult to tell what's going on there - maybe you could post a larger image? Also, you might double-check and make sure you have blending enabled.
20  Java Game APIs & Engines / Engines, Libraries and Tools / LWJGL window with Swing dialog on: 2015-07-27 18:04:43
I have a bunch of credits and licensing info I need to make available with my game, and was thinking of using a Swing dialog to display the info.

I searched for 'lwjgl swing' and found quite a bit of discussion. It sounds like some have used Swing with LWJGL successfully, while others have run into problems. My particular use case is very simple though, so I'm wondering if it would be safe. The details are:

- LWJGL 2.9.3.
- The main window is just a regular native window.
- The dialog is a modeless JDialog with some scrollable text and a 'close' button.
- It's fine if the dialog isn't visible when the main window is fullscreen.

I tried it with OS X, Windows XP and 7, and Linux (Ubuntu), and didn't see any problems. If I'm going to use this method though I want to be sure it's supported and won't break unexpectedly on other systems.

So, I'm appealing to the LWJGL experts here. Is this particular use of Swing with LWJGL supported and safe to do? And if so, is there anything I need to watch out for?
21  Game Development / Newbie & Debugging Questions / Re: TileRenderer Buggy lines on: 2015-07-26 18:06:59
Perhaps it should also be mentioned that another option is not to use atlases at all, which will solve the bleeding problem entirely (and allow you to use mipmaps without concern). The (or a) main reason for using atlases is to reduce the number of draw calls, but I'd say it's not a given that a few more draw calls would be a problem. With no atlases, you might want to group visible tiles by texture before rendering to keep the number of draw calls down, which would add some overhead, but on desktop at least I doubt it would be a problem (I'm not sure what platforms you're targeting).
22  Game Development / Newbie & Debugging Questions / Re: TileRenderer Buggy lines on: 2015-07-26 17:51:32
Its not the same file but it is very similar

Even small differences could matter, but that's probably enough to go on.

Just to be thorough, one possible cause of artifacts like those in your original images would be if your tile vertex positions don't match up exactly (which can happen if the positions are computed using inconsistent floating-point arithmetic). You can test for this by clearing the screen to some distinct color (like magenta) before rendering. If the lines are then magenta, it's a geometry problem. If they're still black, it's probably a bleeding problem.

Looking at your image though, it looks like it's probably a bleeding problem as discussed earlier. One fix is to use point sampling ('nearest' filtering in OpenGL terms), and make sure the texture coordinates capture the desired tiles exactly (I can't remember off the top of my head how this works in OpenGL, but it may involve referencing the centers of the corner pixels exactly). Another option is to put padding between your tiles and fill in the pixels adjacent to the tiles with the nearest pixels from the tiles. As alluded to elsewhere, there are tools that will do this for you. (Note that you can still run into problems here when using mipmaps.)
23  Game Development / Newbie & Debugging Questions / Re: TileRenderer Buggy lines on: 2015-07-26 17:35:16
The spritesheet?

Well, I'm not sure if by 'spritesheet' you mean an image, or a LibGDX class, or something else. If it's an image, post that. If it's something else, tell us what it is. Basically, just post whatever you have Smiley
24  Game Development / Newbie & Debugging Questions / Re: TileRenderer Buggy lines on: 2015-07-26 17:31:14
I am using a Spritesheet which i created myself

Can you post the image? Or is it something that's created procedurally?
25  Game Development / Newbie & Debugging Questions / Re: TileRenderer Buggy lines on: 2015-07-26 17:24:22
Are you using atlases in some form for your tiles? If so, if you have direct access to the atlas image/texture, maybe you could post the image. If the atlases are created procedurally using some tool or using the LibGDX API, you could instead post the relevant settings or code. (Basically, just tell us as much as you can about how the tile textures are being created/manipulated.)
26  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 04:51:03
Er... what do you mean with those indicies?

It doesn't matter Smiley I was just pointing out that there are ways to do it that don't involve conditionals. Anyway, swapping references at the end of the cycle as you mentioned in your last post is probably how I'd do it.

[Edit: Looks like BurntPizza offered a reason why swapping the references might not be the best choice, so I'll take his word on that and withdraw that recommendation.]
27  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 04:45:32
I think this method just adds too much branching... but maybe a pool world help? Who knows.

Whether you do it or the compiler does it (as BurntPizza mentioned), there should only be a couple branches needed at most, so I don't think the branches will be a problem. There are other ways to swap the grids though, such as by swapping a pair of indices (untested):

1  
2  
i = (i + 1) % 2;
j = (i + 1) % 2;

As for pooling, I think you only need a pool of two grids, which is what you have now (maybe that's what you meant). In any case, other than having the conditionals in the inner loop, it seems like you have the right idea with respect to the grid-swapping.
28  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 04:32:54
Profiling is probably the way to go here (optimizing via forum posts is a bit speculative). But, it seems worth mentioning that your new cycle() function has introduced multiple conditionals in the inner loop that weren't there before, which it seems likely could offset any gains from pooling the grids. Since the results of the conditionals are the same each time though, you should just be able to grab references to the grids at the beginning of the function, at which point your inner loop can go back to the way it was previously.
29  Games Center / Showcase / Re: Shard Master 3D Demo on: 2015-07-22 17:08:29
High Quality: ~30-40 FPS, ~30-60 MB
Low Quality: ~35-45 FPS, ~30-60 MB

OS X 10.10.

Camera movement seems smooth, but when you pitch all the way up you can't see the player (maybe that's intentional). Player movement has some hitches - looks kind of like the common problem of updating the camera position before updating the camera target position. Diagonal motion sort of has a disorienting stair-step effect. Collision detection seems to be working though, and other than the aforementioned issues everything seems smooth.
30  Game Development / Newbie & Debugging Questions / Re: Handling curves in a platformer? on: 2015-07-22 04:31:44
I haven't implemented that type of collision detection and response myself, but there's a well-known tutorial here that discusses the SAT with respect to curved shapes. I think this is the game with which the tutorial is associated. It looks like most of the levels don't feature curved tiles, but if you watch the demo for a while you may see some levels with curved elements.

There might be simpler solutions, but we'd probably have to know more about what you have in mind (tile shapes, convex or concave, etc.).
Pages: [1] 2 3 ... 8
 
bilznatch (20 views)
2015-08-04 11:03:17

SHC (39 views)
2015-08-01 03:58:20

Jesse (24 views)
2015-07-29 04:35:27

Riven (45 views)
2015-07-27 16:38:00

Riven (25 views)
2015-07-27 15:35:20

Riven (27 views)
2015-07-27 12:26:13

Riven (18 views)
2015-07-27 12:23:39

BurntPizza (41 views)
2015-07-25 00:14:37

BurntPizza (50 views)
2015-07-24 22:06:39

BurntPizza (33 views)
2015-07-24 06:06:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21
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!