/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nsIVariant.idl"

interface nsIDOMElement;
interface nsIDOMHTMLCanvasElement;
interface nsIPropertyBag;

// XXX should we comment out these typedefs in the C++ header?

typedef unsigned long  WebGLenum;
typedef boolean        WebGLboolean;
typedef unsigned long  WebGLbitfield;
typedef long           WebGLint;
typedef long           WebGLsizei;
typedef long long      WebGLsizeiptr;
typedef long long      WebGLintptr;
typedef unsigned long  WebGLuint;
typedef float          WebGLfloat;
typedef float          WebGLclampf;

%{C++
// for jsval
#include "jsapi.h"

namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla

/* Avoid conflict with WinAPI */
#undef NO_ERROR
%}

[ptr] native WebGLJSObjectPtr (JSObject);
[ptr] native Element (mozilla::dom::Element);

//
// OpenGL object wrappers
//

[scriptable, builtinclass, uuid(0df9f4ed-f5ff-4e51-a6ff-2bd9785a7639)]
interface nsIWebGLTexture : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(9eca9c32-8305-11de-b89b-000c29206271)]
interface nsIWebGLBuffer : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(a6a19e74-8305-11de-9ce9-000c29206271)]
interface nsIWebGLProgram : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(ac7440a4-8305-11de-807b-000c29206271)]
interface nsIWebGLShader : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(beea4b38-3094-4e8d-b6e6-8b21d07e8994)]
interface nsIWebGLShaderArray : nsISupports
{
    readonly attribute unsigned long length;
    nsIWebGLShader item(in unsigned long index);
};

[scriptable, builtinclass, uuid(bce8be60-8305-11de-9f3c-000c29206271)]
interface nsIWebGLFramebuffer : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(c82eacd0-8305-11de-9de9-000c29206271)]
interface nsIWebGLRenderbuffer : nsISupports
{
  [noscript] attribute WebGLuint name;
};

[scriptable, builtinclass, uuid(a85d4fd0-5b9f-4cb8-aeee-5a2c5c5bad76)]
interface nsIWebGLActiveInfo : nsISupports
{
    readonly attribute WebGLint size;
    readonly attribute WebGLenum type;
    readonly attribute DOMString name;
};

[scriptable, builtinclass, uuid(76265e93-2e8f-40ca-b25b-eea5995e9641)]
interface nsIWebGLShaderPrecisionFormat : nsISupports
{
    readonly attribute WebGLint rangeMin;
    readonly attribute WebGLint rangeMax;
    readonly attribute WebGLint precision;
};

[scriptable, builtinclass, uuid(d38b0467-623e-4c82-9140-5f14a3bd1bad)]
interface nsIWebGLUniformLocation : nsISupports
{
    [noscript] attribute WebGLint location;
};

/* Base class for all WebGL extensions, and for those without
 * any additional tokens/methods.
 */
[scriptable, builtinclass, uuid(70814f32-a5c5-4b95-83d5-ac653bac3316)]
interface nsIWebGLExtension : nsISupports
{
};

/* Classes that extend on nsIWebGLExtension and provide
 * extra tokens, functions, etc.
 */
[scriptable, builtinclass, uuid(3de3dfd9-864a-4e4c-989b-2977eaa80b7b)]
interface nsIWebGLExtensionStandardDerivatives : nsIWebGLExtension
{
  //
  //  CONSTANTS
  //

  /* Fragment shader hint */
  const WebGLenum FRAGMENT_SHADER_DERIVATIVE_HINT_OES   = 0x8B8B;
};

[scriptable, builtinclass, uuid(b0afc2eb-0895-4509-98de-5c383d160694)]
interface nsIWebGLExtensionLoseContext : nsIWebGLExtension
{
  void loseContext();
  void restoreContext();
};

[scriptable, builtinclass, uuid(73bfb64d-94bd-4a7a-9eab-6b6d32e57aa0)]
interface nsIWebGLExtensionTextureFilterAnisotropic : nsIWebGLExtension
{
  const WebGLenum TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
  const WebGLenum MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
};

[scriptable, builtinclass, uuid(a1508b6f-f2ab-44cf-bbb4-3cfb339e1e8a)]
interface nsIWebGLExtensionCompressedTextureS3TC : nsIWebGLExtension
{
    /* Compressed Texture Formats */
    const WebGLenum COMPRESSED_RGB_S3TC_DXT1_EXT        = 0x83F0;
    const WebGLenum COMPRESSED_RGBA_S3TC_DXT1_EXT       = 0x83F1;
    const WebGLenum COMPRESSED_RGBA_S3TC_DXT3_EXT       = 0x83F2;
    const WebGLenum COMPRESSED_RGBA_S3TC_DXT5_EXT       = 0x83F3;
};

[scriptable, builtinclass, uuid(ef36f000-c1b2-11e1-afa7-0800200c9a66)]
interface nsIWebGLExtensionDepthTexture : nsIWebGLExtension
{
  const WebGLenum UNSIGNED_INT_24_8_WEBGL = 0x84FA;
};

[builtinclass, uuid(a1fdfb76-6a08-4a1a-b0c9-d92ef3357cb9)]
interface nsIDOMWebGLRenderingContext : nsISupports
{
  // get an underlying GL parameter, without any WebGL intervention.
  // Most useful for querying GL_VENDOR/GL_RENDERER for identifying
  // the underlying renderer to the user.
  [noscript] DOMString mozGetUnderlyingParamString(in WebGLenum pname);
};
