As with all of the other ones, I'm presented with this when opening it.
[img]http://i26.tinypic.com/9lk2mw.png[/img]
Then I get a few things like this.
[img]http://i31.tinypic.com/15hzm7k.png[/img]
None of the sections said they had an error.
[img]http://i31.tinypic.com/nex080.png[/img]
Bunch of errors.
[img]http://i32.tinypic.com/105yu84.png[/img]
So yeah, like I said, it isn't compatible.
Haven't posted on FSG in years.
I'm considering learning C# (and later XNA) together with C++.
I already have some experience with C++ so it shouldn't be that hard, right.
So my question is: is it worth learning?
XNA, Certainly. Good intro to games development. Hell, Beat Hazard was written in XNA and then stuck into a C++ Wrapper.
I thought it was completely ported to C++?
[QUOTE=high;23702751]Fuuuck, I really hate naming shit.
[cpp]public int SubtractOneHalfAndReturnSignum(double d)
{
if (d < .5)
return -1;
else if (d > .5)
return 1;
return 0;
}[/cpp][/QUOTE]
There you go. Equivalent code if you had a signum function defined:
[cpp]public int SubtractOneHalfAndReturnSignum(double d)
{
d -= 0.5;
return signum(d);
}[/cpp]
Math.Sign in .NET
If I return a pointer to a derived class from a function, is it a bad idea to return it as std::auto_ptr to make sure it's cleaned up automatically? Because I'm separating the interface and implementation in a DLL, I can't return the class itself.
Well, that depends. It might be an inconvenience that you cannot copy an auto_ptr and keep both copies alive. Maybe try a shared_ptr instead, unless you are certain that passing and storing it via reference will always be fine.
You could also keep the memory-management in the DLL and free the memory when it gets unloaded (or rather upon DLL_THREAD_DETACH).
I think it's a good idea in general for a function that creates an object to return an auto_ptr rather than a plain pointer. You can turn it into a plain pointer or shared_ptr (by calling release() or passing it to the shared_ptr constructor) so you don't lose any capabilities, but you gain protection against leaks.
I just wanted to ask some advice:
[img]http://filesmelt.com/dl/gamecollisionscreen.jpg[/img]
This is the game i'm working on and i have the walls and the ground separate, so i do wall type collisions with the collision.walls(dark green) and ground type collisions with the collision.ground(green).
I was just wondering if i should keep doing it like this or possibly just have the collision as one big graphic; which one do you think would be more efficient/work better?
I think that if this way can fit in your game, meaning it doesn't prevent you from doing something you want, you should stick with it. It's a platformer so performance isn't all THAT important.
Very nice art style if I may notice.
Hey guys, I'm in a real loss of thought here.
You see, I really want to add animated tiles to my tile engine, but the way I optimize the drawing almost prevents it. My method was to render all the tiles of a map to one texture and just draw that, as opposed to redrawing every tile every frame. Which has worked really nicely so far, but for animated tiles I'd have to remake this large texture every time a tile changes to a new frame, which seems really inefficient to me.
What my first idea was is that I'd create a boost::ptr_list<sf::Sprite> which would hold every animated tile as I add them and just redraw them separately over the the main map. This would be faster than remaking the the whole map image several times with variation depending on the different animation speeds, but I was wondering if there'd be a more efficient way of doing this.
[QUOTE=NorthernGate;23751379]Hey guys, I'm in a real loss of thought here.
You see, I really want to add animated tiles to my tile engine, but the way I optimize the drawing almost prevents it. My method was to render all the tiles of a map to one texture and just draw that, as opposed to redrawing every tile every frame. Which has worked really nicely so far, but for animated tiles I'd have to remake this large texture every time a tile changes to a new frame, which seems really inefficient to me.
What my first idea was is that I'd create a boost::ptr_list<sf::Sprite> which would hold every animated tile as I add them and just redraw them separately over the the main map. This would be faster than remaking the the whole map image several times with variation depending on the different animation speeds, but I was wondering if there'd be a more efficient way of doing this.[/QUOTE]
There should really be no need to write to a larger texture like that.
Hey guys, I'm stuck a little here.
As you might have seen in the WAYWO, I'm working on a webserver and I need to be able to accept data via multipart/form-data. I've read the relevant RFC's but I can't figure out how to go about this.
Basically the request looks something like this:
[code]
POST / HTTP/1.1
Host: localhost
Content-Length: 100876
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary9S0IBLc1TGixx3Al
------WebKitFormBoundary9S0IBLc1TGixx3Al
Content-Disposition: form-data; name="folder"
2
------WebKitFormBoundary9S0IBLc1TGixx3Al
Content-Disposition: form-data; name="Filedata"; filename="Image046.jpg"
Content-Type: image/jpeg
�����JFIF�����������
�����!��������������
��w�!1AQaq"2�B���� #3R�br�
$4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz���������������������������������������������������������������������������������
��w�!1AQaq"2�B���� #3R�br�
$4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz����������������������������������������������������������������������������?��8�6�(Z��k��+�F��+¢�)5�3�����+EZM;ٻ[�I
�ҕ��W�t�t��yt_���%���iŨ�Kn�2��կе�����+O�?��]쬆^/��{��DGR�M�������K��S���ih�kS��nW��DIB���Ւ*|�.�0��������v���cBV��mY$#�����Q�ޠC��m�Su��w�)�vQ���Er���l6T�.[��C+r�1�w���>�Ps�W��c-z=��S�d=��˳��"Zs��욓v]��:2Jr���Z�{�e�m�}ډG�r]�̕���,�;�R���D����>{�%X��9��1ZY��c��8)�))mu�
D�B�{�D�x�]\uy9R������i��Rv�墒M);��&�(�K�
------WebKitFormBoundary9S0IBLc1TGixx3Al
[/code]
So as you can see, it's basically a bunch of sections with a header and a body. It would all be fine and dandy if the sections had a Content-Length header, but they don't.
How do I get the binary data without corrupting it? There's a CRLF after the plain text data in the "folder" section, but I'm not sure if a CRLF is placed after binary data. Even if I figure out that, how do you guys suggest I best go about looking out for the boundary? I'm going to be writing the data of each section to disk as I recieve it, but I'll obviously need to use some kind of buffer to look out for the boundary.
What would be the most efficient way to read incoming data into a buffer, search for the boundary, and write the buffer to disk?
[QUOTE=turb_;23752587]Hey guys, I'm stuck a little here.
As you might have seen in the WAYWO, I'm working on a webserver and I need to be able to accept data via multipart/form-data. I've read the relevant RFC's but I can't figure out how to go about this.
Basically the request looks something like this:
[code]
POST / HTTP/1.1
Host: localhost
Content-Length: 100876
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary9S0IBLc1TGixx3Al
------WebKitFormBoundary9S0IBLc1TGixx3Al
Content-Disposition: form-data; name="folder"
2
------WebKitFormBoundary9S0IBLc1TGixx3Al
Content-Disposition: form-data; name="Filedata"; filename="Image046.jpg"
Content-Type: image/jpeg
�����JFIF�����������
�����!��������������
��w�!1AQaq"2�B���� #3R�br�
$4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz���������������������������������������������������������������������������������
��w�!1AQaq"2�B���� #3R�br�
$4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz����������������������������������������������������������������������������?��8�6�(Z��k��+�F��+¢�)5�3�����+EZM;ٻ[�I
�ҕ��W�t�t��yt_���%���iŨ�Kn�2��կе�����+O�?��]쬆^/��{��DGR�M�������K��S���ih�kS��nW��DIB���Ւ*|�.�0��������v���cBV��mY$#�����Q�ޠC��m�Su��w�)�vQ���Er���l6T�.[��C+r�1�w���>�Ps�W��c-z=��S�d=��˳��"Zs��욓v]��:2Jr���Z�{�e�m�}ډG�r]�̕���,�;�R���D����>{�%X��9��1ZY��c��8)�))mu�
D�B�{�D�x�]\uy9R������i��Rv�墒M);��&�(�K�
------WebKitFormBoundary9S0IBLc1TGixx3Al
[/code]
So as you can see, it's basically a bunch of sections with a header and a body. It would all be fine and dandy if the sections had a Content-Length header, but they don't.
How do I get the binary data without corrupting it? There's a CRLF after the plain text data in the "folder" section, but I'm not sure if a CRLF is placed after binary data. Even if I figure out that, how do you guys suggest I best go about looking out for the boundary? I'm going to be writing the data of each section to disk as I recieve it, but I'll obviously need to use some kind of buffer to look out for the boundary.
What would be the most efficient way to read incoming data into a buffer, search for the boundary, and write the buffer to disk?[/QUOTE]
As for writing to the disk: break the data into chunks and receive the first chunk. Check for the last chunk (by content length or ------WebKitFormBoundaryXXXXXXXXXXXXXXXX) and then write it to disk. Clear the intermediate buffer and receive the next chunk...
But I don't know the content length, and what if the boundary ends up split between chunks?
This may sound a bit stupid, but can someone give me a simple code for 2D collision? I seem to have trouble writing my own.
Are you using any media API? If so, which?
And what programming language are you using?
SFML in C++, but I'm looking for the pseudocode of such a function so I can use it in any project.
In SFML you can simply use the Intersects-function.
You can then also take a look how SFML handles it:
[cpp]template <typename T>
bool Rect<T>::Intersects(const Rect<T>& rectangle, Rect<T>& intersection) const
{
// Compute the intersection boundaries
T left = std::max(Left, rectangle.Left);
T top = std::max(Top, rectangle.Top);
T right = std::min(Left + Width, rectangle.Left + rectangle.Width);
T bottom = std::min(Top + Height, rectangle.Top + rectangle.Height);
// If the intersection is valid (positive non zero area), then there is an intersection
if ((left < right) && (top < bottom))
{
intersection = Rect<T>(left, top, right - left, bottom - top);
return true;
}
else
{
intersection = Rect<T>(0, 0, 0, 0);
return false;
}
}[/cpp]
[QUOTE=blankthemuffin;23752402]There should really be no need to write to a larger texture like that.[/QUOTE]
I'm still a novice at the optimization theories and stuff, but wouldn't it be at least a bit less taxing on the application if I were to have one draw operation for the map a frame than ( MapSize.x * MapSize.y ) draw operations per frame?
How do I know if vertices in an .obj form quads or triangles? I mean, I know you can count how many are connected but is there something before the "f" lines that says the following will represent triangles/quads?
Edit:
Any particular reason why my model loader would fail to draw this? I mean, do you see anything unusual?
[code]# Blender v2,53 (sub 0) OBJ File: <memory2>
# www,blender,org
mtllib ico,mtl
o Icosphere
v 0,000000 -1,000000 0,000000
v 0,723600 -0,447215 0,525720
v -0,276385 -0,447215 0,850640
v -0,894425 -0,447215 0,000000
v -0,276385 -0,447215 -0,850640
v 0,723600 -0,447215 -0,525720
v 0,276385 0,447215 0,850640
v -0,723600 0,447215 0,525720
v -0,723600 0,447215 -0,525720
v 0,276385 0,447215 -0,850640
v 0,894425 0,447215 -0,000000
v 0,000000 1,000000 -0,000000
v 0,425323 -0,850654 0,309011
v -0,162456 -0,850654 0,499995
v 0,262869 -0,525738 0,809012
v 0,425323 -0,850654 -0,309011
v 0,850648 -0,525736 0,000000
v -0,525730 -0,850652 0,000000
v -0,688189 -0,525736 0,499997
v -0,162456 -0,850654 -0,499995
v -0,688189 -0,525736 -0,499997
v 0,262869 -0,525738 -0,809012
v 0,951058 -0,000000 -0,309013
v 0,951058 0,000000 0,309013
v 0,587786 0,000000 0,809017
v 0,000000 0,000000 1,000000
v -0,587786 0,000000 0,809017
v -0,951058 0,000000 0,309013
v -0,951058 -0,000000 -0,309013
v -0,587786 -0,000000 -0,809017
v 0,000000 -0,000000 -1,000000
v 0,587786 -0,000000 -0,809017
v 0,688189 0,525736 0,499997
v -0,262869 0,525738 0,809012
v -0,850648 0,525736 -0,000000
v -0,262869 0,525738 -0,809012
v 0,688189 0,525736 -0,499997
v 0,525730 0,850652 -0,000000
v 0,162456 0,850654 0,499995
v -0,425323 0,850654 0,309011
v -0,425323 0,850654 -0,309011
v 0,162456 0,850654 -0,499995
f 15 13 2
f 13 15 14
f 3 14 15
f 14 1 13
f 17 2 13
f 13 16 17
f 6 17 16
f 13 1 16
f 19 14 3
f 14 19 18
f 4 18 19
f 18 1 14
f 21 18 4
f 18 21 20
f 5 20 21
f 20 1 18
f 22 20 5
f 20 22 16
f 6 16 22
f 16 1 20
f 24 2 17
f 17 23 24
f 11 24 23
f 23 17 6
f 26 3 15
f 15 25 26
f 7 26 25
f 25 15 2
f 28 4 19
f 19 27 28
f 8 28 27
f 27 19 3
f 30 5 21
f 21 29 30
f 9 30 29
f 29 21 4
f 32 6 22
f 22 31 32
f 10 32 31
f 31 22 5
f 33 24 11
f 24 33 25
f 7 25 33
f 25 2 24
f 34 26 7
f 26 34 27
f 8 27 34
f 27 3 26
f 35 28 8
f 28 35 29
f 9 29 35
f 29 4 28
f 36 30 9
f 30 36 31
f 10 31 36
f 31 5 30
f 37 32 10
f 32 37 23
f 11 23 37
f 23 6 32
f 39 7 33
f 33 38 39
f 12 39 38
f 38 33 11
f 40 8 34
f 34 39 40
f 12 40 39
f 39 34 7
f 41 9 35
f 35 40 41
f 12 41 40
f 40 35 8
f 42 10 36
f 36 41 42
f 12 42 41
f 41 36 9
f 38 11 37
f 37 42 38
f 12 38 42
f 42 37 10[/code]
And it's not the commas. I just replaced the dots with it because I can't figure out how to change the decimal symbol for float.Parse
[QUOTE=NorthernGate;23756915]I'm still a novice at the optimization theories and stuff, but wouldn't it be at least a bit less taxing on the application if I were to have one draw operation for the map a frame than ( MapSize.x * MapSize.y ) draw operations per frame?[/QUOTE]
Instancing -> one single call to draw multiple objects.
[editline]02:54PM[/editline]
I also forgot which API you are using, but you could also have a single quad and let the shader decide which texture to use.
[QUOTE=ZeekyHBomb;23757072]Instancing -> one single call to draw multiple objects.
[editline]02:54PM[/editline]
I also forgot which API you are using, but you could also have a single quad and let the shader decide which texture to use.[/QUOTE]
I'm using SFML, so I really have no idea how I would go about doing something like that...
I don't know, I guess when I thought about it stitching together the images seemed like it'd make my life a lot easier when managing chunks, it's kind of a bummer to realize it doesn't do anything in the department of performance, but it still makes managing chunks a bit easier so I think I'll keep it that way for now.
Another thing I'm working on is trying to display an image with OpenTK. I don't know how. Currently using this [cpp] int texture = GL.GenTexture();
GL.BindTexture( TextureTarget.Texture2D, texture );
// when texture area is small, bilinear filter the closest mipmap
GL.TexParameter( TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.LinearMipmapNearest );
// when texture area is large, bilinear filter the original
GL.TexParameter( TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Linear );
// the texture wraps over at the edges (repeat)
GL.TexParameter( TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (float)TextureWrapMode.Repeat );
GL.TexParameter( TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (float)TextureWrapMode.Repeat );
Bitmap bmp = new Bitmap( @"C:\ExampleImage.png" );
int current;
byte[] bytearray = new byte[ 256 * 256 * 4 ];
BitmapData bd = new BitmapData();
bd = bmp.LockBits( new Rectangle( 0, 0, 256, 256 ), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb );
Marshal.Copy( bd.Scan0, bytearray, 0, 256 * 256 * 4 );
bmp.UnlockBits( bd );
GL.TexImage2D( TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, 256, 256, 0, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, PixelType.UnsignedByte, bytearray );
GL.Begin( BeginMode.Quads );
GL.TexCoord2( 0, 0 ); GL.Vertex2( 0, 0 );
GL.TexCoord2( 256, 0 ); GL.Vertex2( 256, 0 );
GL.TexCoord2( 256, 256 ); GL.Vertex2( 256, 256 );
GL.TexCoord2( 0, 256 ); GL.Vertex2( 0, 256 );
GL.End();[/cpp]
But it just draws a white quad, no texture. I have enabled Texture2d.
[QUOTE=Darwin226;23756975]How do I know if vertices in an .obj form quads or triangles? I mean, I know you can count how many are connected but is there something before the "f" lines that says the following will represent triangles/quads?[/QUOTE]
Isn't it just the number of vertex indices after 'f' that dictates it?
e.g. "f 1 2 3" is a tri and "f 5 3 8 2" is a quad. You could count the spaces in the line. I made an obj loader a few months ago and that's how I did it.
[QUOTE=Darwin226;23758116]Another thing I'm working on is trying to display an image with OpenTK. I don't know how. Currently using this [cpp]
GL.Begin( BeginMode.Quads );
GL.TexCoord2( 0, 0 ); GL.Vertex2( 0, 0 );
GL.TexCoord2( 256, 0 ); GL.Vertex2( 256, 0 );
GL.TexCoord2( 256, 256 ); GL.Vertex2( 256, 256 );
GL.TexCoord2( 0, 256 ); GL.Vertex2( 0, 256 );
GL.End();[/cpp][/QUOTE]
Try putting GL.Vertex2 before GL.TexCoord2.
Did you enable texture functionality for the pipeline (glEnable( GL_TEXTURE_2D ))?
[QUOTE=ZeekyHBomb;23759090]Did you enable texture functionality for the pipeline (glEnable( GL_TEXTURE_2D ))?[/QUOTE]
[QUOTE=Darwin226;23758116]I have enabled Texture2d.[/QUOTE]
Sorry, you need to Log In to post a reply to this thread.