1 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
\r
2 //>>description: Tizen WebGL component for gallery3d
\r
4 //>>group: Tizen:Widgets:Lib
\r
6 define( [ ], function ( ) {
\r
7 //>>excludeEnd("jqmBuildExclude");
\r
9 /* ***************************************************************************
\r
10 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
\r
12 * Permission is hereby granted, free of charge, to any person obtaining a
\r
13 * copy of this software and associated documentation files (the "Software"),
\r
14 * to deal in the Software without restriction, including without limitation
\r
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
\r
16 * and/or sell copies of the Software, and to permit persons to whom the
\r
17 * Software is furnished to do so, subject to the following conditions:
\r
19 * The above copyright notice and this permission notice shall be included in
\r
20 * all copies or substantial portions of the Software.
\r
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
\r
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
\r
28 * DEALINGS IN THE SOFTWARE.
\r
29 * ***************************************************************************
\r
31 * Authors: Hyunsook Park <hyunsook.park@samsung.com>
\r
32 * Wonseop Kim <wonseop.kim@samsung.com>
\r
35 ( function ( $, undefined ) {
\r
39 _vertexShader: null,
\r
40 _fragmentShader: null,
\r
42 deleteShaders: function ( gl ) {
\r
43 gl.deleteShader( this._vertexShader );
\r
44 gl.deleteShader( this._fragmentShader );
\r
47 addShaderProgram : function ( gl, vs, fs, isFile ) {
\r
49 vertexShaderSource = {},
\r
50 fragmentShaderSource = {};
\r
53 vertexShaderSource = this.loadShaderFile( vs );
\r
54 fragmentShaderSource = this.loadShaderFile( fs );
\r
56 vertexShaderSource.source = vs;
\r
57 fragmentShaderSource.source = fs;
\r
60 this._vertexShader = this.getShader( gl, gl.VERTEX_SHADER, vertexShaderSource );
\r
61 this._fragmentShader = this.getShader( gl, gl.FRAGMENT_SHADER, fragmentShaderSource );
\r
63 shaderProgram = gl.createProgram();
\r
64 gl.attachShader( shaderProgram, this._vertexShader);
\r
65 gl.attachShader( shaderProgram, this._fragmentShader);
\r
66 gl.linkProgram( shaderProgram );
\r
68 if ( !gl.getProgramParameter( shaderProgram, gl.LINK_STATUS ) ) {
\r
69 window.alert( "Could not initialize Shaders!" );
\r
71 return shaderProgram;
\r
74 loadShaderFile : function ( path ) {
\r
79 success : function ( result ) {
\r
88 getShader: function ( gl, type, script ) {
\r
91 if ( !gl || !type || !script ) {
\r
95 shader = gl.createShader( type );
\r
97 gl.shaderSource( shader, script.source );
\r
98 gl.compileShader( shader );
\r
100 if ( !gl.getShaderParameter( shader, gl.COMPILE_STATUS ) ) {
\r
101 window.alert( gl.getShaderInfoLog( shader ) );
\r
102 gl.deleteShader( shader );
\r
110 attribBufferData: function ( gl, attribArray ) {
\r
111 var attribBuffer = gl.createBuffer();
\r
113 gl.bindBuffer( gl.ARRAY_BUFFER, attribBuffer );
\r
114 gl.bufferData( gl.ARRAY_BUFFER, attribArray, gl.STATIC_DRAW );
\r
115 gl.bindBuffer( gl.ARRAY_BUFFER, null );
\r
117 return attribBuffer;
\r
123 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
\r
125 //>>excludeEnd("jqmBuildExclude");
\r