itemTex[10] = 1.0;
}
- GLfloat itemCoords[] = {itemLoc.x, itemLoc.y, 1.0,
- itemLoc.x+d->dim.x, itemLoc.y, 1.0,
- itemLoc.x+d->dim.x, itemLoc.y+d->dim.y, 1.0,
+ GLfloat itemCoords[] = {itemLoc.x, itemLoc.y, p->z,
+ itemLoc.x+d->dim.x, itemLoc.y, p->z,
+ itemLoc.x+d->dim.x, itemLoc.y+d->dim.y, p->z,
- itemLoc.x+d->dim.x, itemLoc.y+d->dim.y, 1.0,
- itemLoc.x, itemLoc.y+d->dim.y, 1.0,
- itemLoc.x, itemLoc.y, 1.0};
+ itemLoc.x+d->dim.x, itemLoc.y+d->dim.y, p->z,
+ itemLoc.x, itemLoc.y+d->dim.y, p->z,
+ itemLoc.x, itemLoc.y, p->z};
glBindTexture(GL_TEXTURE_2D,d->tex->image[0]);
0.0, 1.0,
1.0, 1.0};
- GLfloat backdrop[] = {offset.x - SCREEN_WIDTH / 2 - 1, offset.y - SCREEN_HEIGHT / 2, -8.1,
- offset.x + SCREEN_WIDTH / 2, offset.y - SCREEN_HEIGHT / 2, -8.1,
- offset.x - SCREEN_WIDTH / 2 - 1, offset.y + SCREEN_HEIGHT / 2, -8.1,
- offset.x + SCREEN_WIDTH / 2, offset.y + SCREEN_HEIGHT / 2, -8.1};
+ GLfloat backdrop[] = {offset.x - SCREEN_WIDTH / 2 - 1, offset.y - SCREEN_HEIGHT / 2, -7.9,
+ offset.x + SCREEN_WIDTH / 2, offset.y - SCREEN_HEIGHT / 2, -7.9,
+ offset.x - SCREEN_WIDTH / 2 - 1, offset.y + SCREEN_HEIGHT / 2, -7.9,
+ offset.x + SCREEN_WIDTH / 2, offset.y + SCREEN_HEIGHT / 2, -7.9};
setFontZ(-8.2);
glUniform1i(textShader_uniform_texture, 0);
offset.x - backgroundOffset.x - 5, offset.y - backgroundOffset.y, 9.9f,
offset.x - backgroundOffset.x - 5, offset.y + backgroundOffset.y, 9.9f};
- glUseProgram(worldShader);
+ GLfloat fron_tex_coord[] = {offset.x - backgroundOffset.x - 5, offset.y + backgroundOffset.y, 9.8f,
+ offset.x + backgroundOffset.x + 5, offset.y + backgroundOffset.y, 9.8f,
+ offset.x + backgroundOffset.x + 5, offset.y - backgroundOffset.y, 9.8f,
+
+ offset.x + backgroundOffset.x + 5, offset.y - backgroundOffset.y, 9.8f,
+ offset.x - backgroundOffset.x - 5, offset.y - backgroundOffset.y, 9.8f,
+ offset.x - backgroundOffset.x - 5, offset.y + backgroundOffset.y, 9.8f};
+
+ glUseProgram(worldShader);
glEnableVertexAttribArray(worldShader_attribute_coord);
glEnableVertexAttribArray(worldShader_attribute_tex);
bgTex++;
glUniform4f(worldShader_uniform_color, .8, .8, .8, 1.3 - static_cast<float>(alpha)/255.0f);
- glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, back_tex_coord);
+ glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, fron_tex_coord);
glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, tex_coord);
glDrawArrays(GL_TRIANGLES, 0 , 6);
drawBackgrounds();
- // draw particles and buildings
- glBindTexture(GL_TEXTURE_2D, colorIndex);
- glUniform1i(worldShader_uniform_texture, 0);
- glUseProgram(worldShader);
-
- glEnableVertexAttribArray(worldShader_attribute_coord);
- glEnableVertexAttribArray(worldShader_attribute_tex);
-
- uint ps = particles.size();
-
- GLfloat partVec[ps * 6 * 5 + 1];
- GLfloat *pIndex = &partVec[0];
-
- for (auto &p : particles) {
- if (!p.behind)
- p.draw(pIndex);
- }
-
- glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[0]);
- glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[3]);
- glDrawArrays(GL_TRIANGLES, 0, ps * 6);
-
- glDisableVertexAttribArray(worldShader_attribute_tex);
- glDisableVertexAttribArray(worldShader_attribute_coord);
-
- glUseProgram(0);
for (auto &l : light) {
if (l.belongsTo) {
// draw the player
p->draw();
+
+ // draw particles like a MASTAH
+ glBindTexture(GL_TEXTURE_2D, colorIndex);
+ glUniform1i(worldShader_uniform_texture, 0);
+ glUseProgram(worldShader);
+
+ glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, .8);
+
+ glEnableVertexAttribArray(worldShader_attribute_coord);
+ glEnableVertexAttribArray(worldShader_attribute_tex);
+
+ uint ps = particles.size();
+ uint pss = ps * 6 * 5;
+ uint pc = 0;
+
+ std::vector<GLfloat> partVec(pss);
+ GLfloat *pIndex = &partVec[0];
+
+ for (uint p = 0; p < ps; p++) {
+ pc += 30;
+ if (pc > pss) {
+ // TODO resize the vector or something better than breaking
+ std::cout << "Whoops:" << pc << "," << partVec.size() << std::endl;
+ break;
+ }
+ particles[p].draw(pIndex);
+ }
+
+ glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[0]);
+ glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &partVec[3]);
+ glDrawArrays(GL_TRIANGLES, 0, ps * 6);
+
+ glDisableVertexAttribArray(worldShader_attribute_tex);
+ glDisableVertexAttribArray(worldShader_attribute_coord);
+
+ glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, 1.0);
+
+ glUseProgram(0);
}
/**
HLINES(1.25), // width
HLINES(1.25), // height
randGet() % 7 * .01 * (randGet() % 2 == 0 ? -1 : 1), // vel.x
- (4 + randGet() % 6) * .05, // vel.y
+ randGet() % 1 ? (8 + randGet() % 6) * .05 : (4 + randGet() % 6) * .05, // vel.y
{ 0, 0, 255 }, // RGB color
2500 // duration (ms)
);