• What Do You Need Help With? V6
    7,544 replies, posted
I'm going to make a simple graphing calculator program with C++ and Qt, because I want something to do and to learn. This is my first time with Qt. How do I start this project? I'm a little rusty with programming, and I don't know how to begin. Can somebody tell me something to do to start me off on the right track?
QT Creator comes with a bunch of example apps, check them out :)
[QUOTE=Pappschachtel;44382453]QT Creator comes with a bunch of example apps, check them out :)[/QUOTE] Alright, thanks!
[QUOTE=Goz3rr;44380784]I'm using OpenTK too, but you can't free them from the finalizer because by that time the graphics context is invalid, what i'm doing right now: [code][...] ~VertexBuffer() { Debug.Assert(id == 0, this + " leaked!"); } [...][/code][/QUOTE] Have you tested whether this actually stops the program, or is it just for logging? The context isn't invalid [I]by the time the finalizer runs[/I], it's just never valid on that thread. If you want to shut down your program cleanly, you have the choice between disposing everything manually or running GC.Collect() and the flushing a queue.
[QUOTE=anthonywolfe;44381640]Gonna piggy back off of Goz3rr's question here but what are COM objects? Does GC automatically clean them up or do I manually have to release them like unmanaged objects and if so is Marshal.ReleaseComObject really as bad as GC.Collect like I've been hearing?[/QUOTE] It's unmanaged, so you [U]have[/U] to call it or you'll leak memory. If you use an automatic wrapper the situation may be different though. [editline]edit[/editline] It seems the runtime already handles this, so it's probably worse than GC.Collect since it's unsafe.
[QUOTE=Tamschi;44383385]Have you tested whether this actually stops the program, or is it just for logging?[/QUOTE] What do you mean exactly? It'll show a warning if i don't call Dispose, which i'm calling in Window.Unload right now Although it prints this to the output, but doesn't throw any exception or whatever: [code] Sdl2 application quit Disposing context 196608. Disposing OpenTK.Platform.SDL2.Sdl2GraphicsContext (handle: 196608) Disposing OpenTK.Platform.SDL2.Sdl2NativeWindow Disposing OpenTK.Platform.SDL2.Sdl2InputDriver Disposing OpenTK.Platform.SDL2.Sdl2JoystickDriver The thread 0x2960 has exited with code 259 (0x103). The thread 0x24b0 has exited with code 259 (0x103). [OpenTK] OpenTK.Platform.SDL2.Sdl2Factory leaked, did you forget to call Dispose()? OpenTK.Toolkit leaked, did you forget to call Dispose()? OpenTK.Platform.Factory leaked, did you forget to call Dispose()? The program '[10228] TestGame.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'. The program '[10228] TestGame.vshost.exe: Program Trace' has exited with code 0 (0x0). [/code]
[QUOTE=Goz3rr;44389344]What do you mean exactly? It'll show a warning if i don't call Dispose, which i'm calling in Window.Unload right now Although it prints this to the output, but doesn't throw any exception or whatever: [code] Sdl2 application quit Disposing context 196608. Disposing OpenTK.Platform.SDL2.Sdl2GraphicsContext (handle: 196608) Disposing OpenTK.Platform.SDL2.Sdl2NativeWindow Disposing OpenTK.Platform.SDL2.Sdl2InputDriver Disposing OpenTK.Platform.SDL2.Sdl2JoystickDriver The thread 0x2960 has exited with code 259 (0x103). The thread 0x24b0 has exited with code 259 (0x103). [OpenTK] OpenTK.Platform.SDL2.Sdl2Factory leaked, did you forget to call Dispose()? OpenTK.Toolkit leaked, did you forget to call Dispose()? OpenTK.Platform.Factory leaked, did you forget to call Dispose()? The program '[10228] TestGame.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'. The program '[10228] TestGame.vshost.exe: Program Trace' has exited with code 0 (0x0). [/code][/QUOTE] Ah, ok. The finalizer isn't very good for actually halting the program since everything in it is terminated after a few seconds or so. IIrc that's true for dialogues too. I usually try to make a program actually crash if I screw up, but it's slightly impractical when the GC is involved :v:
I've been meaning to get into C# development. In case I don't want to work with MS Studio, should I get SharpDevelop or MonoDevelop on windows?
[QUOTE=marvinelo;44391066]I've been meaning to get into C# development. In case I don't want to work with MS Studio, should I get SharpDevelop or MonoDevelop on windows?[/QUOTE] I'd suggest SharpDevelop, but Visual Studio is the best if you ask me.
Hey folks, so I am trying to write an interface. [QUOTE]Declare an interface Filter as follows: [CODE]public interface Filter { boolean accept(Object x); } [/CODE] Write a method [CODE]public static ArrayList<Object> collectAll(ArrayList<Object> objects, Filter f)[/CODE] that returns all objects in the objects array that are accepted by the given filter. Provide a class ShortWordFilter whose filter method accepts all strings of length < 5. Then write a program that reads all words from System.in, puts them into an Array-List<Object>, calls collectAll, and prints a list of the short words.[/QUOTE] So here's what I got. my main is as follows: [CODE] import java.util.ArrayList; import java.util.Scanner; public class guccibandana { static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { ArrayList<Object> wordList = new ArrayList(); ShortWordFilter f = null; displayWords(wordList); addWords(wordList); ArrayList<Object> filteredList = collectAll(wordList, f); displayFilteredList(filteredList); } public static void addWords(ArrayList<Object> wordList) { System.out.println("How many words would you like to add to the list?"); int size = keyboard.nextInt(); int wordCount = 1; keyboard.nextLine(); for (int i = 0; i < size; i++) { System.out.print(wordCount + "."); wordList.add(keyboard.nextLine()); wordCount++; } } public static void displayWords(ArrayList<Object> wordList) { for (int i = 0; i < wordList.size(); i++) { System.out.println(wordList.get(i)); } } public static ArrayList<Object> collectAll(ArrayList<Object> wordList, ShortWordFilter f) { ArrayList<Object> filteredList = new ArrayList(); for (int i = 0; i < wordList.size(); i++) { if (f.accept(wordList.get(i))) { filteredList.add(wordList.get(i)); } } return filteredList; } public static void displayFilteredList(ArrayList<Object> filteredList) { for (int i = 0; i < filteredList.size(); i++) { System.out.println("Accepted word:"); System.out.println(filteredList.toString()); } } } [/CODE] my class: [CODE]public class ShortWordFilter implements Filter { @Override public boolean accept(Object x) { if (x.toString().length() <= 5) { return true; } else return false; } public interface Filter { boolean accept(Object x); } }[/CODE] the interface [CODE]interface Filter { boolean accept(Object x); } [/CODE] I get a null pointer exception on my collectAll method.
snip
There was this .NET library that allowed you to make REST services easily. I can't remember what the name of it was, does anyone remember? I have been trying to google it but I only get REST clients.
[QUOTE=blacksam;44392001]Hey folks, so I am trying to write an interface. So here's what I got. my main is as follows: [CODE] import java.util.ArrayList; import java.util.Scanner; public class guccibandana { static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { ArrayList<Object> wordList = new ArrayList(); ShortWordFilter f = null; displayWords(wordList); addWords(wordList); ArrayList<Object> filteredList = collectAll(wordList, f); displayFilteredList(filteredList); } public static void addWords(ArrayList<Object> wordList) { System.out.println("How many words would you like to add to the list?"); int size = keyboard.nextInt(); int wordCount = 1; keyboard.nextLine(); for (int i = 0; i < size; i++) { System.out.print(wordCount + "."); wordList.add(keyboard.nextLine()); wordCount++; } } public static void displayWords(ArrayList<Object> wordList) { for (int i = 0; i < wordList.size(); i++) { System.out.println(wordList.get(i)); } } public static ArrayList<Object> collectAll(ArrayList<Object> wordList, ShortWordFilter f) { ArrayList<Object> filteredList = new ArrayList(); for (int i = 0; i < wordList.size(); i++) { if (f.accept(wordList.get(i))) { filteredList.add(wordList.get(i)); } } return filteredList; } public static void displayFilteredList(ArrayList<Object> filteredList) { for (int i = 0; i < filteredList.size(); i++) { System.out.println("Accepted word:"); System.out.println(filteredList.toString()); } } } [/CODE] my class: [CODE]public class ShortWordFilter implements Filter { @Override public boolean accept(Object x) { if (x.toString().length() <= 5) { return true; } else return false; } public interface Filter { boolean accept(Object x); } }[/CODE] the interface [CODE]interface Filter { boolean accept(Object x); } [/CODE] I get a null pointer exception on my collectAll method.[/QUOTE] The problem is:[code]ShortWordFilter f = null;[/code]You never create an instance of ShortWordFilter, instead you pass the null value to collectAll(), which tries to call accept() on it.
[QUOTE=marvinelo;44391066]I've been meaning to get into C# development. In case I don't want to work with MS Studio, should I get SharpDevelop or MonoDevelop on windows?[/QUOTE] Late but monodevelop is awful. SharpDevelop is alright, it has all of the major features you would use in Visual Studio but they are ever so slightly worse. Visual Studio Express is free anyway.
Having an issue with C# System.IO .Read() method. I can't read in numbers because it keeps converting them to their ASCII representations no matter what.
[QUOTE=Rofl my Waff;44397247]Having an issue with C# System.IO .Read() method. I can't read in numbers because it keeps converting them to their ASCII representations no matter what.[/QUOTE] Can you post the code that's not working properly?
keep in mind everything is kind of jumbled because I am debugging and moving things around reading in a 9 with test as an int [IMG]http://i.gyazo.com/fa85159b90502e956057d70bde675e68.png[/IMG] with test as a char [IMG]http://i.gyazo.com/a6a0469cfb3e18d19d34211f0a5cd7ce.png[/IMG] both outputting 57 I've tried some other things too but it's still outputting 57 instead of 9
Try using int.Parse() to transform a string that represents a number into its integer equivalent. Obviously "9" is not an integer, it's ASCII, so int.Parse() will turn it into an integer.
Anyone know about accessing IPMI/BMC from C# or Powershell? Need to gather driver information/firmware levels on quite a few machines in bulk. Any information helps.
I have a strange problem... maybe someone can help me out: I create threads for models which i need to load from HDD. So, this is my main: [CODE] //QT 4.x //#include <QtGui/QApplication> //QT 5.x #include <QApplication> #include "engine.h" int main(int argc, char *argv[]) { qDebug("main start..."); QApplication a(argc, argv); Engine e; e.showDebugWindow(); e.initialize(argc, argv); e.setClearColor(0.3f,0.3f,0.3f,1.0f); e.setWindowSize(600,400); Camera * cam = new Camera(); cam->Z_FAR = 20000.0; cam->translate(0.0,50.0,0.0); cam->rotate_global_post_x(15.0); e.setCamera(cam); Model *m = e.loadModel("E://Code//QTProjects//Engine//Engine//misc//models//space_box.obj"); m->set_scale(1100.0,1100.0,1100.0); m->set_rotation(105.0,0.0,0.0); /* Model *m2 = e.loadModel("E://Code//QTProjects//Engine//Engine//misc//models//box.obj"); m2->set_scale(0.05,0.05,0.05); m2->set_position(200.0,0.0,0.0); */ qDebug("main end..."); return a.exec(); } [/CODE] so the e.loadModel(/*path*/) lines actually load models from disk, if they aren't already loaded... Here is the thread creation a bit deeper hidden in some other classes, but still in the main-thread: [CODE]void Streamer::assignModelListToThread(QList<Model *> model_list){ qDebug() << "Creating new thread..."; QThread* thread = new QThread(); qDebug() << " QApplication's Thread (aka Mainthread): " << QApplication::instance()->thread(); qDebug() << " Current thread: " << QThread::currentThread(); qDebug() << " Thread to move: " << thread; StreamToDisk* worker = new StreamToDisk(model_list); qDebug() << " Worker thread: " << worker->thread(); worker->moveToThread(thread); QObject::connect(worker, SIGNAL(error(QString)), this, SLOT(debugMessage(QString)), Qt::QueuedConnection); QObject::connect(thread, SIGNAL(started()), worker, SLOT(stream()), Qt::QueuedConnection); //here we need a slot for returning the model or so... QObject::connect(worker, SIGNAL(loaded(Model*, unsigned long long)), this, SLOT(streamModelFromDiskFinished(Model*, unsigned long long)), Qt::QueuedConnection); QObject::connect(worker, SIGNAL(finished()),this, SLOT(streamThreadFinished()), Qt::QueuedConnection); QObject::connect(worker, SIGNAL(finished()),thread, SLOT(quit()), Qt::QueuedConnection); QObject::connect(worker, SIGNAL(finished()),worker, SLOT(deleteLater()), Qt::QueuedConnection); QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()), Qt::QueuedConnection); thread->start(); }[/CODE] So... now to the problem. One model in main to load causes no problems. This is the output: [CODE]main start... main end... Creating new thread... QApplication's Thread (aka Mainthread): QThread(0x9bd9d0) Current thread: QThread(0x9bd9d0) Thread to move: QThread(0xa31670) Worker thread: QThread(0x9bd9d0) [/CODE] But two of them (two different, cause if i would load the same model it would just get instanced...) make this: [CODE]main start... main end... Creating new thread... QApplication's Thread (aka Mainthread): QThread(0x61d9d0) Current thread: QThread(0x61d9d0) Thread to move: QThread(0x6916a0) Worker thread: QThread(0x61d9d0) Creating new thread... QApplication's Thread (aka Mainthread): QThread(0x61d9d0) Current thread: QThread(0x61d9d0) Thread to move: QThread(0x691790) Worker thread: QThread(0x61d9d0) QObject::moveToThread: Current thread (0x6916a0) is not the object's thread (0x691790). Cannot move to target thread (0x61d9d0) QObject::moveToThread: Current thread (0x6916a0) is not the object's thread (0x691790). Cannot move to target thread (0x61d9d0)[/CODE] or this (which is fine): [CODE]main start... main end... Creating new thread... QApplication's Thread (aka Mainthread): QThread(0x5ad9d0) Current thread: QThread(0x5ad9d0) Thread to move: QThread(0x6216a0) Worker thread: QThread(0x5ad9d0) Creating new thread... QApplication's Thread (aka Mainthread): QThread(0x5ad9d0) Current thread: QThread(0x5ad9d0) Thread to move: QThread(0x621790) Worker thread: QThread(0x5ad9d0) [/CODE] either way, the program is still running and after both runs i have the same result: everything runs as it should, but i get this error or not ... i am confused... this only happens if i load the models directly in the main and more than one... EDIT: It seems like QT somehow switches threads and trys to move my object within a different thread's context (in this example 2 times) and actually switched back and succeeded ... ???
So I have been learning opengl, but I am having problems with shaders. On this website: [url]http://open.gl/drawing[/url] he talks about using GLSL, starting with [code]#version 150[/code], but is this in visual studio?
[QUOTE=robanator1617;44402114]So I have been learning opengl, but I am having problems with shaders. On this website: [url]http://open.gl/drawing[/url] he talks about using GLSL, starting with [code]#version 150[/code], but is this in visual studio?[/QUOTE] this is in GLSL it's openGL's shading language.
[QUOTE=Pappschachtel;44402133]this is in GLSL it's openGL's shading language.[/QUOTE] Thanks for the reply, but what is the extension? And how do I compile it with my c++ code?
My raytracer appears to have a fairly big issue, the reflected vectors are wrong and I only recently noticed. [IMG_THUMB]http://i.imgur.com/w3ht0B2.png[/IMG_THUMB] Red indicates the reflected vector is hitting the nothingness behind the camera whereas blue indicates it's hitting the plane behind the sphere. If anyone knows what I am doing great, as an example here are some values. (-0.002887, 0.988774, 0.14939) is the orginal direction vector, the normal on the intersection is (-0.0708854, -0.1177825, 0.981506) and then the reflected direction vector I calculate is (-0.0113665, 0.989590, 0.208290). I do not see how the reflected vector can have a positive y component, eg toward the plane, that shouldn't be possible as far as I can tell. I am finding the reflected vector by d - 2*d.n*n where d is the original direction and n is the normal. All vectors are normalized.
[QUOTE=robanator1617;44402193]Thanks for the reply, but what is the extension? And how do I compile it with my c++ code?[/QUOTE] you compile it during runtime via openGL calls. glShaderSource and glCompileShader might help you.
[QUOTE=ben1066;44402210]My raytracer appears to have a fairly big issue, the reflected vectors are wrong and I only recently noticed. [IMG_THUMB]http://i.imgur.com/w3ht0B2.png[/IMG_THUMB] Red indicates the reflected vector is hitting the nothingness behind the camera whereas blue indicates it's hitting the plane behind the sphere. If anyone knows what I am doing great, as an example here are some values. (-0.002887, 0.988774, 0.14939) is the orginal direction vector, the normal on the intersection is (-0.0708854, -0.1177825, 0.981506) and then the reflected direction vector I calculate is (-0.0113665, 0.989590, 0.208290). I do not see how the reflected vector can have a positive y component, eg toward the plane, that shouldn't be possible as far as I can tell. I am finding the reflected vector by d - 2*d.n*n where d is the original direction and n is the normal. All vectors are normalized.[/QUOTE] What is d.n?
[QUOTE=Pappschachtel;44402241]you compile it during runtime via openGL calls. glShaderSource and glCompileShader might help you.[/QUOTE] What extension are glsl files?
-snip nevermind-
[QUOTE=robanator1617;44402273]What extension are glsl files?[/QUOTE] you can name them like you want, its just a sequence of chars which you can load from files if you want.
[QUOTE=Pappschachtel;44402295]you can name them like you want, its just a sequence of chars which you can load from files if you want.[/QUOTE] I'm really trying to understand this, but I don't know what hes doing with the shaders here, do you have any idea? [url]http://open.gl/drawing[/url]
Sorry, you need to Log In to post a reply to this thread.