Nothing to see here; move along... (not part of the build)

This commit is contained in:
vladimir%pobox.com 2006-09-03 04:00:42 +00:00
Родитель bd816e2be4
Коммит 62bb22f0ce
19 изменённых файлов: 15994 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,56 @@
#
# ***** 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 code.
#
# The Initial Developer of the Original Code is
# Mozilla
# 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 *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = canvas3d
DIRS = public src
XPI_NAME = canvas3d
INSTALL_EXTENSION_ID = canvas3d@mozilla.com
XPI_PKGNAME = canvas3d
DIST_FILES = install.rdf
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>canvas3d@mozilla.com</em:id>
<em:version>0.1</em:version>
<em:type>2</em:type>
<em:targetApplication>
<!-- Firefox -->
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<!-- this version needs to be set to the exact version this
-- extension was built for, because of the way we're tied
-- to internal interfaces.
-->
<em:minVersion>3.0+</em:minVersion>
<em:maxVersion>3.0+</em:maxVersion>
</Description>
</em:targetApplication>
<!-- front-end metadata -->
<em:creator>Vladimir Vukicevic/mozilla.com</em:creator>
<em:name>Canvas 3D</em:name>
<em:description>Canvas 3D context(s)</em:description>
<em:homepageURL>http://people.mozilla.com/~vladimir/canvas3d/</em:homepageURL>
</Description>
</RDF>

Просмотреть файл

