Questions tagged [c++]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
77 views

How can I avoid coupling between units and their environment?

Currently in the process of making a game like Dwarf Fortress, so without graphics. I'm mostly thinking about how I want to implement everything. While writing code I keep stumbling on general game ...
0
votes
1answer
49 views

Why would I add components in code?

Watching a Unreal Course, and the instructor is creating a default pawn c++ class. He is adding all the components with code, but this seems really inefficient to me. Why can't you add components in ...
0
votes
1answer
59 views

Are there any serious advantages for C++ compared to C? [closed]

so I know a little bit about C (read like a few university level textbooks on it, I am not an experienced programmer or anything) and now I would like to learn the ropes of the Unreal engine to fidle ...
1
vote
0answers
37 views

Setting an array in the HLSL shader

I have a array of six float4x4's in my shader. cbuffer pseudeocb { float4x4 Mypseudo[6]; }; I need to set these in my code. ...
0
votes
0answers
29 views

Rendering a texture with SDL2 causes “Invalid texture” error message [closed]

When SDL_RenderCopy() gets called, it fails and SDL_GetError()returns the error "Invalid texture". Here's my code: ...
0
votes
2answers
94 views

What's the maths behind checking line of sight

I understand in unity there is Phsyics.LineCast(Vector A, VectorB). What's the maths behind doing that, the only thing i can think of is going along the line at small intervals and seeing whether it ...
0
votes
1answer
26 views

Unsure where to right click to delete Unreal C++ class

Trying to delete a c++ class (this should not be this difficult!) and I have deleted the .h, .cpp, and binaries. Next everybody says "now, right click on your .uproject file and select Generate ...
0
votes
2answers
54 views

Should a game object class contain the information for how to render it?

If I have a class called Enemy: // Simplified version class Enemy { float xPosition_; float yPosition_; int hp_; }; Should this class also contain the ...
0
votes
0answers
17 views

Having problems with making a button class (checkIfClick) opengl

Just basing how sfml does it, I get the globalbound of the object and then check if the mouseposition is within the object. I ...
0
votes
1answer
29 views

Get black bars with framebuffer and glViewport

I have read several tutorials and answers regarding framebuffers and glViewport, but I can't seem to resolve this issue I have. I want to take a low resolution framebuffer (400x225) and place it in a ...
0
votes
0answers
25 views

Having trouble with 2d projection (Opengl)

I need to change the normalize coords from -1 to 1 to the width and height of my application. The reason why I want to change the normalize coords is because i think it would be a easier set position ...
1
vote
1answer
43 views

Multithreaded callback

I'm making a multiplayer game where players fight in vehicles, and I am doubting my server architecture. As it will be physics, network and AI intensive I would like to split these 3 topics into their ...
0
votes
0answers
55 views

Game loop implementation

I'm implementing simple Windows game. Here is my game loop, which I've written based on some tutorials found on the Web: ...
1
vote
0answers
32 views

Direct State Access (DSA) is Failing, but pre 4.3 OpenGL works [closed]

I currently have an OpenGL project in which I am using GLFW for the window and context creation, and GLAD for loading OpenGL functions. The GLAD version I am using is OpenGL 4.6, compatibility profile,...
1
vote
1answer
45 views

How do I stop a moving object when colliding with a static wall or falling to a static ground

I'm writing my very first 2D game engine in C++ and SDL2. I wrote a very simplistic RigidBody class that computes the resultant force, applies forces and simulates ...
0
votes
1answer
45 views

Translate code to DIRECTX directxmath

How can i translate the code to directxmath code? ...
0
votes
1answer
35 views

how to move a 2d shape in opengl 4.6 (glfw)

Class Button So from my understanding in order to move a 2d shape you need manipulate the vertices and then update???? If i do need to update the buffer how i would go by doing that? float xpos = 150 ...
1
vote
1answer
120 views

How to update indices for dynamic mesh in OpenGL?

So I am making a 3D batchrenderer for my engine, and the basic concept is that we make large enough VBO and IBO to accompany all the vertex data(positions, normals, uv etc.) and update the VBO using <...
1
vote
0answers
34 views

How do I render halfspace fog?

How do I render halfspace fog? From my interpretation, I have a transparent plane in the scene. Then I use a function that returns a fog color in my shader. Do I render the transparent plane by itself ...
0
votes
1answer
43 views

Memory Usage Issue with declared variables (when swapping between states)

So my problem is that When I make a Shader variable and I swap between mainmenustate and gamestate really fast I notice my memory usage increase alot but as soon I switch my Shader varaible into a ...
0
votes
0answers
42 views

I want the game over screen on this super mario bros C++ remake to trigger arduino/batch file

I found a someone who has listed the source code in C++ for their remake of Super Mario and I would like to know how I could edit the code for the "Game over screen" to trigger my Arduino or ...
1
vote
1answer
33 views

Multiplayer game with differently screen size

I am making a classic ping pong 2D multiplayer and its run on full screen, but i have a problem that the ball touch the limits of screen to one player and other no. Any idea how to solve this ?
0
votes
1answer
90 views

text rendering artifact when rendering in 3D opengl GLfW

Main.cpp ...
1
vote
1answer
113 views

String hashing design

I'm in the process of developing a game engine and I would like to refer to game objects and assets by an integer id rather than by their string name. This should avoid any string comparisons at ...
0
votes
2answers
78 views

Need help with gravity simulation in 2D game engine

I'm writing a 2D game engine using C++ and SDL2 and started implementing a rigidbody component similar to that of unity to my game objects. I have a method in the <...
0
votes
0answers
56 views

C++ Raycast using SFML

