• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=SteveUK;40593046]One alternative is [url=http://tfs.visualstudio.com/en-us/]Team Foundation Service[/url] as they recently added Git support. Limited to 5 users, has a few nice things like building if you're targeting Windows or Java.[/QUOTE] TFS stops being free this year though.
In my C++/SFML project, I have three classes: State, Menu, and Button. In my main(), I create an SFML window and a State. The State creates a Menu, and adds a Button to it. The Button creates an SFML font and text, and its draw function draws both a button image and the text. However, when I build and run this, I get a segfault. When I create the Button directly in main(), where the window is created, it works fine. [url=http://pastebin.com/R3FSTiXn]main.cpp[/url] | [url=http://pastebin.com/YGzXaGXf]state.cpp[/url] | [url=http://pastebin.com/vdkBaD4P]menu.cpp[/url] | [url=http://pastebin.com/MTPEAkVR]button.cpp[/url] Can anyone see what I did wrong?
[QUOTE=Lord Fear;40594556]TFS stops being free this year though.[/QUOTE] Source? I was under the impression that the free plan was staying free
So I've got this little programming exercise on performing a quicksort on a circular doubly linked list. It works fine with most testcases, but sadly when i try to submit 3 out of 15 dont work and i cant view the input-files, so i require some help. I think its either a problem with getting the start and/or end node(s) or with my if condition in quicksort [CODE] package ads1ss13.pa; /** * Sorter Klasse in der die Methode {@link #quicksort(DoublyLinkedList, int)} * implementiert werden soll. * * <p> * In dieser Klasse m&uuml;ssen Sie Ihren Code einf&uuml;gen und die Method * {@link #quicksort(DoublyLinkedList, int)} implementieren. * </p> * * <p> * Sie k&ouml;nnen beliebige neue Variablen und Methoden in dieser Klasse * hinzuf&uuml;gen. * </p> */ public class Sorter { private int i = 0; /** * Quicksort Implementierung * * @param in Unsortierte Eingabefolge * @param numOfElements Gr&ouml;&szlig;e der Eingabefolge * @return Sortiterte Eingabefolge */ public DoublyLinkedList quicksort(DoublyLinkedList in, int numOfElements) { Quicksort(in.first, in.first.prev, in); return in; } public void Quicksort(ListElement l, ListElement r, DoublyLinkedList list){ if (l != r && (r.next != l || list.first == l && list.first.prev == r)) { ListElement cur = l; ListElement start = l; ListElement end = r; ListElement temp; boolean firstNotSwapped = false; boolean firstSwapped = false; while(cur.getId() != r.getId()){ if (cur.getKey() > r.getKey()){ if(firstSwapped == false){ firstSwapped = true; end = cur; } temp = cur.next; changePlace(list, cur, r); cur = temp; } else{ if(firstNotSwapped == false){ firstNotSwapped = true; start = cur; } cur = cur.next; } } Quicksort(start, r.prev, list); Quicksort(r, end, list); } } public void remove(DoublyLinkedList list, ListElement node){ if(node.getId() == list.first.getId()){ list.first = node.next; } node.prev.next = node.next; node.next.prev = node.prev; } public void insertAfter(ListElement node, ListElement newNode){ newNode.next = node.next; newNode.prev = node; node.next.prev = newNode; node.next = newNode; } public void changePlace(DoublyLinkedList list, ListElement old, ListElement predecessor){ ListElement temp = old; remove(list, old); insertAfter(predecessor, temp); } } [/CODE]
-snip-
[QUOTE=Darkwater124;40595980]In my C++/SFML project, I have three classes: State, Menu, and Button. In my main(), I create an SFML window and a State. The State creates a Menu, and adds a Button to it. The Button creates an SFML font and text, and its draw function draws both a button image and the text. However, when I build and run this, I get a segfault. When I create the Button directly in main(), where the window is created, it works fine. [url=http://pastebin.com/R3FSTiXn]main.cpp[/url] | [url=http://pastebin.com/YGzXaGXf]state.cpp[/url] | [url=http://pastebin.com/vdkBaD4P]menu.cpp[/url] | [url=http://pastebin.com/MTPEAkVR]button.cpp[/url] Can anyone see what I did wrong?[/QUOTE] You aren't calling the sf::Text constructor in your Button constructor's initialization list. You need to do it like this: [code] Button(int _x, int _y, int _width, int _height, std::string text) : label(text, font, 16) // note that you already need the font here [/code] How do I know this is the problem? [code] Program received signal SIGSEGV, Segmentation fault. 0x00007ffff799610c in sf::Font::getTexture(unsigned int) const () from /usr/lib/libsfml-graphics.so.2 (gdb) where #0 0x00007ffff799610c in sf::Font::getTexture(unsigned int) const () from /usr/lib/libsfml-graphics.so.2 #1 0x00007ffff79b8fce in sf::Text::draw(sf::RenderTarget&, sf::RenderStates) const () from /usr/lib/libsfml-graphics.so.2 #2 0x00007ffff79b19f4 in sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&) () from /usr/lib/libsfml-graphics.so.2 #3 0x00000000004034d4 in game::Button::draw (this=0xe1f760, window=...) at menu/button.cpp:50 #4 0x0000000000403c4d in game::Menu::draw (this=0x7fffffffde60, window=...) at menu/menu.cpp:23 #5 0x0000000000404436 in game::State::draw (this=0x7fffffffde50) at state.cpp:29 #6 0x0000000000402bb9 in main () at main.cpp:76 (gdb) frame 3 #3 0x00000000004034d4 in game::Button::draw (this=0xe1f760, window=...) at menu/button.cpp:50 50 window.draw(label); (gdb) p label $1 = <incomplete type> [/code] If you're using C++, you need to know how to use a debugger. Because when you paste four source files and say "I'm getting a segfault" that's all that anyone can do.
[QUOTE=Larikang;40602437]You aren't calling the sf::Text constructor in your Button constructor's initialization list. You need to do it like this: [code] Button(int _x, int _y, int _width, int _height, std::string text) : label(text, font, 16) // note that you already need the font here [/code] How do I know this is the problem? [code] Program received signal SIGSEGV, Segmentation fault. 0x00007ffff799610c in sf::Font::getTexture(unsigned int) const () from /usr/lib/libsfml-graphics.so.2 (gdb) where #0 0x00007ffff799610c in sf::Font::getTexture(unsigned int) const () from /usr/lib/libsfml-graphics.so.2 #1 0x00007ffff79b8fce in sf::Text::draw(sf::RenderTarget&, sf::RenderStates) const () from /usr/lib/libsfml-graphics.so.2 #2 0x00007ffff79b19f4 in sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&) () from /usr/lib/libsfml-graphics.so.2 #3 0x00000000004034d4 in game::Button::draw (this=0xe1f760, window=...) at menu/button.cpp:50 #4 0x0000000000403c4d in game::Menu::draw (this=0x7fffffffde60, window=...) at menu/menu.cpp:23 #5 0x0000000000404436 in game::State::draw (this=0x7fffffffde50) at state.cpp:29 #6 0x0000000000402bb9 in main () at main.cpp:76 (gdb) frame 3 #3 0x00000000004034d4 in game::Button::draw (this=0xe1f760, window=...) at menu/button.cpp:50 50 window.draw(label); (gdb) p label $1 = <incomplete type> [/code] If you're using C++, you need to know how to use a debugger. Because when you paste four source files and say "I'm getting a segfault" that's all that anyone can do.[/QUOTE] Thanks! Do you happen to know any good gdb tutorials?
[QUOTE=ollie;40585237]Why are my fonts not loading correctly with SFML? It always returns 0xA, I've tried everything! [code] if(!font.loadFromFile("arial.ttf")) return 0xA; [/code][/QUOTE] Do you have the .ttf file in the correct directory? edit - Nevermind, didn't see it was on the previous page.
[QUOTE=Darkwater124;40603627]Thanks! Do you happen to know any good gdb tutorials?[/QUOTE] Unfortunately not. I only know a handful of commands but it's enough to get by. There are some decent google results for it.
I'd need to mirror/reflect a 3d vector p based on a plane with normal n and pos in origin. How should I do this?
[QUOTE=Donkie;40607357]I'd need to mirror/reflect a 3d vector p based on a plane with normal n and pos in origin. How should I do this?[/QUOTE] You should be able to do it like this: [code]r = p - 2.0*dot(p, norm)*norm[/code] The normal needs to be normalized. [editline]11th May 2013[/editline] I think I misunderstood what you were after.
Yeah that doesn't seem to cut it, I'll draw you a 2d version because I can't draw 3d for shit, but I want it to be applicable on all 3 axises. If you can't find out the formula, I'd be much happy for you pointing me in the right direction. (I have no idea what this type of maths are called)
mirrored = point - 2 * signed_distance_from_plane(point, plane) * plane.normal [editline]11th May 2013[/editline] The signed distance is dot(point, normal) - dot(plane_point, normal)
[QUOTE=ThePuska;40608165]mirrored = point - 2 * signed_distance_from_plane(point, plane) * plane.normal [editline]11th May 2013[/editline] The signed distance is dot(point, normal) - dot(plane_point, normal)[/QUOTE] The plane is on the origin, wouldn't this be the same as what I posted?
Sorry, I didn't even read it. Yes, you said it first and it should work.
Oh right, it did work MakeR, I just fucked up abit. Thanks to you both!
I'm working on my Java homework, it's the last homework problem before our final and the teacher decided it's worth 15% of our grade. We have to take text document logs of a server, and output the 3 IP addresses with highest occurrences. I have the IP addresses sorted into a TreeMap with the amount of occurences per IP address, but I'm lost as to how to sort them. Pointers?
uhh, I'm getting confused here. this doesn't work: [code] local t = sf.seconds(5) -- sf.Time() instance print("t < 4sec = " .. tostring(t < sf.seconds(4))) [/code] [B](gives the lua error: attempt to compare two table values.)[/B] but this does? [code] local t = sf.seconds(5) -- sf.Time() instance print("t < 4sec = " .. tostring(getmetatable(t).__lt(t, sf.seconds(4)))) [/code] exact same scenario for __le. do any of you lua pros see anything wrong?
[QUOTE=zero_slo;40580057]Hi. I'm making a physics simulation of sorts in SFML (C#). I want to have a WinForms window (for controls) and a SFML window (for the simulation) at the same time, kinda like this: [T]http://shrani.si/f/D/jW/2IfEMyYf/brez-naslova.png[/T] anyone? The problem is that when I start the "gameloop" of the SFML Window from the WinForms one, the WinForms window freezes (duh...). How would I go about fixing that? I tried runnig the gameloop in a separate thread, like this: [CODE] private void button1_Click( object sender, EventArgs e ) { Thread t = new Thread( new ThreadStart( game.GameLoop ) ); t.Start(); } [/CODE] But then nothing was showing in the SFML window... (I suspect there can only be one GUI thread?)[/QUOTE] anyone?
[QUOTE=ief014;40613482]uhh, I'm getting confused here. this doesn't work: [code] local t = sf.seconds(5) -- sf.Time() instance print("t < 4sec = " .. tostring(t < sf.seconds(4))) [/code] [B](gives the lua error: attempt to compare two table values.)[/B] but this does? [code] local t = sf.seconds(5) -- sf.Time() instance print("t < 4sec = " .. tostring(getmetatable(t).__lt(t, sf.seconds(4)))) [/code] exact same scenario for __le. do any of you lua pros see anything wrong?[/QUOTE] If you are using LuaJIT (or Lua 5.1) then the problem may be that you are creating a new __lt closure for each sf.Time instance: [lua]local sf = {} function sf.seconds(s) return setmetatable({unixtime = s}, {__lt = function(a, b) return a.unixtime < b.unixtime end}) end local t = sf.seconds(5) print("t < 4sec = " .. tostring(t < sf.seconds(4))) -- doesn't work local t = sf.seconds(5) print("t < 4sec = " .. tostring(getmetatable(t).__lt(t, sf.seconds(4)))) -- works[/lua] You should do it like this: [lua]local timemeta = {} function timemeta:__lt(o) return self.unixtime < o.unixtime end local sf = {} function sf.seconds(s) return setmetatable({unixtime = s}, timemeta) end local t = sf.seconds(5) print("t < 4sec = " .. tostring(t < sf.seconds(4))) -- works[/lua]
[QUOTE=zero_slo;40613871]anyone?[/QUOTE] Try to force redraw the SFML window. [editline]12th May 2013[/editline] Maybe I should be more elaborate. I think the problem is that WinForms doesn't know from the SFML thread that it's drawing stuff to the window, so it doesn't refresh it, because it only redraws windows that needs to be redrawn. If you would resize the SFML window, does it render one frame?
[QUOTE=allyhaxorz;40610874]I'm working on my Java homework, it's the last homework problem before our final and the teacher decided it's worth 15% of our grade. We have to take text document logs of a server, and output the 3 IP addresses with highest occurrences. I have the IP addresses sorted into a TreeMap with the amount of occurences per IP address, but I'm lost as to how to sort them. Pointers?[/QUOTE] You can provide a custom comperator for the TreeMap, thus you can specify how the entries should be sorted.
[QUOTE=MakeR;40614228]If you are using LuaJIT (or Lua 5.1) then the problem may be that you are creating a new __lt closure for each sf.Time instance: -code- You should do it like this: -code-[/QUOTE] alright I'll try that. it's a little strange that every other metamethod works except __lt and __le. [editline]12th May 2013[/editline] ohh I think I see what's wrong with that. alright, thanks MakeR
when attempting to run a simple hello world program just to check to make sure my pc was normal it wouldn't run it, I created a path for it, however it is now saying it cannot locate the file/ won't turn it into a class file. How do I fix this?
Since you said class file, I'm assuming java? [code]$ javac MyJavaClass.java $ java -cp . MyJavaClass[/code] First one compiles it into MyJavaClass.class, the second one runs the Java VM and instructs it to load that.
I wonder if there is a simple way to access hard drives byte by byte on windows. I know I can do this on linux. By just using a simple unformatted fstream and copying /dev/sda or whatever other drive you want to copy onto /dev/sdb (just an example, it depends of course what linux calls the device), I have cloned whole harddisks using this simple method, but I could not find a way to do this on windows in a simple manner. Hopefully somebody can point me in the right direction.
[url=http://support.microsoft.com/kb/100027]Seems like it.[/url]
Lol, that seems to be it. Thanks for the quick reply!
[QUOTE=Robbis_1;40615124]Try to force redraw the SFML window. [editline]12th May 2013[/editline] Maybe I should be more elaborate. I think the problem is that WinForms doesn't know from the SFML thread that it's drawing stuff to the window, so it doesn't refresh it, because it only redraws windows that needs to be redrawn. If you would resize the SFML window, does it render one frame?[/QUOTE] Nope, resizing doesn't work, all it does is this: [T]http://shrani.si/f/P/xp/1a9itrNq/brez-naslova.png[/T] The FPS in the SFML window title do update every second (as they should), but nothing is being displayed in the actual window... Edit: Events in the SFML window also work (Console.WriteLine(...) in handlers...)
If you're rendering in a second thread then maybe you're in the wrong context. Just call the event queue from the game loop to process events, then you can render in the UI thread without freezing.
Sorry, you need to Log In to post a reply to this thread.