• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=Khub;45509285]Just troubleshooting, maybe it's something else.[/QUOTE] That fixed it. Originally I was setting new vectors' metatables the same as vec's.
I'm trying to use TableLayout in android but for some reason nothing is shown. I've probably missed something small that I don't notice since it's my first time using Tablelayout. [CODE] private void buildTable() { tl = new TableLayout(this); for (int i = 0; i < item.length; i++) { TableRow tr = new TableRow(this); tr.setLayoutParams(params); itemTV = new TextView(this); itemTV.setText(item[i]); itemTV.setLayoutParams(params); tr.addView(itemTV); costTV = new TextView(this); costTV.setText("$" + cost[i]); costTV.setLayoutParams(params); tr.addView(costTV); dateTV = new TextView(this); dateTV.setText(date[i]); dateTV.setLayoutParams(params); tr.addView(dateTV); // Add the TableRow to the TableLayout tl.addView(tr, params); } sv.addView(tl); } [/CODE] I call this function before setContentView(sv) in my onCreate. The entire activity is blank even though the data is there.
I'm working on an Android application with my friend and we're running around in circles. The application downloads a set of SVG documents that contain plans of the school building which we want to present to the user. We've managed to find a half-broken library and got it to a working state, so we're now rendering the plan into a Canvas which was also modified to support zooming. Now we're stuck at another bottleneck - we want to detect which room (every room is represented by a Path) does the user click/touch. The problem with this is that the library uses a stack of transform matrices (there's not really another way to go), so if we wanted to cache the points the room consists of, we'd have to run it through the whole matrix stack and save -- not to mention all the further problems with zooming etc. We're targeting API level 8 (that's 2.0 or something near that), so we can't just tell the system to render a HTML page with inline SVG - that feature is 3.0+. Does anyone know of a better, reliable SVG library you'd know? If you feel like we're doing something wrong, feel free to tell, too.
Maybe this is kinda silly to ask but could someone help me with function prototypes? I got the main idea about them but I am kinda confused about the way they have to be included and I also don't understand how this works overall. [CODE]#include <iostream> using namespace std; int Area(int length, int width); int main() { int lenghtOf, widthOf, areaOf; cin >> widthOf; cin >> lenghtOf; areaOf= Area(lenghtOf, widthOf); cout << areaOf; return 0; } int Area(int len, int wid) { return len * wid; }[/CODE] Edit: Oooh, I get it now. It doesn't really matter what name the paramaters do have, everything is called in whatever order they are defined or whatever :v. I guess it just calls the Area function, does the calculation and then returns the value back to my cout, the naming thing confused me slightly for a second. I still don't understand when to define these functions tho. I'd snip my post but I'll just leave it here.
[QUOTE=RaTcHeT302;45522637]Maybe this is kinda silly to ask but could someone help me with function prototypes? I got the main idea about them but I am kinda confused about the way they have to be included and I also don't understand how this works overall. [CODE]#include <iostream> using namespace std; int Area(int length, int width); int main() { int lenghtOf, widthOf, areaOf; cin >> widthOf; cin >> lenghtOf; areaOf= Area(lenghtOf, widthOf); cout << areaOf; return 0; } int Area(int len, int wid) { return len * wid; }[/CODE] Edit: Oooh, I get it now. It doesn't really matter what name the paramaters do have, everything is called in whatever order they are defined or whatever :v. I guess it just calls the Area function, does the calculation and then returns the value back to my cout, the naming thing confused me slightly for a second. I still don't understand when to define these functions tho. I'd snip my post but I'll just leave it here.[/QUOTE] You need those because the compiler only does one single pass through your source file. If it encounters anything it does not know of, it will stop and fail. Because you are using the Area function a few lines before you actually define the function, the compiler would not know what "Area" is supposed to be. So in order to make it known to the compiler, you either move the whole function to the top (i.e. before the first usage), or you forward-declare the function at the top (which you did). Declaring means that you just tell the compiler what "Area" is supposed to be; in your case it would be "a function taking two ints and returning an int". At that time, the compiler does not care about the actual names of the arguments or the function body itself, so "int Area(int, int);" would be sufficient, but in practice it's preferable to use identical names in both declaration and definition. Generally, such declarations go into a header file, which allows you to make functions known in different source files. The actual implementation of the function though stays in one single source file.
What are some good resources to start learning C++? Next course I'm taking is Data Structures in C++. Everyone I've talked to says the hardest part about the course is that they don't know the syntax of C++. Any good books, tutorials, or advice on how to approach it? As far as an IDE's go I have been using Netbeans and Sublime as my text editor of choice; both for Java. Should I pick up codeblocks, eclipse, or mono?
[QUOTE=blacksam;45523982]What are some good resources to start learning C++? Next course I'm taking is Data Structures in C++. Everyone I've talked to says the hardest part about the course is that they don't know the syntax of C++. Any good books, tutorials, or advice on how to approach it? As far as an IDE's go I have been using Netbeans and Sublime as my text editor of choice; both for Java. Should I pick up codeblocks, eclipse, or mono?[/QUOTE] VS2013 Express/C++ Early Objects (BOOK) [url]https://github.com/Proclivitas/CPP_Early_Objects_Eighth_Edition/tree/master[/url] Some of the programming challenges within the book at the end of each chapter.
[QUOTE=Proclivitas;45524064]VS2013 Express/C++ Early Objects (BOOK) [url]https://github.com/Proclivitas/CPP_Early_Objects_Eighth_Edition/tree/master[/url] Some of the programming challenges within the book at the end of each chapter.[/QUOTE] Everyone loves visual studio I hear. What perks am I getting by learning how to use it over eclipse?
[QUOTE=boshadow;45509334]Hi there, I'm working on an area system. When player is inside an area (inside areas table) it will set the variable to that name. Now I have to reset the variable to a default string I defined when player exists the area but I can't seem to get it to work. Tried several things, can't get my head around it. [lua]-- Function to check in what area the player is located. function getArea(player) local areas = PLUGIN.areas local default = "Somewhere in the freaking map"; -- Check if any areas where found, and proceed if so. if #areas > 0 then for k = 1, #areas do local v = areas[k] for k2, v2 in pairs(ents.FindInBox(v.pos1, v.pos2)) do if v2:IsPlayer() and v2:Alive() and v2._Area != v.name then -- Set the _Area variable. v2._Area = v.name; end end -- @@ end end end timer.Create("getArea", 1, 0, getArea, player)[/lua] Now, where I put the "-- @@" comment I guess I should reset the variable, but when I tried player._Area = default; it gave an error saying 'player' is a nil value.[/QUOTE] I don't like to bump as its kind of a dickmove imo but.. bump? ;c
Let's say I wanted to check to see if an array had ANY value of 1 at all. So the array in question would look like array(0)=0 array(1)=0 array(2)=1 array(3)=0 array(4)=0 so that I could check the entire array, and if it sees a one AT ALL, it will return true to some function or boolean. if I check each in a for loop like: [code] for(int i = 0;i<4;i++){ if(array(i)==1){ return true; } } [/code] then I simply get 4 false's and 1 true, so if I were to try to use it like "if this function is true then do this, else do that", then it will only do the return value from the last place in the array, so unless array(4) returns a true, it will only do the false, and vice versa
[QUOTE=proboardslol;45524405]Let's say I wanted to check to see if an array had ANY value of 1 at all. So the array in question would look like array(0)=0 array(1)=0 array(2)=1 array(3)=0 array(4)=0 so that I could check the entire array, and if it sees a one AT ALL, it will return true to some function or boolean. if I check each in a for loop like: [code] for(int i = 0;i<4;i++){ if(array(i)==1){ return true; } } [/code] then I simply get 4 false's and 1 true, so if I were to try to use it like "if this function is true then do this, else do that", then it will only do the return value from the last place in the array, so unless array(4) returns a true, it will only do the false, and vice versa[/QUOTE] I don't quite get what you mean, in any sane language return should break out of the current function. Just return false after the loop, when nothing was found.
[QUOTE=Tamschi;45525603]I don't quite get what you mean, in any sane language return should break out of the current function. Just return false after the loop, when nothing was found.[/QUOTE] There are languages where the return value is just like any other variable, i.e. you can assign to it as much as you want without returning, only when the scope of the function is over the last assigned value is being returned. @proboardslol: What language are you using?
[QUOTE=Khub;45514741]I'm working on an Android application with my friend and we're running around in circles. The application downloads a set of SVG documents that contain plans of the school building which we want to present to the user. We've managed to find a half-broken library and got it to a working state, so we're now rendering the plan into a Canvas which was also modified to support zooming. Now we're stuck at another bottleneck - we want to detect which room (every room is represented by a Path) does the user click/touch. The problem with this is that the library uses a stack of transform matrices (there's not really another way to go), so if we wanted to cache the points the room consists of, we'd have to run it through the whole matrix stack and save -- not to mention all the further problems with zooming etc. We're targeting API level 8 (that's 2.0 or something near that), so we can't just tell the system to render a HTML page with inline SVG - that feature is 3.0+. Does anyone know of a better, reliable SVG library you'd know? If you feel like we're doing something wrong, feel free to tell, too.[/QUOTE] You can invert the matrices (since they are affine transformations and the kernel's dimension is 0, which means the function is bijective), then you can run the touch point through the inverse transformation and check against the original paths. It's faster if you collapse the matrix that into a single one and then invert that though.
Hey everyone, just posting here incase anyone can point me in the right direction for some resources for a task i've been given for work. Essentially my company is working on a project to interface with a machine simmilar to a CNC router, this machine accepts commands from an app written in .NET now from some screenshots this appears to be a webpage, all their documentation shows an app running in a really old version of netscape. In a few days i will have the opportunity to actually sit in front of this machine and need to come up with some solution for interfacing with it either directly or by passing messages to its software. I should have full access to the machine and its terminal, i am assuming it will be running on windows. Now normally this wouldn't be much of an issue however i'm under strict instruction that i cannot "hack" it. the machine calls home to its manufacturer logging information, and the company that owns the machine could possibly face breaking some terms and conditions or something if I go in guns blazing and start pulling the system apart looking for a way in. My initial approach would just be to take a look with wireshark or some simmilar software and see if its doing any communication over the network (we need to interface remotely so this would be the ideal scenario) My second idea was to try sending requests to the app as form data (assuming it is running in a browser, according to screenshots it is) The worst case scenario is we have to so some sort of VNC or some really hacky communication directly with the machine. Ideally we would like to leverage the software already controlling the machine to cut down on our workload. Are there any sort of resources on this or some basic techniques that would give me leg up so to speak?
[QUOTE=Dienes;45525647]There are languages where the return value is just like any other variable, i.e. you can assign to it as much as you want without returning, only when the scope of the function is over the last assigned value is being returned. @proboardslol: What language are you using?[/QUOTE] don't laugh [sp]freebasic[/sp]
So, i have two bytes which represent a color (16 bit color). How can i convert this into 4 bytes which represent the same color but in 32bit? I'm using C# so working with individual bits is a pain in the ass. I'm really frustrated because this seems to be such a common problem, but google didn't help me AT ALL. I mean, it's like nobody ever asked this question. [editline]28th July 2014[/editline] Ultimately it would be better to just know how to show a 16bit image properly, because i'll be editing that image and i would have to convert it back to 16bit which doesn't sound very cool. I'm using System.Drawing.Bitmap btw. [editline]28th July 2014[/editline] Answered in WAYWO.
Are there any guarantees in C++ that dictate struct order? For example lets say I have this class: [cpp]class foo{ bar q; bar x, y; short c; int i; };[/cpp] Is there a guarantee that x will be right beside y? Disregarding if there is padding between the two. Also, if I have an array, would the padding between x and y be the same as the padding in between them in the class? I would think so, since the struct bar would already be padded, so they would be aligned if put right beside eachother.
[QUOTE=WTF Nuke;45528468]Are there any guarantees in C++ that dictate struct order? For example lets say I have this class: [cpp]class foo{ bar q; bar x, y; short c; int i; };[/cpp] Is there a guarantee that x will be right beside y? Disregarding if there is padding between the two. Also, if I have an array, would the padding between x and y be the same as the padding in between them in the class? I would think so, since the struct bar would already be padded, so they would be aligned if put right beside eachother.[/QUOTE] Class/struct member ordering is always preserved. There are zero guarantees regarding padding. However, every modern compiler supports various "#pragma" directives to override the defaults.
But would these two be equal? [cpp]class foo{bar x, y;}; //and bar z[2];[/cpp] in memory
[QUOTE=WTF Nuke;45529350]But would these two be equal? [cpp]class foo{bar x, y;}; //and bar z[2];[/cpp] in memory[/QUOTE] Not necessarily.
[QUOTE=WTF Nuke;45529350]But would these two be equal? [cpp]class foo{bar x, y;}; //and bar z[2];[/cpp] in memory[/QUOTE] If it was a packed struct then yes, in C++ structs and classes aren't different besides classes having their members set public by default. (But i don't think you can pack classes)
[QUOTE=Tamschi;45529549]Not necessarily.[/QUOTE] Why not? Wouldn't the bars be packed by the compiler to fall into address boundaries and then the array would just use them? Or does the array not include the padding, or any padding at all, which is in the original class/struct? If so, then how can we easily traverse an array if it doesn't have its members aligned.
[QUOTE=WTF Nuke;45529918]Why not? Wouldn't the bars be packed by the compiler to fall into address boundaries and then the array would just use them? Or does the array not include the padding, or any padding at all, which is in the original class/struct? If so, then how can we easily traverse an array if it doesn't have its members aligned.[/QUOTE] The specification says so. If it doesn't it makes no guarantee it's the same, so you shouldn't assume it is.
I see, thanks. Now to figure out why I can't initialize arrays with initializer_lists in an initialization list.
[QUOTE=WTF Nuke;45530037]I see, thanks. Now to figure out why I can't initialize arrays with initializer_lists in an initialization list.[/QUOTE] Can you show some code that is failing? Something like this should work:[cpp]struct S { S(std::initializer_list<int>) {} }; S s[2] = {{1, 2, 3}, {4, 5, 6}};[/cpp]
[QUOTE=Dienes;45532844]Can you show some code that is failing? Something like this should work:[cpp]struct S { S(std::initializer_list<int>) {} }; S s[2] = {{1, 2, 3}, {4, 5, 6}};[/cpp][/QUOTE] I'm trying to initialize an array of glm::vec3s with move semantics, so something like this: [cpp]foo(vec3 && a, vec3&& b):array{(std::move(a)), (std::move(b))}{}[/cpp] but I get "cannot specify explicit initializer for arrays"
[QUOTE=WTF Nuke;45537763]I'm trying to initialize an array of glm::vec3s with move semantics, so something like this: [cpp]foo(vec3 && a, vec3&& b):array{(std::move(a)), (std::move(b))}{}[/cpp] but I get "cannot specify explicit initializer for arrays"[/QUOTE] VS2013? then probably [URL="http://connect.microsoft.com/VisualStudio/feedback/details/792161/constructor-initializer-list-does-not-support-braced-init-list-form"]a bug[/URL]. You can use std::array as a workaround. BTW, does glm::vec3 even have a move constructor? I suppose the type will be copied anyway.
[QUOTE=WTF Nuke;45537763]I'm trying to initialize an array of glm::vec3s with move semantics, so something like this: [cpp]foo(vec3 && a, vec3&& b):array{(std::move(a)), (std::move(b))}{}[/cpp] but I get "cannot specify explicit initializer for arrays"[/QUOTE] Try using a second pair of curly braces.
Yeah vs2013. And you are also right, vec3 don't have a move constructor so it doesn't even matter. Out of curiosity, wouldn't adding a move constructor be as simple as assigning the floats with std::move()? I know this won't work with GLM because they are a lot more templated and there's a lot more going on behind the scenes, but if I had my own vec3 class would that be the case? I tried putting curly brackets everywhere and I get the same issue. Actually, is there even a point to moving primitives? Or is the performance increase so negligible, or possibly even non-existent (since I assume you'd have to move the memory address the data refers to, which is as large as an int in most cases).
Move constructors really only matter for resources. Stuff like pointers, handles, etc.
Sorry, you need to Log In to post a reply to this thread.