I'm looking to make some cross-platform GUI applications. So far I've found Qt to be the most recommended, and from what I can see, it seems damn good. Does anybody have experience with it/this issue, and would it be a good choice?
[QUOTE=account;39401610]I'm looking to make some cross-platform GUI applications. So far I've found Qt to be the most recommended, and from what I can see, it seems damn good. Does anybody have experience with it/this issue, and would it be a good choice?[/QUOTE]
I use Qt all the time and I really like it. Although you would need to either use their QtCreator IDE or use the Visual Studio plugin, or else you will have to do a lot of stuff manually.
Anyone familiar with coding with RFID devices?
What reason could my program (c++ compiled in mingw) have to not work properly when launched from the exe in windows, but then work fine when launched from mingw?
video showing what I mean:
[vid]https://dl.dropbox.com/u/17738517/Videos/wtf.webm[/vid]
I've been having some problems with my Android app, with it crashing right after startup, and even crashing the installer on my phone (then complaining it isn't installed)
I ran it with DDMS, and got this back:
[code]01-29 12:26:54.071: E/AndroidRuntime(1309): FATAL EXCEPTION: main
01-29 12:26:54.071: E/AndroidRuntime(1309): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.radnorge/com.example.radnorge.RadiationMainActivity}: android.os.NetworkOnMainThreadException
01-29 12:26:54.071: E/AndroidRuntime(1309): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
01-29 12:26:54.071: E/AndroidRuntime(1309): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-29 12:26:54.071: E/AndroidRuntime(1309): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-29 12:26:54.071: E/AndroidRuntime(1309): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-29 12:26:54.071: E/AndroidRuntime(1309): at android.os.Handler.dispatchMessage(Handler.java:99)
01-29 12:26:54.071: E/AndroidRuntime(1309): at android.os.Looper.loop(Looper.java:137)
01-29 12:26:54.071: E/AndroidRuntime(1309): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-29 12:26:54.071: E/AndroidRuntime(1309): at java.lang.reflect.Method.invokeNative(Native Method)
01-29 12:26:54.071: E/AndroidRuntime(1309): at java.lang.reflect.Method.invoke(Method.java:511)
01-29 12:26:54.071: E/AndroidRuntime(1309): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-29 12:26:54.071: E/AndroidRuntime(1309): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-29 12:26:54.071: E/AndroidRuntime(1309): at dalvik.system.NativeStart.main(Native Method)
01-29 12:26:54.071: E/AndroidRuntime(1309): Caused by: android.os.NetworkOnMainThreadException
01-29 12:26:54.071: E/AndroidRuntime(1309): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
01-29 12:26:54.071: E/AndroidRuntime(1309): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
01-29 12:26:54.071: E/AndroidRuntime(1309): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
01-29 12:26:54.071: E/AndroidRuntime(1309): at java.net.InetAddress.getAllByName(InetAddress.java:214)
01-29 12:26:54.071: E/AndroidRuntime(1309): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
01-29 12:26:54.071: E/AndroidRuntime(1309): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
01-29 12:26:54.071: E/AndroidRuntime(1309): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
01-29 12:26:54.071: E/AndroidRuntime(1309): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
01-29 12:26:54.071: E/AndroidRuntime(1309): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
01-29 12:26:54.071: E/AndroidRuntime(1309): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)
01-29 12:26:54.071: E/AndroidRuntime(1309): at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)
01-29 12:26:54.071: E/AndroidRuntime(1309): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
01-29 12:26:54.071: E/AndroidRuntime(1309): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
01-29 12:26:54.071: E/AndroidRuntime(1309): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
01-29 12:26:54.071: E/AndroidRuntime(1309): at com.example.radnorge.RadiationMainActivity.onCreate(RadiationMainActivity.java:33)
01-29 12:26:54.071: E/AndroidRuntime(1309): at android.app.Activity.performCreate(Activity.java:5104)
01-29 12:26:54.071: E/AndroidRuntime(1309): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-29 12:26:54.071: E/AndroidRuntime(1309): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-29 12:26:54.071: E/AndroidRuntime(1309): ... 11 more
[/code]
The code in question here, is supposed to load an XML file from [url]http://radnett.nrpa.no/radnett.xml[/url] for later parsing.
[cpp]xml_url = new URL("http://radnett.nrpa.no/radnett.xml");
URLConnection ucon = xml_url.openConnection();
ucon.connect();
InputStream radiaton_xml = xml_url.openStream();[/cpp]
[QUOTE=Bloodsh0t;39400418]Does anyone know of a place where i can learn about code and project formatting? How to name variables, how to use headers and general coding ethics. I feel i get lost in my own code sometimes because i havent placed my things properly. Basically I want to get better structure in my projects.
Currently reading c++[/QUOTE]
Not sure f this is what you meant but for stuff like naming conventions and such check out the idTech standards, of course there are somethings that just wont apply [url]ftp://ftp.idsoftware.com/idstuff/doom3/source/CodeStyleConventions.doc[/url]
[QUOTE=Bloodsh0t;39400418]Does anyone know of a place where i can learn about code and project formatting? How to name variables, how to use headers and general coding ethics. I feel i get lost in my own code sometimes because i havent placed my things properly. Basically I want to get better structure in my projects.
Currently reading c++[/QUOTE]
Try to format your code according to a set of rules you set for yourself — do it however seems most natural to you. Read an article or two about code style, and go with what you find makes most sense. Over time, you'll develop your own style.
Oh and I'm sure you've heard this before, but the key is to be consistent.
In Ruby, let's say I've got a method #x defined on most classes, but not all.
What would be the easiest way to define #y for those which have #x defined?
[QUOTE=Z_guy;39401857]I use Qt all the time and I really like it. Although you would need to either use their QtCreator IDE or use the Visual Studio plugin, or else you will have to do a lot of stuff manually.[/QUOTE]
Yeah, I was planning on using their IDE so I can still compile with gcc, hopefully. Thanks!
[QUOTE=Mozartkugeln;39403079]Try to format your code according to a set of rules you set for yourself — do it however seems most natural to you. Read an article or two about code style, and go with what you find makes most sense. Over time, you'll develop your own style.
Oh and I'm sure you've heard this before, but the key is to be consistent.[/QUOTE]
Oh okay, thanks.
[QUOTE=Liquid Helium;39402522]What reason could my program (c++ compiled in mingw) have to not work properly when launched from the exe in windows, but then work fine when launched from mingw?
video showing what I mean:
[vid]https://dl.dropbox.com/u/17738517/Videos/wtf.webm[/vid][/QUOTE]
I assume you're loading that image from a relative string, you need to pass it an absolute, or work relative to the exe.
[QUOTE=Topgamer7;39405362]I assume you're loading that image from a relative string, you need to pass it an absolute, or work relative to the exe.[/QUOTE]
I'm pretty sure you are right, but how do you supply relative paths in c++?
If I do this
[cpp]
std::ifstream fileStream("./resources/shader.frag");
if (!fileStream.is_open()){
std::cout << "Error";
}
[/cpp]
It runs fine from the terminal, but when I double click the executable it prints Error (on my mac now) what am I missing? same thing happens for "resources/shader.frag", ".\\resources\\shader.frag" and "resources\\shader.frag"
[QUOTE=Liquid Helium;39407248]I'm pretty sure you are right, but how do you supply relative paths in c++?
If I do this
[cpp]
std::ifstream fileStream("./resources/shader.frag");
if (!fileStream.is_open()){
std::cout << "Error";
}
[/cpp]
It runs fine from the terminal, but when I double click the executable it prints Error (on my mac now) what am I missing? same thing happens for "resources/shader.frag", ".\\resources\\shader.frag" and "resources\\shader.frag"[/QUOTE]
in your if statement, load the stream to ../resources/shader.frag
[QUOTE=Gulen;39402812]I've been having some problems with my Android app, with it crashing right after startup, and even crashing the installer on my phone (then complaining it isn't installed)
I ran it with DDMS, and got this back:
-snip-
The code in question here, is supposed to load an XML file from [url]http://radnett.nrpa.no/radnett.xml[/url] for later parsing.
[cpp]xml_url = new URL("http://radnett.nrpa.no/radnett.xml");
URLConnection ucon = xml_url.openConnection();
ucon.connect();
InputStream radiaton_xml = xml_url.openStream();[/cpp][/QUOTE]
Solved it, turns out Android isn't a fan of running connections in it's main thread.
I don't need help with anything! Posted in the wrong thread, someone please remove this if possible.
I am completely new to programming other than a bit of visual basic but I am looking to make a basic platform game for a college assignment. It doesn't need to be perfect and I have a year and a half to get it done so hopefully I should have time to learn. What programming language would you guys recommend?
[QUOTE=squids_eye;39413738]I am completely new to programming other than a bit of visual basic but I am looking to make a basic platform game for a college assignment. It doesn't need to be perfect and I have a year and a half to get it done so hopefully I should have time to learn. What programming language would you guys recommend?[/QUOTE]
I think C++ is generally considered the industry standard for games. Java would also be a good option since it's cross platform and more strictly object-oriented, which I feel helps keep the code pure.
[QUOTE=account;39413758]I think C++ is generally considered the industry standard for games. Java would also be a good option since it's cross platform and more strictly object-oriented, which I feel helps keep the code pure.[/QUOTE]
Kiiind of - it seems that a whole lot of game programming is done in C# nowadays, and Microsoft apparently wants pretty much everything to be managed = .NET
[editline]30th January 2013[/editline]
And C# is the [I]de facto[/I] standard language for .NET so you'll probably find plenty of opportunities to use it.
[QUOTE=account;39413758]I think C++ is generally considered the industry standard for games. Java would also be a good option since it's cross platform and more strictly object-oriented, which I feel helps keep the code pure.[/QUOTE]
I've heard that C++ is difficult to learn. Would learning Java be easier or have I been misinformed?
[QUOTE=squids_eye;39413873]I've heard that C++ is difficult to learn. Would learning Java be easier or have I been misinformed?[/QUOTE]
Learning is "difficult". You can learn either, just try to maintain your dedication. I find learning C++ teaches you quite a lot more lower level knowledge. Which I feel isn't a bad thing.
[QUOTE=squids_eye;39413873]I've heard that C++ is difficult to learn. Would learning Java be easier or have I been misinformed?[/QUOTE]
Are you going to learn a programming language as a part of a class, or in a class in the future or something? If so, use that one.
[editline]30th January 2013[/editline]
If not, C++ is a good one or simply whatever's easiest for you. I want to say Python because there's so many good resources for learning it (Udacity, Codecademy!)
So the general consensus is C++? If so, I would be grateful if someone could direct me towards some good learning resources.
Good day. I have a programming related problem.
I have to create a program which asks for national identification number, reads every digit and gives information about sex, date of birth and name of the hospital where the person was registered in. Then it uses some algorithm and determines whether the number is valid.
Now I have done everything. It can read the number and tell the information. However, I thought "Why not go further ?" So far it simply asked the code and told you the information.
Say the code is 39214212713. The program would then reply that
Person is male and born in 20th century. This is determined by 1st digit.
Born (DD/MM/YYYY): 21.14.1992
Where : in some hospital (no point in names at the moment)
And that the code is invalid. Even if the date were correct it'd be invalid.
Now I thought it would be clever if I could make a loop so if the NIN isn't 11 digits long OR the first digit isnt 00 < X < 7 OR the month isn't 00 < X < 13 OR date isn't 00 < X < 31 it would ask for the number again.
Here :
[code]
// All the ints and strings have been declared. Headers have been added
do {
std::cout << "Enter ID yadda yadda yadda";
std::getline(std::cin, kood); // String
n1 = atoi (kood.substr (0,1).c_str()); // I start separating numbers from the whole string to do the comparisons later.
n2_3 = atoi (kood.substr (1,2).c_str()); // Number for the last 2 numbers of year
n4_5 = atoi (kood.substr (3,2).c_str()); // Number for the month.
n6_7 = atoi (kood.substr (5,2).c_str()); // Number for the date.
} while ((kood.length() != 11) || (n1>6 || n1<1) || (n6_7 > 31 || n6_7 < 1) || (n4_5 > 12 || n4_5 < 1));
// SO. If code isnt 11 digits long
//OR first number isnt 1-6
//OR number which marks the date isn't 01-31
//OR number which marks the month isn't 01-12, it will loop.
[/code]
The kood.length () part doesn't really work. Or rather it works sometimes.
If the ID number entered is longer than 11 digits it will loop. If it is less than 11 digits it will loop UNLESS !!! it is less than 5 digits long - then it will crash.
So in conclusion if I enter 112 or 12 or 1923 or 8 - it will crash.
It's really bizarre and I can't figure out why it crashes only then.
Debug output :
[code]
'kt_3_4.exe': Loaded 'C:\Users\mart\Documents\Visual Studio 2010\Projects\kt_3_4\Debug\kt_3_4.exe', Symbols loaded.
'kt_3_4.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'kt_3_4.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'kt_3_4.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'kt_3_4.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'kt_3_4.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
First-chance exception at 0x755c812f in kt_3_4.exe: Microsoft C++ exception: std::out_of_range at memory location 0x0014f290..
Unhandled exception at 0x755c812f in kt_3_4.exe: Microsoft C++ exception: std::out_of_range at memory location 0x0014f290..
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
The thread 'Win32 Thread' (0x8e8) has exited with code -1073741510 (0xc000013a).
The program '[616] kt_3_4.exe: Native' has exited with code -1073741510 (0xc000013a).
[/code]
I'd appreciate the help and I'm sorry for so fucking long post.
So I have to make a guitar tuner app for Android. Never worked in Android before. Anybody have a good resource for this? I've looked into it a bit and I think we will have to do a Fourier Transform to get frequencies and shit.
Could someone recommend an app for the quick creation of algorithm flowcharts?
[QUOTE=valiant1k;39414461]-snip snip, long post -[/QUOTE]
Ok, this one took me a little while to figure out, but when I did, it's really simple. I'll try and explain to you why what you did was wrong, instead of just telling you what to do to fix it.
Words, or strings, are just a collection of characters, right? Well, that's how it is in C++ as well. A string is really a char array (there's probably a lot of other differences between the two, but I'm trying to keep it simple here), so instead of having that string, you COULD do this:
[cpp]char mychar[11] = "39214212713";[/cpp]
Now, if I were to run substr(5,2), it'd look at the characters at mychar[5] and mychar[6], put them together into a string and give it back to you. Now, let's say you don't have mychar[5] and mychar[6], that the user only entered "3921", then mychar[5] and mychar[6] wouldn't exist, and substr has no idea what to do, and crashes.
So, to fix this, just put some ifs around your code.
[cpp]
if(kood.length() < 5){
continue;
} else {
n1 = atoi (kood.substr (0,1).c_str()); // I start separating numbers from the whole string to do the comparisons later.
n2_3 = atoi (kood.substr (1,2).c_str()); // Number for the last 2 numbers of year
n4_5 = atoi (kood.substr (3,2).c_str()); // Number for the month.
n6_7 = atoi (kood.substr (5,2).c_str()); // Number for the date.
}[/cpp]
continue; basically tells the loop to skip whatever is after this, and run the loop again, so the "else" isn't technically needed there. Of course, if you have to use the numbers after this, like you for some reason have to use the last 4 numbers, you can just do
[cpp] if(kood.length() < 11)[/cpp]
Instead.
[QUOTE=Gulen;39415213]-Helpful post-[/QUOTE]
That is fantastic. Thank you so much.
Though why didn't it crash when I entered 5 digits. substr (5,2) starts from 6'th digit, shouldn't it have crashed then too?
[QUOTE=Gulen;39415213]snip[/QUOTE]
man I'm so sad because that's what I thought the issue was but I'm always too worried about looking dumb
[QUOTE=valiant1k;39415402]Though why didn't it crash when I entered 5 digits. substr (5,2) starts from 6'th digit, shouldn't it have crashed then too?[/QUOTE]
Anything involving memory you haven't allocated [i]might[/i] work. Improperly. If you're lucky.
Basically what happens when you read past your allocated memory is undefined and depends on your platform and luck.
[editline]30th January 2013[/editline]
Wait, no, if substr cares about the terminating null-byte then it just read that one \0 instead
C++ question:
Say I wanted this struct MenuItem
[cpp]class Menu {
public:
enum MenuResult { Exit, Options, Back, ChangeResolution, Play, Nothing };
struct MenuItem {
public:
sf::IntRect buttonrect;
MenuResult action;
};
MenuResult showMMenu(sf::RenderWindow &window);
MenuResult showOMenu(sf::RenderWindow &window);
MenuResult highlightButton(MenuResult menuresult);
private:
MenuResult getMenuResponse(sf::RenderWindow &window);
MenuResult handleClick(int x, int y);
Menu::MenuResult Menu::handleButtonHover(sf::RenderWindow &window, MenuItem text, int x, int y);
std::list<MenuItem> menuItems;
};
[/cpp]
to be able to share the functions of another class, Text
[cpp]class Text {
public:
...
void highlightRectOutline(sf::RenderWindow &window, Text txt, sf::Color color);[/cpp]
The reason for this is because I want to be able to highlight the outline of the menuitem. Or will I just need to create a duplicate function for the MenuItem class?
Sorry, you need to Log In to post a reply to this thread.