Skip to content

feat: player hud and text renderer - #39

Closed
OmarGamal10 wants to merge 8 commits into
mainfrom
feat/player-hud
Closed

feat: player hud and text renderer#39
OmarGamal10 wants to merge 8 commits into
mainfrom
feat/player-hud

Conversation

@OmarGamal10

@OmarGamal10 OmarGamal10 commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator

PLEASE DON'T PANIC, THE JSON FILE FOR THE FONT IS ABOUT 4300 LINES, SO THE PR IS ONLY ABOUT 500 LINES.

  • Adds the health bar and weapon photo, san andreas style. can be easily reposition or swapped
  • adds a generic text renderer using bitmap fonts

Limitations

  • RIght now font loading will be duplicated across all entities who need the same font, the solution for this is to not load fonts in a system, but rather load once with assetLoader and just get the reference from there. I didn't want to touch the asset loader now because of feat: model loader #28

Comment thread src/common/mesh/mesh.hpp
Comment on lines +88 to +92
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(Vertex), vertices.data(), GL_DYNAMIC_DRAW);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, elements.size() * sizeof(unsigned int), elements.data(),
GL_DYNAMIC_DRAW);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this reallocates the buffer each call
consider using BufferSubData

if (newSize <= currentCapacity) {
    glBufferSubData(...);
}
else {
    glBufferData(...); // reallocate
    currentCapacity = newSize;
}

if (!data.is_object()) return;
maxHealth = data.value("maxHealth", maxHealth);
currentHealth = data.contains("currentHealth") ? data["currentHealth"].get<float>() : maxHealth;
currentHealth = data.value("currentHealth", currentHealth);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change in this pr ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to change it back, same reason as below

public:
float maxHealth = 100.0f;
float currentHealth = 100.0f;
float currentHealth = 75.0f;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change too ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mb, I had it less than 100 to show the reviewer how health looks when it's not full

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants