• What Do You Need Help With? V6
    7,544 replies, posted
I'm not sure where would be executing periodically in this code tbh ha.
You could just add an infinite loop somewhere.
So after whipping up my old engine I ran into a problem with the new GLFW3 version: [code]1>GLFW3.lib(gamma.obj) : error LNK2019: unresolved external symbol __libm_sse2_pow_precise referenced in function _glfwSetGamma[/code] Does anyone know a solution to this? It's the only linker error I get after I fixed the rest, but can't manage to figure this one out.. There's no sign of it anywhere either according to google.
Did you compile the library yourself or did you use a pre-compiled version? The pre-compiled version might not be ABI compatible with the VS run-time. You might need libm from MinGW or Cygwin or compile GLFW in VS (or look for a pre-compiled version compiled with VS).
[QUOTE=ZeekyHBomb;41482286]Did you compile the library yourself or did you use a pre-compiled version? The pre-compiled version might not be ABI compatible with the VS run-time. You might need libm from MinGW or Cygwin or compile GLFW in VS (or look for a pre-compiled version compiled with VS).[/QUOTE] Yep, you're right. I tried compiling it myself and it worked wonders. Thanks. Now to fix the rest of the huge amount of bugs coming from the GLFW3 version, lol.
I'm working with Visual C++ .NET and am looking to HTTP-fetch some JSON and parse it. What JSON parser do you guys recommend? I'm only looking to read JSON, not write. Also, any tips on multi-threading that will enable me to update the main form thread? Thanks!
C++ .NET? You mean C++/CLI? Or just 'plain' C++ and your IDE is Visual Studio?
Yeah C++/CLI, my bad
Weird, I thought it was just being used to interface with .NET APIs from C++ projects or writing "proper" interfaces (without P/Invoke) to C or C++ libraries without porting the entire code base. Anyways, [url=http://www.json.org/]json.org[/url] has a big list of bindings. There's no C++/CLI, but I presume you can use either the C++, C# or Visual Basic ones. That list doesn't mention that [url=http://www.boost.org/doc/libs/1_54_0/doc/html/boost_propertytree/parsers.html#boost_propertytree.parsers.json_parser]Boost also has a JSON parser[/url].
Thanks, I went with jansson. Too bad it's complaining that I'm feeding it a String^ when it wants a const char * If you can't tell I'm really bad at C++
[QUOTE=Banana Lord.;41488216]Thanks, I went with jansson. Too bad it's complaining that I'm feeding it a String^ when it wants a const char * If you can't tell I'm really bad at C++[/QUOTE] Just convert the std::string to a C string (that is, a char *) with the [url=http://en.cppreference.com/w/cpp/string/basic_string/c_str]std::string::c_str()[/url] method as you pass it in.
std::string is not the same as a .NET String. Use [url=http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.stringtohglobalansi.aspx]Marshal::StringToHGlobalAnsi[/url] and reinterpret_cast the pointer to char*. You need to free the memory with [url=http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.freehglobal.aspx]Marshal::FreeHGlobal[/url]. You can convert the char* back to String^ via [url=http://msdn.microsoft.com/en-us/library/7b620dhe.aspx]Marshal::PtrToStringAnsi[/url].
Hey Zeeky I just made a while(true) loop and put an if statement in it to print a messagebox if the debugger is attached. I just said [CODE] if (System.Diagnostics.Debugger.IsAttached) MessageBox.Show("Debugger is attached");[/CODE] However, I also put a if statement before I even attach a debugger, and I have checked if the w3wp process is running and it's not, and it still prints out a messagebox saying the debugger is attached. What do you think could cause this?
That property is true when a debugger is attached to this process, not if the Visual Studio Debugger is attached to anything. You can find a list of processes the debugger is attached to via the [url=http://msdn.microsoft.com/en-us/library/vstudio/envdte.debugger.debuggedprocesses.aspx]DebuggedProcesses[/url] property of EnvDTE.Debugger (so the _applicationObject.Debugger instance, not System.Diagnostics.Debugger).
Guys I'm writing a midpoint displacement algorithm, which outputs a nice 2D terrain, but the terrain doesn't tend towards the end vertice, it seems to just end up at a random spot at the end of the graph. [code] float[] PlasmaLine(int StartArPos, int EndArPos, float[] vertices, Random r, int itterations) { float Ave = (vertices[StartArPos]+vertices[EndArPos])/2; //find average of two ends int MidArPos = (int) Math.floor((StartArPos+EndArPos)/2); //find array value between two vertices[MidArPos] = Ave + ((r.nextFloat() - 0.5f)/(1+itterations*2)); //adjust its Y value according to the average System.out.print(Ave +"\n"); if((EndArPos-StartArPos) > 2) //check if you've reach array resolution { //store the array value PlasmaLine(StartArPos, MidArPos, vertices, r, itterations+1); //call function PlasmaLine with (Start and newValue) PlasmaLine(MidArPos,EndArPos, vertices, r, itterations+1); //call function PlasmaLine with (newValue and End) } return vertices; } [/code] If I set my start vertex to 1 and end vertex to 0, then the graph should jump arround but tend towards 0 right?
[QUOTE=ZeekyHBomb;41490751]That property is true when a debugger is attached to this process, not if the Visual Studio Debugger is attached to anything. You can find a list of processes the debugger is attached to via the [url=http://msdn.microsoft.com/en-us/library/vstudio/envdte.debugger.debuggedprocesses.aspx]DebuggedProcesses[/url] property of EnvDTE.Debugger (so the _applicationObject.Debugger instance, not System.Diagnostics.Debugger).[/QUOTE] Yeah I actually tried that just before you replied! Thanks for all the help with this, you the man. All I need to do now is make a toggleable button so that when the button is first pressed, the process is attached, and when the button is pressed again, the process is detached, hopefully that shouldn't be too hard :)
[QUOTE=The Sparrow;41491042]Guys I'm writing a midpoint displacement algorithm, which outputs a nice 2D terrain, but the terrain doesn't tend towards the end vertice, it seems to just end up at a random spot at the end of the graph. [code] float[] PlasmaLine(int StartArPos, int EndArPos, float[] vertices, Random r, int itterations) { float Ave = (vertices[StartArPos]+vertices[EndArPos])/2; //find average of two ends int MidArPos = (int) Math.floor((StartArPos+EndArPos)/2); //find array value between two vertices[MidArPos] = Ave + ((r.nextFloat() - 0.5f)/(1+itterations*2)); //adjust its Y value according to the average System.out.print(Ave +"\n"); if((EndArPos-StartArPos) > 2) //check if you've reach array resolution { //store the array value PlasmaLine(StartArPos, MidArPos, vertices, r, itterations+1); //call function PlasmaLine with (Start and newValue) PlasmaLine(MidArPos,EndArPos, vertices, r, itterations+1); //call function PlasmaLine with (newValue and End) } return vertices; } [/code] If I set my start vertex to 1 and end vertex to 0, then the graph should jump arround but tend towards 0 right?[/QUOTE] Yeah, looks like it. I think you unintentionally randomize some vertices though if you call it with an even number of vertices. In the case of Start = 0 and End = 3, Mid is 1, so you call PlasmaLine with 0 and 1 as Start and End, which causes Mid to be 0. In the case of Start = 0 and End = 6, you randomize 0 also and 3 twice I think.
I've recently gotten SFML and begun working with it. Although I've had C++ programming for four years on my previous college, I've not done it for a year, so it took a bit getting back into things. I got SFML working with the dynamically linked DLLs, and managed to compile the basic shape-drawing program and got it all to work. I set up my gamestate switch, and made a testclass to test some drawing and stuff, going through the tutorials on the SFML website. However, for some reason I just cannot get stuff to draw to the screen. Perhaps you guys can see what's wrong? Here's the main: [code]int main() { gamestate = GAMESTATE_GAME; loadGraphics(); ship.Init(200,200); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); } switch(gamestate){ case GAMESTATE_INTRO: window.clear(); window.display(); break; case GAMESTATE_MAINMENU: window.clear(); window.display(); break; case GAMESTATE_GAME: window.clear(); ship.Handle(); ship.Draw(); window.display(); break; case GAMESTATE_PAUSE: window.clear(); window.display(); break; } } return 0; }[/code] And the testclass Draw() function. [code]void testClass::Draw(){ if (drawActive){ std::cout << "Drawing bananaship at: " << posX << "," << posY << std::endl; sprBananaShip.setOrigin(28,28); sprBananaShip.move(posX,posY); testShape.setOrigin(50.f,50.f); testShape.move(posX,posY); testShape.setFillColor(sf::Color::Red); window.draw(sprBananaShip); window.draw(testShape); } }[/code] I first tested it with a sprite, but after that failed I tried it with a shape. Both the sprite and shape are defined elsewhere, and I can confirm the sprite loads just fine (after I changed the working directory and whatnot). The program compiles, and the std::cout prints that the function is being handled, and that the bananaShip should be drawn at 200,200, but the screen remains black. Using SFML 2.0 on Visual Studio 2012.
If I'm doing [code] std::unique_ptr< Potion::StateManager > game( new Potion::StateManager() ); [/code] So I'd create a smart pointer on the stack and the object of StateManager on the heap, it will delete itself and the contained object at the end of the smart ptr's scope. What's the difference between doing this and simply creating the object of StateManager on the stack? It would delete itself at the end too, right?
[QUOTE=Asgard;41491585]If I'm doing [code] std::unique_ptr< Potion::StateManager > game( new Potion::StateManager() ); [/code] So I'd create a smart pointer on the stack and the object of StateManager on the heap, it will delete itself and the contained object at the end of the smart ptr's scope. What's the difference between doing this and simply creating the object of StateManager on the stack? It would delete itself at the end too, right?[/QUOTE] The purpose of smart pointers is to pass the objects to outside the scope it's created in, you don't really need them if you can use the stack instead.
That's not the purpose of smart pointers. That's one of the purposes of heap memory. You might have meant that, but your sentence is very imprecise. You can basically use smart pointers where ever you have been using raw pointers before. But just keep on using the stack where you've been using the stack before.
Anybody who knows about C# plugins. My plugin seems to work, however, when I press the button to do it, it gets grayed out and I can't use it again unless I stop visual studio and restart it. Any ideas how I can make it so when I press the button once, it does some stuff, and when I press it again, it does something else? Like a start and stop button. Also how would you make the button sort of indent so it looks like its been pushed in to show its in use, and then un-indent when its pressed again. I basically want to attach my process on the button press and then detach it when it's pressed again.
[QUOTE=Over-Run;41491727]Anybody who knows about C# plugins. My plugin seems to work, however, when I press the button to do it, it gets grayed out and I can't use it again unless I stop visual studio and restart it. Any ideas how I can make it so when I press the button once, it does some stuff, and when I press it again, it does something else? Like a start and stop button. Also how would you make the button sort of indent so it looks like its been pushed in to show its in use, and then un-indent when its pressed again. I basically want to attach my process on the button press and then detach it when it's pressed again.[/QUOTE] Well, you could set a variable? And then on the click event, check what the current state of the variable is, do the appropriate action, and then change the variable to something else. Also, the greyed out stuff is caused by the Button.Enabled variable, it's set to false. And the "indent", I'm not sure, maybe when you check the variable and have it do something, also do some paint effects or something like that.
Hmm, well when I went into Visual Studio to make the plugin, it generated random code. It looks like they are using some Command thing as the button? [CODE] if (connectMode == ext_ConnectMode.ext_cm_UISetup) { object[] contextGUIDS = new object[] { }; Commands2 commands = (Commands2)_applicationObject.Commands; Microsoft.VisualStudio.CommandBars.CommandBar standardToolBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["Project"]; try { Command command = commands.AddNamedCommand2(_addInInstance, "AttachProcess", "Attach Process...", "Executes the command for AttachProcess", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); if ((command != null) && (standardToolBar != null)) { CommandBarControl ctrl =(CommandBarControl)command.AddControl(standardToolBar, 1); ctrl.TooltipText = "Executes the command for AttachProcess"; } } catch (System.ArgumentException) { }[/CODE] Can I just add a button there instead of a Command?
Does anyone know why a QTreeWidget's tab order goes down the children without going across each child's columns first? I want: [1][2][3] [4][5][6] ... Qt does: [1][ ][ ] [2][ ][ ] [3][ ][ ] ... I've scoured google and duckduckgo, and the QTreeWidget and QTreeWidgetItem class references on the Qt project site and I'm still coming up with nothing standard to implement this. The best I can see is to set up a filter which catches key events and manually implements tab ordering, and I would like to avoid this. I'm using pyqt4 with python3 and qt4-designer for the UI.
I'm guessing that this is just what most other toolkits do? I would have thought that using tab would go outside the TreeWidget and select the next one and instead would use the arrow keys to browse the tree. Anyways, [url=http://pyqt.sourceforge.net/Docs/PyQt4/qwidget.html#setTabOrder]QWidget.setTabOrder[/url] probably won't work since QTreeWidgetItems are not QWidgets (this makes me more surprised that tabbing works in a TreeWidget). Filtering events would be one possibility, but it would seem more natural to me if you'd subclass QTreeWidget and override the event handler.
[QUOTE=ZeekyHBomb;41495467]I'm guessing that this is just what most other toolkits do? I would have thought that using tab would go outside the TreeWidget and select the next one and instead would use the arrow keys to browse the tree. Anyways, [url=http://pyqt.sourceforge.net/Docs/PyQt4/qwidget.html#setTabOrder]QWidget.setTabOrder[/url] probably won't work since QTreeWidgetItems are not QWidgets (this makes me more surprised that tabbing works in a TreeWidget). Filtering events would be one possibility, but it would seem more natural to me if you'd subclass QTreeWidget and override the event handler.[/QUOTE] You can set selection to be by item, instead of by row, and then use the arrow keys to move around, but this requires that you hit enter before you move through a row, otherwise you are still in edit mode and it thinks you are just trying the move the cursor about. I'm not sure it is so important right now that I'm about to muck around with handling the events myself (although if it is an issue that may be what I end up doing). Thanks, and if anyone knows of a simpler way I'd really appreciate it.
More Lua stuff. This is probably a dumb question but I don't know what I'm doing so most of the things I say will probably be dumb anyway. I've got two bits of code and I'm trying to make one call the other one, but I'm not sure if this will actually work. First: [code]-------------------------- -- Event fires if message is recieved -------------------------- function frmEventFrame:CHAT_MSG_WHISPER(event, ...) -- event triggers when user recieves a message -- Gets information about the whisper -- We only care about sender and the message message, sender, _, _, _, _, _, _, _, _, _, _ = ... -- Now we scan the message for the keywords listed above -- This will call another function I still need to write -- code code code --Then we call function Reply Reply(playerName) --? end [/code] second [code]------------------------- -- This will send the auto reply if there's been enough time ------------------------- function Reply(playerName) -- Make sure at least ten seconds have passed and then send reply. If not ten seconds, wait and then send. local nCurrentTime = GetTime(); if (nCurrentTime - nLastMsgTime >= 10) then --send reply nLastMsgTime = nCurrentTime else --stall and then send after 10s nLastMsgTime = nCurrentTime end end [/code] So theoretically the first event fires, then it calls one function (which I haven't written yet) and then it will call the Reply function. (The one I haven't written yet will basically determine the text of the reply, I'm not sure if I should call Reply from within THAT function or if doing it this way is fine) Either way, is this how you call functions from within other ones? it's how i'd do it in c++. [editline]17th July 2013[/editline] also i need to figure out how to suspend a code for x amount of time and then execute it but that will happen later
Your function-call syntax is correct. You cannot suspend the code for an amount of time (unless you want to stall, like while(GetTime() < nCurrentTime + 10) do end, but I'm guessing not). You'll have to look for timer functionality provided by the framework, or perhaps some sort of update-function that is called repeatedly. You don't need that ", _"-chain. Just do message, sender = ..., the rest will be discarded implicitly.
Oh, okay. I was just copying it from another addon that happened to use it (this is for wow, if that wasn't already obvious) I have a ton of questions but I'm trying not to be annoying with them. Since the first bit uses message,sender,etc. and I want whatever name is "sender" to be used in Reply(playerName) as playerName, if I call it as Reply(sender), will that make sender == playerName? I asked that REALLY poorly, but hopefully you get what I mean. [editline]17th July 2013[/editline] also if there's no way to suspend code, what if i wrote it like this [code]function Reply(playerName) local nCurrentTime = GetTime() if (nCurrentTime - nLastMsgTime >= 10) then send reply else Reply(playerName) end[/code] Wouldn't that basically loop it until that condition is true?
Sorry, you need to Log In to post a reply to this thread.