Questions tagged [c]

C is a general-purpose computer programming language used for operating systems, libraries, games and other high performance work.

Filter by
Sorted by
Tagged with
0 votes
0 answers
8 views

Can a C file compiled from CGo code, be imported into Cython? [closed]

Is it possible to 'include' a C file compiled from CGo (C+Golang) code, into Cython (C+Python) ? If not, is there any other way to access Golang API hosted on a server, from Python clients ?
Neel's user avatar
  • 229
0 votes
0 answers
34 views

How can I handle voxels that require extra data in my octree?

I am using octrees as an efficient way to store voxel data in a voxel game. The details of my octree implementation can be found here, but in a nutshell, each node is 16 bits, and the most significant ...
user16217248's user avatar
1 vote
2 answers
75 views

Reduce entity-component system boilerplate

I'm attempting to create an entity-component system in C++. However, I've run into an annoying issue where a component system function inherently involves a lot of ceremony and boilerplate. This is ...
Red Needle's user avatar
1 vote
0 answers
52 views

Why opengl code in a lib doesn't renderer?

I am experimenting with opengl using c99 on windows and vs 2022 i tried to create an window using glfw in one project and put a function that supposed to generate a texture in another project that is ...
Abn Alsrag's user avatar
0 votes
0 answers
31 views

How to use SDL_RenderSetLogicalSize() properly in SDL2?

I want to handle different resolutions without altering any game objects. I tried using SDL_RenderSetLogicalSize() but I don't know how to implement it properly. ...
RGthehuman's user avatar
0 votes
1 answer
87 views

How to achieve no gaps between triangles in software renderer like in Quake?

I've heard alot that I need to use fixed-point math, top-left rule, etc. to eliminate gaps between triangles but the thing is how did Quake not have any gaps, did it? I've seen Quake's math file and ...
MaximMogulev's user avatar
5 votes
3 answers
777 views

How to install game with dependencies on Linux?

I am creating a game using C and some libraries. I wish to not require my users to download anything but the game as most games are self contained. What is the usual process for compiling and ...
Lead Vaxeral's user avatar
0 votes
1 answer
67 views

How to add a slot to processing queue using a ring buffer with three pointers?

I am working on a farm game made in C. I am currently working on adding item processing, such as milling wheat into flour. Under the hood, I am using a ring buffer to handle the queues for processing. ...
Dotz0cat's user avatar
0 votes
0 answers
41 views

Jittery and Jumpy camera movement with SDL2 and OpenGL

i have successfully been able to draw a cube using openGL and SDL2. To me the next natural step would be to add some basic forward/backward movement to the camera. I did so with this code here: ...
Watch With Veer's user avatar
0 votes
0 answers
27 views

SDL Frame Independent Movement Issues

I am using SDL2 with C to program a frame independent movement. I have a struct that defines a position of a sprite (its top left corner): ...
Stone Paul's user avatar
0 votes
0 answers
67 views

Why are there gaps in my fibonacci sphere?

I recently took an interest in sphere topologies to find which one is the best. The most popular one seems to be the fibonacci sphere. So I went and did some research and found some C code online that ...
Chillzy's user avatar
  • 47
0 votes
1 answer
77 views

How to set up view and model matrices for 3D rendering?

For various reasons I am building a very simple graphics engine. I have a pretty good 2D thing using plain SDL2 and C that essentially boils down to a single "putpixel" function. I can ...
MalphasWats's user avatar
1 vote
1 answer
77 views

Why is my texture moving?

I tried sampling equirectangular texture as a reflection. It simply does not work as intended. The texture is moving with my camera in a weird manner. Here is what I tried to do. Fragment shader: <...
Eskimo Joe's user avatar
0 votes
1 answer
91 views

Strange flashing cube bug in snake game

I'm trying to make a simple snake game in C and OpenGL, and I have this at the moment, which runs almost perfectly: ...
Scollier's user avatar
  • 103
0 votes
0 answers
69 views

How can I make a reliable time-based object upating system?

So an object has a position, velocity, and is affected by gravity. ...
user16217248's user avatar
1 vote
0 answers
88 views

Are there OpenGL functions that are only available for specific platforms?

I want to load the OpenGL functions for my project myself. Are there any specific functions besides wglGetSwapIntervalEXT that require me to query the spec for its availability? And if there are, ...
Cherestes Radu's user avatar
0 votes
0 answers
64 views

