Home | History | Annotate | Download | only in GLES_V2
      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 <GLES2/gl2.h>
     17 #include <GLcommon/objectNameManager.h>
     18 #include "ProgramData.h"
     19 
     20 ProgramData::ProgramData() :  ObjectData(PROGRAM_DATA),
     21                               AttachedVertexShader(0),
     22                               AttachedFragmentShader(0),
     23                               LinkStatus(GL_FALSE) {
     24     infoLog = new GLchar[1];
     25     infoLog[0] = '\0';
     26 }
     27 
     28 ProgramData::~ProgramData () {
     29     delete[] infoLog;
     30 };
     31 
     32 void ProgramData::setInfoLog(GLchar* log) {
     33     delete[] infoLog;
     34     infoLog = log;
     35 }
     36 
     37 GLchar* ProgramData::getInfoLog() {
     38     return infoLog;
     39 }
     40 
     41 GLuint ProgramData::getAttachedVertexShader() {
     42     return AttachedVertexShader;
     43 }
     44 
     45 GLuint ProgramData::getAttachedFragmentShader() {
     46     return AttachedFragmentShader;
     47 }
     48 
     49 GLuint ProgramData::getAttachedShader(GLenum type) {
     50     GLuint shader = 0;
     51     switch (type) {
     52     case GL_VERTEX_SHADER:
     53         shader = AttachedVertexShader;
     54         break;
     55     case GL_FRAGMENT_SHADER:
     56         shader = AttachedFragmentShader;
     57         break;
     58     }
     59     return shader;
     60 }
     61 
     62 bool ProgramData::attachShader(GLuint shader,GLenum type) {
     63     if (type==GL_VERTEX_SHADER && AttachedVertexShader==0) {
     64         AttachedVertexShader=shader;
     65         return true;
     66     }
     67     else if (type==GL_FRAGMENT_SHADER && AttachedFragmentShader==0) {
     68         AttachedFragmentShader=shader;
     69         return true;
     70     }
     71     return false;
     72 }
     73 
     74 bool ProgramData::isAttached(GLuint shader) {
     75     return (AttachedFragmentShader==shader || AttachedVertexShader==shader);
     76 }
     77 
     78 bool ProgramData::detachShader(GLuint shader) {
     79     if (AttachedVertexShader==shader) {
     80         AttachedVertexShader = 0;
     81         return true;
     82     }
     83     else if (AttachedFragmentShader==shader) {
     84         AttachedFragmentShader = 0;
     85         return true;
     86     }
     87     return false;
     88 }
     89 
     90 void ProgramData::setLinkStatus(GLint status) {
     91     LinkStatus = status;
     92 }
     93 
     94 GLint ProgramData::getLinkStatus() {
     95     return LinkStatus;
     96 }
     97