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
1
vote
1answer
112 views

SDL Detect change score

I have this in my loop , it works but I get verry low fps and game is working in slow motion : ...
0
votes
1answer
624 views

C SDL render text?

I'm making a game in C using SDL library and I want to display a score. I have 9 photos with numbers from 0-9 and I want to know if I can use them somehow to display score, if my score is 2679 the ...
0
votes
1answer
111 views

Text-based hold 'em game in C using TCP

So I'm trying to create a simple text input Texas Hold 'Em game that can be played in a Terminal between multiple computer. (Disturbing lack of hold 'em games that don't require Facebook integration ...
0
votes
1answer
121 views

Errors in Xcode using SDL

I am using Lazy Foo's Production tutorials for making an SDL game in C in Xcode 6.1 - http://lazyfoo.net/tutorials/SDL/index.php#Hello%20SDL. I'm using Xcode 7 but I don't think they are very ...
0
votes
2answers
113 views

Build SDL_Surface before blitting it

I have a function in which I'm looping y and x over my array of sprites. That's a lot of loops, and it is very slow; I'd like to ...
0
votes
1answer
219 views

How to map intensity from dot product to float RGB from 0 to 1?

I'm getting the dot product of the surface normal and light position. The weird thing is the dot product is larger than 1. Also, I want to map that intensity from 0->1 to Float RGB from 0->1. Here is ...
0
votes
1answer
2k views

Is it possible to use C++ in SDL for Android?

I have successfully compiled SDL for Android using the example, which uses C. Is it possible to use C++ too? I am trying to port a C++ game which uses SDL 2 to Android. If it is possible, how can I ...
0
votes
2answers
229 views

Prevent rendering queue from overflowing when using Vsync

My game loop currently looks something like this: ...
4
votes
1answer
2k views

How to pass PNG image data directly to SDL?

Well passing just external PNG to SDL is very easy with the SDL_image library. I have a class that does just that. The code looks like the following: ...
3
votes
1answer
86 views

OpenGL Perspective Issue

I'm trying to troubleshoot a problem with my simple OpenGL test program, which I've written in C. I've written some math routines to do the matrix manipulation, but even after copying known working ...
0
votes
1answer
103 views

C & SDL: Unexpected Behaviour with Renderer

I'm creating a clone of the memory testing game SIMON. My program is simply four differently colored squares that light up one at a time in a random order. I wrote some code that lights up one square, ...
0
votes
1answer
22 views

Setting Square to Dim in Color on MOUSEUP

I'm trying to create a simple recreation of the popular memory game "Simon" using C and SDL2. The idea is that the game is a small window with four squares of different colors that are purposefully ...
1
vote
0answers
38 views

C99: Dynamic dispatch in math library depending on SIMD [closed]

Say I am developing a Math library and I want it to be such that it will detect whether or not user's machine support SSE (and which version) and based on that, different functions will be called. I ...
1
vote
3answers
872 views

What is the lowest-level way of making graphics from scratch?

I am currently trying to get into game development and trying to understand 3D games. I would like to learn to code from scratch without any 3D engines. Some of the things I found was libraries like ...
0
votes
1answer
43 views

How to get rid of an image upon collision detection in SDL?

I am fairly new to SDL in C, but I have written a simple game whereby a character has to reach the end of a level and avoid bad stars on the way. If he hits a star, he dies. There are also good stars ...
1
vote
1answer
35 views

Custom Tile Collision Detection Has Trouble With Edges

So, I'm writing my own game to expand on my abilities as a programmer. However, I have come to a writer's-block of sorts. The game I am building uses tile collision, but allows the player to be in an ...
2
votes
1answer
440 views

Having issue's with a confusing access violation? - C , OpenGL 3.3+ , SDL 2.0+

Hello this code seems so well done and yet I'm getting this weird access violation error when I use anything but 0 in glShaderSources 2nd argument : ...
3
votes
0answers
253 views

GLSL shader with light colors wrong on nvidia optimus

So, I built some code to draw a spinning cube with a red light on the right side, and a blue one on the left. I run it on my laptop with optimus graphics, and on my desktop with nvidia. On the laptop, ...
0
votes
1answer
131 views

What causes SFML pollEvent to segfault here?

I'm writing an SFML application in C. Currently sfRenderWindow_pollEvent() and sfRenderWindow_waitEvent() always segfault. Here'...
0
votes
1answer
429 views

Simulate Keyboard Button Press [SDL Library]

I am trying to simulate an SDL keyboard button press (using C). I have looked up the SDL info pages online but I still don't have anything that consistently works. I have the following (removed the ...
0
votes
1answer
291 views

csfml wait event

I would like to spawn a separate thread to deal with inputs using c and sfml. I made a prototype that waits for input in main() and it works fine. I made a prototype that spawns a new thread and waits ...
4
votes
1answer
680 views

Creating a Roguelike game in C

I'm trying to create a simple rogue-like game in ncurses in a C program. The idea here is that, I'd parse a file like this: ...
1
vote
1answer
922 views

OpenGL dynamic font glyph cache library

I have begun work on an OpenGL application (all on my own and with little knowledge) and started with FTGL, rendering true type fonts, which, with alot of text has a great impact on frames per second. ...
-4
votes
2answers
85 views

Confused about arrays in C [closed]

Hey guys I am learning the basics of C language and I am a little bit confused about how to use arrays. I mean what are they used for?
-2
votes
1answer
189 views

how is c useful in game development [closed]

I know that C++ is the king in game development especially in the AAA market can anyone tell my how is C helpful I am a Computer Science student in my first year and are they any aspects of C i have ...
7
votes
1answer
270 views

How to execute game logic every 100ms but render as fast as possible?

I have created a simple snake clone and would like to execute game logic every 100ms while rendering as fast as possible. How can I achieve this when the program might run with very different frame ...
1
vote
0answers
85 views

Having trouble making game time pause and unpause

I've been trying to make it where when the player does a certain task, the game's time will pause. When the player does another action, the game's time would unpause and continue. I had my code like ...
2
votes
0answers
304 views

SDL2 SDL_CreateTexture returns pointer to existing texture

I have an initialized renderer in SDL2 that works fine. I create some textures from images using SDL_CreateTextureFromSurface and store them in a vector. ...
0
votes
1answer
46 views

traversing the area

i want to move point along spiral like hexagon for example i want to traverse the whole area and my player (point) is standing where i have placed it manually. now i want to start from this point and ...
1
vote
1answer
1k views

Quaternion rotations & transforms from global to local space

I am trying to solve this problem and getting no where, could really use some assistance. Rotation is defined as X (rotate left/right), Y(rotate up/down), Z(roll) Coordinates are X: Forward/backward, ...
0
votes
1answer
409 views

opengl matrix multiplication

Can someone provide some type of example of multiplying a 4x4 matrix without using loops? typedef struct matrix4 { data[16]; } m4; can someone provide a ...
0
votes
1answer
83 views

a shader type class in c

Is it possible to setup something sort of like a class in C++ but in c in the simplest terms? I want to avoid using c++ but I would like to create a simple struct that has glsl shader program. for ...
0
votes
1answer
1k views

Segmentation fault on reallocation of memory but why? [closed]

I have been learning to code in C from this amazing resource http://c.learncodethehardway.org/book/ I am on exercise 17. Basically creating your own simple database using Malloc. I modified the ...
0
votes
1answer
63 views

Cannot Get The Texture Showed Up Correctly glDrawElements

I still have this problem almost 1 month. Tried to search on Google but did not find any solution to this. I have loaded all the data correctly but don't know why the texture came up like this. Here ...
1
vote
2answers
2k views

Move towards view direction opengl?

I'm trying to get the basics of 3d with opengl 2.0(I know, I know, it's deprecated etc, etc. It's just for the sake of prototyping). I'm trying to get a cube on the screen which you can move around. I ...
3
votes
1answer
779 views

2D day night mapping

I'm looking for this kind of effect MINUS the lights and snow (Another problem). It needs to change depending on the time of year. Doesn't need snow or city lights. Now I'm pretty new to shaders (...
1
vote
2answers
806 views

Registering a C++ callback with Lua API without additional libraries

Basically, I'm trying to register a callback into a Lua state like this: ...
0
votes
2answers
2k views

Is there any easy way to understand the Alpha Beta for Othello?

I'm stuck with coding the Alpha Beta algorithm for a console-based game I'm developping at the moment. I tried to understand how it works for a week but still no idea how to get started with it. Here ...
1
vote
2answers
919 views

Are SDL games trivially portable from Linux to Windows?

I have a small game made with SDL2 and I want to port it to Windows. Would I hav eto write a lot of #ifdefs to port it or will the very same code work on Windows ...
0
votes
2answers
624 views

What's the correct way to move 2d sprites in opengl 2.1?

I'm getting into Opengl 2.1 and wanted to know how can I move 2d sprites. I already created my vbo and ibo, and the vertex data is already there. But, how can I move a sprite once it's already drawn? ...
1
vote
1answer
172 views

opengl : Running at least 25 windows with different Draw callback

I need to run at least 25 windows concurrently with each window rendering a different game state. I am storing all the 25 game states in the array of type GameState allGameStates[25]. For each of the ...
3
votes
2answers
175 views

Rogue Door Connection logic

I'm having a bit of trouble developing code to figure out which doors connect in Rogue which is written in c. Not the actual path making. I just dont understand how they link to each other. If rooms ...
3
votes
1answer
194 views

Where can I find OpenGL state changes profiling?

Is there any benchmark that actually measure state changes cost in OpenGL 3.x/4.x and gather an average statics for all graphics cards? (I don't want to optimize only for my old AMD card, I'm not even ...
1
vote
2answers
109 views

Overload how an object instance of a class is treated when used

So I've made this struct that encapsulates a glm::vec4. This is because vec3s are treated as 16-byte in GLSL, but I don't want ...
2
votes
1answer
612 views

C++ Ray Traversing in 3D Voxel game

I'm currently working on a Voxel game in 3D and need a tad bit of help to figure out what Voxel the player is looking at. This is the data I currently have: ...
1
vote
3answers
104 views

c - Starting an user defined function after the current one ends

The game I am creating displays a menu before starting, the user may select to start the game, or do some stuff. When the user selects an option, I need to call another function which actually does ...
1
vote
1answer
72 views

How can I send matrix data to shaders without the Effects11 framework?

I'm making a Direct3D engine but I'm stuck with this one little problem. I want to not use effect files but instead use shader files. What can I use to send matrix variables to shaders if I don't use ...
5
votes
2answers
3k views

How to detect graphics API at runtime with SDL2?

Using SDL2, is there a way to determine at runtime whether the application is using OpenGL, OpenGLES, or DirectX? EDIT: If there is a way to figure it out without using the SDL2 API, I'm willing to ...
2
votes
1answer
1k views

Emscripten code and three.js

I would like, if it's possible, to use Emscripten code generated from C/C++ with the Javascript library three.js. For example, from emscripten code I want to pass rendering information to the three.js ...
0
votes
1answer
150 views

Can I directly pass a Boost ptr_vector list to glBufferData?

I have a data structure like this: typedef struct vertex_ { float x; float y; float z; float s; float t; }vertex; Then I add to a list called: ...