int main() { glfwInit(); glfwOpenWindow(500,500, 0,0,0,0,0,0, GLFW_WINDOW); glewInit(); try { // Data buffers float positions[] = { -1,-1,+0, +0,+1,+0, +1,-1,+0 }; float colors[] = { 1,0,0, 0,1,0, 0,0,1 }; glw::Buffer p_buffer(GL_STATIC_DRAW, sizeof(positions), positions); glw::Buffer c_buffer(GL_STATIC_DRAW, sizeof(colors), colors); // Shader program glw::Program::Shaders shaders = { { GL_VERTEX_SHADER, vsource }, { GL_FRAGMENT_SHADER, fsource } }; glw::Program program(shaders); if(program.build() != GL_NO_ERROR) { std::cerr << program.log() << "\n"; return 0; } program.setAttribute("v_position", p_buffer()); program.setAttribute("v_color", c_buffer()); // Rendering while(glfwGetWindowParam(GLFW_OPENED) && !glfwGetKey(GLFW_KEY_ESC)) { glClear(GL_COLOR_BUFFER_BIT); program.setUniform<float>("u_time", glfwGetTime()); program.execute(GL_TRIANGLES, 0, 3); glfwSwapBuffers(); } } catch(const glw::Error& e) { std::cerr << e.what() << " : " << glw::error_string(e.error()) << " (" << e.error() << ")\n"; } return 0; }
QByteArray Model::imageData() const { QByteArray p_data; QBuffer p_buffer(&p_data); p_buffer.open(QBuffer::WriteOnly); QDataStream p_stream(&p_buffer); p_stream << image; p_buffer.close(); return p_data; }
void CTexture::Swizzle() { // // Create the swizzle buffer // const u32 width( m_nCanvasWidth * 4 ); const u32 texture_size( width * m_nCanvasHeight ); u8 * p_buffer( new u8[ texture_size ] ); swizzle_fast( p_buffer, m_pBuffer, m_nCanvasWidth * 4, m_nCanvasHeight ); memcpy( p_buffer, m_pBuffer, texture_size ); SAFE_DELETE( p_buffer ); }