Skip to content

Commit

Permalink
Fix starfield not showing in webgl.
Browse files Browse the repository at this point in the history
  • Loading branch information
mooflu committed Oct 28, 2023
1 parent 045d96d commit 8706a84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/shaders/texture.vert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ out vec4 v_color;

void main()
{
gl_PointSize = 1.0;
v_uv = uv;
v_color = color;
gl_Position = modelViewMatrix * vertex;
Expand Down
7 changes: 7 additions & 0 deletions game/Starfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ void Starfield::draw(bool showStars, bool showNebulas) {
// XTRACE();

if (showStars) {
glm::mat4& modelview = MatrixStack::model.top();
glm::mat4& projection = MatrixStack::projection.top();
Program* prog = ProgramManagerS::instance()->getProgram("texture");
prog->use(); //needed to set uniforms
GLint modelViewMatrixLoc = glGetUniformLocation(prog->id(), "modelViewMatrix");
glUniformMatrix4fv(modelViewMatrixLoc, 1, GL_FALSE, glm::value_ptr(projection * modelview));

GLfloat starVertices[NUM_STARS * 3];
GLfloat starColors[NUM_STARS * 4];

Expand Down

0 comments on commit 8706a84

Please sign in to comment.