SDL2 Not destroying textures properly when updating text

Im implementing a series of textboxes in sdl2 ,however my program is not working correctly -sdl is not destroying textures when the destroytexture function is callled resulting in a weird overlap of ...
Exiatron00's user avatar
0 votes
0 answers
95 views

When creating explosion effects, does a PNG need its own texture when using SDL blending, color modulation and alpha functions?

When creating explosion effects, does an explosion PNG need its own texture when using the SDL functions: SDL_SetRenderDrawBlendMode() ...
Ravenslock's user avatar
1 vote
1 answer
379 views

No vertex shader bound at draw?

I tried asking this on reddit but I didn't get any answers so I might as well try here So I'm making a program to generate some terrain and it's not giving me the results I expected. It's drawing ...
Chillzy's user avatar
  • 47
23 votes
7 answers
3k views

Consistent cross platform procedural generation

What techniques have people successfully used or can suggest to deal with a consistent cross platform math for procedural world generation? Also, if you have done this, what were the pros and cons of ...
MadMan's user avatar
  • 568
1 vote
1 answer
233 views

Raycasting : computing x position of sprite on the screen

I am trying to create a raycasting engine using C and CSFML, I already have the walls and textures rendering done and right now I would like to be able to render sprites into the scene. The difficulty ...
Xscreade's user avatar
0 votes
1 answer
96 views

glDrawArrays draws nothing in C. Trying to draw point in openGL(in C), no error but draws nothing

...
Sage.Z's user avatar
  • 1
2 votes
1 answer
1k views

SDL2 memory leak

I've been creating a 2D game in sdl2 in C and within my main game loop, I have found a section of code that causes a massive memory leak in my program, roughly leaking 100MB of memory per second. The ...
Bilal Ahmed's user avatar
1 vote
1 answer
3k views

How to create editable SDL2 text input boxes?

Hi all, I'm working on an SDL2 project and I require multiple editable square textboxes as shown in the image above. Is there any way I can do this?
Bilal Ahmed's user avatar
0 votes
1 answer
172 views

Rotation matrix for a model where the forward axis is not +X

I'm trying to convert a normalized unit vector, representing an entity heading, into a rotation matrix for rendering. The problem is that I'm using an (apparently) unusual forward vector for my ...
Nairou's user avatar
  • 584
1 vote
1 answer
300 views

Can't create Render Target with CreateDxgiSurfaceRenderTarget

I'm trying to create ID2D1RenderTarget to be used for writing text with DirectWrite. I tried two methods but can't get it working, both yield "The parameter is incorrect" error code. In the ...
Just Adude's user avatar
1 vote
1 answer
144 views

One global game loop vs multiple local game loops

What are the advantages of using multiple game loops instead of one? Assume Level1, Level2, Level3. These levels may bring totally different problems and needs and they may also be completely separate,...
user avatar
0 votes
1 answer
163 views

while(1) in separate threads. safe and efficient

In my TCP multithreaded server written in C, I have multiple threads with infinite loops checking for new inputs from thread safe queue and then doing their jobs. pseudocode: ...
user154155's user avatar
0 votes
0 answers
284 views

State machine in C for SDL game

I want to create a state machine for menu in my SDL game. So this is my code without the SDL I just want to ask if this is a good way to create it. here is a code: ...
matthews's user avatar
0 votes
1 answer
114 views

Need help with optimizing loops scanning for enemies in tile based horizontal scroller

I'm looking for an optimization for my loops searching for enemies in a tile based horizonal scroller. My enemy array is in a struct and I am looping through the array with 3 loops. First loop finds ...
Andy Dansby's user avatar
1 vote
2 answers
361 views

Why would I want to set a minimal OpenGL version before creating the context?

Typical GLFW applications have these lines after glfwInit(): ...
user avatar
0 votes
0 answers
68 views

Best way to save screenshots in a game?

I'm making a game, and I'm adding a screenshots feature. Currently I save screenshot files to <Home Directory>/Pictures/MyGame/. However, I'm not sure if ...
user avatar
0 votes
1 answer
120 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 ...
papajo's user avatar
  • 101
0 votes
2 answers
186 views

How can I handle input in C without halting the main loop?

I want my C program to update the console every second, and it was working fine until I tried to handle input. Now the program halts since it waits an input from the user. How can I do this? ...
AliTeo's user avatar
  • 35
