From patchwork Thu Jul 21 12:36:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandros Frantzis X-Patchwork-Id: 2974 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4D9E323F4D for ; Thu, 21 Jul 2011 12:43:27 +0000 (UTC) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.216.173]) by fiordland.canonical.com (Postfix) with ESMTP id 1D5EEA18287 for ; Thu, 21 Jul 2011 12:43:27 +0000 (UTC) Received: by mail-qy0-f173.google.com with SMTP id 10so3962301qyk.11 for ; Thu, 21 Jul 2011 05:43:26 -0700 (PDT) Received: by 10.229.217.3 with SMTP id hk3mr209500qcb.38.1311252206886; Thu, 21 Jul 2011 05:43:26 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs139541qcb; Thu, 21 Jul 2011 05:43:26 -0700 (PDT) Received: by 10.216.165.76 with SMTP id d54mr163356wel.76.1311251794772; Thu, 21 Jul 2011 05:36:34 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id t79si2367762weq.147.2011.07.21.05.36.34; Thu, 21 Jul 2011 05:36:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QjsUS-0000D0-Jr for ; Thu, 21 Jul 2011 12:36:32 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id A2B892E8957 for ; Thu, 21 Jul 2011 12:36:30 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 11 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 11: Add Mesh::render_vbo_attrib() that renders using user-defined vertex attributes exclusively. Message-Id: <20110721123630.17019.51476.launchpad@loganberry.canonical.com> Date: Thu, 21 Jul 2011 12:36:30 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13475"; Instance="initZopeless config overlay" X-Launchpad-Hash: 0aa96f7ba0bbc1d136f0f01b8e1dfd2fa8b8e36a ------------------------------------------------------------ revno: 11 committer: Alexandros Frantzis timestamp: Thu 2010-07-08 11:34:51 +0300 message: Add Mesh::render_vbo_attrib() that renders using user-defined vertex attributes exclusively. modified: mesh.cpp mesh.h --- lp:glmark2 https://code.launchpad.net/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription === modified file 'mesh.cpp' --- mesh.cpp 2010-07-07 12:29:59 +0000 +++ mesh.cpp 2010-07-08 08:34:51 +0000 @@ -1,4 +1,5 @@ #include "mesh.h" +#include "shader.h" Texel::Texel() { @@ -154,11 +155,11 @@ Vector3f *vertex; Texel *texel; Vector3f *normal; - + vertex = new Vector3f[mVertexQty]; texel = new Texel[mVertexQty]; normal = new Vector3f[mVertexQty]; - + for(unsigned i = 0; i < mVertexQty; i++) { vertex[i] = mVertex[i].v; @@ -166,26 +167,26 @@ normal[i] = mVertex[i].n; } - // Generate And Bind The Vertex Buffer - glGenBuffersARB(1, &mVBOVertices); // Get A Valid Name - glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBOVertices); // Bind The Buffer - // Load The Data - glBufferDataARB(GL_ARRAY_BUFFER_ARB, mVertexQty * sizeof(Vector3f), vertex, GL_STATIC_DRAW_ARB); - - // Generate And Bind The normal Buffer - glGenBuffersARB(1, &mVBONormals); // Get A Valid Name - glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBONormals); // Bind The Buffer - // Load The Data - glBufferDataARB(GL_ARRAY_BUFFER_ARB, mVertexQty * sizeof(Vector3f), normal, GL_STATIC_DRAW_ARB); - - // Generate And Bind The Texture Coordinate Buffer - glGenBuffersARB(1, &mVBOTexCoords); // Get A Valid Name - glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBOTexCoords); // Bind The Buffer - // Load The Data - glBufferDataARB(GL_ARRAY_BUFFER_ARB, mVertexQty * sizeof(Texel), texel, GL_STATIC_DRAW_ARB); + // Generate And Bind The Vertex Buffer + glGenBuffersARB(1, &mVBOVertices); // Get A Valid Name + glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBOVertices); // Bind The Buffer + // Load The Data + glBufferDataARB(GL_ARRAY_BUFFER_ARB, mVertexQty * sizeof(Vector3f), vertex, GL_STATIC_DRAW_ARB); + + // Generate And Bind The normal Buffer + glGenBuffersARB(1, &mVBONormals); // Get A Valid Name + glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBONormals); // Bind The Buffer + // Load The Data + glBufferDataARB(GL_ARRAY_BUFFER_ARB, mVertexQty * sizeof(Vector3f), normal, GL_STATIC_DRAW_ARB); + + // Generate And Bind The Texture Coordinate Buffer + glGenBuffersARB(1, &mVBOTexCoords); // Get A Valid Name + glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBOTexCoords); // Bind The Buffer + // Load The Data + glBufferDataARB(GL_ARRAY_BUFFER_ARB, mVertexQty * sizeof(Texel), texel, GL_STATIC_DRAW_ARB); glBindBuffer(GL_ARRAY_BUFFER, 0); - + delete [] vertex; delete [] texel; delete [] normal; @@ -200,10 +201,10 @@ glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBOVertices); + glVertexPointer(3, GL_FLOAT, 0, 0); glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBONormals); glNormalPointer(GL_FLOAT, 0, 0); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBOVertices); - glVertexPointer(3, GL_FLOAT, 0, 0); glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBOTexCoords); glTexCoordPointer(2, GL_FLOAT, 0, 0); @@ -213,5 +214,27 @@ glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); +} + +void Mesh::render_vbo_attrib() +{ + // Enable the attributes + glEnableVertexAttribArray(Shader::VertexAttribLocation); + glEnableVertexAttribArray(Shader::NormalAttribLocation); + glEnableVertexAttribArray(Shader::TexCoordAttribLocation); + + glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBOVertices); + glVertexAttribPointer(Shader::VertexAttribLocation, 3, GL_FLOAT, GL_FALSE, 0, 0); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBONormals); + glVertexAttribPointer(Shader::NormalAttribLocation, 3, GL_FLOAT, GL_FALSE, 0, 0); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBOTexCoords); + glVertexAttribPointer(Shader::TexCoordAttribLocation, 2, GL_FLOAT, GL_FALSE, 0, 0); + + glDrawArrays(GL_TRIANGLES, 0, mVertexQty); + + // Disable the attributes + glDisableVertexAttribArray(Shader::TexCoordAttribLocation); + glDisableVertexAttribArray(Shader::NormalAttribLocation); + glDisableVertexAttribArray(Shader::VertexAttribLocation); } === modified file 'mesh.h' --- mesh.h 2010-07-07 12:29:59 +0000 +++ mesh.h 2010-07-08 08:34:51 +0000 @@ -46,6 +46,7 @@ void render_array(); void build_vbo(); void render_vbo(); + void render_vbo_attrib(); }; #endif