/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (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.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is canvas 3D.
 *
 * The Initial Developer of the Original Code is
 *   Mozilla Corporation.
 * Portions created by the Initial Developer are Copyright (C) 2006
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Vladimir Vukicevic <vladimir@pobox.com>
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "nsICanvasRenderingContextGL.idl"
#include "nsICanvasRenderingContextGLBuffer.idl"

interface nsIDOMHTMLElement;

[scriptable, uuid(209a9c93-495e-4085-a3e4-29354b404cc4)]
interface nsICanvasRenderingContextGLWeb20 : nsICanvasRenderingContextGL
{
  void activeTexture (in PRUint32 texture);

  void attachShader (in PRUint32 program, in PRUint32 shader);
  void bindAttribLocation (in PRUint32 program, in PRUint32 index, in string name);

  void bindBuffer (in PRUint32 target, in PRUint32 buffer);
  void bindTexture (in PRUint32 target, in PRUint32 texid);

  void blendColor (in float red, in float green, in float blue, in float alpha);
  void blendEquation (in PRUint32 mode);
  void blendEquationSeparate (in PRUint32 modeRGB, in PRUint32 modeAlpha);
  void blendFunc (in PRUint32 sfactor, in PRUint32 dfactor);
  void blendFuncSeparate (in PRUint32 srcRGB, in PRUint32 dstRGB, in PRUint32 srcAlpha, in PRUint32 dstAlpha);

  
  void bufferData (/*in PRUint32 target, in object[] array, in PRUint32 type, in PRUint32 usage*/);
  void bufferSubData (/*in PRUint32 target, in PRUint32 offset, in object[] array, in PRUint32 type*/);

  void clear (in PRUint32 mask);
  void clearColor (in float red, in float green, in float blue, in float alpha);
  void clearDepth (in float depth);
  void clearStencil (in PRInt32 s);
  void colorMask (in boolean red, in boolean green, in boolean blue, in boolean alpha);
  // NO compressedTexImage2D
  // NO compressedTexSubImage2D

  void copyTexImage2D (in PRUint32 target, in PRInt32 level, in PRUint32 internalFormat, in PRInt32 x, in PRInt32 y, in PRUint32 width, in PRUint32 height, in PRInt32 border);
  void copyTexSubImage2D (in PRUint32 target, in PRInt32 level, in PRInt32 xoffset, in PRInt32 yoffset, in PRInt32 x, in PRInt32 y, in PRUint32 width, in PRUint32 height);

  PRUint32 createProgram ();
  PRUint32 createShader (in PRUint32 type);
  void cullFace (in PRUint32 face);

  void deleteBuffers (/*in PRUint32[] buffers*/);
  void deleteTextures (/*in PRUint32[] textures*/);
  void deleteProgram (in PRUint32 program);
  void deleteShader (in PRUint32 shader);
  void detachShader (in PRUint32 program, in PRUint32 shader);
  void depthFunc (in PRUint32 func);
  void depthMask (in boolean flag);
  void depthRange (in float zNear, in float zFar);
  void disable (in PRUint32 mode);
  void disableVertexAttribArray (in PRUint32 index);
  void drawArrays (in PRUint32 mode, in PRUint32 first, in PRUint32 count);
  void drawElements (/*in PRUint32 mode, in PRUint32 count, in PRUint32 type, in PRUint32[] indices*/);
  void enable (in PRUint32 mode);
  void enableVertexAttribArray (in PRUint32 index);
  void finish();
  void flush();
  void frontFace (in PRUint32 face);

  // getActiveAttrib returns an object: { name: "..", size: .., type: .. }
  void getActiveAttrib (in PRUint32 program, in PRUint32 index);

  // getActiveUniform returns an object: { name: "..", size: .., type: .. }
  void getActiveUniform (in PRUint32 program, in PRUint32 index);

  // returns an array of shader IDs
  void getAttachedShaders (in PRUint32 program);

  PRInt32 getAttribLocation (in PRUint32 program, in string name);

  // getBooleanv, getIntegerv, getFloatv, getDoublev, getString
  // are all rolled into a single function that uses scriptable
  // magic to return the right type of jsobj.  Colors are always
  // returned as normalized floats (0.0 .. 1.0).

  void getParameter (in PRUint32 pname);
  void getBufferParameter (in PRUint32 target, in PRUint32 pname);

  void genBuffers (in PRUint32 n);
  void genTextures (in PRUint32 n);

  void generateMipmap (in PRUint32 target);

  PRUint32 getError ();

  void getProgramParameter (in PRUint32 program, in PRUint32 pname);

  string getProgramInfoLog (in PRUint32 program);

  void getTexParameter(in PRUint32 target, in PRUint32 pname);

  void getUniform (in PRUint32 program, in PRUint32 location);
  PRInt32 getUniformLocation (in PRUint32 program, in string name);

  void getVertexAttrib (in PRUint32 index, in PRUint32 pname);
  // NO void getVertexAttribPointerv 

  void hint (in PRUint32 target, in PRUint32 mode);

  boolean isBuffer (in PRUint32 buffer);
  boolean isEnabled (in PRUint32 cap);
  boolean isProgram (in PRUint32 program);
  boolean isShader (in PRUint32 shader);
  boolean isTexture (in PRUint32 texture);

  void lineWidth (in float width);
  void linkProgram (in PRUint32 program);

  // NO pixelStore

  void pixelStore (in PRUint32 pname, in PRInt32 param);

  void polygonOffset (in float factor, in float units);

  void readPixels (in PRUint32 x, in PRUint32 y, in PRUint32 width, in PRUint32 height, in PRUint32 format, in PRUint32 type);

  void sampleCoverage (in float value, in boolean invert);
  void scissor (in PRInt32 x, in PRInt32 y, in PRInt32 width, in PRInt32 height);
  void stencilFunc (in PRUint32 func, in PRInt32 ref, in PRUint32 mask);
  void stencilFuncSeparate (in PRUint32 face, in PRUint32 func, in PRInt32 ref, in PRUint32 mask);
  void stencilMask (in PRUint32 mask);
  void stencilMaskSeparate (in PRUint32 face, in PRUint32 mask);
  void stencilOp (in PRUint32 fail, in PRUint32 zfail, in PRUint32 zpass);
  void stencilOpSeparate (in PRUint32 face, in PRUint32 fail, in PRUint32 zfail, in PRUint32 zpass);

  void texSubImage2D ();
  void texImage2D ();
  void texSubImage2DHTML (in PRUint32 target, in PRUint32 level, in PRInt32 x, in PRInt32 y, in nsIDOMHTMLElement imageOrCanvas);
  void texImage2DHTML (in PRUint32 target, in PRUint32 level, in nsIDOMHTMLElement imageOrCanvas);

  void texParameter();

  // YES void texSubImage2DHTML (...);

  void uniform1i(in PRUint32 id, in PRInt32 x);
  void uniform2i(in PRUint32 id, in PRInt32 x, in PRInt32 y);
  void uniform3i(in PRUint32 id, in PRInt32 x, in PRInt32 y, in PRInt32 z);
  void uniform4i(in PRUint32 id, in PRInt32 x, in PRInt32 y, in PRInt32 z, in PRInt32 w);
 
  void uniform1iv(/*in PRUint32 id, in int[] array */);
  void uniform2iv(/*in PRUint32 id, in int[] array */);
  void uniform3iv(/*in PRUint32 id, in int[] array */);
  void uniform4iv(/*in PRUint32 id, in int[] array */);

  void uniform1f(in PRUint32 id, in float x);
  void uniform2f(in PRUint32 id, in float x, in float y);
  void uniform3f(in PRUint32 id, in float x, in float y, in float z);
  void uniform4f(in PRUint32 id, in float x, in float y, in float z, in float w);
  
  void uniform1fv(/*in PRUint32 id, in float[] array */);
  void uniform2fv(/*in PRUint32 id, in float[] array */);
  void uniform3fv(/*in PRUint32 id, in float[] array */);
  void uniform4fv(/*in PRUint32 id, in float[] array */);

  void uniformMatrix2fv(/*in PRUint32 id, in float[] array */);
  void uniformMatrix3fv(/*in PRUint32 id, in float[] array */);
  void uniformMatrix4fv(/*in PRUint32 id, in float[] array */);

  void useProgram (in PRUint32 program);
  void validateProgram (in PRUint32 program);

  void vertexAttrib1f(in PRUint32 id, in float x);
  void vertexAttrib2f(in PRUint32 id, in float x, in float y);
  void vertexAttrib3f(in PRUint32 id, in float x, in float y, in float z);
  void vertexAttrib4f(in PRUint32 id, in float x, in float y, in float z, in float w);

  void vertexAttrib1fv(/*in PRUint32 id, in float[] array*/);
  void vertexAttrib2fv(/*in PRUint32 id, in float[] array*/);
  void vertexAttrib3fv(/*in PRUint32 id, in float[] array*/);
  void vertexAttrib4fv(/*in PRUint32 id, in float[] array*/);

  void vertexAttribPointer (/*in PRUint32 index, in PRInt32 size, in PRUint32 type, in PRBool normalized, in PRUint32 stride, in Object[] array*/);

  void viewport (in PRInt32 x, in PRInt32 y, in PRInt32 width, in PRInt32 height);

  void compileShader (in PRUint32 shader);
  void getShaderParameter (in PRUint32 shader, in PRUint32 pname);
  string getShaderInfoLog (in PRUint32 shader);
  string getShaderSource (in PRUint32 shader);
  void shaderSource(in PRUint32 shader, in string source);

  void getImageData (in PRUint32 x, in PRUint32 y, in PRUint32 width, in PRUint32 height);

  //
  // framebuffer_object methods
  //

  void bindRenderbuffer (in PRUint32 target, in PRUint32 renderbuffer);
  boolean isRenderbuffer (in PRUint32 renderbuffer);
  void deleteRenderbuffers (/*in PRUint32[] renderbuffers*/);
  void genRenderbuffers (in PRUint32 n);

  void renderbufferStorage (in PRUint32 target, in PRUint32 internalFormat, in PRUint32 width, in PRUint32 height);

  void getRenderbufferParameter (in PRUint32 target, in PRUint32 pname);

  void bindFramebuffer (in PRUint32 target, in PRUint32 framebuffer);
  boolean isFramebuffer (in PRUint32 framebuffer);
  void deleteFramebuffers (/*in PRUint32[] framebuffers*/);
  void genFramebuffers (in PRUint32 n);

  PRUint32 checkFramebufferStatus (in PRUint32 target);

  void framebufferTexture2D (in PRUint32 target, in PRUint32 attachmentPoint, in PRUint32 textureTarget, in PRUint32 texture, in PRInt32 level);

  void framebufferRenderbuffer (in PRUint32 target, in PRUint32 attachmentPoint, in PRUint32 renderbufferTarget, in PRUint32 renderbuffer);

  void getFramebufferAttachmentParameter (in PRUint32 target, in PRUint32 attachment, in PRUint32 pname);

};