0 votes
0 answers
61 views

Problem with bullet movement

I'm trying to draw "bullets" in my game, but I think something is wrong with velocity computation. Sometimes the "bullets" are going in the right way, but sometimes they won't. The ...
ExTrayEx's user avatar
1 vote
0 answers
347 views

glReadPixels performance not improving with PBO

I'm currently using glReadPixels to read from the depth buffer to calculate where on the map the player is pointing, for the purpose of placing objects on the ground. I do this after rendering the ...
Nairou's user avatar
  • 584
0 votes
0 answers
1k views

How to load a PNG in pure C

PNG loading: I've been creating a game engine for almost a year, and since the start of the development, I have been using stb_image for loading images. It ...
Álvaro Rodrigo's user avatar
0 votes
2 answers
913 views

Rotating camera in 3D without yawing diagonally

I'm programming a C raytracer. I'm having trouble getting the camera to rotate the way I intend. I would like the camera to rotate by pressing keys: F & H rotate left & right around the world'...
zoom's user avatar
  • 31
1 vote
1 answer
1k views

How can I render a font in C with OpenGL? [closed]

What I tried: I was testing some things in order to render text with stb_truetype.h and OpenGL in C. I took as a reference the example that appears here. Basically, this example, loads a .ttf file and ...
Álvaro Rodrigo's user avatar
1 vote
1 answer
536 views

Polling events with SDL results in stuttering response when dealing with multiple objects

I'm new to SDL programming and I'm not quite sure I got how it handles events. Given an instance like this defined in "game.c": ...
Gian's user avatar
  • 113
3 votes
1 answer
558 views

Rotate Object in world space - Raytracing

I’m programming a C raytracing project. I’ve been wanting to implement object rotations (square, cylinder) for several days but I can’t do it. For each object I have its position (x, y, z) in the ...
zoom's user avatar
  • 31
6 votes
3 answers
3k views

Convert integer to float while also dividing down the scale, without data loss

I'm working on a game, and my intent is to avoid use of floating point for unit positions. To that end, I'm using 32-bit integers for all positions, with a millimeter scale. However, for rendering, I ...
Nairou's user avatar
  • 584
2 votes
2 answers
84 views

Reducing adjacency bookkeeping work in constrained Delaunay triangulation

I'm using the Sloan algorithm for constraining a generated Delaunay triangulation. This primarily consists of edge flipping for the edges that overlap the constrained edges. In order to flip an edge, ...
Nairou's user avatar
  • 584
1 vote
0 answers
70 views

Understanding Quake I Timer

Here is a snippet of code from Quake I. ...
kontrarian's user avatar
0 votes
0 answers
62 views

I need help with my pathfinding algorithm

I am a student that is learning how to program and I started to develop my first platform game using C. However, I’m struggling with the pathfinding algorithm for the enemies. My levels are basically ...
FireBall3's user avatar
0 votes
1 answer
2k views

SDL2. Why I'm getting a Segmentation Fault in the free() function? Also, am I doing the rendering stuff right?

So, I'm new at C programming and SDL2 and I'm trying to get something working here to write some games. First, I would like to know if I'm doing the rendering stuff the right way. I'm kind of ...
user avatar
1 vote
1 answer
1k views

Creating a game on Linux with SDL and distributing it

TL, DR: Will I be able to get a single .exe file which will work smooth in a PC which does not have SDL or so installed ever. If not, how close will be the closest ...
muyustan's user avatar
  • 111
1 vote
1 answer
105 views

Throttling or adding delays between OnTriggerEnter2D calls

I have 2 game objects: Explosion and Enemy. At any given point, an enemy can collide with multiple ...
Norbert's user avatar
  • 121
0 votes
0 answers
177 views

Cyclone LED gaming code HOW TO HELP?

I am very new to programming. For a project I decided to make a game of cyclone using some LEDs,a push button, and a raspberry pi. I researched how to at least start on the game, but the problem that ...
user134189's user avatar
0 votes
2 answers
793 views

Proper 2D isometric tile depth sorting?

I'm using Raylib, and I'm attempting to place tiles on a level, and the algorithm for placing the tiles is working. The problem is that the player will display over the walls on the bottom right hand ...
Hawkbirdtree's user avatar

1
2 3 4 5 6