VBO多维数据集无法渲染 - 测试不支持的功能

时间:2013-03-15 05:42:39

标签: c++ opengl vbo opengl-3

我正在尝试渲染一个由其他立方体组成的大型立方体(“10x10x10,总共1000个立方体”)。它工作正常我的电脑和我朋友的电脑之一,但另一个只是得到一个空白的屏幕。我假设这是因为他们没有一些我正在使用的支持功能。我想知道它是什么功能以及我怎么能告诉他们没有它的支持所以我可以告诉他们。

编辑:有问题的计算机正在做一切但是渲染立方体。它提供了一个完全空白的屏幕,具有适当的背景颜色。

我将所有这些隐藏在课堂中,所以我只是给出相关部分。

如果您需要更多信息,请询问。

GL_VENDOR,GL_RENDER,GL_VERSION ann问题计算机的GL_EXTENSION(复制并粘贴到格式更好):

[01:28:02] GL_VENDOR: Intel
[01:28:02] GL_RENDERER: Intel(R) HD Graphics
[01:28:02] GL_VERSION: 2.1.0 - Build 8.15.10.2858
[01:28:02] GL_EXTENSIONS: GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_blend_color GL_EXT_abgr GL_EXT_texture3D GL_EXT_clip_volume_hint GL_EXT_compiled_vertex_array GL_SGIS_texture_edge_clamp GL_SGIS_generate_mipmap GL_EXT_draw_range_elements GL_SGIS_texture_lod GL_EXT_rescale_normal GL_EXT_packed_pixels GL_EXT_texture_edge_clamp GL_EXT_separate_specular_color GL_ARB_multitexture GL_EXT_texture_env_combine GL_EXT_bgra GL_EXT_blend_func_separate GL_EXT_secondary_color GL_EXT_fog_coord GL_EXT_texture_env_add GL_ARB_texture_cube_map GL_ARB_transpose_matrix GL_ARB_texture_env_add GL_IBM_texture_mirrored_repeat GL_EXT_multi_draw_arrays GL_NV_blend_square GL_ARB_texture_compression GL_3DFX_texture_compression_FXT1 GL_EXT_texture_filter_anisotropic GL_ARB_texture_border_clamp GL_ARB_point_parameters GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_env_crossbar GL_EXT_texture_compression_s3tc GL_ARB_shadow GL_ARB_window_pos GL_EXT_shadow_funcs GL_EXT_stencil_wrap GL_ARB_vertex_program GL_EXT_texture_rectangle GL_ARB_fragment_program GL_EXT_stencil_two_side GL_ATI_separate_stencil GL_ARB_vertex_buffer_object GL_EXT_texture_lod_bias GL_ARB_occlusion_query GL_ARB_fragment_shader GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_texture_non_power_of_two GL_ARB_vertex_shader GL_NV_texgen_reflection GL_ARB_point_sprite GL_ARB_fragment_program_shadow GL_EXT_blend_equation_separate GL_ARB_depth_texture GL_ARB_texture_rectangle GL_ARB_draw_buffers GL_ARB_color_buffer_float GL_ARB_half_float_pixel GL_ARB_texture_float GL_ARB_pixel_buffer_object GL_EXT_framebuffer_object GL_ARB_draw_instanced GL_ARB_half_float_vertex GL_EXT_draw_buffers2 GL_WIN_swap_hint GL_EXT_texture_sRGB GL_EXT_packed_float GL_EXT_texture_shared_exponent GL_ARB_texture_rg GL_ARB_texture_compression_rgtc GL_NV_conditional_render GL_EXT_texture_swizzle GL_ARB_sync GL_ARB_framebuffer_sRGB GL_EXT_packed_depth_stencil GL_ARB_depth_buffer_float GL_EXT_transform_feedback GL_EXT_framebuffer_blit GL_ARB_framebuffer_object GL_EXT_texture_array GL_ARB_map_buffer_range GL_EXT_texture_snorm GL_INTEL_performance_queries GL_ARB_copy_buffer GL_ARB_sampler_objects GL_NV_primitive_restart GL_ARB_seamless_cube_map GL_ARB_uniform_buffer_object GL_ARB_depth_clamp GL_ARB_vertex_array_bgra GL_ARB_draw_elements_base_vertex GL_EXT_gpu_program_parameters GL_ARB_compatibility GL_ARB_vertex_array_object 

