0% found this document useful (0 votes)
30 views

How+I+rewrote+my+C+++game+engine+or+framework+in+C

The document discusses rewriting a C++ game engine in C. It provides examples of converting C++ code like initializing arrays, passing vectors to shaders, and defining classes to equivalent C code using structs. It also mentions thanking people who helped with the C version implementation, including batch rendering. The overall structure of initializing, updating, rendering, and cleaning up remains the same between the C++ and C versions.

Uploaded by

Muhammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

How+I+rewrote+my+C+++game+engine+or+framework+in+C

The document discusses rewriting a C++ game engine in C. It provides examples of converting C++ code like initializing arrays, passing vectors to shaders, and defining classes to equivalent C code using structs. It also mentions thanking people who helped with the C version implementation, including batch rendering. The overall structure of initializing, updating, rendering, and cleaning up remains the same between the C++ and C versions.

Uploaded by

Muhammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

16/04/2022, 13:39 How I rewrote my C++ game engine or framework in C.

- Michael Grieco ------------------ For the series on OpenGL


- The Cherno ---------------------- For the series on OpenGL as well
- templalizer1284/cshader --------- For shader loading in C
- MousieDev ----------------------- For giving me countless tips on C, build
systems and so much overall
- NrdyBhu1 ------------------------ For contributing to the project
- From Harold Serrano's server: --- For helping me implementing batch rendering in
the C++ version of the engine:
> redeye6699
> dandymcgee

typedef
struct

https://md2pdf.netlify.app 1/6
16/04/2022, 13:39 How I rewrote my C++ game engine or framework in C.

// C++
int array[10] = { 0 };

// C
int array[10];
for (int i = 0; i < 10; i++) {
array[i] = 0;
}

float vec4[4] = { 1.0f, 1.0f, 1.0f, 1.0f };


glUniform4(uniformLocation, vec4[0], vec4[1], vec4[2], vec4[3]);

class Character {
public:
Character(int x, int y, int z, const std::string& name);
~Character();

void SetName(const std::string& name);


std::string GetName();

void SetX(int x);


void SetY(int y);
void SetZ(int z);

int GetX(); int GetY();


https://md2pdf.netlify.app 2/6
16/04/2022, 13:39 How I rewrote my C++ game engine or framework in C.

int GetZ();

private:
int x, y z;
std::string name;

};

typedef struct {
int x, y, z;
const char * name;
} Character;

Character character = { .x = 10, .y = 120, .z = 21, .name =


"Lol" };

GLFWwindow * window
Program Props:
VBO, IBO, VAO = { 1, 1, 1 }:

https://md2pdf.netlify.app 3/6
16/04/2022, 13:39 How I rewrote my C++ game engine or framework in C.

Init();
Update();
Render();
Clean();

Init();
Update();
Render();
Clean();

Init();
Update();
Render();
Clean();

https://md2pdf.netlify.app 4/6
16/04/2022, 13:39 How I rewrote my C++ game engine or framework in C.

https://md2pdf.netlify.app 5/6
16/04/2022, 13:39 How I rewrote my C++ game engine or framework in C.

https://md2pdf.netlify.app 6/6

You might also like