• What do you need help with? V. 3.0
    4,884 replies, posted
  • [QUOTE=WeltEnSTurm;30524819][code] ..\source\network\network_server.cpp:18:18: error: 'F_SETFL' was not declared in this scope ..\source\network\network_server.cpp:18:27: error: 'O_NONBLOCK' was not declared in this scope ..\source\network\network_server.cpp:18:37: error: 'fcntl' was not declared in this scope[/code] oh what the hell And yes, I included the headers. Using MinGW[/QUOTE] try ioctl
  • Metahelp problem. I've seen it spelt two ways, is the shortened plural of polygons: Polys? or Polies? Also can anyone point me towards a transform method/matrix for a kind of 4 point skew, so say I want to squash a square image into one that encompasses 2 points (think image perspective correction)
  • Kay, having just started working with shaders and the lighting implementation, I'm having a little trouble understanding how to implement cone lighting, I've been trying for the past two days, so I must be missing something really obvious. Here is my current cone light PS: [code] PixelToFrame Output = (PixelToFrame)0; float4 ColorMap = tex2D(ColorMapSampler, PSIn.TexCoord); float3 NormalMap = (2.0f * (tex2D(NormalMapSampler, PSIn.TexCoord))) - 1.0f; float3 Pixel; Pixel.x = ScreenWidth * PSIn.TexCoord.x; Pixel.y = ScreenHeight * PSIn.TexCoord.y; Pixel.z = 0; float3 LightDirection = LightPosition - Pixel; float3 LightNormal = normalize(LightDirection); float Amount = max(dot(NormalMap, LightNormal), 0); float Attenuation = saturate(1.0f - length(LightDirection) / LightDecay); float3 Reflection = normalize(2 * Amount * NormalMap - LightNormal); float Specular = min(pow(saturate(dot(Reflection, float3(0, 0, 1))), 10), Amount); float ConeLight = dot(ConeAngle, -LightDirection); if(ConeLight > ConeSize) { float ConeIntensity = pow(ConeLight, 0); Attenuation *= ConeIntensity; Output.Color = ColorMap * Attenuation * LightColor * LightStrength + (Specular * Attenuation * SpecularStrength); } return Output; [/code] which always produces something similar to this: [img]http://img857.imageshack.us/img857/6123/screenshot2011061808021.png[/img] My main problem right now is just getting the cone to shrink from it's stubborn 180 size. Any assistance would be lovely.
  • [QUOTE=Wyzard;30516225]Read about the [url=http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4]form content types[/url]; you should use multipart/form-data, not application/x-www-form-urlencoded. And put the form data in the body of your POST, not in the URL. Servers impose length limits on URLs, so putting the entire contents of a file into a URL is a bad idea.[/QUOTE] I don't quite understand how to differentiate between the URL and the body of my POST, or also how to separate the URL-encoded parameters like: [code] data = URLEncoder.encode("email", enc) + "=" + URLEncoder.encode(Main.getEmail(), enc); data += "&" + URLEncoder.encode("password", enc) + "=" + URLEncoder.encode(Main.getPassword(), enc);[/code] from the multipart/form-data encoded file: [code]data += "&" + URLEncoder.encode("data", "enc") + "=" + URLEncoder.encode(codec.encode(bytes).toString(), enc); //Here the file has been converted to a byte array, then to binary using the Apache BinaryCodec, then to a String. //wtf i don't even know what i'm doing[/code] [editline]lolwat[/editline] [url=http://pastebin.com/SUycckTZ]Here's the code if anyone wants to see.[/url]
  • [QUOTE=Nigey Nige;30544641]I don't quite understand how to differentiate between the URL and the body of my POST[/QUOTE] You know how GET puts the parametres in the URL? Well, POST sends them separately. Just... Look up HTTP documentation somewhere.
  • Install Wireshark and have it capture traffic while you upload a file to a website somewhere. Looking at some valid HTTP traffic will probably help more than just reading specs.
  • Anyone know how to fix the perceptive so it doesn't stretch the geometry at the edges of the screen? Example, cubes look strange on the right: [img]http://gyazo.com/dc763ab4a0522c38af7149fd600e09fd.png[/img]
  • I'm assuming you're not using anything like XNA, but I think what you're creating is a Perspective view matrix, when you want an Orthographic. You can do it in XNA by Matrix.CreateOrthographic.
  • I still want it to have some depth though, wont Orthographic take away all perspective?
  • [QUOTE=foszor;30550946]Anyone know how to fix the perceptive so it doesn't stretch the geometry at the edges of the screen?[/QUOTE] If you want to reduce the perspective effect, move the camera back and narrow its field of view. Read about [url=http://en.wikipedia.org/wiki/Dolly_zoom]dolly zoom[/url] to understand why. (If you dolly-zoomed the camera back to an infinite distance, that'd be an orthographic view.)
  • Something confusing that I just can't figure out and I'm probably going to feel stupid once I get this working. [code] /***********************************************************/ /************************* State.h *************************/ /***********************************************************/ #ifndef __SYS_STATE_H__ #define __SYS_STATE_H__ #include <vector> #include <sys/Component.h> namespace sys { class State { public: State(void); ~State(void); bool AllowExclusiveDrawing; //false will not call draw on objects outside of bounds virtual void Initialized(); virtual void Exit(); virtual void Tick(float dt); virtual void Draw(); virtual void OnMouseMove(int x, int y); virtual void OnMouseDown(int x, int y, unsigned int button); virtual void OnMouseUp(int x, int y, unsigned int button); virtual void OnMouseWheel(int x, int y, int d); virtual void OnKeyPress(char key); virtual void OnKeyUnpress(char key); inline bool IsFocused(const Component &c); protected: std::vector<Component*> Components; private: Component* focusedComponent_; }; } #endif // __SYS_STATE_H__ /***********************************************************/ /*********************** Component.h ***********************/ /***********************************************************/ #ifndef __SYS_COMPONENT_H__ #define __SYS_COMPONENT_H__ #include "Point.h" #include "State.h" namespace sys { class Component { public: Component(State* s); ~Component(); Point Position; Point Size; bool Locked; bool Visible; virtual void Tick(float dt); virtual void Draw(); virtual void OnMouseHover(int localx, int localy); virtual void OnMouseMoved(int localx, int localy); virtual void OnMouseMovedInside(int localx, int localy); virtual void OnMouseDown(int x, int y, unsigned int button); virtual void OnMouseUp(int x, int y, unsigned int button); virtual void OnMouseClick(int localx, int localy, unsigned int button); virtual void OnMouseUnclick(int localx, int localy, unsigned int button); virtual void OnMouseWheel(int localx, int localy, unsigned int button); virtual void OnKeyPress(char key); virtual void OnKeyUnpress(char key); private: State* parent_; }; } #endif // __SYS_COMPONENT_H__ /***********************************************************/ /********************** Component.cpp **********************/ /***********************************************************/ #include "Point.h" #include "State.h" #include "Component.h" using namespace sys; Component::Component(State* s) : parent_(s), Position(Point(0,0)), Size(Point(0,0)) { } Component::~Component() { } /* Removed bunch of empty voids from header for this paste */ [/code] Errors I'm getting: (I'm certain it has something to do with the two headers including eachother) Output [code] Compiling... Engine.cpp c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(13) : error C2061: syntax error : identifier 'State' c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C2143: syntax error : missing ';' before '*' c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int main.cpp c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(13) : error C2061: syntax error : identifier 'State' c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C2143: syntax error : missing ';' before '*' c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int State.cpp c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(13) : error C2061: syntax error : identifier 'State' c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C2143: syntax error : missing ';' before '*' c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\state.cpp(31) : warning C4018: '<' : signed/unsigned mismatch c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\state.cpp(49) : warning C4018: '<' : signed/unsigned mismatch c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\state.cpp(59) : warning C4018: '<' : signed/unsigned mismatch Component.cpp c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(13) : error C2061: syntax error : identifier 'State' c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C2143: syntax error : missing ';' before '*' c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.cpp(9) : error C2511: 'sys::Component::Component(sys::State *)' : overloaded member function not found in 'sys::Component' c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.h(11) : see declaration of 'sys::Component' c:\users\ief015\documents\visual studio 2008\projects\mitosis\mitosis\sys\component.cpp(67) : fatal error C1004: unexpected end-of-file found Generating Code... Results Build log was saved at "file://c:\Users\ief015\Documents\Visual Studio 2008\Projects\mitosis\mitosis\Debug\BuildLog.htm" mitosis - 18 error(s), 3 warning(s) [/code] help most appreciated :buddy:
  • You have circular includes: State.h includes Component.h, and Component.h includes State.h. The #include "State.h" in Component.h does nothing because __SYS_STATE_H__ is already defined, because line 5 in State.h is the reason why Component.h is being read in the first place.
  • [QUOTE=Wyzard;30554363]You have circular includes: State.h includes Component.h, and Component.h includes State.h. The #include "State.h" in Component.h does nothing because __SYS_STATE_H__ is already defined, because line 5 in State.h is the reason why Component.h is being read in the first place.[/QUOTE] Ugh, I knew it was something like that. I've been on a programming hiatus for a couple months and I'm trying to get back at it. ;D Thanks [editline]18th June 2011[/editline] [QUOTE=Wyzard;30554363]You have circular includes: State.h includes Component.h, and Component.h includes State.h. The #include "State.h" in Component.h does nothing because __SYS_STATE_H__ is already defined, because line 5 in State.h is the reason why Component.h is being read in the first place.[/QUOTE] Interesting I have removed [b]Component(State* s);[/b] in Component.cpp and replaced it with a blank constructor and modified the .cpp as necessary, and the same with [b]State* parent_;[/b] and now it seems to be compiling without errors. This is basically what I'm trying to do [url]http://pastebin.com/7qNJw6Rt[/url]
  • Messing with the FoV and distance seemed to help the most. Its not perfect but its a lot better.
  • Oh god :doh:, I just realised I could define the other class as "class State;" in Components.h and "class Component;" in State.h Woohoo!
  • Hey guys, I've been working on a small game in XNA and I want to use XML files for config, you know, screen res, fullscreen. shit like that. So I want it to read then use what it's read to control the engine size. Right now it's basically this. [code] public void Read() { XmlTextReader textReader = new XmlTextReader("%USERPROFILE%\\Saved Games\\Saturn\\settings.config"); textReader.Read(); } public void Size() { graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; graphics.IsFullScreen = false; graphics.ApplyChanges(); }[/code] How would I get the reader to change the resolution?
  • I made a thread about this but I might as well also ask here. Does anyone know of any useful tutorials or of any open source program written in Python 3 with Pygame (it must be 3) that deal with map making? I mean just simple 2D map making btw. I want to have something to base my map maker off of so I don't start coding it super horribly. I'm just trying to make a simple platformer.
  • [QUOTE=foszor;30555401]Messing with the FoV and distance seemed to help the most. Its not perfect but its a lot better.[/QUOTE] Taking an easy example like Minecraft - resize the window to an extremely wide window and you get stretching like this, that really can't be avoided. Normal shot of a house: [quote][img]http://dl.dropbox.com/u/19978518/Minecraft%20pictures/Other/2011-06-19_00.52.01.png[/img][/quote] I moved forward a bit to get a better example of stretching, but here you go: [quote][img_thumb]http://dl.dropbox.com/u/19978518/Minecraft%20pictures/Other/2011-06-19_00.52.27.png[/img_thumb][/quote] check out that fuggin' torch
  • [QUOTE=esalaka;30545104]You know how GET puts the parametres in the URL? Well, POST sends them separately. Just... Look up HTTP documentation somewhere.[/QUOTE] [QUOTE=Wyzard;30545613]Install Wireshark and have it capture traffic while you upload a file to a website somewhere. Looking at some valid HTTP traffic will probably help more than just reading specs.[/QUOTE] So I did both of these, but everything I know about programming is in Java, and I can't figure out how all this information translates. I don't know the syntax for all the stuff that's being explained, and nowhere seems to have the info in a format I can understand. All I want to do is make an app that uploads images to tumblr! :smith: [editline]adf[/editline] [img]http://i.imgur.com/7mSWQ.png[/img] I'm just gonna go bang my head against a wall for a while.
  • [QUOTE=Staneh;30525330]Right. I am using a Timer, to increase an int value, which determines the rotation of my rectangle, the code for that: [cpp] rectrotation = new Timer(100, new RectRotationHandler()); class RectRotationHandler implements ActionListener{ public void actionPerformed(ActionEvent e){ rotation += 5; } } [/cpp] Now, for the drawing, I use a BufferedImage, like this: [cpp] public void drawRectangle(){ Graphics2D b = buffer.createGraphics(); if(b instanceof Graphics2D){ b.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); b.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } int rectx = 80; int recty = 80; b.rotate(rotation * Math.PI / 180); b.setColor(Color.RED); b.drawRect(rectx,recty,40,40); }[/cpp] The rectangle is drawn with a simple drawRect(), and the rotation is done by doing b.rotate(), with as parameter the rotation int, which is being increased by the timer, so it rotates automatically. Now, I need to mess with the b.translate, so it doesn't rotate around the 0,0 axis of my level, but I have no idea how. [editline]17th June 2011[/editline] Look at post #506[/QUOTE] You are drawing your rectangle with an offset: don't do that. Instead, b.translate() to rectx and recty, b.rotate(), and then b.drawRect(-20, -20, 20, 20). This is of course assuming whatever library you are using works how I think it works...
  • Can anyone help me with SFML and OpenGL? for some reason even the example opengl doesn't work [code] //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include <SFML/Window.hpp> //////////////////////////////////////////////////////////// /// Entry point of application /// /// \return Application exit code /// //////////////////////////////////////////////////////////// int main() { // Create the main window sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL"); // Create a clock for measuring time elapsed sf::Clock Clock; // Set color and depth clear value glClearDepth(1.f); glClearColor(0.f, 0.f, 0.f, 0.f); // Enable Z-buffer read and write glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); // Setup a perspective projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90.f, 1.f, 1.f, 500.f); // Start game loop while (App.IsOpened()) { // Process events sf::Event Event; while (App.GetEvent(Event)) { // Close window : exit if (Event.Type == sf::Event::Closed) App.Close(); // Escape key : exit if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape)) App.Close(); // Resize event : adjust viewport if (Event.Type == sf::Event::Resized) glViewport(0, 0, Event.Size.Width, Event.Size.Height); } // Set the active window before using OpenGL commands // It's useless here because active window is always the same, // but don't forget it if you use multiple windows or controls App.SetActive(); // Clear color and depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Apply some transformations glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.f, 0.f, -200.f); glRotatef(Clock.GetElapsedTime() * 50, 1.f, 0.f, 0.f); glRotatef(Clock.GetElapsedTime() * 30, 0.f, 1.f, 0.f); glRotatef(Clock.GetElapsedTime() * 90, 0.f, 0.f, 1.f); // Draw a cube glBegin(GL_QUADS); glVertex3f(-50.f, -50.f, -50.f); glVertex3f(-50.f, 50.f, -50.f); glVertex3f( 50.f, 50.f, -50.f); glVertex3f( 50.f, -50.f, -50.f); glVertex3f(-50.f, -50.f, 50.f); glVertex3f(-50.f, 50.f, 50.f); glVertex3f( 50.f, 50.f, 50.f); glVertex3f( 50.f, -50.f, 50.f); glVertex3f(-50.f, -50.f, -50.f); glVertex3f(-50.f, 50.f, -50.f); glVertex3f(-50.f, 50.f, 50.f); glVertex3f(-50.f, -50.f, 50.f); glVertex3f(50.f, -50.f, -50.f); glVertex3f(50.f, 50.f, -50.f); glVertex3f(50.f, 50.f, 50.f); glVertex3f(50.f, -50.f, 50.f); glVertex3f(-50.f, -50.f, 50.f); glVertex3f(-50.f, -50.f, -50.f); glVertex3f( 50.f, -50.f, -50.f); glVertex3f( 50.f, -50.f, 50.f); glVertex3f(-50.f, 50.f, 50.f); glVertex3f(-50.f, 50.f, -50.f); glVertex3f( 50.f, 50.f, -50.f); glVertex3f( 50.f, 50.f, 50.f); glEnd(); // Finally, display rendered frame on screen App.Display(); } return EXIT_SUCCESS; } [/code] Apparently [code] gluPerspective(90.f, 1.f, 1.f, 500.f); [/code] is giving the error... [code] 1>------ Build started: Project: SFML-TEST, Configuration: Debug Win32 ------ 1> main.cpp 1>main.obj : error LNK2001: unresolved external symbol _gluPerspective@32 1>C:\Users\Bamford\documents\visual studio 2010\Projects\SFML-TEST\Debug\SFML-TEST.exe : fatal error LNK1120: 1 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== [/code]
  • [QUOTE=Bambo.;30563098]Can anyone help me with SFML and OpenGL? for some reason even the example opengl doesn't work[/QUOTE] Make sure you link with glu32.lib.
  • [QUOTE=jA_cOp;30563120]Make sure you link with glu32.lib.[/QUOTE] Ah ok, i'll give that a shot. It doesn't say anything about that in the tutorials, i dont think? [editline]19th June 2011[/editline] Ah fantastic, it works! Thanks alot.
  • I guess it assumes you already know something on how to use OpenGL with your compiler, so I doesn't bother tell you which libraries to link to and so on.
  • [QUOTE=Bambo.;30563148]It doesn't say anything about that in the tutorials, i dont think?[/QUOTE] The answer depends entirely on your programming environment, which the error message you posted gave away. And as Chris220 said, it's probably not in the scope of the tutorial anyway.
  • I've been working on a simple game engine project for a few of my friends to use, and even though I'm not very experienced with much programming at all in C++, and it's QUITE a big step, it's something I'm all up for. BUT, I've run into a dead end. I can't for the love of all that is sacred figure out how to use lua 5.1 to, when embedded, load a script, and then execute only a function from that script. How is it possible? [b]tl;rd[/b] Call lua function from c++ code [code] function bleh() print( "dicks" ) end[/code] How do I call bleh() from a C++ program?