@ -0,0 +1,55 @@
#
# ***** 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 code.
#
# The Initial Developer of the Original Code is
# Mozilla
# 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 *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = canvas3d
XPI_NAME = canvas3d
XPIDLSRCS = nsICanvasRenderingContextGLES11.idl \
$(NULL)
# nsICanvasRenderingContextGLES20.idl
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,732 @@
/* -*- 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 "nsISupports.idl"
interface nsIDOMHTMLElement;
interface nsIDOMHTMLCanvasElement;
interface nsICanvasRenderingContextGLES11;
[scriptable, uuid(7c5ec0b3-a64c-4d9e-a8d5-acb574269dc4)]
interface nsICanvasRenderingContextGLES11Buffer : nsISupports
{
readonly attribute nsICanvasRenderingContextGLES11 ownerContext;
readonly attribute PRBool disposed;
// immediately free the memory held by this buffer,
// even before this object is destroyed (e.g. by the JS GC)
void dispose();
readonly attribute PRUint32 usage; // either STATIC_DRAW or DYNAMIC_DRAW
readonly attribute PRUint32 length; // number of elements
readonly attribute PRUint32 type; // type of each element
};
[scriptable, uuid(27a45ca4-0847-4f2e-8e32-6d4966ff3e56)]
interface nsICanvasRenderingContextGLES11Texture : nsISupports
{
readonly attribute nsICanvasRenderingContextGLES11 ownerContext;
readonly attribute PRBool disposed;
const PRUint32 TARGET_2D = 0;
const PRUint32 TARGET_RECT = 1;
readonly attribute PRUint32 target;
// in pixels; the texture coordinates
// are 0..w/h for TARGET_RECT, or 0.0 .. 1.0
// for TARGET_2D
readonly attribute PRUint32 width;
readonly attribute PRUint32 height;
const PRUint32 FILTER_TYPE_MAG = 0;
const PRUint32 FILTER_TYPE_MIN = 1;
const PRUint32 FILTER_NEAREST = 0;
const PRUint32 FILTER_LINER = 1;
void setFilter (in PRUint32 filterType, in PRUint32 filterMode);
const PRUint32 WRAP_TYPE_S = 0;
const PRUint32 WRAP_TYPE_T = 0;
const PRUint32 WRAP_CLAMP_TO_EDGE = 1;
const PRUint32 WRAP_REPEAT = 3;
const PRUint32 WRAP_MIRRORED_REPEAT = 4;
void setWrap (in PRUint32 wrapType, in PRUint32 wrapMode);
};
[scriptable, uuid(619a102d-6c58-4660-ba35-60d9b8de92ab)]
interface nsICanvasRenderingContextGLES11 : nsISupports
{
readonly attribute nsIDOMHTMLCanvasElement canvas;
/**
** GL constants
**/
/* types */
const PRUint32 BYTE = 0x1400;
const PRUint32 UNSIGNED_BYTE = 0x1401;
const PRUint32 SHORT = 0x1402;
const PRUint32 UNSIGNED_SHORT = 0x1403;
const PRUint32 INT = 0x1404;
const PRUint32 UNSIGNED_INT = 0x1405;
const PRUint32 FLOAT = 0x1406;
const PRUint32 TWO_BYTES = 0x1407;
const PRUint32 THREE_BYTES = 0x1408;
const PRUint32 FOUR_BYTES = 0x1409;
const PRUint32 DOUBLE = 0x140A;
/* ClearBufferMask */
const PRUint32 DEPTH_BUFFER_BIT = 0x00000100;
const PRUint32 STENCIL_BUFFER_BIT = 0x00000400;
const PRUint32 COLOR_BUFFER_BIT = 0x00004000;
/* BeginMode */
const PRUint32 POINTS = 0x0000;
const PRUint32 LINES = 0x0001;
const PRUint32 LINE_LOOP = 0x0002;
const PRUint32 LINE_STRIP = 0x0003;
const PRUint32 TRIANGLES = 0x0004;
const PRUint32 TRIANGLE_STRIP = 0x0005;
const PRUint32 TRIANGLE_FAN = 0x0006;
/* AlphaFunction */
const PRUint32 NEVER = 0x0200;
const PRUint32 LESS = 0x0201;
const PRUint32 EQUAL = 0x0202;
const PRUint32 LEQUAL = 0x0203;
const PRUint32 GREATER = 0x0204;
const PRUint32 NOTEQUAL = 0x0205;
const PRUint32 GEQUAL = 0x0206;
const PRUint32 ALWAYS = 0x0207;
/* BlendingFactorDest */
const PRUint32 ZERO = 0;
const PRUint32 ONE = 1;
const PRUint32 SRC_COLOR = 0x0300;
const PRUint32 ONE_MINUS_SRC_COLOR = 0x0301;
const PRUint32 SRC_ALPHA = 0x0302;
const PRUint32 ONE_MINUS_SRC_ALPHA = 0x0303;
const PRUint32 DST_ALPHA = 0x0304;
const PRUint32 ONE_MINUS_DST_ALPHA = 0x0305;
/* BlendingFactorSrc */
/* ZERO */
/* ONE */
const PRUint32 DST_COLOR = 0x0306;
const PRUint32 ONE_MINUS_DST_COLOR = 0x0307;
const PRUint32 SRC_ALPHA_SATURATE = 0x0308;
/* SRC_ALPHA */
/* ONE_MINUS_SRC_ALPHA */
/* DST_ALPHA */
/* ONE_MINUS_DST_ALPHA */
/* ClipPlaneName */
const PRUint32 CLIP_PLANE0 = 0x3000;
const PRUint32 CLIP_PLANE1 = 0x3001;
const PRUint32 CLIP_PLANE2 = 0x3002;
const PRUint32 CLIP_PLANE3 = 0x3003;
const PRUint32 CLIP_PLANE4 = 0x3004;
const PRUint32 CLIP_PLANE5 = 0x3005;
/* ColorMaterialFace */
/* FRONT_AND_BACK */
/* ColorMaterialParameter */
/* AMBIENT_AND_DIFFUSE */
/* CullFaceMode */
const PRUint32 FRONT = 0x0404;
const PRUint32 BACK = 0x0405;
const PRUint32 FRONT_AND_BACK = 0x0408;
/* DepthFunction */
/* NEVER */
/* LESS */
/* EQUAL */
/* LEQUAL */
/* GREATER */
/* NOTEQUAL */
/* GEQUAL */
/* ALWAYS */
/* EnableCap */
const PRUint32 FOG = 0x0B60;
const PRUint32 LIGHTING = 0x0B50;
const PRUint32 TEXTURE_2D = 0x0DE1;
const PRUint32 CULL_FACE = 0x0B44;
const PRUint32 ALPHA_TEST = 0x0BC0;
const PRUint32 BLEND = 0x0BE2;
const PRUint32 COLOR_LOGIC_OP = 0x0BF2;
const PRUint32 DITHER = 0x0BD0;
const PRUint32 STENCIL_TEST = 0x0B90;
const PRUint32 DEPTH_TEST = 0x0B71;
/* LIGHT0 */
/* LIGHT1 */
/* LIGHT2 */
/* LIGHT3 */
/* LIGHT4 */
/* LIGHT5 */
/* LIGHT6 */
/* LIGHT7 */
const PRUint32 POINT_SMOOTH = 0x0B10;
const PRUint32 LINE_SMOOTH = 0x0B20;
const PRUint32 SCISSOR_TEST = 0x0C11;
const PRUint32 COLOR_MATERIAL = 0x0B57;
const PRUint32 NORMALIZE = 0x0BA1;
const PRUint32 RESCALE_NORMAL = 0x803A;
const PRUint32 POLYGON_OFFSET_FILL = 0x8037;
const PRUint32 VERTEX_ARRAY = 0x8074;
const PRUint32 NORMAL_ARRAY = 0x8075;
const PRUint32 COLOR_ARRAY = 0x8076;
const PRUint32 TEXTURE_COORD_ARRAY = 0x8078;
const PRUint32 MULTISAMPLE = 0x809D;
const PRUint32 SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
const PRUint32 SAMPLE_ALPHA_TO_ONE = 0x809F;
const PRUint32 SAMPLE_COVERAGE = 0x80A0;
/* ErrorCode */
const PRUint32 NO_ERROR = 0;
const PRUint32 INVALID_ENUM = 0x0500;
const PRUint32 INVALID_VALUE = 0x0501;
const PRUint32 INVALID_OPERATION = 0x0502;
const PRUint32 STACK_OVERFLOW = 0x0503;
const PRUint32 STACK_UNDERFLOW = 0x0504;
const PRUint32 OUT_OF_MEMORY = 0x0505;
/* FogMode */
/* LINEAR */
const PRUint32 EXP = 0x0800;
const PRUint32 EXP2 = 0x0801;
/* FogParameter */
const PRUint32 FOG_DENSITY = 0x0B62;
const PRUint32 FOG_START = 0x0B63;
const PRUint32 FOG_END = 0x0B64;
const PRUint32 FOG_MODE = 0x0B65;
const PRUint32 FOG_COLOR = 0x0B66;
/* FrontFaceDirection */
const PRUint32 CW = 0x0900;
const PRUint32 CCW = 0x0901;
/* GetPName */
const PRUint32 CURRENT_COLOR = 0x0B00;
const PRUint32 CURRENT_NORMAL = 0x0B02;
const PRUint32 CURRENT_TEXTURE_COORDS = 0x0B03;
const PRUint32 POINT_SIZE = 0x0B11;
const PRUint32 POINT_SIZE_MIN = 0x8126;
const PRUint32 POINT_SIZE_MAX = 0x8127;
const PRUint32 POINT_FADE_THRESHOLD_SIZE = 0x8128;
const PRUint32 POINT_DISTANCE_ATTENUATION = 0x8129;
const PRUint32 SMOOTH_POINT_SIZE_RANGE = 0x0B12;
const PRUint32 LINE_WIDTH = 0x0B21;
const PRUint32 SMOOTH_LINE_WIDTH_RANGE = 0x0B22;
const PRUint32 ALIASED_POINT_SIZE_RANGE = 0x846D;
const PRUint32 ALIASED_LINE_WIDTH_RANGE = 0x846E;
const PRUint32 CULL_FACE_MODE = 0x0B45;
const PRUint32 FRONT_FACE = 0x0B46;
const PRUint32 SHADE_MODEL = 0x0B54;
const PRUint32 DEPTH_RANGE = 0x0B70;
const PRUint32 DEPTH_WRITEMASK = 0x0B72;
const PRUint32 DEPTH_CLEAR_VALUE = 0x0B73;
const PRUint32 DEPTH_FUNC = 0x0B74;
const PRUint32 STENCIL_CLEAR_VALUE = 0x0B91;
const PRUint32 STENCIL_FUNC = 0x0B92;
const PRUint32 STENCIL_VALUE_MASK = 0x0B93;
const PRUint32 STENCIL_FAIL = 0x0B94;
const PRUint32 STENCIL_PASS_DEPTH_FAIL = 0x0B95;
const PRUint32 STENCIL_PASS_DEPTH_PASS = 0x0B96;
const PRUint32 STENCIL_REF = 0x0B97;
const PRUint32 STENCIL_WRITEMASK = 0x0B98;
const PRUint32 MATRIX_MODE = 0x0BA0;
// VIEWPORT -> VIEWPORT_VALUE, because viewport() conflicts
const PRUint32 VIEWPORT_VALUE = 0x0BA2;
const PRUint32 MODELVIEW_STACK_DEPTH = 0x0BA3;
const PRUint32 PROJECTION_STACK_DEPTH = 0x0BA4;
const PRUint32 TEXTURE_STACK_DEPTH = 0x0BA5;
const PRUint32 MODELVIEW_MATRIX = 0x0BA6;
const PRUint32 PROJECTION_MATRIX = 0x0BA7;
const PRUint32 TEXTURE_MATRIX = 0x0BA8;
const PRUint32 ALPHA_TEST_FUNC = 0x0BC1;
const PRUint32 ALPHA_TEST_REF = 0x0BC2;
const PRUint32 BLEND_DST = 0x0BE0;
const PRUint32 BLEND_SRC = 0x0BE1;
const PRUint32 LOGIC_OP_MODE = 0x0BF0;
const PRUint32 SCISSOR_BOX = 0x0C10;
/* SCISSOR_TEST */
const PRUint32 COLOR_CLEAR_VALUE = 0x0C22;
const PRUint32 COLOR_WRITEMASK = 0x0C23;
const PRUint32 UNPACK_ALIGNMENT = 0x0CF5;
const PRUint32 PACK_ALIGNMENT = 0x0D05;
const PRUint32 MAX_LIGHTS = 0x0D31;
const PRUint32 MAX_CLIP_PLANES = 0x0D32;
const PRUint32 MAX_TEXTURE_SIZE = 0x0D33;
const PRUint32 MAX_MODELVIEW_STACK_DEPTH = 0x0D36;
const PRUint32 MAX_PROJECTION_STACK_DEPTH = 0x0D38;
const PRUint32 MAX_TEXTURE_STACK_DEPTH = 0x0D39;
const PRUint32 MAX_VIEWPORT_DIMS = 0x0D3A;
const PRUint32 MAX_ELEMENTS_VERTICES = 0x80E8;
const PRUint32 MAX_ELEMENTS_INDICES = 0x80E9;
const PRUint32 MAX_TEXTURE_UNITS = 0x84E2;
const PRUint32 SUBPIXEL_BITS = 0x0D50;
const PRUint32 RED_BITS = 0x0D52;
const PRUint32 GREEN_BITS = 0x0D53;
const PRUint32 BLUE_BITS = 0x0D54;
const PRUint32 ALPHA_BITS = 0x0D55;
const PRUint32 DEPTH_BITS = 0x0D56;
const PRUint32 STENCIL_BITS = 0x0D57;
const PRUint32 POLYGON_OFFSET_UNITS = 0x2A00;
// POLYGON_OFFSET_FILL = 0x8037;
const PRUint32 POLYGON_OFFSET_FACTOR = 0x8038;
const PRUint32 TEXTURE_BINDING_2D = 0x8069;
const PRUint32 VERTEX_ARRAY_SIZE = 0x807A;
const PRUint32 VERTEX_ARRAY_TYPE = 0x807B;
const PRUint32 VERTEX_ARRAY_STRIDE = 0x807C;
const PRUint32 NORMAL_ARRAY_TYPE = 0x807E;
const PRUint32 NORMAL_ARRAY_STRIDE = 0x807F;
const PRUint32 COLOR_ARRAY_SIZE = 0x8081;
const PRUint32 COLOR_ARRAY_TYPE = 0x8082;
const PRUint32 COLOR_ARRAY_STRIDE = 0x8083;
const PRUint32 TEXTURE_COORD_ARRAY_SIZE = 0x8088;
const PRUint32 TEXTURE_COORD_ARRAY_TYPE = 0x8089;
const PRUint32 TEXTURE_COORD_ARRAY_STRIDE = 0x808A;
const PRUint32 VERTEX_ARRAY_POINTER = 0x808E;
const PRUint32 NORMAL_ARRAY_POINTER = 0x808F;
const PRUint32 COLOR_ARRAY_POINTER = 0x8090;
const PRUint32 TEXTURE_COORD_ARRAY_POINTER = 0x8092;
const PRUint32 SAMPLE_BUFFERS = 0x80A8;
const PRUint32 SAMPLES = 0x80A9;
const PRUint32 SAMPLE_COVERAGE_VALUE = 0x80AA;
const PRUint32 SAMPLE_COVERAGE_INVERT = 0x80AB;
/* GetTextureParameter */
/* TEXTURE_MAG_FILTER */
/* TEXTURE_MIN_FILTER */
/* TEXTURE_WRAP_S */
/* TEXTURE_WRAP_T */
/* HintMode */
const PRUint32 DONT_CARE = 0x1100;
const PRUint32 FASTEST = 0x1101;
const PRUint32 NICEST = 0x1102;
/* HintTarget */
const PRUint32 PERSPECTIVE_CORRECTION_HINT = 0x0C50;
const PRUint32 POINT_SMOOTH_HINT = 0x0C51;
const PRUint32 LINE_SMOOTH_HINT = 0x0C52;
const PRUint32 POLYGON_SMOOTH_HINT = 0x0C53;
const PRUint32 FOG_HINT = 0x0C54;
const PRUint32 GENERATE_MIPMAP_HINT = 0x8192;
/* LightModelParameter */
const PRUint32 LIGHT_MODEL_AMBIENT = 0x0B53;
const PRUint32 LIGHT_MODEL_TWO_SIDE = 0x0B52;
const PRUint32 LIGHT_MODEL_LOCAL_VIEWER = 0x0B51;
const PRUint32 LIGHT_MODEL_COLOR_CONTROL = 0x81F8;
/* LightParameter */
const PRUint32 AMBIENT = 0x1200;
const PRUint32 DIFFUSE = 0x1201;
const PRUint32 SPECULAR = 0x1202;
const PRUint32 POSITION = 0x1203;
const PRUint32 SPOT_DIRECTION = 0x1204;
const PRUint32 SPOT_EXPONENT = 0x1205;
const PRUint32 SPOT_CUTOFF = 0x1206;
const PRUint32 CONSTANT_ATTENUATION = 0x1207;
const PRUint32 LINEAR_ATTENUATION = 0x1208;
const PRUint32 QUADRATIC_ATTENUATION = 0x1209;
/* LogicOp */
/* CLEAR -> CLEAR_OP, because clear() is a method */
const PRUint32 CLEAR_OP = 0x1500;
const PRUint32 AND = 0x1501;
const PRUint32 AND_REVERSE = 0x1502;
const PRUint32 COPY = 0x1503;
const PRUint32 AND_INVERTED = 0x1504;
const PRUint32 NOOP = 0x1505;
const PRUint32 XOR = 0x1506;
const PRUint32 OR = 0x1507;
const PRUint32 NOR = 0x1508;
const PRUint32 EQUIV = 0x1509;
const PRUint32 INVERT = 0x150A;
const PRUint32 OR_REVERSE = 0x150B;
const PRUint32 COPY_INVERTED = 0x150C;
const PRUint32 OR_INVERTED = 0x150D;
const PRUint32 NAND = 0x150E;
const PRUint32 SET = 0x150F;
/* MaterialFace */
/* FRONT_AND_BACK */
/* MaterialParameter */
const PRUint32 EMISSION = 0x1600;
const PRUint32 SHININESS = 0x1601;
const PRUint32 AMBIENT_AND_DIFFUSE = 0x1602;
/* MatrixMode */
const PRUint32 MODELVIEW = 0x1700;
const PRUint32 PROJECTION = 0x1701;
const PRUint32 TEXTURE = 0x1702;
/* LightName */
const PRUint32 LIGHT0 = 0x4000;
const PRUint32 LIGHT1 = 0x4001;
const PRUint32 LIGHT2 = 0x4002;
const PRUint32 LIGHT3 = 0x4003;
const PRUint32 LIGHT4 = 0x4004;
const PRUint32 LIGHT5 = 0x4005;
const PRUint32 LIGHT6 = 0x4006;
const PRUint32 LIGHT7 = 0x4007;
/* ShadingModel */
const PRUint32 FLAT = 0x1D00;
const PRUint32 SMOOTH = 0x1D01;
/* StencilFunction */
/* NEVER */
/* LESS */
/* EQUAL */
/* LEQUAL */
/* GREATER */
/* NOTEQUAL */
/* GEQUAL */
/* ALWAYS */
/* StencilOp */
/* ZERO */
const PRUint32 KEEP = 0x1E00;
const PRUint32 REPLACE = 0x1E01;
const PRUint32 INCR = 0x1E02;
const PRUint32 DECR = 0x1E03;
/* INVERT */
/* StringName */
const PRUint32 VENDOR = 0x1F00;
const PRUint32 RENDERER = 0x1F01;
const PRUint32 VERSION = 0x1F02;
const PRUint32 EXTENSIONS = 0x1F03;
/* TextureEnvMode */
const PRUint32 MODULATE = 0x2100;
const PRUint32 DECAL = 0x2101;
/* BLEND */
const PRUint32 ADD = 0x0104;
// REPLACE
/* COMBINE */
/* TextureEnvParameter */
const PRUint32 TEXTURE_ENV_MODE = 0x2200;
const PRUint32 TEXTURE_ENV_COLOR = 0x2201;
/* TextureEnvTarget */
const PRUint32 TEXTURE_ENV = 0x2300;
/* TextureMagFilter */
const PRUint32 NEAREST = 0x2600;
const PRUint32 LINEAR = 0x2601;
/* TextureMinFilter */
/* NEAREST */
/* LINEAR */
const PRUint32 NEAREST_MIPMAP_NEAREST = 0x2700;
const PRUint32 LINEAR_MIPMAP_NEAREST = 0x2701;
const PRUint32 NEAREST_MIPMAP_LINEAR = 0x2702;
const PRUint32 LINEAR_MIPMAP_LINEAR = 0x2703;
/* TextureParameterName */
const PRUint32 TEXTURE_MAG_FILTER = 0x2800;
const PRUint32 TEXTURE_MIN_FILTER = 0x2801;
const PRUint32 TEXTURE_WRAP_S = 0x2802;
const PRUint32 TEXTURE_WRAP_T = 0x2803;
const PRUint32 GENERATE_MIPMAP = 0x8191;
/* TextureUnit */
const PRUint32 TEXTURE0 = 0x84C0;
const PRUint32 TEXTURE1 = 0x84C1;
const PRUint32 TEXTURE2 = 0x84C2;
const PRUint32 TEXTURE3 = 0x84C3;
const PRUint32 TEXTURE4 = 0x84C4;
const PRUint32 TEXTURE5 = 0x84C5;
const PRUint32 TEXTURE6 = 0x84C6;
const PRUint32 TEXTURE7 = 0x84C7;
const PRUint32 TEXTURE8 = 0x84C8;
const PRUint32 TEXTURE9 = 0x84C9;
const PRUint32 TEXTURE10 = 0x84CA;
const PRUint32 TEXTURE11 = 0x84CB;
const PRUint32 TEXTURE12 = 0x84CC;
const PRUint32 TEXTURE13 = 0x84CD;
const PRUint32 TEXTURE14 = 0x84CE;
const PRUint32 TEXTURE15 = 0x84CF;
const PRUint32 TEXTURE16 = 0x84D0;
const PRUint32 TEXTURE17 = 0x84D1;
const PRUint32 TEXTURE18 = 0x84D2;
const PRUint32 TEXTURE19 = 0x84D3;
const PRUint32 TEXTURE20 = 0x84D4;
const PRUint32 TEXTURE21 = 0x84D5;
const PRUint32 TEXTURE22 = 0x84D6;
const PRUint32 TEXTURE23 = 0x84D7;
const PRUint32 TEXTURE24 = 0x84D8;
const PRUint32 TEXTURE25 = 0x84D9;
const PRUint32 TEXTURE26 = 0x84DA;
const PRUint32 TEXTURE27 = 0x84DB;
const PRUint32 TEXTURE28 = 0x84DC;
const PRUint32 TEXTURE29 = 0x84DD;
const PRUint32 TEXTURE30 = 0x84DE;
const PRUint32 TEXTURE31 = 0x84DF;
const PRUint32 ACTIVE_TEXTURE = 0x84E0;
const PRUint32 CLIENT_ACTIVE_TEXTURE = 0x84E1;
/* TextureWrapMode */
const PRUint32 REPEAT = 0x2901;
const PRUint32 CLAMP_TO_EDGE = 0x812F;
/* Texture combine + dot3 */
const PRUint32 SUBTRACT = 0x84E7;
const PRUint32 COMBINE = 0x8570;
const PRUint32 COMBINE_RGB = 0x8571;
const PRUint32 COMBINE_ALPHA = 0x8572;
const PRUint32 RGB_SCALE = 0x8573;
const PRUint32 ADD_SIGNED = 0x8574;
const PRUint32 INTERPOLATE = 0x8575;
const PRUint32 CONSTANT = 0x8576;
const PRUint32 PRIMARY_COLOR = 0x8577;
const PRUint32 PREVIOUS = 0x8578;
const PRUint32 OPERAND0_RGB = 0x8590;
const PRUint32 OPERAND1_RGB = 0x8591;
const PRUint32 OPERAND2_RGB = 0x8592;
const PRUint32 OPERAND0_ALPHA = 0x8598;
const PRUint32 OPERAND1_ALPHA = 0x8599;
const PRUint32 OPERAND2_ALPHA = 0x859A;
const PRUint32 ALPHA_SCALE = 0x0D1C;
const PRUint32 SRC0_RGB = 0x8580;
const PRUint32 SRC1_RGB = 0x8581;
const PRUint32 SRC2_RGB = 0x8582;
const PRUint32 SRC0_ALPHA = 0x8588;
const PRUint32 SRC1_ALPHA = 0x8589;
const PRUint32 SRC2_ALPHA = 0x858A;
const PRUint32 DOT3_RGB = 0x86AE;
const PRUint32 DOT3_RGBA = 0x86AF;
/* Buffers */
const PRUint32 STATIC_DRAW = 0x88E4;
const PRUint32 DYNAMIC_DRAW = 0x88E8;
const PRUint32 ARRAY_BUFFER = 0x8892;
const PRUint32 ELEMENT_ARRAY_BUFFER = 0x8893;
const PRUint32 ARRAY_BUFFER_BINDING = 0x8894;
const PRUint32 ELEMENT_ARRAY_BUFFER_BINDING = 0x8895;
/**
** GL ES 1.1 API
**
** Section numbers refer to the GL ES Common/Common-Lite Profile Specification 1.0 document
**/
void enable (in PRUint32 mode);
void disable (in PRUint32 mode);
void clientActiveTexture (in PRUint32 texture);
void enableClientState (in PRUint32 mode);
void disableClientState (in PRUint32 mode);
// 2.5 GL Errors
PRUint32 getError ();
// 2.7 Vertex Specification
void normal (in float nx, in float ny, in float nz);
void multiTexCoord (in PRUint32 target, in float s, in float t, in float r, in float q);
void color (in float r, in float g, in float b, in float a);
// 2.8 Vertex Arrays
// Note: these are handled via scriptable helpers to avoid unnencessary type conversions
//X void vertexPointer (in PRUint8 size, in PRUint32 type, in object [] vertexArray);
void vertexPointer ();
//X void normalPointer (in PRUint32 type, in object [] normalArray);
void normalPointer ();
//X void texCoordPointer (in PRUint8 size, in PRUint32 type, in object [] texCoordArray);
void texCoordPointer ();
//X void colorPointer (in PRUint8 size, in PRUint32 type, in object [] colorArray);
void colorPointer ();
//X void drawElements (in PRUint32 mode, in PRUint32 count, in PRUint32 type, in object [] indices);
void drawElements ();
void drawArrays (in PRUint32 mode, in PRUint32 first, in PRUint32 count);
// 2.9 Buffer Objects
void genBuffers (in PRUint32 n);
/* [array of buffers] */
void deleteBuffers ();
void bindBuffer (in PRUint32 target, in PRUint32 buffer);
/* array, type, usage */
void bufferData ();
/* offset, array, type */
void bufferSubData ();
// JS buffer objects; will use buffer objects extension if available,
// otherwise will just store in client memeory
//void bindBufferObject (in PRUint32 target, in nsICanvasRenderingContextGLES11Buffer obj);
//X nsICanvasRenderingContextGLES11Buffer
//X createBuffer(in PRInt32 usage, in PRInt32 componentSize, in PRInt32 type, in [] array);
nsICanvasRenderingContextGLES11Buffer createBuffer();
// 2.11 Coordinate Transformations
void depthRange (in float zNear, in float zFar);
void viewport (in PRInt32 x, in PRInt32 y, in PRInt32 width, in PRInt32 height);
void matrixMode (in PRUint32 mode);
//X void loadMatrix (in float [] matrix);
void loadMatrix ();
//X void multMatrix (in float [] matrix);
void multMatrix ();
void loadIdentity ();
void rotate (in float angle, in float x, in float y, in float z);
void scale (in float x, in float y, in float z);
void translate (in float x, in float y, in float z);
void frustum (in float left, in float right, in float bottom, in float top, in float zNear, in float zFar);
void ortho (in float left, in float right, in float bottom, in float top, in float zNear, in float zFar);
void pushMatrix ();
void popMatrix ();
// 2.12 Clipping
//void clipPlane (in PRUint32 plane, in float [] equation);
//void getClipPlane (in PRUint32 pname, out float [] equation);
// 2.14 Colors and Coloring
void frontFace (in PRUint32 face);
void material ();
void getMaterial ();
void light ();
void getLight ();
void lightModel ();
void shadeModel (in PRUint32 pname);
// 3.3 Points
void pointSize (in float size);
void pointParameter ();
void lineWidth (in float width);
// 3.5 Polygons
void cullFace (in PRUint32 mode);
void polygonOffset (in float factor, in float units);
// 3.6 Pixel Rectangles
// glReadPixels is not supported (XXX well, it might be)
// and TexImage2D behaves differently, so no need for PixelStore[i]
// 3.8.5 Texture State
void activeTexture (in PRUint32 texture);
nsICanvasRenderingContextGLES11Texture createTextureObject (in nsIDOMHTMLElement imageOrCanvas);
void bindTextureObject (in nsICanvasRenderingContextGLES11Texture texture);
void deleteTextureObject (in nsICanvasRenderingContextGLES11Texture texture);
// This needs some work; we need to allow specifying the internal format, so that
// we can load A/L/LA images as well as RGB/RGBA, which is all we'd get from a DOM Image
void texImage2DHTML (in nsIDOMHTMLElement imageOrCanvas);
//void texSubImage2DHTML (...);
void texParameter();
void getTexParameter();
void bindTexture (in PRUint32 target, in PRUint32 texid);
void deleteTextures ();
void genTextures (in PRUint32 n);
//boolean isTexture (in PRUint32 texture);
void texEnv();
void getTexEnv();
// 3.9 Fog
//X (this is called glFog{fi}[v], but we can't call it "fog" because
// we have FOG as a glEnable const already)
void fogParameter ();
// 4.1 Per-Fragment Operations
void scissor (in PRInt32 x, in PRInt32 y, in PRInt32 width, in PRInt32 height);
void sampleCoverage (in float value, in boolean invert);
void alphaFunc (in PRUint32 func, in float ref);
void stencilFunc (in PRUint32 func, in PRInt32 ref, in PRUint32 mask);
void stencilMask (in PRUint32 mask);
void stencilOp (in PRUint32 fail, in PRUint32 zfail, in PRUint32 zpass);
void depthFunc (in PRUint32 func);
void depthMask (in boolean flag);
void blendFunc (in PRUint32 sfactor, in PRUint32 dfactor);
void logicOp (in PRUint32 opcode);
// 4.2 Whole Framebuffer Operations
void colorMask (in boolean red, in boolean green, in boolean blue, in boolean alpha);
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);
// 4.3 Drawing, Reading, and Copying Pixels
// we should support ReadPixels at some point
// 5.5 Flush and Finish
// I'm not sure if this is useful for our purposes; we can't block the UI, soo...
// 5.6 Hints
void hint (in PRUint32 target, in PRUint32 mode);
// 6.1 Querying GL State
// 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);
// Other
void swapBuffers ();
// More other
void gluPerspective (in float fovy, in float aspect, in float znear, in float zfar);
void gluLookAt (in float eyex, in float eyey, in float eyez,
in float ctrx, in float ctry, in float ctrz,
in float upx, in float upy, in float upz);
};

