C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.

learn more… | top users | synonyms

0
votes
1answer
149 views

How do you build a rotation matrix from a normalized vector?

I'm trying to find the correct way to build a rotation matrix from a unit vector. I have two arbitrary points in space (p1 and p2), and I'm trying to create the vertices for a rectangle to span ...
0
votes
1answer
45 views

Unable to load two enemies with same pic in sdl2

I have loaded two enemies(with the same pic) into my game. However, when I draw them onto the screen it only draws and animates one enemy, instead of two. I can't seem to figure this out. Here is my ...
0
votes
1answer
60 views

Irrlicht app: Creating STL exception leads to segfault

I'm developing application with C++ language and Irrlicht engine. When I add std::runtime_error("err") expression into my code, I got segmentation fault at address 0 (before entering to main). If ...
0
votes
0answers
53 views

Boost vs cereal for Serialization

I am preparing to make a simple 3D game with OpenGL and one thing that came up pretty quickly was storing the required data. If I recall correctly, Java has a class called "ObjectWriter" which ...
4
votes
3answers
498 views

Manage user input and diffentiate it between the player and the app

I hope the title makes sense. Basically, I am trying to figure out how the app will know I the input I am sending it is meant for the app and not the player, and vice-versa. (It is very similar to ...
0
votes
1answer
48 views

Strange shadow behavior when light direction is parallel to a plane

i have a strange problem with shadow acne. It occurs when the light direction is parallel to a plane. Here is my code and a few images of the problem: //this calculates the shadow matrix ...
2
votes
0answers
46 views

How come these 2 lines of code are causing a memory leak? [closed]

I'm confused, I commented these 2 lines out resulting in no memory leaks, and when I added them again it's leaking. However I can't understand why it's actually leaking? This is the 2 lines of ...
0
votes
0answers
32 views

Non-real time simulation of overlapping repulsive balls

I want to make a non-real time simulation of overlapping repulsive balls, initially in 2D and later in 3D. With "non-real" I mean that rendering is not needed after each time step. First of all, ...
0
votes
2answers
139 views

Switched from immediate mode to VBOs, game runs slower

trying to improve draw performance on my c++, OpenGL, SDL game. Back in school we mostly learned immediate mode, so thats how my drawing was originally implemented. When I started reading up online ...
1
vote
1answer
109 views

Collisions being detected before objects are intersecting

I'm making space invaders (in OpenGL/SDL) and I'm currently having issues with getting the collisions (box collisions) between the bullets and the enemies to be properly detected. In my update() ...
2
votes
1answer
72 views

How to replicate Unity's Rigidbody.AddForceAtPosition in C++?

I am trying to replicate the function Rigidbody.AddForceAtPosition of Unity in C++, it means, to apply force to a body offset from its center. How could I achieve that in C++?
2
votes
2answers
1k views

Offline texture mipmap generation

I want to generate mipmaps for 2D textures as an offline step. My priority is for image quality, execution time is not a concern. The images will, naturally, always be halved and will always be ...
1
vote
0answers
749 views

Get derived Pawn from collision actor in UE4

I am trying to build a basic RTS unit selection but any time I try to possess the target pawn it crashes. The pawn in the collision is a blueprint derived directly from APawn. Am I casting from the ...
25
votes
9answers
25k views

How do I create a save file for a C++ game?

I am coding my final for a Video game Programming course, and I want to know how to create a save file for my game, so that a user can play, and then come back later. Any idea how this is done, every ...
1
vote
3answers
134 views

Get the tile that my mouse pointer is currently over?

I want to get the tile that my cursor is over in my game. I did some googling though most of the examples we're in other languages/libraries and if they weren't, they didn't work for me because I use ...
3
votes
1answer
151 views

How can I separate processing input and update?

I know that game loop is broken up into three distinct phases: processing inputs, update, and render, but I just can't see how I can make processing input and update independent of each other. Let's ...
0
votes
0answers
28 views

Should all textures be power of 2 in SDL2? [duplicate]

I come from Gamemaker background, and I know that anything you give Gamemaker is put onto a texture page that is power of 2 size, but I am now making an SDL game engine and I am wondering, should all ...
0
votes
1answer
25 views

How can I clear the screen in Xcode?

so I am following a tutorial to make a snake game in my Xcode console. But the tutorial i am following is using windows and therefore the "system("clear")" command isn't working with my mac, and all ...
0
votes
0answers
36 views

C++ render Umlaute with Spritefont

I have a SpriteFont-Class and with that I render text to my game. Now my problem is, that it doesn't render Umlaute like ä, ü, ö, ß... Because I am German it is very important, that I can render these ...
0
votes
2answers
95 views

DeltaTime won't create smooth movement

The problem : I tried adding deltaTime into my game, which seems to not be working when I try to smoothly move a object in my game. How I calculate delta time : Delta Time variables : ...
0
votes
4answers
81 views

Issue translating objects by one unit in the y direction

I'm currently making space invaders (in OpenGL/SDL) and I'm running into an issue with the movement of the aliens. I have a 2-d vector of aliens (5 rows of 11) and I'm translating each in the x ...
1
vote
1answer
67 views

How to make a triangle move and rotate using GDI in C++

I want to make a triangle move from one place to another then rotate it 270 degrees using Polygon() function does anyone knows how to?? Just a simple one.
0
votes
0answers
27 views

Methods to load .fbx using FBX SDK in binary data chunk

I am trying to acquire model information from .fbx in binary data chunk to see if loading time can be faster than regular accessing. For this purpose, I found a sample called "My Own Reader/Writer" ...
0
votes
1answer
109 views

Is it safe to set Lua Table data from multiple C++ threads?

As the title states. I'm curious if it's safe to set data in different Lua tables that exist in the same lua state. From multiple C++ threads. I'm asking this because my current system actually has a ...
0
votes
1answer
65 views

Why does invoking glm::refract function return NaN?

At the present time, I make a simple raytracing project and I encounter an issue : When I invoking the glm::refract function, it returns me a vec3 with "NaN" values. However, my input data seems to be ...
3
votes
1answer
2k views

Pixel Perfect Collision Detection in Cocos2dx

I am trying to port the pixel perfect collision detection in Cocos2d-x the original version was made for Cocos2D and can be found here: ...
0
votes
1answer
51 views

My Sprite class generates a EXC_BAD_ACCESS error, and is sometimes NULL? Rect has weird values?

So, lets start off with the weird Sprite* object sometimes being NULL. I run my game, the EXC_BAD_ACCESS error comes and sometimes, only sometimes my Sprite* has a value when it crashes. Sometimes ...
1
vote
1answer
42 views

Allowing a unit to equip only certain types of weapons

I'm making a FireEmblem style game, and I am working on items at the moment. I have a Weapon class from which Sword, Axe, etc. are derived. I also have character classes like Swordsman, Mage, etc. I ...
48
votes
10answers
14k views

Game State 'Stack'?

I was thinking about how to implement game states into my game. The main things I want for it are: Semi-transparent top states-being able to see through a pause menu to the game behind Something ...
1
vote
1answer
50 views

How can I avoid referring directly to the state type when transition to new states in a state machine?

I finally found a good way to implement a "stack-of-states" to manage what screen I am on. Minimal example: class gameEngine { public: //Removes state at the "back" of the stack and puts the ...
0
votes
0answers
27 views

Why does Intel Graphics Monitor crash after I set a depth stencil state in my Direct3D 11 application?

I'm programming a managed Direct3D 11 application with SlimDX. I want to use Intel Graphics Monitor to capture draw calls for a single frame. When I try to set a depth stencil state my application ...
0
votes
0answers
62 views

Doing camera shake together with culling isometric tiles

Following this question, I've tried to do camera shake together with culling the tiles to no avail. The base code for camera shake is from this question. This is the code that I tried but failed ...
0
votes
0answers
17 views

Cocos2dx : Lua with C++: lua_pcall closing my app

I'll try to explain what is happening with my current project: I want to make some custom scripts myself without using the lua script engine from cocos2dx, so I linked lua51.lib on Linker->Input, and ...
3
votes
0answers
50 views

Optimal batching for 2D objects with transparency

I have a collection of 2d objects with transparency. Each object has a depth value to determine draw order and a material. I'm trying to batch them in an optimal way to minimize draw calls. Assume ...
1
vote
1answer
49 views

How can I access the members of XMVECTOR?

So I have been reading these articles, and I find implementing them a trouble. Currently, all I am trying to do is add two vectors together, leaving my question more specifically this: How can I add ...
0
votes
1answer
85 views

Why does SDL render the background from the operating system to the window?

My code displays a fully transparent window that copies the background from the operating system. This is the code I use for rendering: void render() { SDL_RenderClear(renderer); ...
0
votes
1answer
80 views

Sprite quickly disappears after rendering

I'm currently making space invaders and I'm using the game loop pattern as described here. I have an entity class from which there is a spaceship derived class. The base entity class contains all of ...
4
votes
1answer
88 views

How to solve Sweep and prune false positives concerning large floor plane

I am developing a 3d sweep and prune module for a project, and it is producing false positives. The pair generation code is as follows: for (unsigned int i = 0; i < mXExtents.size(); i +=2) ...
2
votes
1answer
254 views

Immovable object impact physics

I am trying to do some physics calculations from scratch, and as a result am creating a small bouncing ball example. However, I have some issues getting correct results from my impact physics when the ...
2
votes
2answers
121 views

Example/Tutorial of passing structured data over network C++

This is very general question, about strategies how to pack same informations about state of my game-world on server ( e.g. position/orientation of players, projectiles, etc. ) into data stream so ...
1
vote
0answers
67 views

Memory leak with glfwSetWindowTitle? [closed]

I am using GLFW for a game, and I have a function which allows me to set the window title. // PROBLEM WITH INCREASING MEMORY USAGE void WindowSystem::setTitle( const string & title ) ...
0
votes
0answers
33 views

Screen Size 2D Gameboard Background

I am trying to get the screen size of the current monitor and then render the game board to match the screen orientation but currently I am scaling the game board to a larger size which not the best ...
0
votes
1answer
109 views

Updating a multithreaded Entity-Component-System

I am currently trying to implement an (sort-of) Entity-Component-System. I've got the gist of it, that is, how an ECS is supposed to work. So far i have 4 classes in my design (not yet fully ...
2
votes
2answers
72 views

Calculate matrix transformation components separately

It is possible to calculate the translation, rotation and scale that were used to build a matrix? I mean if I have a matrix M can I calculate the rotation, scale, and translation it represents? Of ...
0
votes
1answer
74 views

How can I correctly instantiate an octree in UE4?

I tried to create a simple Octree like this: (I looked at the FMeshTriOctree source code since no question in answers.unrealengine.com helped me) // My FVertex class is slightly more complexe, but ...
1
vote
1answer
258 views

How do I render a 2D overlay with DirectX 9?

I'm working in C++ with DirectX 9 on a 3D game, but I want a 2D overlay for rendering a HUD. I've heard that I could use D3DXMatrixOrthoLH, but I'm very confused on how to use it. I'm more familiar ...
0
votes
0answers
45 views

Why won't my object go 3D DirectX11?

I am trying to make a 3d mesh within my code. For some reason it looks deformed, which makes no sense because I specified the vertices correctly I am pretty sure. Also sorry that I am posting loads of ...
0
votes
1answer
40 views

D3D11CreateDevice leads to syntax error [closed]

I'm following the book Introduction to 3D Game Programming with DirectX 11 by Frank Luna (link) and I'm trying to make the empty project in Chapter 4 (don't worry, I don't expect you to read the book) ...
1
vote
1answer
111 views

GLSL strange if statement problems

I'm trying to use if statement in my fragment shader. I want to compare my in int finalLightType[4]; Here is my vertex shader code and fragment shader code: Vertex: #version 400 core in vec3 ...
0
votes
0answers
22 views

Pleats and folding

We have a C++ module that produces mesh dynamically and simulates it with a physics engine. We want pleats on the surface of our mesh, pleats that remain sharp and folded during simulation while ...