[QUOTE=thf;31759756]Keep doing it until the first pointer is higher than or equal the second instead of only until they are equal, because otherwise it will loop forever on words with an even amount of characters :v:[/QUOTE]
Thanks bro - I forgot to add that in. :smile:
Just checking, "OpenGL SuperBible: Comprehensive Tutorial and Reference (5th Edition)" is the book to get if you want to learn about OpenGL, right?
[QUOTE=Jookia;31759429]While I do enjoy being riffed on, it is heavily optimized in comparison.[/QUOTE]
The only significant change you made is checking if the iterators pass each other, which I do not call heavy optimization.
btw, since string::iterators are random access iterators, you can implement the same check.
[QUOTE=ZeekyHBomb;31760234]The only significant change you made is checking if the iterators pass each other, which I do not call heavy optimization.
btw, since string::iterators are random access iterators, you can implement the same check.[/QUOTE]
I think he's also referring to not using any STL stuff, just raw pointers and standard data types.
It increased performance by a whopping [i]200%[/i].
[QUOTE=ZeekyHBomb;31760234]The only significant change you made is checking if the iterators pass each other, which I do not call heavy optimization.
btw, since string::iterators are random access iterators, you can implement the same check.[/QUOTE]
Actually, the most significant change is probably no longer receiving that string by value.
[QUOTE=Grabigel;31753042]Alright, thank you, I'll be sure to try this.
I was using cout 4 times simply to try the curly brackets, letting more than one line print.
By while loops, do you basically mean restarting the program? (Try Again?)
I just corrected everything, and changed theNumber to give a random number. It works!
<code snip>
Thank you![/QUOTE]
Another thing, your current indentation style will get very, very annoying you if need a lot of if/else if/else if statements. Try doing this instead:
[cpp]if(something)
{
// stuff
}
else if(something else)
{
// other stuff
}
else if(another thing)
{
// more stuff
}[/cpp]
[QUOTE=jA_cOp;31760346]Actually, the most significant change is probably no longer receiving that string by value.[/QUOTE]
Damn, I forgot that. When I first wrote the C++ code I specifically avoided taking the string by reference as it may of looked confusing.
[QUOTE=Jookia;31760337]It increased performance by a whopping [i]200%[/i].[/QUOTE]
makes sense, instead of doing two passes over the string (one to copy, one to check), you're only doing one pass.
[QUOTE=pinkfreud;31760403]makes sense, instead of doing two passes over the string (one to copy, one to check), you're only doing one pass.[/QUOTE]
Oh, then I didn't factor that in. I was mainly joking about only iterating to the middle.
[QUOTE=pinkfreud;31760403]makes sense, instead of doing two passes over the string (one to copy, one to check), you're only doing one pass.[/QUOTE]
I would imagine the heap memory allocation being a much more significant overhead in cases like this one with very short strings.
[QUOTE=thf;31760250]I think he's also referring to not using any STL stuff, just raw pointers and standard data types.[/QUOTE]
I don't think this counts as optimization, especially not heavy optimization.
When compiled the STL iterators become pointers 'n shiz.
[QUOTE=jA_cOp;31760346]Actually, the most significant change is probably no longer receiving that string by value.[/QUOTE]
Most std::string implementation re-use the memory when copying afaik, but indeed I missed that. I mostly expect that non-trivial typed are passed as const reference :S
[QUOTE=ZeekyHBomb;31760551]I don't think this counts as optimization, especially not heavy optimization.
When compiled the STL iterators become pointers 'n shiz.[/QUOTE]
Really? Didn't know that actually.
[editline]16th August 2011[/editline]
[QUOTE=Jookia;31760416]Oh, then I didn't factor that in. I was mainly joking about only iterating to the middle.[/QUOTE]
That would equal to approximately 200% higher performance then (1/3 of the time taken) :v:
Anyone good at maths here?
I need a function that goes through points (0;1) and (80;0). Such linear function would be easy, but I want it to have shape like this:
[IMG]http://dl.dropbox.com/u/8226262/random/func.png[/IMG]
-snip-
[QUOTE=sim642;31762060]Anyone good at maths here?
I need a function that goes through points (0;1) and (80;0). Such linear function would be easy, but I want it to have shape like this:
[IMG]http://dl.dropbox.com/u/8226262/random/func.png[/IMG][/QUOTE]
You could use a quadratic or (as thf suggested) an exponential. Just depends what kind of shape you want
Does anyone know of a good tutorial for building a chat application in Java? I don't really have a great grasp of servers, synchronisation, sockets and all that jazz.
[QUOTE=thf;31762076][code]f(x) = 2 - exp(x * log(2)/80)[/code]
I think that should work.[/QUOTE]
That doesn't have the shape I wanted: [url]http://www.wolframalpha.com/input/?i=f%28x%29+%3D+2+-+exp%28x+*+log%282%29%2F80%29+where+x%3D0..80[/url]
I know nothing about non-linear functions so it would be really great if someone would put together a suitable function. If someone knows a good guide that I could use it would also be great.
[QUOTE=sim642;31762627]That doesn't have the shape I wanted: [url]http://www.wolframalpha.com/input/?i=f%28x%29+%3D+2+-+exp%28x+*+log%282%29%2F80%29+where+x%3D0..80[/url]
I know nothing about non-linear functions so it would be really great if someone would put together a suitable function. If someone knows a good guide that I could use it would also be great.[/QUOTE]
Oh shit, I didn't realise it had to have a peticular shape, missed that somehow.
[editline]16th August 2011[/editline]
What about this one?
[url]http://www.wolframalpha.com/input/?i=f%28x%29+%3D+0.99*exp%28x*log%281%2F99%29%2F80%29-0.01+where+x%3D0..80[/url]
[QUOTE=sim642;31762627]That doesn't have the shape I wanted: [url]http://www.wolframalpha.com/input/?i=f%28x%29+%3D+2+-+exp%28x+*+log%282%29%2F80%29+where+x%3D0..80[/url]
I know nothing about non-linear functions so it would be really great if someone would put together a suitable function. If someone knows a good guide that I could use it would also be great.[/QUOTE]
[url]http://www.wolframalpha.com/input/?i=f%28x%29+%3D+1-sqrt%28x%29%2F9+where+x%3D0..80[/url]
[editline]16th August 2011[/editline]
[url]http://www.wolframalpha.com/input/?i=f%28x%29+%3D+1-sqrt%28sqrt%28x%29%29%2F3+where+x%3D0..80[/url]
[editline]16th August 2011[/editline]
I don't know how to make a cubic root in wolfram, so the last one's a bit jerky :v:
[QUOTE=WeltEnSTurm;31763031][url]http://www.wolframalpha.com/input/?i=f%28x%29+%3D+1-sqrt%28x%29%2F9+where+x%3D0..80[/url]
[editline]16th August 2011[/editline]
[url]http://www.wolframalpha.com/input/?i=f%28x%29+%3D+1-sqrt%28sqrt%28x%29%29%2F3+where+x%3D0..80[/url]
[editline]16th August 2011[/editline]
I don't know how to make a cubic root in wolfram, so the last one's a bit jerky :v:[/QUOTE]
Cubic root can be done with x^(1/3), though it looks like you use the forth root.
Wolfram has cbrt() for cubic root. Also stuff like "4th root of x" should work.
[QUOTE=thf;31760125]Just checking, "OpenGL SuperBible: Comprehensive Tutorial and Reference (5th Edition)" is the book to get if you want to learn about OpenGL, right?[/QUOTE]
Overv told me that it's good as a reference but not as a tutorial since a lot of the examples are bad and sometimes don't even compile or something.
In XNA, my SpriteBatch isn't drawing my map when providing a scale bigger than 1.0f :(
I call it like this:
[code]
spriteBatch.Begin(SpriteSortMode.Immediate, null, SamplerState.PointWrap, null, RasterizerState.CullNone, null,
Matrix.CreateTranslation(-camera.Position.X, -camera.Position.Y, 0)
* Matrix.CreateScale(2f));
Level.Draw(spriteBatch, gameTime, null);
spriteBatch.End();
[/code]
This never happened before.
Also it works fine for every value equal and lower than 1.0f
Can anyone help ? :(
edit: when setting the 3rd parameter of CreateTranslation to -0.1 the "safe" value for the scale rises up to 1.1f
So I assume it has something to do with near clipping??
But I dont even use any 3d or something...
edit2:
This fixes it. I have no idea why this happened, but this seems to work.
Matrix.CreateTranslation(-camera.Position.X, -camera.Position.Y, - (camera.Zoom - 1.0f))
I would really like to know what caused this glitch. So if anyone has an explanation please let me know!
Does anybody know how to set the screen resolution using SDL? Or another library? I really don't want to mess with platform-specific stuff at this point.
[cpp] if(fullscreen)
{
// While the SDL_FULLSCREEN flag exists, it hijacks the window manager.
// Noticably, window switching and keybinds don't work.
// Simply making a window the size of the screen and hiding the frame
// mimics a fullscreen window and allows the window manager to handle it.
SDLFlags |= SDL_NOFRAME;
const SDL_VideoInfo* info = SDL_GetVideoInfo();
width = info->current_w;
height = info->current_h;
}[/cpp]
I'm trying to get the hwnd of a window to check the title, but all I have is the processID / handle, and I can't seem to make sense of EnumWindows() and callbacks to compare the process IDs of the windows on the desktop to the process ID of the game I'm reading values out of. Help?
That's interesting, I can't seem to look at the first page of the thread anymore. Gives me a 404.
[QUOTE=Murkat;31778542]That's interesting, I can't seem to look at the first page of the thread anymore. Gives me a 404.[/QUOTE]
Same here, although it works with [url]http://www.facepunch.com/threads/1092921-What-do-you-need-help-with-V.-3.0/page1[/url] (i.e explicitly putting /page1 on the end of the URL)
Hey i've been having this problem when trying to add models to my C# with XNA 4.0 project, i always get this error...
[code]
Microsoft.Xna.Framework.Content.Pipeline.Graphics.NodeContent but trying to load as Microsoft.Xna.Framework.Graphics.Model.
[/code]
its strange... i read here [url]http://blog.callemin.be/?p=231[/url] that you are supposed to change the content processor to "Model - XNA Framework" however when i try to open the dropdown or type in the box visual studio crashes!
Does anyone know of any secure ways to use steam chat on linux that arent wine? Vapor isnt logging me in and I dont know how else I can chat with FPprogrammers.
Also has the IRC been closed?
Sorry, you need to Log In to post a reply to this thread.