代码:

void Block::setColor(float r, float g, float b) {
this->m_colorBuffer.clear();

this->m_colorBuffer.push_back(Color(r, g, b));
this->m_colorBuffer.push_back(Color(r, g, b));
this->m_colorBuffer.push_back(Color(r, g, b));
this->m_colorBuffer.push_back(Color(r, g, b));
this->m_colorBuffer.push_back(Color(r, g, b));
this->m_colorBuffer.push_back(Color(r, g, b));
this->m_colorBuffer.push_back(Color(r, g, b));
this->m_colorBuffer.push_back(Color(r, g, b));

    //Send the color data to OpenGL
if (m_colorvbo[0] != -1) glDeleteBuffers(1, m_colorvbo);
glGenBuffers(1, m_colorvbo);
    glBindBuffer(GL_ARRAY_BUFFER, m_colorvbo[0]); //Bind the vertex buffer
    glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 3 * m_colorBuffer.size(), &m_colorBuffer[0], GL_STATIC_DRAW); //Send the data to OpenGL
}

bool Block::initialize()
{
    glGenBuffers(LAST_BUFFER, m_vbos); //Generate a buffer for the vertices, indices and colors

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);

    float size = 0.5f;
    //Push back 8 vertices that make up a cube
    m_vertices.push_back(Vertex(-size, -size,  size));
    m_vertices.push_back(Vertex(-size, -size, -size));
    m_vertices.push_back(Vertex( size, -size, -size));
    m_vertices.push_back(Vertex( size, -size,  size));

    m_vertices.push_back(Vertex(-size,  size,  size));
    m_vertices.push_back(Vertex(-size,  size, -size));
    m_vertices.push_back(Vertex( size,  size, -size));
    m_vertices.push_back(Vertex( size,  size,  size));

    //Push back the indices that make up the triangles for each face.
    m_indices.push_back(0);
    m_indices.push_back(2);
    m_indices.push_back(3);
    m_indices.push_back(0);
    m_indices.push_back(1);
    m_indices.push_back(2);

    m_indices.push_back(4);
    m_indices.push_back(6);
    m_indices.push_back(7);
    m_indices.push_back(4);
    m_indices.push_back(5);
    m_indices.push_back(6);

m_indices.push_back(0);
m_indices.push_back(4);
m_indices.push_back(1);
m_indices.push_back(4);
m_indices.push_back(5);
m_indices.push_back(1);

m_indices.push_back(2);
m_indices.push_back(6);
m_indices.push_back(3);
m_indices.push_back(6);
m_indices.push_back(7);
m_indices.push_back(3);

m_indices.push_back(6);
m_indices.push_back(1);
m_indices.push_back(5);
m_indices.push_back(6);
m_indices.push_back(2);
m_indices.push_back(1);

m_indices.push_back(0);
m_indices.push_back(7);
m_indices.push_back(4);
m_indices.push_back(0);
m_indices.push_back(3);
m_indices.push_back(7);


    glBindBuffer(GL_ARRAY_BUFFER, m_vbos[VERTEX_BUFFER]); //Bind the vertex buffer
    glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 3 * m_vertices.size(), &m_vertices[0], GL_STATIC_DRAW); //Send the data to OpenGL

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_vbos[INDEX_BUFFER]); //Bind the vertex buffer
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint) * m_indices.size(), &m_indices[0], GL_STATIC_DRAW); //Send the data to OpenGL

bufferInit = true;

    return true;
}

void Block::render()
{
    glPushMatrix();
    //Set the vertex pointer for the cube
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_vbos[INDEX_BUFFER]); //Bind the vertex buffer
    glBindBuffer(GL_ARRAY_BUFFER, m_vbos[VERTEX_BUFFER]);
    glVertexPointer(3, GL_FLOAT, 0, 0);

    glBindBuffer(GL_ARRAY_BUFFER, m_colorvbo[0]);
    glTranslatef(this->position.x, this->position.y, this->position.z);
    //glScalef(this->size, this->size, this->size);
    glColorPointer(3, GL_FLOAT, 0, 0);
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    glDrawElements(GL_TRIANGLES, m_indices.size(), GL_UNSIGNED_INT, 0);
    glPopMatrix();
}

0 个答案:

没有答案