• What do you need help with? Version 1
    5,001 replies, posted
How would you guys get the url of the first picture in google ? lets say this page : [url]http://www.google.nl/images?q=cheese[/url] just need some pseudocode, have no idea how I could identify the picture links
[QUOTE=Darwin226;22796251]I meant stuff like this: GL.Begin( BeginMode.Points ); vs. Gl.glBegin(Gl.GL_POINTS); Obviously nicer to write but it's not the same as the C API. I am getting convinced that OpenTK might be worth trying again, it's documentation looks nice (and the site design isn't bad XD).[/QUOTE] Are you kidding? It's exactly the same as the C api... A different capitalization scheme and properly using namespacing is surely not going to be an issue for anybody trying to port code from other languages.
[QUOTE=quincy18;22796345]How would you guys get the url of the first picture in google ? lets say this page : [url]http://www.google.nl/images?q=cheese[/url] just need some pseudocode, have no idea how I could identify the picture links[/QUOTE] I guess you could search for the image-tag which has "http://t[0-9]+\.gstatic\.com/images\?q=:[A-Za-z0-9]+:*" as its source (quickly looked up POSIX regex). And the string in that last * is the original URL. Found out by looking at the generated html ._.
BeginMode.Points, how is that EXACTLY the same as the C api?
Did you read his second sentence ;) If you read glBegin( GL_POINTS ); in a C tutorial, you'll easily find GL.Begin and find out that it gets a BeginMode passed as first (and only) argument. When you then see BeginMode.Points you'll know it's right :)
How do I make a biased random system where, for example, generating values from 0 to 100 but having a higher chance to generate numbers closer to 50?
You could do something like [cpp]static inline void SQ(double &x){ x *= x;} double returnBiasedValue(){ const double x = rand(0, 1); //return random number in [0..1] return 100 * 16 * (SQ(SQ(x - 0.5)) - 0.5 * SQ(x - 0.5)) }[/cpp] That mathematical equation was just played around with, starting from x^4-x^2 :p Probably not the best solution. If you're up to Boost, then look at Boost.Random, specifically the binomial distribution.
[QUOTE=blankthemuffin;22794961]Certainly a viable alternative to MSVC before you even consider how utterly broken Microsoft's C support is.[/QUOTE] There's nothing anywhere that says Microsoft has to implement C99. It's also the best compiler for Windows right now.
I think the intel c compiler is actually marginally faster, but it's bloody expensive.
[QUOTE=TheBoff;22804599]I think the intel c compiler is actually marginally faster, but it's bloody expensive.[/QUOTE] Only on Intel processors. AMD finally got their lawsuit determined. If the Intel compiled program ran on anything not an Intel processor, it would take the slowest path possible. It still does this IIRC, but AMD gets paid for it now :/
Any ideas why this program would run at 1200FPS? [cpp]using System; using System.Collections.Generic; using System.Linq; using System.Text; using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; namespace OpenTK_3DTest { class World { public GameWindow Window; public World () { Window = new OpenTK.GameWindow( 800, 600 ); Window.UpdateFrame += new EventHandler<FrameEventArgs>( UpdateFrame ); Window.UpdateFrame += new EventHandler<FrameEventArgs>( RenderFrame ); GL.ClearColor( Color4.Black ); Window.VSync = VSyncMode.Off; Window.Run( 0, 60 ); } public void UpdateFrame ( object target, FrameEventArgs args ) { Window.Title = "OpenTK_3DTest FPS: " + Window.UpdateFrequency; if ( Window.Keyboard[ OpenTK.Input.Key.Escape ] ) Window.Exit(); } public void RenderFrame ( object target, FrameEventArgs args ) { GL.Clear( ClearBufferMask.ColorBufferBit ); Window.SwapBuffers(); } } } [/cpp]
[cpp]Window.VSync = VSyncMode.Off;[/cpp] You're not limiting the framerate in any way [B]and[/B] have VSync disabled.
1200 is incredibly low. With Tao, something like that ran at 400K FPS (yea, yea, I know. Don't use FPS). That 330 times faster. Obviously I did something wrong.
Because you don't use the FPS to measure speed. Let's assume you expect to have an FPS of 4000. Have a look at this: 1200 FPS ~ 0,00083 sec/frame 4000 FPS ~ 0,00025 sec/frame When looking at the FPS, it looks like an extreme difference, which it really isn't. The difference is a few milliseconds, which is negligible with a rate of 1200 frames per second. [b]Edit:[/b] I highly doubt Tao gave you an FPS of ~400k. The usual frame rate with an empty screen is around 4000.
40k, I meant 40k. 1 zero slipped and I just calculated with 400 000. Still. 40k is WAY faster than 1200.
But 40k is just plain wrong. You can't refresh the screen that many times. How did you measure the framerate?
It renders at 60fps lock, updates as fast as it can. This is the code that is displaying 40k FPS as I'm looking at it. [code] double currentTime = Glfw.glfwGetTime(); FrameTime = (float)( currentTime - lastTime ); lastTime = currentTime; Glfw.glfwSetWindowTitle( (1 / FrameTime).ToString() );[/code] [editline]02:01AM[/editline] I just figured out that frames per second isn't the best way to name it since it only updates that fast while it draws at 60 FPS.
Try counting the frames every second instead.
Done, it displays about 700 000 (yes, I double checked) [code] double currentTime = Glfw.glfwGetTime(); FrameTime = (float)( currentTime - lastTime ); lastTime = currentTime; frameCount++; secondCounter += FrameTime; if ( secondCounter >= 1 ) { secondCounter = 0; Glfw.glfwSetWindowTitle( frameCount.ToString() ); frameCount = 0; }[/code]
[QUOTE=Chandler;22804089]There's nothing anywhere that says Microsoft has to implement C99. It's also the best compiler for Windows right now.[/QUOTE] I never said they did, I just said their C support is entirely broken. They do it deliberately too. My other point was that MingW is a perfectly capable and production tested compiler. I'm pretty sure your massive hello world is a problem at your end not theirs.
[QUOTE=Darwin226;22811019]Done, it displays about 700 000 (yes, I double checked) [code] double currentTime = Glfw.glfwGetTime(); FrameTime = (float)( currentTime - lastTime ); lastTime = currentTime; frameCount++; secondCounter += FrameTime; if ( secondCounter >= 1 ) { secondCounter = 0; Glfw.glfwSetWindowTitle( frameCount.ToString() ); frameCount = 0; }[/code][/QUOTE] No, use DateTime to compare the second. Something like: [code]if ( lastSecond != currentSecond ) { fps = frames; frames = 0; lastSecond = currentSecond; } else { frames++; }[/code]
Displaying around 300 000 now: [code] frameCount++; if ( lastSecond != DateTime.Now.Second ) { lastSecond = DateTime.Now.Second; Glfw.glfwSetWindowTitle( frameCount.ToString() ); frameCount = 0; }[/code] Anyways, do you see anything wrong with the OpenTK code that would cause it to drop to 1200? Without the GL.Clear() and the buffer swap it ran at 10 000 (which still seems low to me but since different ways of measuring the frame rate obviously have a huge impact I don't mind)
You should use QueryPerformanceCounter for the best precision. [cpp]public static class PerformaceTimer { #region Fields private static Int64 _Frequency = 0; #endregion #region Properties public static bool IsPerfCounterSupported { get; private set; } public static Int64 Frequency { get { return _Frequency; } private set { _Frequency = value; } } public static Int64 TickCount { get { Int64 tickCount = 0; if (IsPerfCounterSupported) QueryPerformanceCounter(ref tickCount); else tickCount = (Int64)Environment.TickCount; return tickCount; } } #endregion #region Imports [DllImport("kernel32.dll")] private static extern int QueryPerformanceCounter(ref Int64 count); [DllImport("kernel32.dll")] private static extern int QueryPerformanceFrequency(ref Int64 frequency); #endregion #region Methods public static void Init() { int ret = QueryPerformanceFrequency(ref _Frequency); if (ret != 0 && Frequency != 1000) IsPerfCounterSupported = true; else Frequency = 1000; } #endregion }[/cpp] That should do the job.
I'm currently having mixed feeling about OpenTK. Part of me loves the fact that it's way easier to write OpenGL code in it, but... I've implemented the DateTime thing on it and it reads 3000 FPS (very low if you ask me but I don't even care anymore), I open up my task manager and see that the empty window drains 50% of my CPU, what the hell?? I googled a bit and found [URL="http://www.opentk.com/node/1045"]this[/URL] meaning I can't limit my render rate without the 50% drain unless I use Thread.Sleep(1) which effectively locks my FPS to 1k (+ I don't know anything about threading yet and I have no frickin' idea how this is going to affect it) More up to date my ass... that guy said they are reworking the code in July LAST YEAR! You know, I have no problem with a refresh rate of a 3000 Hz but unless I want my CPU at 50% all the time I have to settle with 1000, and that's on an empty window, anything more I do just adds up on that. Please someone, prove me wrong. Tao might be old but it did what it was supposed to at very high frame rates and low CPU usage.
The latest stable release as on the site is dated 2010-Mar-24, so I think it is pretty up-to-date. That it hogs the CPU and is rendering quite a bit slower is surprising though. [url=http://www.opentk.com/node/393]Some guy said that enabling vsync helps[/url], but that comment was made 2 years ago. You could still try, maybe OpenTK simply completely bugs without vsync. [editline]02:42PM[/editline] I also just found out that your code shouldn't run, since the first argument of Run is 0: [url]http://www.opentk.com/files/doc/class_open_t_k_1_1_game_window.html#aff16d3a5aeb78782c4a9f8e74c8d0e89[/url]
The fact it uses up one core is because of the render loop that's constantly running. When you use Thread.Sleep, you will give the processor a break. Also, 3000 is a fine FPS for an empty window. I get something around that with both DirectX and OpenGL.
[QUOTE=ZeekyHBomb;22821953]I also just found out that your code shouldn't run, since the first argument of Run is 0: [url]http://www.opentk.com/files/doc/class_open_t_k_1_1_game_window.html#aff16d3a5aeb78782c4a9f8e74c8d0e89[/url][/QUOTE] [QUOTE=Darwin226;22809131] [cpp]-snip- Window.Run( 0, 60 ); -snip-[/cpp][/QUOTE] But uhh... it is? 0 is for no limit I think.
Of coarse VSync helps but it locks the frame rate at 60, that's actually bad since I can't compare different ways of doing stuff, unless they lower the frame rate below 60, if I don't use a profiler.
[QUOTE=Overv;22822114]The fact it uses up one core is because of the render loop that's constantly running. When you use Thread.Sleep, you will give the processor a break. Also, 3000 is a fine FPS for an empty window. I get something around that with both DirectX and OpenGL.[/QUOTE] It does bug you when you know that you can get more with about the same framework. [QUOTE=raBBish;22822128]But uhh... it is? 0 is for no limit I think.[/QUOTE] 'tis what I said. And if you look at the link you'll see that it should throw an exception if it is 0.
[QUOTE=Overv;22822114]The fact it uses up one core is because of the render loop that's constantly running. When you use Thread.Sleep, you will give the processor a break. Also, 3000 is a fine FPS for an empty window. I get something around that with both DirectX and OpenGL.[/QUOTE] I won't accept 3000 FPS if it drains my CPU. If it ran normally at 3000 FPS it would be enough. [editline]02:49PM[/editline] Parameter should be inside the range [0.0, 200.0] The range includes 0 and 200, 0 then probably means no limit.
Sorry, you need to Log In to post a reply to this thread.