Просмотреть файл

@ -0,0 +1,169 @@
#
# ***** 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 code.
#
# The Initial Developer of the Original Code is
# Mozilla
# 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 *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = canvas3d
LIBRARY_NAME = canvas3d
XPI_NAME = canvas3d
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsCanvas3DModule
GRE_MODULE = 1
MOZILLA_INTERNAL_API = 1
REQUIRES = \
xpcom \
string \
gfx \
content \
layout \
widget \
dom \
js \
locale \
unicharutil \
necko \
view \
pref \
docshell \
xpconnect \
xuldoc \
caps \
imglib2 \
mimetype \
exthandler \
uconv \
intl \
cairo \
thebes \
$(NULL)
GLITZ_SRC_DIR = $(topsrcdir)/gfx/cairo/glitz/src
VPATH += $(GLITZ_SRC_DIR)
GLITZ_CSRCS = \
glitz.c \
glitz_buffer.c \
glitz_compose.c \
glitz_context.c \
glitz_drawable.c \
glitz_filter.c \
glitz_format.c \
glitz_framebuffer.c \
glitz_geometry.c \
glitz_operator.c \
glitz_pixel.c \
glitz_program.c \
glitz_rect.c \
glitz_region.c \
glitz_status.c \
glitz_surface.c \
glitz_texture.c \
glitz_trap.c \
glitz_util.c \
$(NULL)
ifdef MOZ_X11
GLITZ_PLATFORM_SRC_DIR = $(GLITZ_SRC_DIR)/glx
VPATH += $(GLITZ_PLATFORM_SRC_DIR)
GLITZ_CSRCS += \
glitz_glx_drawable.c \
glitz_glx_format.c \
glitz_glx_info.c \
glitz_glx_extension.c \
glitz_glx_context.c \
glitz_glx_pbuffer.c \
$(NULL)
EXTRA_DSO_LIBS += GL
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
GLITZ_PLATFORM_SRC_DIR = $(GLITZ_SRC_DIR)/wgl
VPATH += $(GLITZ_PLATFORM_SRC_DIR)
GLITZ_CSRCS += \
glitz_wgl_drawable.c \
glitz_wgl_format.c \
glitz_wgl_info.c \
glitz_wgl_extension.c \
glitz_wgl_context.c \
glitz_wgl_pbuffer.c \
$(NULL)
endif
ifneq (,$(filter $(MOZ_GFX_TOOLKIT),mac cocoa))
endif
CSRCS = $(GLITZ_CSRCS) \
glew.c \
$(NULL)
CPPSRCS = nsCanvas3DModule.cpp \
nsCanvasRenderingContextGLES11.cpp \
$(NULL)
DEFINES += -DXPCOM_GLUE -DGLEW_MX -DGLEW_STATIC
EXTRA_DSO_LIBS += gkgfx thebes js3250 mozcairo mozlibpixman xpcom nspr4 xpcom_core
include $(topsrcdir)/config/rules.mk
CFLAGS += -I$(GLITZ_SRC_DIR) -I$(GLITZ_PLATFORM_SRC_DIR) $(RTL_FLAGS)
CXXFLAGS += -I$(GLITZ_SRC_DIR) -I$(GLITZ_PLATFORM_SRC_DIR) $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
ifdef MOZ_X11
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
EXTRA_DSO_LDOPTS += opengl32.lib glu32.lib
endif
ifneq (,$(filter $(MOZ_GFX_TOOLKIT),mac cocoa))
endif
EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

