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

learn more… | top users | synonyms

0
votes
1answer
35 views

Can't figure out how to create texture from a font-surface

I can't seem to be able to render my font, it crashes and I can't figure out why. It seems to load the font correctly, but the parts relating to surface crashes. Why does my texture crash? Here is ...
1
vote
1answer
66 views

Is this Data Oriented Programming without OOP or am I doing it wrong?

I have been reading many resources about data oreinted programming, and one thing I do understand about it is that it's about keeping chunks of memory together to improve performance. Other than that, ...
1
vote
1answer
23 views

SDL Player do something for 3 seconds then stop

I'll make my player respawn after 1 of his lives is taken, but I want him to be invincible for 2 or 3 seconds and not instadie again because he will be in the way of enemy bullets. for (int i = 0; i &...
1
vote
1answer
24 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 : while (!done) { //Check for events done = processEvents(window, &player); ...
0
votes
1answer
76 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
40 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
0answers
28 views

gl_VertexID always 0 under some hardware

I'm trying draw a color box with TBO technique for my project, but something strange happens! Please Help Me. VERTEX SHADER: #version 330 uniform mat4 matPrj; uniform mat4 matView; uniform mat4 ...
0
votes
1answer
25 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
35 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 improve the performance. I would like to only have to build the ...
0
votes
0answers
14 views

Using a pixmap as background for Xlib

I'm having an issue with the Xlib library, coding with C what I would like is using a pixmap as a background but I can't seem to get this right. For anyone with knowledge of this library I'd like an ...
0
votes
0answers
32 views

Mapping intensity in flat shading

I have a 16bit RGB565 and I have the result from dot product and its 0->1. I would like to map the dot product value from light source to the normal vector in a mesh to 16bit color value. ...
0
votes
1answer
88 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
219 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 ...
1
vote
0answers
33 views

Prevent rendering queue from overflowing when using Vsync

My game loop currently looks something like this: while (!quit) { takeInput(); // Input is sampled however fast loop can run time_now = get_time() time_passed += (time_now - time_prev); ...
4
votes
1answer
157 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: SDL_Surface* Texture::LoadImg(const char *...
4
votes
1answer
44 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
43 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
21 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 ...
0
votes
0answers
70 views

Is this the correct method for collision detection

i'm trying to write a 3d game from scratch. Firstly i created a floor in the zx plane and a man to walk around the environment. When I added walls i was detecting them using the intersection of the ...
1
vote
0answers
19 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
252 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
24 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
28 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 ...
21
votes
7answers
6k views

What advantage do OpenGL, SFML and SDL have over software rendering?

I started watching the Handmade Hero stream, where Casey Muratori creates a game engine without using frameworks or such. Yesterday I got to the part where he showed how an image is drawn onto the ...
3
votes
1answer
217 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 : glShaderSource( fragshader, 0, fragfilebuff, NULL )...
2
votes
0answers
98 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
45 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's the cleaned code that shows the issue. sfRenderWindow* window; ...
0
votes
1answer
108 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
126 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 ...
3
votes
1answer
304 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: 10X10 ds2 de2 dw5 12X12 ds3 de2 dw1 14X14 ds5 de1 dw5 10X10 ds5 de3 dw5 ...
0
votes
1answer
224 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
68 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
133 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 ...
6
votes
1answer
230 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
47 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
132 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. Afterwards, I create an empty texture so as ...
0
votes
1answer
42 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
408 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, ...
1
vote
1answer
594 views

Setting up an efficient OpenGL rendering loop

This is the code that I use to setup my shader char* vertexShaderSource = getResource("vert.shad"); char* fragmentShaderSource = getResource("frag.shad"); vshad = readFile(vertexShaderSource); fshad ...
0
votes
1answer
66 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 sample of how you you'd multiply two of ...
0
votes
1answer
73 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
54 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
43 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 ...
0
votes
2answers
549 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
345 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
1answer
305 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: class MyClass { public: int myLuaFunction(lua_State* L) { //do something } }; I want ...
0
votes
2answers
278 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
345 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 and Linux? Or is it more complicated? ...
0
votes
2answers
280 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
150 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 ...