I know this isn't exactly C++ related, however, I was just wondering if anyone knew anything about texture mapping onto a raycaster. I'm currently trying to write my own and I'm struggling to map ...
0
votes
1answer
40 views

How to combine bilateral blur passes?

I'm changing to bilateral blur for my SSAO implementation, just wondering how people usually combine the two passes - do you just add them together, or average, or something else? I happen to be ...
0
votes
1answer
55 views

Difference between shader input element classification between D3D12 and Vulkan

I'm confused about the difference between the shader input element classifications in D3D12 and Vulkan. For example, in Vulkan I could have the following declarations: ...
0
votes
0answers
56 views

c++/openGL 3D Bouncing Cube

I'm trying to write a little program with a bouncing cube but I can't find the right values for it. I have these lines: ...
0
votes
0answers
38 views

How to implement jumping on the left and right?

I am trying to make a platform game in C++ and SDL2. I tried to add a jump in the update() function of the main code below , but it does not work as expected, as you can see in the video: Note: I did ...
0
votes
0answers
25 views

C++ && SFML game class [duplicate]

Im making c++ && sfml game for my teacher. I need to make game class naturaly I make constructor and destructor, but I cant figure out what methods should game class contain. curently it has ...
1
vote
0answers
31 views

Unreal Engine 4.25.4 - CreateDefaultSubobject inside a child component attached to an actor loses values in blueprint editor

I have the following actor: ...
0
votes
0answers
14 views

reflecting objects by rendering them to the cubemap

I have 2 sphere objects and it isn't reflecting the other one. The picture is when it simply reflects the cube map but when I try to render to the cube map the spheres turn out black. In camera class: ...
0
votes
1answer
95 views

How to update the data in the source code to avoid cheats?

I developed a multiplayer fps game in C++ and many peoples appreciated it, and today someone has created cheats for my game and he is trying to spoil my hard work which I spend developing the game. I ...
0
votes
0answers
26 views

How to implement layer based collision in C++?

I need layer based collision for my game, the problem is I don't really have an idea how to implement it. I'm using C++ and a graphics library called SFML. The only idea I got would be an array of ...
1
vote
1answer
34 views

How to disable present function when window is invisible to user. Win32 & DXGI

When my game window is hidden say by minimising it or hitting Ctrl, Alt, Del. I get the DXGI error: 0x087A0001 : The Present operation was invisible to the user. I've tried wrapping the present ...
0
votes
1answer
42 views

C++ SDL2: How to join two windows in one: top_Window + bottom_Window?

I have a code where the camera scroll left, right, up, down, and I would like to add a progress bar similar to the one below at the bottom of my window Is it possible to create the progress bar in a ...
2
votes
1answer
79 views

What's causing this stutter when framerate fluctuates?

I'm working on a class responsible for arm sway in an fps engine, and am having an issue with a stutter that appears to be related to fluctuating framerate. However I have also noticed it when locking ...
0
votes
0answers
76 views

is there any different solution for different buildings different behaviours

I'm trying to make different behaviours for workers of different buildings, let's say an agricultural worker would need to sow wheat seed and collect the wheat grain when it's grown. let's call that <...
0
votes
0answers
38 views

SDL_Init segfault on linux

I am using Manjaro linux and SDL 2. However, when I build the application in debug mode and use gdb or something like qtcreator with gdb, to debug it, it gives me a segfault, when the function ...
0
votes
1answer
55 views

JoyStick::GetInfo(JoyStick::id1).dwButtonNumber always returns 0x1

I am using an XBox 360 gamepad for Windows. I am having an issue with the following legacy code base, which relies on JOYINFOEX, ...
0
votes
0answers
48 views

Frustum culling issue at oblique angles

I am using the following algorithm to test if my camera frustum contains an axis-aligned bounding box: ...
0
votes
0answers
22 views

Unreal4, C++: Spawned actors visible after stopping, not during play

I've created a class with a function InitializeModel, that is exposed to blueprint. In this function some AStaticMeshActors should be spawned, but I cannot see them during play, I need to stop the ...
-1
votes
1answer
75 views

What is the best way to approach a multi pass rendering system?

I am trying to code a new feature in my engine but I can't find a way to implement my idea, which is the next one. I am trying to get multi pass rendering with more than two passes. I know how to do a ...
0
votes
1answer
60 views

OpenGL/C++ Rotate relative to shooting gun

I'm trying to make a 2D game where I have a gun that i use to shot things in the direction of the mouse resulting in an angle that I can get. I have some problems with the trajectory of the bullet ...
1
vote
1answer
119 views

How to allow infinite custom inputs?

Summary: What approach should I take to allow custom inputs saved in a file be interpreted in the engine? So I am making a game engine similar to Mugen where I want characters to have their own ...
2
votes
2answers
68 views

Getting data from the backbuffer D3D11 using Map [duplicate]

I'm having some trouble using ID3D11DeviceContext::Map() correctly. Here's the whole function so far: ...
0
votes
1answer
75 views

How do I get my sprite to do a regular jump instead of jolt up?

I have been getting into game development and I have made some progress. I have come across an obstacle which is jumping I managed to get the Jumping to semi work but it doesn't look like a jump but ...
0
votes
0answers
46 views

How to efficiently average multiple rotations (quaternions)?

So, I'm working on an animation system in C++, and am trying to blend multiple animations together. A slerp is easy on two quaternions, but is it efficient (or accurate) to chain together for more ...
1
vote
0answers
62 views

OpenGL model not rendering properly

I have been playing with OpenGL for a while and I came into the wall that I don't know how to pass. I am trying to render a model of an object based on a .obj file. In that file I have position ...

1
2 3 4 5
80