• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #include <GLcommon/GLESpointer.h>
17 #include <stdlib.h>
18 
GLESpointer()19 GLESpointer::GLESpointer():m_size(4),
20                            m_type(GL_FLOAT),
21                            m_stride(0),
22                            m_enabled(false),
23                            m_normalize(false),
24                            m_data(NULL),
25                            m_buffer(NULL),
26                            m_bufferName(0),
27                            m_buffOffset(0),
28                            m_isVBO(false){};
29 
30 
getType() const31 GLenum GLESpointer:: getType() const {
32     return m_type;
33 }
34 
getSize() const35 GLint GLESpointer::getSize() const  {
36     return m_size;
37 }
38 
getStride() const39 GLsizei GLESpointer::getStride() const {
40     return m_stride;
41 }
42 
getArrayData() const43 const GLvoid* GLESpointer::getArrayData() const {
44     return m_data;
45 }
46 
getBufferData() const47 GLvoid* GLESpointer::getBufferData() const {
48     return  m_buffer ? static_cast<unsigned char*>(m_buffer->getData()) + m_buffOffset : NULL;
49 }
50 
getData() const51 const GLvoid* GLESpointer::getData() const{
52     return m_isVBO ? getBufferData():getArrayData();
53 }
54 
redirectPointerData()55 void GLESpointer::redirectPointerData(){
56     m_data = getBufferData();
57 }
58 
getBufferName() const59 GLuint GLESpointer::getBufferName() const {
60     return m_bufferName;
61 }
62 
getBufferOffset() const63 unsigned int GLESpointer::getBufferOffset() const {
64 
65     return  m_buffOffset;
66 }
67 
isEnable() const68 bool GLESpointer::isEnable() const {
69     return m_enabled;
70 }
71 
isNormalize() const72 bool GLESpointer::isNormalize() const {
73     return m_normalize;
74 }
75 
isVBO() const76 bool GLESpointer::isVBO() const {
77     return m_isVBO;
78 }
79 
enable(bool b)80 void GLESpointer::enable(bool b) {
81     m_enabled = b;
82 }
83 
setArray(GLint size,GLenum type,GLsizei stride,const GLvoid * data,bool normalize)84 void GLESpointer::setArray(GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) {
85     m_size   = size;
86     m_type   = type;
87     m_stride = stride;
88     m_data   = data;
89     m_buffer = NULL;
90     m_bufferName = 0;
91     m_normalize = normalize;
92     m_isVBO = false;
93 }
94 
setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer * buf,GLuint bufferName,int offset,bool normalize)95 void GLESpointer::setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,GLuint bufferName,int offset,bool normalize) {
96     m_size   = size;
97     m_type   = type;
98     m_stride = stride;
99     m_data   = NULL;
100     m_buffer = buf;
101     m_bufferName = bufferName;
102     m_buffOffset = offset;
103     m_normalize = normalize;
104     m_isVBO = true;
105 }
106 
getBufferConversions(const RangeList & rl,RangeList & rlOut)107 void GLESpointer::getBufferConversions(const RangeList& rl,RangeList& rlOut) {
108     m_buffer->getConversions(rl,rlOut);
109 }
110