aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/opengl/host/libs/Translator/GLcommon/GLESpointer.cpp
blob: 372257ee61a7c03c254e181d99d33e6275b3ac1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <GLcommon/GLESpointer.h>
#include <stdlib.h>

GLESpointer::GLESpointer():m_size(4),
                           m_type(GL_FLOAT),
                           m_stride(0),
                           m_enabled(false),
                           m_normalize(false),
                           m_data(NULL),
                           m_buffer(NULL),
                           m_bufferName(0),
                           m_buffOffset(0),
                           m_isVBO(false){};


GLenum GLESpointer:: getType() const {
    return m_type;
}

GLint GLESpointer::getSize() const  {
    return m_size;
}

GLsizei GLESpointer::getStride() const {
    return m_stride;
}

const GLvoid* GLESpointer::getArrayData() const {
    return m_data;
}

GLvoid* GLESpointer::getBufferData() const {
    return  m_buffer ? static_cast<unsigned char*>(m_buffer->getData()) + m_buffOffset : NULL;
}

const GLvoid* GLESpointer::getData() const{
    return m_isVBO ? getBufferData():getArrayData();
}

void GLESpointer::redirectPointerData(){
    m_data = getBufferData();
}

GLuint GLESpointer::getBufferName() const {
    return m_bufferName;
}

unsigned int GLESpointer::getBufferOffset() const {

    return  m_buffOffset;
}

bool GLESpointer::isEnable() const {
    return m_enabled;
}

bool GLESpointer::isNormalize() const {
    return m_normalize;
}

bool GLESpointer::isVBO() const {
    return m_isVBO;
}

void GLESpointer::enable(bool b) {
    m_enabled = b;
}

void GLESpointer::setArray(GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) {
    m_size   = size;
    m_type   = type;
    m_stride = stride;
    m_data   = data;
    m_buffer = NULL;
    m_bufferName = 0;
    m_normalize = normalize;
    m_isVBO = false;
}

void GLESpointer::setBuffer(GLint size,GLenum type,GLsizei stride,GLESbuffer* buf,GLuint bufferName,int offset,bool normalize) {
    m_size   = size;
    m_type   = type;
    m_stride = stride;
    m_data   = NULL;
    m_buffer = buf;
    m_bufferName = bufferName;
    m_buffOffset = offset;
    m_normalize = normalize;
    m_isVBO = true;
}

void GLESpointer::getBufferConversions(const RangeList& rl,RangeList& rlOut) {
    m_buffer->getConversions(rl,rlOut);
}