void QtUtil :: Grid3DView :: contextMenuEvent (QContextMenuEvent * e) { QMenu m; QMenu set_plane (tr ("Plane")); { set_plane .addAction (tr ("XY (Front)"), this, SLOT (set_xy())); set_plane .addAction (tr ("XZ (Top)"), this, SLOT (set_xz())); set_plane .addAction (tr ("YZ (Side)"), this, SLOT (set_yz())); } m .addMenu (& set_plane); m .exec (mapToGlobal (e -> pos ())); }
Tile::Tile(GLuint shader_id, int x, int z) { glGenVertexArrays(1, &vao); glGenBuffers(1, &vbo); glGenBuffers(1, &ebo); glBindVertexArray(vao); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); GLuint posAttrib = glGetAttribLocation(shader_id, "position_model"); GLuint norAttrib = glGetAttribLocation(shader_id, "normal_model"); GLuint texAttrib = glGetAttribLocation(shader_id, "texcoord"); GLuint colAttrib = glGetAttribLocation(shader_id, "color"); glEnableVertexAttribArray(posAttrib); glEnableVertexAttribArray(norAttrib); glEnableVertexAttribArray(texAttrib); glEnableVertexAttribArray(colAttrib); glVertexAttribPointer(posAttrib, 3, GL_FLOAT, GL_FALSE, 11*sizeof(float), 0 ); glVertexAttribPointer(norAttrib, 3, GL_FLOAT, GL_FALSE, 11*sizeof(float), (void*)(3*sizeof(float))); glVertexAttribPointer(texAttrib, 2, GL_FLOAT, GL_FALSE, 11*sizeof(float), (void*)(6*sizeof(float))); glVertexAttribPointer(colAttrib, 3, GL_FLOAT, GL_FALSE, 11*sizeof(float), (void*)(8*sizeof(float))); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); glEnable(GL_PRIMITIVE_RESTART); glPrimitiveRestartIndex((TILE_SIZE+1)*(TILE_SIZE+1)+TILE_SIZE); reload_vbo = false; reload_ebo = false; needs_rebuild = false; needs_gen = true; show = false; lod(0); set_xz(x,z); update_vertices(); update_indices(); }