Sign in to follow this  

[java] Equivalent of glGenTextures in Java (a function that returns unique numbers)?

This topic is 4733 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest Anonymous Poster
Well, you could use your brain a little, and think a bit, like normal programmers do. You could try doing the most simple of searches to learn one of the most fundamental elements of the java standard libraries (system.currentTimeMillis()), or you could try using a non-repeating pseudo-RNG ( java.lang.Random IIRC)

Seeing as you can't write a game without using timing, you're in a lot of trouble if you can't be bothered to find out how to query timing in java...

Share this post


Link to post
Share on other sites
Anonymous Poster:
Are you the previous poster? The one with the nick capn_midnight?

If so, then why the insult? You answered my question with an attitude and I paid you with the same coin. Why the bitterness? If you hadn't replied as such, I would have politely asked you to provide more information.

Either way, I hope that next time you will be a bit more polite and will take the time to look at all the posts before replying.

As for your answers:
The Java docs have nothing on class java.land.Random. There is class java.util.Random which DOES NOT produce unique numbers but picks one at random from a sequence of 4294967295 numbers.

Also, I googled the keywords "Time Java" and got a link to the Time object which wasn't useful, hence my second question.

Did you consider these possibilities before posting? Perhaps, it is you that does not use his brain at all.

BTW, thanks for the System.currentTimeMillis(). That WAS useful.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by bah
Anonymous Poster:
Are you the previous poster? The one with the nick capn_midnight?


Nope.

Quote:

If so, then why the insult?


You:
- couldn't be bothered to ask your original question, you just typed a title and said "nuff said".
- you got a perfectly good answer requiring only a tiny amount of research for you to use, and replied to it with a response that suggested even when an answer was given you couldn't be bothered to research for one of the most basic features of the language you were using.

Quote:

I would have politely asked you to provide more information.


IMHO you started with a lazy half-assed question and got a fair response. That's just me, though.

Quote:

As for your answers:
There is class java.util.Random which DOES NOT produce unique numbers


Fine. I said you should find a non-repeating RNG, and suggested Random might have that ability. I'm sure you could type those three words into google and do a little research. It's not my problem I'm trying to solve, and you haven't bothered to provide much information, like the basics such as:

- why a function that returns an integer one greater than last time is not good enough? You can write this yourself in 10-20 seconds.

Quote:

Also, I googled the keywords "Time Java" and got a link to the Time object which wasn't useful, hence my second question.


I'm sure you also got links to more useful stuff. The secret to google is to try 10, 20, or 100 of the results, not just one.

It sounds as if you need to go and learn the basics of java. Sun has a free set of tutorials online (look in the FAQ for the address; if they're not there, the FAQ needs fixing ;)) that cover most of what you need, and I would be very surprised if currentTimeMillis() wasn't in there somewhere...

Quote:

Perhaps, it is you that does not use his brain at all.


:). Maybe.

Quote:

BTW, thanks for the System.currentTimeMillis(). That WAS useful.


No probs. But you still need to read through the major tutorials if you don't know this stuff yet...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
glGenTextures only generates ids that aren't already in use, which also includes the posibillity of releasing ids to be re-used later. The easiest solution is to use a hashset and an integer counter. If the current counter value is unique (ie, not within the set) return that and increment it. If it is in use then keep incrementing it until it is unique/unused. Dead easy to implement.

If you're worried about the possibly odd performance of that ('cos you might have to search for a while to get an unused id) then what you really need is two pools of ids, one for unused, one for used. Pools can be done easily with a stack, shifting the ids from one stack to another as they are allocated/deallocated.

OT.

Share this post


Link to post
Share on other sites
Quote:

You:
- couldn't be bothered to ask your original question, you just typed a title and said "nuff said".


What is it that you don't understand from the original question and why didn't you ask for clarifications?
Also, I said "Good morning" and "The subject sums it up" and "Thanks".

Quote:

- you got a perfectly good answer requiring only a tiny amount of research for you to use, and replied to it with a response that suggested even when an answer was given you couldn't be bothered to research for one of the most basic features of the language you were using.


First, I got an answer from a person with an attitude and responded in a similar fashion not because I didn't think his suggestion was useful but because of the way he responded.

Second, didn't I say that I googled the phrase "Time Java" and got a link to the Time object?

Quote:

IMHO you started with a lazy half-assed question and got a fair response.


I posed an accurate question. The equivalent of glGenTextures in Java. If you know what the function does, then you might know an equivalent in Java. As if that wasn't enough, I refined the question by saying "a function that returns unique numbers" which combined with the first part of the question should give you a good clue as to what I am looking for.

Quote:

Fine. I said you should find a non-repeating RNG, and suggested Random might have that ability. I'm sure you could type those three words into google and do a little research.


First, I could have specified a "non-repeating RNG" but I thought that more people would be familiar with the glGenTextures function and that I would get more answers in a shorter period of time.

Second, you specified java.lang.Random which does not exist. Did you bother to verify the very same advice that you were giving out?

Quote:

It's not my problem I'm trying to solve, and you haven't bothered to provide much information, like the basics such as:

- why a function that returns an integer one greater than last time is not good enough? You can write this yourself in 10-20 seconds.


Again, read the topic of this thread. "An equivalent of glGenTextures in Java". If you did not know what that functions does, you should have asked (or done a little googling yourself).

Did you really post to be helpful or spiteful?

Quote:

I'm sure you also got links to more useful stuff. The secret to google is to try 10, 20, or 100 of the results, not just one.


Sure I did, but the point of posting here is that I can get a quick answer to a question without having to go through tons of online documentation.

Quote:

It sounds as if you need to go and learn the basics of java. Sun has a free set of tutorials online (look in the FAQ for the address; if they're not there, the FAQ needs fixing ;)) that cover most of what you need, and I would be very surprised if currentTimeMillis() wasn't in there somewhere...


If you had taken the time to look at the other threads that I've started (all seven of them which are visible immediately as you enter this forum), you would have realised that I am new to this language.


Even if you did think that my second post was inappropriate, why did you respond in such a manner? Were the insults really necessary? Or is it that you prefer to insult others online because you lack the courage necessary to do it in the real world and, of course, face the consequences?

Please, keep in mind that it's not my or anybody's fault if you have problems in your life. You shouldn't be taking them out on people that have done you no harm.

Share this post


Link to post
Share on other sites

This topic is 4733 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this