• What do you need help with? V4 (January 2012)
    966 replies, posted
Trying to make a simple program using wxWidgets [code]#include <wx/wx.h> #include <wx/url.h> #include <wx/stream.h> #include <wx/sstream.h> #incldue <wx/string.h> int main(int argc, char* argv[]) { wxURL url(wxT("http://google.com")); if (url.GetError()==wxURL_NOERR) { wxString htmldata; wxInputStream *in = url.GetInputStream(); if (in && in->IsOk()) { wxStringOutputStream html_stream(&htmldata); in->Read(html_stream); } wxPuts(html_stream.GetString(); } } [/code] It, however, gives me the following errors: [code] main.cpp In function 'int main(int, char**)': main.cpp 8 error: 'wxURL' was not declared in this scope main.cpp 8 error: expected ';' before 'url' main.cpp 9 error: 'url' was not declared in this scope main.cpp 9 error: 'wxURL_NOERR' was not declared in this scope main.cpp 12 error: 'wxInputStream' was not declared in this scope main.cpp 12 error: 'in' was not declared in this scope main.cpp 15 error: 'wxStringOutputStream' was not declared in this scope main.cpp 15 error: expected ';' before 'html_stream' main.cpp 16 error: 'html_stream' was not declared in this scope main.cpp 18 error: 'html_stream' was not declared in this scope === Build finished: 10 errors, 0 warnings === [/code] Should I be using OnInit() instead of main()?
[QUOTE=SuperHoboMan;34168608]I'm hoping my problem will be easy to solve. I'm trying to get a script in the program AutoHotKey to work like this: I need space to be pressed every 3 seconds. I got that part down, as it's easy. [code]loop { send {space} sleep 3000 }[/code] I ALSO need the z key to be pressed and HELD DOWN for 3 seconds, every 15 seconds. This is the part I can't seem to get. I don't know much of anything when it comes to coding in any language :([/QUOTE] [quote="AutoHotKey help file"]Repeating or Holding Down a Key To repeat a keystroke: Enclose in braces the name of the key followed by the number of times to repeat it. For example: [code]Send {DEL 4} ; Presses the Delete key 4 times. Send {S 30} ; Sends 30 uppercase S characters. Send +{TAB 4} ; Presses Shift-Tab 4 times.[/code] To hold down or release a key: Enclose in braces the name of the key followed by the word Down or Up. For example: [code]Send {b down}{b up} Send {TAB down}{TAB up} Send {Up down} ; Press down the up-arrow key. Sleep 1000 ; Keep it down for one second. Send {Up up} ; Release the up-arrow key.[/code] When a key is held down via the method above, it does not begin auto-repeating like it would if you were physically holding it down (this is because auto-repeat is a driver/hardware feature). However, a Loop can be used to simulate auto-repeat. The following example sends 20 tab keystrokes: [code]Loop 20 { Send {Tab down} ; Auto-repeat consists of consecutive down-events (with no up-events). Sleep 30 ; The number of milliseconds between keystrokes (or use SetKeyDelay). } Send {Tab up} ; Release the key.[/code] The word DownTemp may also be used. Its effect is the same as Down except for the modifer keys (Control/Shift/Alt/Win). In those cases, DownTemp tells subsequent sends that the key is not permanently down, and may be released whenever a keystroke calls for it. For example, Send {Control DownTemp} followed later by Send a would produce a normal "a" keystroke, not a control-A keystroke.[/quote]
[QUOTE=Mikolah;34172075]Trying to make a simple program using wxWidgets [code]#include <wx/wx.h> #include <wx/url.h> #include <wx/stream.h> #include <wx/sstream.h> #incldue <wx/string.h> int main(int argc, char* argv[]) { wxURL url(wxT("http://google.com")); if (url.GetError()==wxURL_NOERR) { wxString htmldata; wxInputStream *in = url.GetInputStream(); if (in && in->IsOk()) { wxStringOutputStream html_stream(&htmldata); in->Read(html_stream); } wxPuts(html_stream.GetString(); } } [/code] It, however, gives me the following errors: [code] main.cpp In function 'int main(int, char**)': main.cpp 8 error: 'wxURL' was not declared in this scope main.cpp 8 error: expected ';' before 'url' main.cpp 9 error: 'url' was not declared in this scope main.cpp 9 error: 'wxURL_NOERR' was not declared in this scope main.cpp 12 error: 'wxInputStream' was not declared in this scope main.cpp 12 error: 'in' was not declared in this scope main.cpp 15 error: 'wxStringOutputStream' was not declared in this scope main.cpp 15 error: expected ';' before 'html_stream' main.cpp 16 error: 'html_stream' was not declared in this scope main.cpp 18 error: 'html_stream' was not declared in this scope === Build finished: 10 errors, 0 warnings === [/code] Should I be using OnInit() instead of main()?[/QUOTE] Since you're missing the functions, it looks like you're not linking against the wx library. With gcc you'd do that with -lwx when you compile but not sure what you would do. .
I'm having problems linking SFML2... The command line I'm using is: [code] compile myapp -lsfml-window-2,-lsfml-system-2 [/code] (compile is a little batch script) And the output is: [code] myapp.o:myapp.cpp:(.text+0x55): undefined reference to `sf::Sleep(unsigned int)' myapp.o:myapp.cpp:(.text+0x75): undefined reference to `sf::Clock::Clock()' myapp.o:myapp.cpp:(.text+0x1f3): undefined reference to `sf::Thread::Launch()' myapp.o:myapp.cpp:(.text+0x21d): undefined reference to `sf::Thread::Wait()' myapp.o:myapp.cpp:(.text+0x250): undefined reference to `sf::Thread::~Thread()' myapp.o:myapp.cpp:(.text+0x2b6): undefined reference to `sf::Thread::~Thread()' collect2: ld returned 1 exit status [/code]
[QUOTE=Octave;34174504]Since you're missing the functions, it looks like you're not linking against the wx library. With gcc you'd do that with -lwx when you compile but not sure what you would do. .[/QUOTE] But those are compiler errors, not linker errors. And I have linked all the wx libraries I need.
[QUOTE=MegaJohnny;34174973]I'm having problems linking SFML2... The command line I'm using is: [code] compile myapp -lsfml-window-2,-lsfml-system-2 [/code] (compile is a little batch script) And the output is: [code] myapp.o:myapp.cpp:(.text+0x55): undefined reference to `sf::Sleep(unsigned int)' myapp.o:myapp.cpp:(.text+0x75): undefined reference to `sf::Clock::Clock()' myapp.o:myapp.cpp:(.text+0x1f3): undefined reference to `sf::Thread::Launch()' myapp.o:myapp.cpp:(.text+0x21d): undefined reference to `sf::Thread::Wait()' myapp.o:myapp.cpp:(.text+0x250): undefined reference to `sf::Thread::~Thread()' myapp.o:myapp.cpp:(.text+0x2b6): undefined reference to `sf::Thread::~Thread()' collect2: ld returned 1 exit status [/code][/QUOTE] I think you should be linking to sfml-system not sfml-system-2. At least that's what my libraries are.
Cant get my head around this so i am just leaving this here [lua] INSERT INTO users ('username', 'password', 'email', 'key', 'permissions', 'ip') VALUES( 'Fuck', 'fd44cf5c716a0385eab4d9e84f13c454', 'Fuck', 'PxlV7a5SgbyUqOF2dPJD', 1, 2130706433 ); #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, permissions, ip) VALUES( 'Fuck', 'fd44cf5c716a0385eab4d9e84f13c454',' at line 1[/lua]
[QUOTE=Mikolah;34175238]But those are compiler errors, not linker errors. And I have linked all the wx libraries I need.[/QUOTE] If you don't link against a library you need functions from the compiler complains because the functions you use aren't defined. A linker error would be caused if you tried to link against a nonexistent library. I think I see some of the problems: [code] #include <wx/wx.h> #include <wx/url.h> #include <wx/stream.h> #include <wx/sstream.h> #incldue <wx/string.h> int main(int argc, char* argv[]) { wxURL url = wxT("http://google.com"); // fixed if (url.GetError()==wxURL_NOERR) { wxString htmldata; wxInputStream *in = url.GetInputStream(); if (in && in->IsOk()) { wxStringOutputStream html_stream = &htmldata; //fixed in->Read(html_stream); } wxPuts(html_stream.GetString()); // was missing parenthesis } }[/code] You were declaring variables with parentheses, when the syntax is type varname = value; [editline]12th January 2012[/editline] [QUOTE=OldFusion;34176968]Cant get my head around this so i am just leaving this here [lua] INSERT INTO users ('username', 'password', 'email', 'key', 'permissions', 'ip') VALUES( 'Fuck', 'fd44cf5c716a0385eab4d9e84f13c454', 'Fuck', 'PxlV7a5SgbyUqOF2dPJD', 1, 2130706433 ); #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, permissions, ip) VALUES( 'Fuck', 'fd44cf5c716a0385eab4d9e84f13c454',' at line 1[/lua][/QUOTE] Try adding a space between VALUES and its opening '('
[QUOTE=Octave;34177905]I think I see some of the problems: [code] #include <wx/wx.h> #include <wx/url.h> #include <wx/stream.h> #include <wx/sstream.h> #incldue <wx/string.h> int main(int argc, char* argv[]) { wxURL url = wxT("http://google.com"); // fixed if (url.GetError()==wxURL_NOERR) { wxString htmldata; wxInputStream *in = url.GetInputStream(); if (in && in->IsOk()) { wxStringOutputStream html_stream = &htmldata; //fixed in->Read(html_stream); } wxPuts(html_stream.GetString()); // was missing parenthesis } }[/code] You were declaring variables with parentheses, when the syntax is type varname = value;[/QUOTE] You can also construct objects by using parentheses, which is the actual way of doing it.
[QUOTE=sim642;34178010]You can also construct objects by using parentheses, which is the actual way of doing it.[/QUOTE] I'm assuming he's using C, where you can't, but if it is C++ then oh well :v:
[QUOTE=Octave;34177905]If you don't link against a library you need functions from the compiler complains because the functions you use aren't defined. A linker error would be caused if you tried to link against a nonexistent library. I think I see some of the problems: [code] #include <wx/wx.h> #include <wx/url.h> #include <wx/stream.h> #include <wx/sstream.h> #incldue <wx/string.h> int main(int argc, char* argv[]) { wxURL url = wxT("http://google.com"); // fixed if (url.GetError()==wxURL_NOERR) { wxString htmldata; wxInputStream *in = url.GetInputStream(); if (in && in->IsOk()) { wxStringOutputStream html_stream = &htmldata; //fixed in->Read(html_stream); } wxPuts(html_stream.GetString()); // was missing parenthesis } }[/code] You were declaring variables with parentheses, when the syntax is type varname = value; [/quote] Also html_stream is declared/defined inside of the If block but he's trying to use it outside of the if block Out of scope But I think he haven't included the wx's include files in the project settings What he can do is read a tutorial on how to add libs and includes to a project in visual studio... or copy all the headers to the source code's directory and change these <wx/blah.h> to these "wx/blah.h
(Somewhat unrelated to my post on page 3) For my VM I'm trying to build argument lists incrementally. For this I'm using libffcall, specifically avcall. This has me wondering: The library can build argument lists by pushing individual arguments one after the other, but for this you need to know the type. For example: [CODE] void add(int a, int b) { int result = a+b; std::cout << "Result: " << result << std::endl; } int main() { av_alist A; av_start_void(A,&add); av_int(A,2); av_int(A,2); av_call(A); return 0; } [/CODE] There are facilities to push structures and pointers, but how would you go about building argument lists that contain arbitrary arguments, from integers to objects? For example, what if I'm trying to pass the argument list to a function that takes gsl_matrix structures, QWidget objects, that kind of stuff. I've experimented and determined you can do this: [CODE] void add(int a, int b) { int result = a+b; std::cout << "Result: " << result << std::endl; } int main() { av_alist A; av_start_void(A,&add); av_ptr(A,int,2); av_ptr(A,int,2); av_call(A); return 0; } [/CODE] Passing an integer implicitly. Could this be done for [B]arbitrary[/B] types? ints, chars, longs, abstract objects and structures?
[QUOTE=OldFusion;34176968]Cant get my head around this so i am just leaving this here INSERT INTO users ('username', 'password', 'email', 'key', 'permissions', 'ip') VALUES( 'Fuck', 'fd44cf5c716a0385eab4d9e84f13c454', 'Fuck', 'PxlV7a5SgbyUqOF2dPJD', 1, 2130706433);#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, permissions, ip) VALUES( 'Fuck', 'fd44cf5c716a0385eab4d9e84f13c454',' at line 1[/QUOTE] Try: [PHP]INSERT INTO users (`username`, `password`, `email`, `key`, `permissions`, `ip`) VALUES( 'Fuck', 'fd44cf5c716a0385eab4d9e84f13c454', 'Fuck', 'PxlV7a5SgbyUqOF2dPJD', 1, 2130706433 );[/PHP]
How I make previous cin line hidden after pressing enter? [cpp] char message[256]; cin.ignore(); cin.get( message, 256 ); cin.clear(); [/cpp]
Anyone familiar with multi-pass lighting and how to implement it correctly? What I'm doing now is for each light I render a circle into a framebuffer. Then render polygons to cover the "light" to act as shadows like so: [img]http://j.mp/yP4prg[/img] I then render the first frame buffer as a full-screen quad into another buffer, blending it together: (Then I clear the first buffer and repeat until all of the lights are accumulated into the second buffer) This is done so "shadows" don't interfere with other lights. [img]http://j.mp/w9OxWs[/img] I then XOR logic render it into the main buffer (So white turns black), blending it so that the color's from the lights modulate the main buffer. [img]http://j.mp/zQaHHi[/img] This method works well but it isn't very fast. (It can only render about 50 lights before maxing out my CPU, regardless of the fact that the light's vertex buffers are not changing or being recalculated) I feel like I'm doing something very wrong; can someone shed some light upon my stupor? [editline]13th January 2012[/editline] I was just alerted by devbug that I should use stencil buffers. Time to delve into vague stenciling tutorials.
Your technique sounds fine to me. What I would do: 1. Render the albedo (fullbright diffuse color) for the entire scene to a texture. 2. For each light: 2.a. Render the shadow volumes to the stencil buffer. 2.b. Render the lights additively with stencil testing enabled, sampling from the albedo buffer to get the color for that fragment. I don't know if this will be faster or not, I think it should be slightly faster because the stencil test allows you to discard fragments early. [QUOTE=Naelstrom;34202668]It can only render about 50 lights before maxing out my CPU[/QUOTE] CPU? Or GPU?
My camera rotation is behaving very oddly, it appears that the axis for pitch isn't rotating with the rest of the matrix, what could be causing it? [csharp]private void updateCamera() { cameraRotMatrix = Matrix.CreateFromYawPitchRoll(additionalCameraYaw, additionalCameraPitch, additionalCameraRoll); cameraPosition = Vector3.Transform(cameraPosition, cameraRotMatrix); Vector3 cameraUp = new Vector3(0, 1, 0); viewMatrix = Matrix.CreateLookAt(cameraPosition, new Vector3(0, 0, 0), cameraUp); projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiO ver4, device.Viewport.AspectRatio, 0.2f, 500.0f); }[/csharp] [editline]14th January 2012[/editline] A video of the issue that's happening [video=youtube;RlPCQoPpitk]http://www.youtube.com/watch?v=RlPCQoPpitk&feature=youtu.be[/video]
[QUOTE=ROBO_DONUT;34202923]CPU? Or GPU?[/QUOTE] Definitely CPU, task manager shows it stuck at 50% when the lights begin to lag. I'm not recalculating non-moving lights so I guess all these frame buffers have an impact on CPU? (and no i'm not generating an FBO every frame) [QUOTE=ROBO_DONUT;34202923]Render shadow volumes to stencil buffer[/QUOTE] That's what i'm attempting to figure out now, not using glfw or glut makes it difficult to enable the stencil buffer.
[QUOTE=Naelstrom;34203842]not using glfw or glut makes it difficult to enable the stencil buffer.[/QUOTE] Huh? When you make your FBO, add a GL_STENCIL_INDEX format renderbuffer object to GL_STENCIL_ATTACHMENT in your framebuffer object, or make your depth buffer GL_DEPTH24_STENCIL8 and use GL_DEPTH_STENCIL_ATTACHMENT if you want both. I've always written core OpenGL without problems... Should be something like: [cpp] glGenRenderbuffers(1, &stencil_rbo); glBindRenderbuffer(GL_RENDERBUFFER, stencil_rbo); glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX, w, h); glBindRenderbuffer(GL_RENDERBUFFER, 0); glGenFramebuffers(1, &shadow_fbo); glBindFramebuffer(GL_FRAMEBUFFER, shadow_fbo); /* bind color attachments, if required */ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil_rbo); glBindFramebuffer(GL_FRAMEBUFFER, 0); [/cpp] Also, you need to enable stencil testing with glEnable(GL_STENCIL_TEST), and set glStencilFunc/glStencilOp
Yeah my mistake, I just needed to add a [code]GLX_STENCIL_SIZE, 8[/code] to my window attributes in Xlib. It wasn't hard at all. I plan to avoid custom frame buffers as much as possible though. I guess I'm using them wrong how slow they are. If you really want me to be righteous in the ways of the frame buffer feel free to chat me up on steam and i'll show you some of the code snippets i'm using.
I'm still having problems with the linking... but I have a few more details now. This source compiles fine and displays a window which exits correctly when I press the close button. [code] #include<SFML/Window.hpp> #include<iostream> int main() { sf::Window myapp(sf::VideoMode(800, 600, 32), "My SFML Window"); sf::Event windowEvent; bool run = true; while (run) { myapp.WaitEvent(windowEvent); if (windowEvent.Type == sf::Event::Closed) { run = false; } } return EXIT_SUCCESS; } [/code] However this code gives a linking error: [code] #include<SFML/Window.hpp> #include<iostream> bool run = true; void printHello() { sf::Clock clk; while (run && clk.GetElapsedTime() < 5000) { std::cout << "Hello World" << std::endl; sf::Sleep(500); } } int main() { sf::Window myapp(sf::VideoMode(800, 600, 32), "My SFML Window"); sf::Event windowEvent; while (run) { myapp.WaitEvent(windowEvent); if (windowEvent.Type == sf::Event::Closed) { run = false; } } return EXIT_SUCCESS; } [/code] [code] myapp.o:myapp.cpp:(.text+0xd): undefined reference to `_imp___ZN2sf5ClockC1Ev' myapp.o:myapp.cpp:(.text+0x41): undefined reference to `_imp___ZN2sf5SleepEj' myapp.o:myapp.cpp:(.text+0x57): undefined reference to `_imp___ZNK2sf5Clock14Get ElapsedTimeEv' collect2: ld returned 1 exit status [/code] As before, the command line is: [code] compile myapp -lsfml-window,-lsfml-system [/code]
Is the comma supposed to be there ? My guess is that sfml_windows is linked correctly, but because of the comma sfml-system is ignored. This would explain why the code doesn't compile anymore when you use the Clock class.
That comma isn't supposed to be there.
It's to do with how Windows does batch scripts... or so I thought. I just typed this in explicitly and it worked fine. g++ myapp.o -o myapp.exe -lsfml-window -lsfml-system There must be a problem with my batch script, sorry guys.
The problem was that comma
I'm using the C Lua API for the first time and I'm kind of getting the hang of it, but tables have me stumped. I'm creating a simple method to help myself understand Lua tables in the C API. Here's the function so far: [cpp] // Here's how I'm calling the method in lua: // PrintTable( {10, 20, 10} ) // And I expect it to output "10 20 10" int PrintTable(lua_State* s) { lua_gettable(s, 1); while(lua_next(s, 1)) { switch(lua_type(s, 0)) { case LUA_TNUMBER: std::cout << lua_tonumber(s, 0) << std::endl; break; } lua_pop(s, 1); } return 0; } [/cpp] The C function fails at lua_next Anyone able to point me in the right direction here?
[QUOTE=ief014;34217659]I'm using the C Lua API for the first time and I'm kind of getting the hang of it, but tables have me stumped. I'm creating a simple method to help myself understand Lua tables in the C API. Here's the function so far: [cpp] // Here's how I'm calling the method in lua: // PrintTable( {10, 20, 10} ) // And I expect it to output "10 20 10" int PrintTable(lua_State* s) { lua_gettable(s, 1); while(lua_next(s, 1)) { switch(lua_type(s, 0)) { case LUA_TNUMBER: std::cout << lua_tonumber(s, 0) << std::endl; break; } lua_pop(s, 1); } return 0; } [/cpp] The C function fails at lua_next Anyone able to point me in the right direction here?[/QUOTE] cout is c++, not c. you want printf().
[QUOTE=Octave;34217802]cout is c++, not c. you want printf().[/QUOTE] I'm aware of that. C++ can use C APIs, too.
[QUOTE=ief014;34217829]I'm aware of that. C++ can use C APIs, too.[/QUOTE] well I didn't know what you were in, was just trying to help
[QUOTE=ief014;34217659]I'm using the C Lua API for the first time and I'm kind of getting the hang of it, but tables have me stumped. I'm creating a simple method to help myself understand Lua tables in the C API. Here's the function so far: [cpp] // Here's how I'm calling the method in lua: // PrintTable( {10, 20, 10} ) // And I expect it to output "10 20 10" int PrintTable(lua_State* s) { lua_gettable(s, 1); while(lua_next(s, 1)) { switch(lua_type(s, 0)) { case LUA_TNUMBER: std::cout << lua_tonumber(s, 0) << std::endl; break; } lua_pop(s, 1); } return 0; } [/cpp] The C function fails at lua_next Anyone able to point me in the right direction here?[/QUOTE] You're looking at the stack the wrong way. Using positive numbers counts from the bottom of the stack, negative from the top. Also, lua_gettable doesn't do what you think it does. It's used for accessing fields of a table. When you call the function, the table argument is at the bottom of the stack, index 1. lua_next takes one argument and uses it to find the next field of the table, then pushes the key and the value to the stack. So. [cpp]lua_pushnil(L); // passing nil to lua_next starts at beginning while(lua_next(L, 1)) // the table is at index 1, bottom of the stack { // now the key and value are at the top of the stack, indices -2 and -1 respectively (or 2 and 3 counting from bottom) switch(lua_type(L, -1)) { case LUA_TNUMBER: std::cout << lua_tostring(L, -2) << " = " << lua_tonumber(L, -1) << std::endl; break; } lua_pop(L, 1); // we pop only the value off the stack, leaving the key at the top, as the argument for lua_next } lua_pop(L, 1); // pop the key[/cpp]
Sorry, you need to Log In to post a reply to this thread.