Skip to content

Commit 8706a84

Browse files
committed
Fix starfield not showing in webgl.
1 parent 045d96d commit 8706a84

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

data/shaders/texture.vert.glsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ out vec4 v_color;
99

1010
void main()
1111
{
12+
gl_PointSize = 1.0;
1213
v_uv = uv;
1314
v_color = color;
1415
gl_Position = modelViewMatrix * vertex;

game/Starfield.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ void Starfield::draw(bool showStars, bool showNebulas) {
122122
// XTRACE();
123123

124124
if (showStars) {
125+
glm::mat4& modelview = MatrixStack::model.top();
126+
glm::mat4& projection = MatrixStack::projection.top();
127+
Program* prog = ProgramManagerS::instance()->getProgram("texture");
128+
prog->use(); //needed to set uniforms
129+
GLint modelViewMatrixLoc = glGetUniformLocation(prog->id(), "modelViewMatrix");
130+
glUniformMatrix4fv(modelViewMatrixLoc, 1, GL_FALSE, glm::value_ptr(projection * modelview));
131+
125132
GLfloat starVertices[NUM_STARS * 3];
126133
GLfloat starColors[NUM_STARS * 4];
127134

0 commit comments

Comments
 (0)