New answers tagged

0

The answer turns out to be rather easy, altho lengthy, Instead of cleaning up faces (now called points) and preparing the list for gldrawarrays, I instead create a new list of unique faces/points as a base reference: Ill just post the entire function: void objload4(string filename, vector<glm::vec3>&vertices, vector<glm::vec2>&texcords, ...


0

It's possible the player object moves into a wall and the position is updated, then collision is detected and the players position is then corrected creating a "bouncing" effect. To correct this, compute your collisions prior to moving the player (or probably any object).


1

The problem was this: bool AStar::Contains(std::vector<Node*> _pVector, Node* _pNode) { return find(_pVector.begin(), _pVector.end(), _pNode) != _pVector.end(); } It made a copy of the vector every single time it was called, wich made it incredibly slow. Making it a pointer to the vector increased the time from about 30 Seconds to only about 6 ...


1

EDIT: Setting it on Release mode will make the pathfinding ALMOST instant This is probably the key piece of information. Although you don't say so, your problem is presumably that you're using the STL in a debug build in something being compiled within Visual Studio. Visual Studio's implementation of the STL is notoriously (and catastrophically) slow ...


0

You could convert one of the OBBs to an AABB by applying the inverse of the first OBBs transform to both OBBs. Now the first OBBs is an AABB and the other is still an OBB, so you can use the AABB vs OBB function to test if they overlap. If the collision function returns a normal/position, you must transform them by the fist OBBs transform to put them back ...


0

So, as you know, readimagefile displays an image to the screen by reading it off the disk, and on some systems, it apparently only ever reads it from the disk without caching the image. So, what we need to do is move calls to readimagefile out of the loop and into some initializing portion of the code. You mentioned getimage and putimage in your question, ...


0

I noticed many comments where people believe that TCP packets are bigger than UDP packets. Don't just trust me, read the documentation. The protocol is as follow: a few bytes for Ethernet header (2 bytes message type, 48 bit MAC, 6 bytes) (for Wifi, header may differ) 20 bytes for IP 20 bytes for TCP or UDP x bytes for the data x ranging from 0 to about 1500 ...


0

Neither UDP or TCP (or any other variant) is out-right superior, not even in terms of speed/latency. Your choice must be made depending on the requirements of your application. To do this, you should compare the features each protocol offers, realizing that more features implies more overhead. So, if the goal is to minimize latency or maximize speed, then ...


0

Main ways to speed up frustum culling (and collision in general): simplified bounding: you have AABBs (check) fast collision functions: looks like you are doing this (in progress) spatial partitioning objects in the world: ??? Spatial partitioning gives the most speed up. Are you doing anything? Depending on game type, there are a ton of easy ways to get ...


1

You may compare the first diagram of RFC 768 (UDP) to the first diagram of RFCP 793 (TCP) page 15. Both show 16 bits for a “source port” followed by 16 bits for a “destination port”. Both show 16 bits for a “checksum”. According to RFC 768, UDP's “checksum procedure is the same as is used in TCP.” Whereas ...


3

Release does not return an HRESULT, it returns a ULONG. That ULONG is the new reference count on the object (after the release). hr == S_FALSE in your code because Release is returning 1 (which is what S_FALSE is defined as), which means there's one pending reference count to the object after you release it (that's not necessarily a problem, it could be an ...


2

Whether or not you decouple your window creation from your engine code is up to you. You can do it both ways. If you don't handle window creation in your code, you'll expect the user of your code to handle it. That will include forwarding window events to you somehow -- probably by calling interface methods on your game engine object you define for them. ...


3

Since performance is the most important thing - I would rewrite this to use arrays rather than standard library containers. The problem with using data structures designed and developed by someone else is that if you don't understand how they're implemented you'll very easily end up performing millions of unnecessary operations - including memory allocation ...


0

You don't render a skybox as a "cubemap". You often render objects using a environment cubemap that matches the skybox, but the skybox itself is just rendered with a set of 2D textures. On Direct3D Feature Level 10.0 or later hardware, you can use a Texture2D array with 6 faces as both a cubemap and with another shader as six individual faces. The WIC ...


1

I know that UDP is usually recommended for real-time multiplayer games with high data usage Is UDP still superior in terms of speed and latency? Could recent TCP optimizations have made TCP perform better than UDP? Your assumptions are wrong. TCP and UDP differ primarily in what model they represent (unreliable datagrams versus in-order reliable ...


2

When i is 0 you copy the row 0 into the row 1, then i is 1 and you copy the row 1 into the row 2, etc. The problem is that when you copy the row 1, it has already been overriden. You probably also have a problem when i = HEIGHT because i+1 is out of bounds. The solution would be to iterate from the bottom row to the top row (from HEIGHT-1 to 1): for (i = ...


1

In a high bandwidth MPG, you don't care if you missed a packet giving you the location and health of monster #425, because you'll be getting another update in some fraction of a second. This is and example where UDP makes TCP look stupid for making you wait for instantly obsolete data. In that same game, you want the patches to show up exactly as they ...


1

Consider what's happening for a moment. To simplify the scenarios, you have two choices when trying to send a state change (like your player just changed direction, or shot a gun, or some other player just set off a bomb): Keep a TCP session open, and when the bomb is to go off send a TCP message to all players (if possible, see below) Keep a UDP port ...


17

We agree upon both TCP and UDP being protocols built on top of IP, don't we? IP specifies how messages are delivered across the internet, but nothing is about the messages structure, format. Here come TCP and UDP protocols. They use IP properties, but let the programmer focus on the message exchange without worrying about the lower layers of net ...


7

TCP <- Transmission Control Protocol. It's made to control transmission. TCP was created to be a good and diplomatic network citizen. It focuses on making the networking a good experience for everyone, and willingly decreases it's throughput to achieve that. It adjusts to the environment by adding latency. Reasons are for example: Receiver detects a ...


0

Has all the TCP optimized routers made TCP perform better than UDP? One more question is: does "data heavy" mean you will frequently load scenes? If yes, you may need to send large pieces of data (>1k) intensively in which TCP may be much more efficient because especially on the server side the NICs will provide various offloads which same lot of ...


7

I see a few issues. you are doing a lot of linear scans over vectors (at least 2 for each neighbour for each node you examine). This will be pretty slow. You don't even need the closed set if you just have a bool isClosed in the Node. You should sort the openset or make the openSet a min heap of some description. This will make the search for the next ...


105

No, UDP is still superior in terms of performance latency, and will always be faster, because of the philosophy of the 2 protocols - assuming your communication data was designed with UDP or any other lossy communication in mind. If you send 2 updates on TCP, and a packet of the first update gets lost, you will not see the second update until: The loss of ...


0

Rather than using entire sprite sheet animation, I would recommend a 2D skeletal approach. Tools like Spine can help you here and are supported by cocos2d-x framework. The class in question is the SkeletonAnimation object. Here is a sample code on how to initialize the same source- cpp tests from cocos2d-x //initilize the object with animation atlas ... ...


1

To render a cross-hair, all you would need to do is render a piece of geometry using just a screen-space transformation, followed by the projection matrix. Mapping the identity matrix as your view will do this for you. A view matrix allows us to transform vertices into view space; removing this step allows us to go directly from model-space to screen-space. ...


0

Looks like that by luck I found the solution to the problem. I really don't like the glm documentation, was my understanding that glm doc was intentionally skinny since it matches corresponding glsl and glut. Anyway documentation is a mess. doc v 0.92 doesnt specify what unit to use, the gluPerspective uses degree, so that's why I used degrees. doc v0.94 ...


1

I think you need some documentation about collisions. It seems you want to check the collision between 2 hitbox on a 2D game: if (rect1.x < rect2.x + rect2.width && rect1.x + rect1.width > rect2.x && rect1.y < rect2.y + rect2.height && rect1.height + rect1.y > rect2.y) { // collision detected! } But you're ...


0

All you seem to be missing is a call to g_pDirect3D_Device->Present().


0

The 5th "stride" argument in all of your 4 glVertexAttribPointer calls is specified as 3 * sizeof(GLfloat), while in your case it should be 0, as you are using separate buffers per vertex attribute (see https://www.opengl.org/sdk/docs/man/html/glVertexAttribPointer.xhtml). That argument is non-zero for cases when you interleave those attributes in a single ...


1

Your issue is that SDL sends keyboard events only when the state changes. So, if you move your current buffer to the previous buffer and then clear the current buffer, your keystate won't be correct on any of the frames after a key press. On the frame when the key was pressed, the current buffer should hold the value, but on frames after, there won't be a ...


0

It's not clear what you are trying to achieve, but changing the < operators to <= might be a step in the right direction.


0

Your issue seems to be that you are only checking a single tile if your player is 32 or less pixels wide. That obviously does not work, because your player is taller than one tile. Hence, you need to remove the first easy-oit as it breaks the detection, and simply just rely on the looping method.


0

What you have here is not a multidimensional array. What you have is a vector which references a bunch of vectors which reference a bunch of vectors which reference a bunch of objects. The problem with these many layers of indirection is 1. that your CPU needs to jump through all these memory references each time it looks for a tile and 2. that these memory ...


-1

http://www.geforce.com/hardware/desktop-gpus/geforce-gtx-670/specifications Nvidia homepage says only 4.2 is supported. Check the error logs and for any other opengl error and fix them if any.


1

Main Question: Is there a specific way of setting up and rendering OpenGL for NVIDIA Graphics so that it renders properly, and not a black screen? NVIDIA graphics cards are no different from any other cards seen from an OpenGL perspective. Different behavior on different platforms may exist as a result of: - Different capabilities. Some cards may ...


1

You could rebuild the spears orientation matrix from a direction vector. Good example with dx code is here.. http://stackoverflow.com/questions/4237873/rotate-a-sphere-so-that-its-pole-heads-towards-the-camera/4237921#4237921


0

Strictly speaking, no. You can have as many threads as you want (on desktop platforms at least). If you are using threads to boost performance, however, you will not see any gains (and will likely lose performance again) past the number of "CPU threads", except with specific scenarios like asynchronous I/O. This is outside of the scope of your question, ...


3

Edit The observed behavior of the ball going through the paddle prompts me to check your collision detection statements, and I believe they are the problem. The condition if (ballx == x + (P1W / 1.0)) will only return true if ballxis exactly equal to a specific point of your paddle. What you want to check is if any part of your ball overlaps any part of ...


1

You need to both define and declare static variables. I'm assuming that you declared your SDL_Event* variable in a header file, inside a class declaration or something similar. That's only half the work of adding a static variable. You need to also define it, such as static SDL_Event* MyClass::event. Anyways, you probably don't need to make the event static. ...


1

I understood by myself how to retrieve the frame rendered and now I have this method : void Renderer::getVideoStream(){ glReadBuffer(GL_BACK); int width = m_window->width(); int height = m_window->height(); vector< unsigned char > buf( width * height * 3 ); glPixelStorei( GL_PACK_ALIGNMENT, 1 ); glReadPixels( 0, 0, ...


0

In Ye olden days we used to use the bottom 16 bits of a long as the fraction part. struct HiLo { public: unsigned short m_lo; unsigned short m_hi; }; union LongFraction { public: LongFraction() { m_all = 0; } HiLo m_hilo; unsigned long m_all; }; Then 0-65535 becomes the fraction part. LongFraction pos; pos.m_all += ...


0

I suggest using a space-partitioning data structure, i.e. Quadtrees. They reduce running time from linear to logarithmic in the number of rectangles, which will give you the desired performance boost. Here is a nice tutorial on how to implement and use them. ...


0

I think this is what you want: It's adds a movement vector to the pawn.


1

Your collider uses a different width and height than your sf::RectangleShape: at line 22, you swaped width and height.


2

One way to do this is to only run physics and render code when the event queue is empty: ALLEGRO_EVENT_QUEUE* e = al_create_event_queue(); al_register_event_source(e, al_get_keyboard_event_source()); al_register_event_source(e, al_get_mouse_event_source()); al_register_event_source(e, al_get_joystick_event_source()); al_register_event_source(e, ...


2

Using integer ID's allows you to keep all your objects in an std::vector<GameObject>. Accessing a vector by index is a constant-time operation. If you want to keep using strings as object keys (having human-readable keys might be more convenient for the user), consider using an std::unordered_map<string, GameObject> to map strings to objects. It ...


3

If you use al_wait_for_event, then you need to use a ALLEGRO_TIMER as well to generate pulses (every 1/60th of a second for example) and you update your movement every pulse. That way there is always an event happening on Allegro. If you still don't want to use a timer, you can use al_wait_for_event_until and then specify till when you wait for an event for ...


3

The only reason you need to extend a vector to 4 dimensions (homogeneous coordinates, not 4-Dimensional space) is so that you can apply transforms or matrices (model, etc) to it. Unless you're explicitly making a game in a 4-Dimensional space you don't need to include the w component in the calculations you mentioned. Indeed, as you noted, using a w ...



Top 50 recent answers are included