• What Do You Need Help With? V8
    1,074 replies, posted
[QUOTE=dnqboy;52064950]Is anyone decent at Java? I have a project due soon that involves arrays and classes and I have been struggling for hours to set up the array (jumbled crossword basically) but I just don't comprehend how they work at all in 2D form. If I could PM someone some code (so I don't get fucked for cheating) and they offer me some tips/direction that would be amazing.[/QUOTE] i'll be at work for the next 7 or so hours but i'd be glad to help after.
My game which I am making using C++ and SDL seems to be getting memory leaks, and I cannot quite figure out what is causing it. Here is what the debug output in VS2015 says: [code]Detected memory leaks! Dumping objects -> {143} normal block at 0x00CC94D0, 80 bytes long. Data: <ABCDEFGHIJKLMNOP> 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 {142} normal block at 0x00CE08B8, 8 bytes long. Data: < > D4 A7 AC 00 00 00 00 00 Object dump complete.[/code] Does that look familiar to anybody? This is nothing urgent since Task Manager does not seem to show the memory usage going out of control and the program does what it is supposed to do, but I do not want little problems like these causing bigger problems later.
[QUOTE=daigennki;52066192]My game which I am making using C++ and SDL seems to be getting memory leaks, and I cannot quite figure out what is causing it. Here is what the debug output in VS2015 says: [code]Detected memory leaks! Dumping objects -> {143} normal block at 0x00CC94D0, 80 bytes long. Data: <ABCDEFGHIJKLMNOP> 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 {142} normal block at 0x00CE08B8, 8 bytes long. Data: < > D4 A7 AC 00 00 00 00 00 Object dump complete.[/code] Does that look familiar to anybody? This is nothing urgent since Task Manager does not seem to show the memory usage going out of control and the program does what it is supposed to do, but I do not want little problems like these causing bigger problems later.[/QUOTE] it can be a pain to find memory leaks if you have already coded up a shit load of code, but try this might help you pin point the class/method thats causing the leaks [url]https://msdn.microsoft.com/en-us/library/x98tx3cf.aspx[/url] [editline]7th April 2017[/editline] specifically you want to be able to break when the leaks are detected so try this [code]_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); _CrtSetBreakAlloc(143); _CrtSetBreakAlloc(142);[/code]
[QUOTE=antianan;52063678]I don't know man, they have examples on pretty much everything in their wiki, + it might be worth reading a bit of Schlee's book. It covers most of the basic concepts used in the framework, and it also has some excellent examples on how to start with Qt's GUI part.[/QUOTE] The main issue I was having was the weird/broken way includes can work if you don't use one of their pre-built project files, but I added the whole Qt include directory to my project's include search path and that fixed things (fucking duh). Now I'm just getting weird errors that I think are bugs in the 5.9 alpha, but Qt 5.8 won't build on MSVC because of constexpr funkiness (welp).
I'm trying to do a project for java and when I try to count the rows in a CSV, it runs in a loop forever. If I add a quick print of the values in the CSV, it works fine and ends. This spins forever: [code] //Count rows in CSV so we know how many to declare in arrays later: while (file_stream.hasNext()){ row_count++; } System.out.print(row_count); file_stream.close(); [/code] This does not: [code] //Count rows in CSV so we know how many to declare in arrays later: while (file_stream.hasNext()){ System.out.print(file_stream.next() + "/" + "\n"); row_count++; } System.out.print(row_count); file_stream.close(); [/code] I don't know what it's hanging on.
[QUOTE=Adelle Zhu;52067913]I'm trying to do a project for java and when I try to count the rows in a CSV, it runs in a loop forever. If I add a quick print of the values in the CSV, it works fine and ends. This spins forever: [code] //Count rows in CSV so we know how many to declare in arrays later: while (file_stream.hasNext()){ row_count++; } System.out.print(row_count); file_stream.close(); [/code] This does not: [code] //Count rows in CSV so we know how many to declare in arrays later: while (file_stream.hasNext()){ System.out.print(file_stream.next() + "/" + "\n"); row_count++; } System.out.print(row_count); file_stream.close(); [/code] I don't know what it's hanging on.[/QUOTE] In the first example, you're not using `file_stream.next()`. Without this call, you will always look at the same row in the CSV --> `hasNext()` will never return false. Basically, `file_stream.next()` will give you the current row AND move the internal pointer to the next row.
[QUOTE=Adelle Zhu;52067913]I'm trying to do a project for java and when I try to count the rows in a CSV, it runs in a loop forever. If I add a quick print of the values in the CSV, it works fine and ends. This spins forever: [code] //Count rows in CSV so we know how many to declare in arrays later: while (file_stream.hasNext()){ row_count++; } System.out.print(row_count); file_stream.close(); [/code] This does not: [code] //Count rows in CSV so we know how many to declare in arrays later: while (file_stream.hasNext()){ System.out.print(file_stream.next() + "/" + "\n"); row_count++; } System.out.print(row_count); file_stream.close(); [/code] I don't know what it's hanging on.[/QUOTE] hasNext only returns whether there is a next element or not, it does not return it, effectively resulting in while(true) { } next() actually "pops" the element from the stream
[QUOTE=Pat.Lithium;52066926]it can be a pain to find memory leaks if you have already coded up a shit load of code, but try this might help you pin point the class/method thats causing the leaks [url]https://msdn.microsoft.com/en-us/library/x98tx3cf.aspx[/url] [editline]7th April 2017[/editline] specifically you want to be able to break when the leaks are detected so try this [code]_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); _CrtSetBreakAlloc(143); _CrtSetBreakAlloc(142);[/code][/QUOTE] Weird, nothing changed, and although I defined _CRTDBG_MAP_ALLOC it does not show which line of which file is the cause.
How can I turn [b]weaponA = weaponA.Function();[/b] into [b]weaponA.Function();[/b] [code]Transform t = transform.FindChild("Gun"); weaponA = weaponA.InstantiateWeapon(t); weaponB = weaponB.InstantiateWeapon(t); weaponC = weaponC.InstantiateWeapon(t);[/code] [code]public Weapon InstantiateWeapon(Transform t) { Weapon wep = Instantiate(this); wep.transform.localPosition = t.position; wep.transform.rotation = t.rotation; wep.transform.parent = t; return wep; }[/code] If that doesn't work I at least thought of making it a static function so I can just call [b]weaponA = Weapon.InstantiateWeapon();[/b] but if I make it static I can't do [b]Weapon wep = Instantiate(this);[/b] (this can't be used but I need to instantiate wep in unity this way). Obviously I can't add [b]this = wep;[/b] into the Instantiate function, but is there something similar to that? Any ideas? C# by the way.
I'm not sure what you are exactly trying to do, but why not use a builder pattern to build and create weapon instances? Generally when you instantiate something using this, it is a code smell and there is likely a better way to accomplish what you're trying to do. I also don't understand your interface. In each of your examples you pass two different type of objects, a Tranform object type and whatever class contains the InstantiateWeapon method.
Need to write an Oracle SQL query that shows a boss' name, and all their subordinates in one row. So far got this [code]SELECT b.firstname || ' ' || b.lastname AS Boss, b.employeeid, e.firstname || ' ' || e.lastname AS Subordinates FROM employees b JOIN employees e ON e.reportsto = b.employeeid[/code] And that returns things like this currently: [code]BOSS EMPLOYEEID SUBORDINATES Andrew Fuller 2 Laura Callahan Andrew Fuller 2 Steven Buchanan Andrew Fuller 2 Margaret Peacock[/code] Whereas it needs to be more like [code]BOSS EMPLOYEEID SUBORDINATES Andrew Fuller 2 Laura Callahan, Steven Buchanan, Margaret Peacock[/code] Can't seem to wrap my head around LISTAGG atm; either i'm being really retarded or i'm on the verge of having an aneurysm.
Is there any hope for me if I'm having trouble solving the basic Project Euler questions? I'm legitimately considering just dropping all of my CompSci hopes and switching gears. I'm just [I]so[/I] bad at math, it seems, that I can't even solve these basic ass puzzles.
See if you can switch from a BS to a BA in computer science. It requires less math (no calculus). It's what I did, the highest level math I had to do was statistics. Still have the same job and earning potential. Only people who are elitist will judge you from getting a BA vs a BS, and any employer who cares about the difference is likely not somebody you want to work for.
[QUOTE=MilkBiscuit;52117964]Is there any hope for me if I'm having trouble solving the basic Project Euler questions? I'm legitimately considering just dropping all of my CompSci hopes and switching gears. I'm just [I]so[/I] bad at math, it seems, that I can't even solve these basic ass puzzles.[/QUOTE] If I gave up every time I felt bad at a topic, even when it seemed entirely hopeless, I wouldn't have made it through my second year of college (which is when I became cognizant of being bad lol). What has you stuck? Can you link more about it? Whats your mathematics background? The problem with college and math is that sometimes you can end up not practicing math you need for a year or more, and when you come across it the knowledge seems to be gone. Usually it takes a quite bit of polish and some work on your specific weaknesses to get going again. And honestly, these are some hard damn problems. CompSci is a flexible field, with lots of different sub-fields and jobs for one to specialize in. If computational mathematics is not your strong point, then its not your strong point but it doesn't say anything about your potential in CompSci or your ability to succeed in a workplace some day. I'm having trouble debugging my Qt OpenGL efforts. Whenever I try to use renderdoc to capture the OpenGL output, I'm pretty sure it justs grabbing onto what must be the context Qt uses to render their UI window alone, because the event log looks like this: [t]http://i.imgur.com/xSt1sB6.png[/t] Drawing two 6-element arrays looks like drawing a plane to me, and the logs of these calls is nothing like what I do (and I call glDrawElements anyways) - I try to do this: [t]http://i.imgur.com/Gc7qibq.png[/t] and this is the event log tied to the glDrawArrays calls: [t]http://i.imgur.com/HFJ6qY6.png[/t] Am I just capturing the OpenGL context used to render Qts usual GUI stuff, or is something completely fuckulated? I can't figure out why my window doesn't work, I've followed tutorials to the letter and its pretty just [URL="http://doc.qt.io/qt-5/qtopengl-cube-example.html"]this[/URL], but using a 3.3 context and a couple more modern options. Everything on my side and in the C++ code I've written seems fine: handles being bound are valid, mesh data from imported objects is being sent to OpenGL and loaded in VBOs/EBOs correctly, and so on, but nothing is rendering and I can't even get a debugger in there to look at it in more detail :/ I'm getting really frustrated too, I've been stuck on this at work for a week now and the first few days was just me fighting Qt to get the right kind of context initialized, then forcing it to not somehow make two contexts, then forcing it to not break the context init, and so on.
I'm still stuck on the same fucking jQuery nonsense I started two weeks ago. I'm trying to modify an existing script from the UI kit I'm using to accept data from outside sources. I need multiple fields in a form perform an ajax query to a different endpoint. Basically it seems I have to have multiple separate selectors that each have a different endpoint. Can anyone help me along with the script?
I can probably help ya. Can you post your code?
[URL="https://pastebin.com/yLHQJ6nJ"]Here is the script I'm working with.[/URL] It only has support for data that is predefined in an array or similar fashion. I need it to make an ajax call to an endpoint via POST to a flask function that returns json data. I have the endpoint function set up already, I just need the jQuery to render the list.
[QUOTE=paindoc;52121123] ~ QT fuckery ~ [/QUOTE] So this is not directly helpful because it doesn't really solve the issue at hand but an approach worth checking out is embedding your OpenGL application inside a QT app instead of creating an OpenGL context in QT. It really depends a lot on what you're trying to accomplish but depending on the use case splitting up the app like this makes it both easier to debug your rendering because it's in a whole different process that you can just debug separately and also doesn't tie you to whatever contexts QT supports.
[QUOTE=Adelle Zhu;52121714][URL="https://pastebin.com/yLHQJ6nJ"]Here is the script I'm working with.[/URL] It only has support for data that is predefined in an array or similar fashion. I need it to make an ajax call to an endpoint via POST to a flask function that returns json data. I have the endpoint function set up already, I just need the jQuery to render the list.[/QUOTE] I think modifying the existing autocomplete script isn't the best approach. If it doesn't work out of the box for your needs, then I would probably handroll my own autocomplete. What problem are you running into exactly? Be specific. I was hoping for you to post the code that you are writing.
[QUOTE=JWki;52124155]So this is not directly helpful because it doesn't really solve the issue at hand but an approach worth checking out is embedding your OpenGL application inside a QT app instead of creating an OpenGL context in QT. It really depends a lot on what you're trying to accomplish but depending on the use case splitting up the app like this makes it both easier to debug your rendering because it's in a whole different process that you can just debug separately and also doesn't tie you to whatever contexts QT supports.[/QUOTE] Yeah, I'm trying to do that now by separating into the OpenGL stuff into its own project. I need to get better about separating the parts of my application too, I'm almost tying my CLI application to the GUI application and that's less than ideal. Part of my original idea was making sure the CLI backend and GUI frontend were distinct. [editline]19th April 2017[/editline] it looks like this is what openage did, so I'm going to see what I can glean from that [editline]19th April 2017[/editline] well, this actually raises more problems. I need to be able to create something nearly resembling a CAD programs style of viewing and manipulation, and doing so while separating the windows/sub-applications entirely could considerably complicate input handling. Qt does render to an OpenGL texture though, but I did find out how to inject renderdoc correctly and get it to capture the rendering I'm doing in addition to the other stuff.
[URL="https://github.com/bogde/HX711/blob/master/HX711.cpp#L74"]This[/URL] is a library for the [URL="https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf"]HX711[/URL]. On line 80 there's this [code] // Construct a 32-bit signed integer value = ( static_cast<unsigned long>(filler) << 24 | static_cast<unsigned long>(data[2]) << 16 | static_cast<unsigned long>(data[1]) << 8 | static_cast<unsigned long>(data[0]) ); [/code] Is this just a clever way of combining the array values, or is there something else behind it?
[QUOTE=brianosaur;52116668]I'm not sure what you are exactly trying to do, but why not use a builder pattern to build and create weapon instances? Generally when you instantiate something using this, it is a code smell and there is likely a better way to accomplish what you're trying to do. I also don't understand your interface. In each of your examples you pass two different type of objects, a Tranform object type and whatever class contains the InstantiateWeapon method.[/QUOTE] The Weapon class contains the InstantiateWeapon method and takes a transform in order to be moved and parented to it, but that's irrelevant. My question was how do I condense Weapon weaponA = weaponA.InstantiateWeapon(); into something shorter, but now that I think of it, I could probably just replace the default constructor to have the code instead of a separate method. Though the problem here is that I can't really do that anyway as I need to replace the object i'm calling the function from with an instantiated object in unity, so I have to call object = Instantiate(object).
[QUOTE=gokiyono;52125747][URL="https://github.com/bogde/HX711/blob/master/HX711.cpp#L74"]This[/URL] is a library for the [URL="https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf"]HX711[/URL]. On line 80 there's this [code] // Construct a 32-bit signed integer value = ( static_cast<unsigned long>(filler) << 24 | static_cast<unsigned long>(data[2]) << 16 | static_cast<unsigned long>(data[1]) << 8 | static_cast<unsigned long>(data[0]) ); [/code] Is this just a clever way of combining the array values, or is there something else behind it?[/QUOTE] From my analysis of the code, it's reading 3 8-bit values into the 'data' array, then checks if the 3rd value is signed or unsigned, and lastly combines them in a single 32-bit value (in little-endian order). For example, if you read in the values "89 67 45", the resulting 32-bit integer will be 0xFF456789 and not 0x456789 because of that check we do on line 74. Hope this helps clear it up for you!
[QUOTE=CarLuver69;52127561]From my analysis of the code, it's reading 3 8-bit values into the 'data' array, then checks if the 3rd value is signed or unsigned, and lastly combines them in a single 32-bit value (in little-endian order). For example, if you read in the values "89 67 45", the resulting 32-bit integer will be 0xFF456789 and not 0x456789 because of that check we do on line 74. Hope this helps clear it up for you![/QUOTE] Yeah, I feel a little stupid that I didn't get that :v: I have another question about this part [code] HX711::HX711(byte dout, byte pd_sck, byte gain) { begin(dout, pd_sck, gain); } void HX711::begin(byte dout, byte pd_sck, byte gain) { // Whatevs set_gain(gain); } [/code] I've noticed that when I use the library, I never use the 'gain' parameter. This also happens in the [URL="https://github.com/bogde/HX711/blob/master/examples/HX711SerialBegin/HX711SerialBegin.ino#L13"]example[/URL] they use on line 13. What kind of magic is this? Normally that would give a 'too few arguments in function' error. So why not here?
[QUOTE=gokiyono;52128151]Yeah, I feel a little stupid that I didn't get that :v: I have another question about this part [code] HX711::HX711(byte dout, byte pd_sck, byte gain) { begin(dout, pd_sck, gain); } void HX711::begin(byte dout, byte pd_sck, byte gain) { // Whatevs set_gain(gain); } [/code] I've noticed that when I use the library, I never use the 'gain' parameter. This also happens in the [URL="https://github.com/bogde/HX711/blob/master/examples/HX711SerialBegin/HX711SerialBegin.ino#L13"]example[/URL] they use on line 13. What kind of magic is this? Normally that would give a 'too few arguments in function' error. So why not here?[/QUOTE] Because in the header file, a default value of 128 is defined: [code]// Allows to set the pins and gain later than in the constructor void begin(byte dout, byte pd_sck, byte gain = 128); [/code] It's an optional parameter, which is why it's not an error.
[QUOTE=CarLuver69;52128161]Because in the header file, a default value of 128 is defined: [code]// Allows to set the pins and gain later than in the constructor void begin(byte dout, byte pd_sck, byte gain = 128); [/code] It's an optional parameter, which is why it's not an error.[/QUOTE] Boy do I feel stupid now. Thanks for the help
I implemented a few things like boost property trees from JSON and vectors in my game programmed with C++ and suddenly I am getting a shitload of memory leaks. Looks like the boost property trees have more to do with it judging by the dump that Visual Studio outputs, what might I have done wrong?
I've got a shape made out of 2D vectors. Each vector is connected to its neighbor via spring and can be moved around (the entire shape can change its position and can vary in size). Example shape: [img]http://i.imgur.com/xBMUEzh.png[/img] Now the problem comes down to rendering, as you can see the texture doesn't fully cover the shape (the circles are sticking out). Before rendering the texture I want to offset each vector by some value so that it covers the shape. I've been trying to scale the texture, offset each vector by a fraction of the circle radius, but all attempts gave me weird deformed results. How could I offset each vector from its position by a fraction the circle radius so that my texture covers the shape?
I'm writing a single file Python 3 program but I've added a second file called test.py (to contain tests) in the same directory. I want to import the first file into test.py so I can test it but I can't seem to find any non-hacky way of doing this in Python 3 - I've read a bunch of different suggestions but the only way I've managed to get it to work is by adding sys.path.append('..') to the top of test.py and pretending that the directory is a package. Is there a proper way to do this without playing around with what paths Python looks for packages in?
did you add an __init__.py file in the directory?
Sorry, you need to Log In to post a reply to this thread.