Просмотреть файл

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,89 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
// vim:expandtab:ts=4 sw=4:
/* ***** 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 Mozilla.
*
* 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> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 "nsServiceManagerUtils.h"
#include "nsIComponentManager.h"
#include "nsIGenericFactory.h"
#ifndef MOZILLA_1_8_BRANCH
#include "nsIClassInfoImpl.h"
#endif
#include "nsICanvasRenderingContextGLES11.h"
// {21788585-e91c-448c-8bb9-6c51aba9735f}
#define NS_CANVASRENDERINGCONTEXTGLES11_CID \
{ 0x21788585, 0xe91c, 0x448c, { 0x8b, 0xb9, 0x6c, 0x51, 0xab, 0xa9, 0x73, 0x5f } }
nsresult NS_NewCanvasRenderingContextGLES11(nsICanvasRenderingContextGLES11** aResult);
#define MAKE_CTOR(ctor_, iface_, func_) \
static NS_IMETHODIMP \
ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \
{ \
*aResult = nsnull; \
if (aOuter) \
return NS_ERROR_NO_AGGREGATION; \
iface_* inst; \
nsresult rv = func_(&inst); \
if (NS_SUCCEEDED(rv)) { \
rv = inst->QueryInterface(aIID, aResult); \
NS_RELEASE(inst); \
} \
return rv; \
}
NS_DECL_CLASSINFO(nsCanvasRenderingContextGLES11)
MAKE_CTOR(CreateCanvasRenderingContextGLES11, nsICanvasRenderingContextGLES11, NS_NewCanvasRenderingContextGLES11)
static const nsModuleComponentInfo components[] = {
{ "GLES 1.1 Canvas Context",
NS_CANVASRENDERINGCONTEXTGLES11_CID,
"@mozilla.org/content/canvas-rendering-context;1?id=gles11",
CreateCanvasRenderingContextGLES11,
nsnull, nsnull, nsnull,
NS_CI_INTERFACE_GETTER_NAME(nsCanvasRenderingContextGLES11),
nsnull, &NS_CLASSINFO_NAME(nsCanvasRenderingContextGLES11),
nsIClassInfo::DOM_OBJECT
},
};
NS_IMPL_NSGETMODULE(nsCanvas3DModule, components)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,20 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="application/x-javascript">
function doload() {
var cvs = document.getElementById('canvas');
var ctx = cvs.getContext('gles11');
ctx.clearColor(.2,.2,.2,1);
ctx.clear(ctx.COLOR_BUFFER_BIT);
ctx.swapBuffers();
}
</script>
</head>
<body onload="doload()">
<canvas id="canvas" width="400" height="400" style="border: 2px solid black;"></canvas>
</body>
</html>

Просмотреть файл

@ -0,0 +1,99 @@
<html>
<head>
<script type="application/x-javascript">
function makeImageCanvas() {
var cvs = document.createElement('canvas');
cvs.width = 128;
cvs.height = 128;
var ctx = cvs.getContext('2d');
var grad = ctx.createLinearGradient(0, 0, 128, 128);
grad.addColorStop(0.0, "rgba(200,0,0,1.0)");
grad.addColorStop(0.5, "rgba(0,200,0,1.0)");
grad.addColorStop(1.0, "rgba(0,0,200,1.0)");
ctx.fillStyle = grad;
ctx.fillRect(0, 0, 128, 128);
return cvs;
}
function doload() {
var cvs = document.getElementById('canvas');
var gl = cvs.getContext('gles11');
gl.clearColor(.2,.2,.4,1);
gl.clear(gl.COLOR_BUFFER_BIT);
// (optinally) set up lighting
if (0) {
gl.enable(gl.LIGHTING);
gl.light(gl.LIGHT0, gl.AMBIENT, [1.0, 1.0, 1.0, 1]);
gl.light(gl.LIGHT0, gl.DIFFUSE, [1.0, 1.0, 1.0, 1]);
gl.light(gl.LIGHT0, gl.POSITION, [3, 3, -5, 0]);
gl.light(gl.LIGHT0, gl.SPECULAR, [1, 1, 1, 1]);
gl.enable(gl.LIGHT0);
}
// set up our viewing parameters
gl.matrixMode(gl.PROJECTION);
gl.loadIdentity();
gl.gluPerspective(45, 1, 0.1, 20);
gl.matrixMode(gl.MODELVIEW);
gl.loadIdentity();
gl.gluLookAt(0, 0, 4,
0, 0, 0,
0, 1, 0);
// set up texture
var texId = (gl.genTextures(1))[0];
gl.bindTexture(gl.TEXTURE_2D, texId);
var img = makeImageCanvas();
gl.texParameter(gl.TEXTURE_2D, gl.GENERATE_MIPMAP, true);
gl.texImage2DHTML(img);
gl.enable(gl.TEXTURE_2D);
// set up and draw geometry
var vertArray = [ -1, 1, 0,
-1, -1, 0,
1, 1, 0,
1, -1, 0 ];
var normArray = [ 0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1 ];
var texCoordArray = [ 0, 1,
0, 0,
1, 1,
1, 0 ];
var colorArray = [ 1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1 ];
gl.vertexPointer(3, gl.FLOAT, vertArray);
gl.normalPointer(gl.FLOAT, normArray);
gl.texCoordPointer(2, gl.FLOAT, texCoordArray);
gl.colorPointer(4, gl.FLOAT, colorArray);
gl.enableClientState(gl.VERTEX_ARRAY);
gl.enableClientState(gl.NORMAL_ARRAY);
gl.enableClientState(gl.TEXTURE_COORD_ARRAY);
gl.enableClientState(gl.COLOR_ARRAY);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertArray.length / 3);
gl.disableClientState(gl.VERTEX_ARRAY);
gl.disableClientState(gl.NORMAL_ARRAY);
gl.disableClientState(gl.TEXTURE_COORD_ARRAY);
gl.disableClientState(gl.COLOR_ARRAY);
gl.swapBuffers();
}
</script>
</head>
<body onload="doload()">
<canvas id="canvas" width="400" height="400" style="border: 2px solid black;"></canvas>
</body>
</html>

Просмотреть файл

@ -0,0 +1,100 @@
<html>
<head>
<script type="application/x-javascript">
var gl = null;
function draw() {
// set up and draw geometry
var vertArray = [ -1, 1, 0,
-1, -1, 0,
1, 1, 0,
1, -1, 0 ];
var normArray = [ 0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1 ];
var texCoordArray = [ 0, 1,
0, 0,
1, 1,
1, 0 ];
var colorArray = [ 1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1 ];
gl.vertexPointer(3, gl.FLOAT, vertArray);
gl.normalPointer(gl.FLOAT, normArray);
gl.texCoordPointer(2, gl.FLOAT, texCoordArray);
gl.colorPointer(4, gl.FLOAT, colorArray);
gl.enableClientState(gl.VERTEX_ARRAY);
gl.enableClientState(gl.NORMAL_ARRAY);
gl.enableClientState(gl.TEXTURE_COORD_ARRAY);
gl.enableClientState(gl.COLOR_ARRAY);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertArray.length / 3);
gl.disableClientState(gl.VERTEX_ARRAY);
gl.disableClientState(gl.NORMAL_ARRAY);
gl.disableClientState(gl.TEXTURE_COORD_ARRAY);
gl.disableClientState(gl.COLOR_ARRAY);
}
function startTextureLoad() {
var img = document.createElement("img");
img.onload = function () {
// set up texture
var texId = (gl.genTextures(1))[0];
gl.bindTexture(gl.TEXTURE_2D, texId);
gl.texParameter(gl.TEXTURE_2D, gl.GENERATE_MIPMAP, true);
gl.texImage2DHTML(img);
gl.enable(gl.TEXTURE_2D);
draw();
gl.swapBuffers();
};
img.src = "tex.png";
}
function doload() {
var cvs = document.getElementById('canvas');
gl = cvs.getContext('gles11');
gl.clearColor(.2,.2,.4,1);
gl.clear(gl.COLOR_BUFFER_BIT);
// (optionally) set up lighting
if (0) {
gl.enable(gl.LIGHTING);
gl.light(gl.LIGHT0, gl.AMBIENT, [1.0, 1.0, 1.0, 1]);
gl.light(gl.LIGHT0, gl.DIFFUSE, [1.0, 1.0, 1.0, 1]);
gl.light(gl.LIGHT0, gl.POSITION, [3, 3, -5, 0]);
gl.light(gl.LIGHT0, gl.SPECULAR, [1, 1, 1, 1]);
gl.enable(gl.LIGHT0);
}
// set up our viewing parameters
gl.matrixMode(gl.PROJECTION);
gl.loadIdentity();
gl.gluPerspective(45, 1, 0.1, 20);
gl.matrixMode(gl.MODELVIEW);
gl.loadIdentity();
gl.gluLookAt(0, 0, 4,
0, 0, 0,
0, 1, 0);
startTextureLoad();
draw ();
gl.swapBuffers();
}
</script>
</head>
<body onload="doload()">
<canvas id="canvas" width="400" height="400" style="border: 2px solid black;"></canvas>
</body>
</html>

Просмотреть файл

@ -0,0 +1,122 @@
<html>
<head>
<script type="application/x-javascript">
var gl = null;
var buffers = { };
function bufferSetup() {
var vertArray = [ -1, 1, 0,
-1, -1, 0,
1, 1, 0,
1, -1, 0 ];
var normArray = [ 0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1 ];
var texCoordArray = [ 0, 1,
0, 0,
1, 1,
1, 0 ];
var colorArray = [ 1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1 ];
buffers.vertex = gl.createBuffer(gl.STATIC_DRAW,
3, gl.FLOAT,
vertArray);
buffers.normal = gl.createBuffer(gl.STATIC_DRAW,
3, gl.FLOAT,
normArray);
buffers.texCoord = gl.createBuffer(gl.STATIC_DRAW,
2, gl.FLOAT,
texCoordArray);
buffers.color = gl.createBuffer(gl.STATIC_DRAW,
4, gl.FLOAT,
colorArray);
}
function draw() {
// set up and draw geometry
gl.vertexPointer(buffers.vertex);
gl.normalPointer(buffers.normal);
gl.texCoordPointer(buffers.texCoord);
gl.colorPointer(buffers.color);
gl.enableClientState(gl.VERTEX_ARRAY);
gl.enableClientState(gl.NORMAL_ARRAY);
gl.enableClientState(gl.TEXTURE_COORD_ARRAY);
gl.enableClientState(gl.COLOR_ARRAY);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
gl.disableClientState(gl.VERTEX_ARRAY);
gl.disableClientState(gl.NORMAL_ARRAY);
gl.disableClientState(gl.TEXTURE_COORD_ARRAY);
gl.disableClientState(gl.COLOR_ARRAY);
}
function startTextureLoad() {
var img = document.createElement("img");
img.onload = function () {
// set up texture
var texId = (gl.genTextures(1))[0];
gl.bindTexture(gl.TEXTURE_2D, texId);
gl.texParameter(gl.TEXTURE_2D, gl.GENERATE_MIPMAP, true);
gl.texImage2DHTML(img);
gl.enable(gl.TEXTURE_2D);
draw();
gl.swapBuffers();
};
img.src = "tex.png";
}
function doload() {
var cvs = document.getElementById('canvas');
gl = cvs.getContext('gles11');
gl.clearColor(.2,.2,.4,1);
gl.clear(gl.COLOR_BUFFER_BIT);
// (optionally) set up lighting
if (0) {
gl.enable(gl.LIGHTING);
gl.light(gl.LIGHT0, gl.AMBIENT, [1.0, 1.0, 1.0, 1]);
gl.light(gl.LIGHT0, gl.DIFFUSE, [1.0, 1.0, 1.0, 1]);
gl.light(gl.LIGHT0, gl.POSITION, [3, 3, -5, 0]);
gl.light(gl.LIGHT0, gl.SPECULAR, [1, 1, 1, 1]);
gl.enable(gl.LIGHT0);
}
// set up our viewing parameters
gl.matrixMode(gl.PROJECTION);
gl.loadIdentity();
gl.gluPerspective(45, 1, 0.1, 20);
gl.matrixMode(gl.MODELVIEW);
gl.loadIdentity();
gl.gluLookAt(0, 0, 4,
0, 0, 0,
0, 1, 0);
startTextureLoad();
bufferSetup();
draw ();
gl.swapBuffers();
}
</script>
</head>
<body onload="doload()">
<canvas id="canvas" width="400" height="400" style="border: 2px solid black;"></canvas>
</body>
</html>

Просмотреть файл

@ -0,0 +1,137 @@
<html>
<head>
<script type="application/x-javascript">
var gl = null;
var buffers = { };
function bufferSetup() {
var vertArray = [ -1, 1, 0,
-1, -1, 0,
1, 1, 0,
1, -1, 0 ];
var normArray = [ 0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1 ];
var texCoordArray = [ 0, 1,
0, 0,
1, 1,
1, 0 ];
var colorArray = [ 1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1 ];
buffers.vertex = gl.createBuffer(gl.STATIC_DRAW,
3, gl.FLOAT,
vertArray);
buffers.normal = gl.createBuffer(gl.STATIC_DRAW,
3, gl.FLOAT,
normArray);
buffers.texCoord = gl.createBuffer(gl.STATIC_DRAW,
2, gl.FLOAT,
texCoordArray);
buffers.color = gl.createBuffer(gl.STATIC_DRAW,
4, gl.FLOAT,
colorArray);
}
function draw() {
// set up and draw geometry
gl.vertexPointer(buffers.vertex);
gl.normalPointer(buffers.normal);
gl.texCoordPointer(buffers.texCoord);
gl.colorPointer(buffers.color);
gl.enableClientState(gl.VERTEX_ARRAY);
gl.enableClientState(gl.NORMAL_ARRAY);
gl.enableClientState(gl.TEXTURE_COORD_ARRAY);
gl.enableClientState(gl.COLOR_ARRAY);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
gl.disableClientState(gl.VERTEX_ARRAY);
gl.disableClientState(gl.NORMAL_ARRAY);
gl.disableClientState(gl.TEXTURE_COORD_ARRAY);
gl.disableClientState(gl.COLOR_ARRAY);
}
function startTextureLoad() {
var img = document.createElement("img");
img.onload = function () {
// set up texture
var texId = (gl.genTextures(1))[0];
gl.bindTexture(gl.TEXTURE_2D, texId);
gl.texParameter(gl.TEXTURE_2D, gl.GENERATE_MIPMAP, true);
gl.texImage2DHTML(img);
gl.enable(gl.TEXTURE_2D);
};
img.src = "tex.png";
}
var tlast = 0;
var alast = 0;
function animStep() {
gl.clearColor(.2,.2,.4,1);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.loadIdentity();
gl.gluLookAt(0, 0, 4,
0, 0, 0,
0, 1, 0);
// rotate at 'speed' degrees per second
const speed = 40;
if (tlast != 0) {
var tdelta = Date.now() - tlast;
var ang = (alast + ((tdelta / 1000) * speed)) % 360.0;
gl.rotate(ang, 0, 1, 0);
alast = ang;
}
tlast = Date.now();
draw ();
gl.swapBuffers();
}
function doload() {
var cvs = document.getElementById('canvas');
gl = cvs.getContext('gles11');
// (optionally) set up lighting
if (0) {
gl.enable(gl.LIGHTING);
gl.light(gl.LIGHT0, gl.AMBIENT, [1.0, 1.0, 1.0, 1]);
gl.light(gl.LIGHT0, gl.DIFFUSE, [1.0, 1.0, 1.0, 1]);
gl.light(gl.LIGHT0, gl.POSITION, [3, 3, -5, 0]);
gl.light(gl.LIGHT0, gl.SPECULAR, [1, 1, 1, 1]);
gl.enable(gl.LIGHT0);
}
gl.matrixMode(gl.PROJECTION);
gl.loadIdentity();
gl.gluPerspective(45, 1, 0.1, 20);
gl.matrixMode(gl.MODELVIEW);
startTextureLoad();
bufferSetup();
setInterval (animStep, 100);
animStep();
}
</script>
</head>
<body onload="doload()">
<canvas id="canvas" width="400" height="400" style="border: 2px solid black;"></canvas>
</body>
</html>

Просмотреть файл