sl@0: /* sl@0: * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: Background implementation sl@0: * sl@0: */ sl@0: sl@0: sl@0: /*! sl@0: * \internal sl@0: * \file sl@0: * \brief Background implementation sl@0: */ sl@0: sl@0: #ifndef M3G_CORE_INCLUDE sl@0: # error included by m3g_core.c; do not compile separately. sl@0: #endif sl@0: sl@0: #include "m3g_background.h" sl@0: #include "m3g_image.h" sl@0: #include "m3g_memory.h" sl@0: #include "m3g_animationtrack.h" sl@0: #include "m3g_rendercontext.h" sl@0: sl@0: /*---------------------------------------------------------------------- sl@0: * Internal functions sl@0: *--------------------------------------------------------------------*/ sl@0: sl@0: /*! sl@0: * \internal sl@0: * \brief Destroys this Background object. sl@0: * sl@0: * \param obj Background object sl@0: */ sl@0: static void m3gDestroyBackground(Object *obj) sl@0: { sl@0: Background *background = (Background *) obj; sl@0: M3G_VALIDATE_OBJECT(background); sl@0: sl@0: M3G_ASSIGN_REF(background->image, NULL); sl@0: m3gDestroyObject(obj); sl@0: } sl@0: sl@0: /*! sl@0: * \internal sl@0: * \brief Applies background color and image sl@0: * using a textured quad. sl@0: * sl@0: * \param ctx render context sl@0: * \param background Background object sl@0: */ sl@0: static void m3gApplyBackground(RenderContext *ctx, Background *background) sl@0: { sl@0: GLbitfield glBits = 0; sl@0: GLfixed temp[4]; sl@0: sl@0: if (background->depthClearEnable) { sl@0: glBits |= GL_DEPTH_BUFFER_BIT; sl@0: } sl@0: sl@0: /* Skip color buffer clearing if the background image sl@0: * fills the whole viewport. This is guaranteed to happen sl@0: * if the crop rectangle is non-zero and both X and Y sl@0: * wrapping modes are REPEAT. */ sl@0: sl@0: if (background->colorClearEnable) { sl@0: if (background->image == NULL || sl@0: background->crop.width == 0 || sl@0: background->crop.height == 0 || sl@0: background->modeX == M3G_BORDER || sl@0: background->modeY == M3G_BORDER) sl@0: { sl@0: glBits |= GL_COLOR_BUFFER_BIT; sl@0: m3gGLColor(background->color, temp); sl@0: glClearColorx(temp[0], temp[1], temp[2], temp[3]); sl@0: } sl@0: } sl@0: sl@0: /* Clear color and/or depth buffer (or neither) */ sl@0: glClear(glBits); sl@0: sl@0: /* Apply background image using a quad that sl@0: fills the viewport */ sl@0: sl@0: if (background->colorClearEnable && sl@0: background->image != NULL && sl@0: background->crop.width != 0 && sl@0: background->crop.height != 0) sl@0: { sl@0: { sl@0: /* Texture coordinates */ sl@0: M3Gshort texvert[4 * 2]; sl@0: /* Quad that fills the viewport */ sl@0: M3Gint vert[4 * 3] = { -65536, 65536, 0, sl@0: -65536, -65536, 0, sl@0: 65536, 65536, 0, sl@0: 65536, -65536, 0 }; sl@0: Rect rImage, rIntersection; sl@0: M3Gbool intersects; sl@0: Image *imagePow2; sl@0: sl@0: /* Get power of two image */ sl@0: imagePow2 = m3gGetPowerOfTwoImage(background->image); sl@0: /* If NULL -> out of memory */ sl@0: if (!imagePow2) { sl@0: return; sl@0: } sl@0: sl@0: rImage.x = 0; sl@0: rImage.y = 0; sl@0: rImage.width = m3gGetWidth(background->image); sl@0: rImage.height = m3gGetHeight(background->image); sl@0: sl@0: /* Intersection of source image and crop rectangle */ sl@0: intersects = m3gIntersectRectangle(&rIntersection, &rImage, &background->crop); sl@0: sl@0: /* Setup X vertices and texture S coordinates */ sl@0: if (background->modeX == M3G_BORDER) { sl@0: /* If both modes are border and no intersection -> sl@0: nothing to draw */ sl@0: if (background->modeY == M3G_BORDER && !intersects) { sl@0: return; sl@0: } sl@0: sl@0: texvert[0 * 2 + 0] = (M3Gshort) rIntersection.x; sl@0: texvert[1 * 2 + 0] = (M3Gshort) rIntersection.x; sl@0: texvert[2 * 2 + 0] = (M3Gshort) (rIntersection.x + rIntersection.width); sl@0: texvert[3 * 2 + 0] = (M3Gshort) (rIntersection.x + rIntersection.width); sl@0: sl@0: vert[0 * 3 + 0] = -65536 + 2 * 65536 * (rIntersection.x - background->crop.x) / background->crop.width; sl@0: vert[1 * 3 + 0] = vert[0 * 3 + 0]; sl@0: vert[2 * 3 + 0] = vert[0 * 3 + 0] + 2 * 65536 * rIntersection.width / background->crop.width; sl@0: vert[3 * 3 + 0] = vert[2 * 3 + 0]; sl@0: } sl@0: else { sl@0: /* In repeat mode texture coordinates are directly crop rectangle coordinates */ sl@0: texvert[0 * 2 + 0] = (M3Gshort) background->crop.x; sl@0: texvert[1 * 2 + 0] = (M3Gshort) background->crop.x; sl@0: texvert[2 * 2 + 0] = (M3Gshort) (background->crop.x + background->crop.width); sl@0: texvert[3 * 2 + 0] = (M3Gshort) (background->crop.x + background->crop.width); sl@0: } sl@0: sl@0: /* Setup Y vertices and texture T coordinates */ sl@0: if (background->modeY == M3G_BORDER) { sl@0: texvert[0 * 2 + 1] = (M3Gshort) rIntersection.y; sl@0: texvert[1 * 2 + 1] = (M3Gshort) (rIntersection.y + rIntersection.height); sl@0: texvert[2 * 2 + 1] = (M3Gshort) rIntersection.y; sl@0: texvert[3 * 2 + 1] = (M3Gshort) (rIntersection.y + rIntersection.height); sl@0: sl@0: sl@0: vert[0 * 3 + 1] = 65536 - 2 * 65536 * (rIntersection.y - background->crop.y) / background->crop.height; sl@0: vert[1 * 3 + 1] = vert[0 * 3 + 1] - 2 * 65536 * rIntersection.height / background->crop.height; sl@0: vert[2 * 3 + 1] = vert[0 * 3 + 1]; sl@0: vert[3 * 3 + 1] = vert[1 * 3 + 1]; sl@0: } sl@0: else { sl@0: /* In repeat mode texture coordinates are directly crop rectangle coordinates */ sl@0: texvert[0 * 2 + 1] = (M3Gshort) background->crop.y; sl@0: texvert[1 * 2 + 1] = (M3Gshort) (background->crop.y + background->crop.height); sl@0: texvert[2 * 2 + 1] = (M3Gshort) background->crop.y; sl@0: texvert[3 * 2 + 1] = (M3Gshort) (background->crop.y + background->crop.height); sl@0: } sl@0: sl@0: /* Disable unwanted state and depth writes */ sl@0: m3gApplyAppearance(NULL, ctx, 0); sl@0: glDepthMask(GL_FALSE); sl@0: sl@0: /* Disable color array, normals and textures*/ sl@0: glDisableClientState(GL_COLOR_ARRAY); sl@0: glDisableClientState(GL_NORMAL_ARRAY); sl@0: sl@0: /* Background image to texture unit 0 */ sl@0: glClientActiveTexture(GL_TEXTURE0); sl@0: glActiveTexture(GL_TEXTURE0); sl@0: glEnableClientState(GL_TEXTURE_COORD_ARRAY); sl@0: glTexCoordPointer(2, GL_SHORT, 0, texvert); sl@0: glEnable(GL_TEXTURE_2D); sl@0: glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, (GLfixed) GL_REPLACE); sl@0: m3gBindTextureImage(imagePow2, sl@0: M3G_FILTER_BASE_LEVEL, sl@0: m3gIsAccelerated(ctx) ? M3G_FILTER_LINEAR : M3G_FILTER_NEAREST); sl@0: sl@0: /* Set wrapping */ sl@0: if (background->modeX == M3G_REPEAT) { sl@0: glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); sl@0: } sl@0: else { sl@0: glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); sl@0: } sl@0: sl@0: if (background->modeY == M3G_REPEAT) { sl@0: glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); sl@0: } sl@0: else { sl@0: glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); sl@0: } sl@0: sl@0: /* Texture matrix scale */ sl@0: glMatrixMode(GL_TEXTURE); sl@0: glLoadIdentity(); sl@0: glScalef( m3gRcp((M3Gfloat)m3gGetWidth(background->image)), sl@0: m3gRcp((M3Gfloat)m3gGetHeight(background->image)), sl@0: 1.f); sl@0: glMatrixMode(GL_MODELVIEW); sl@0: sl@0: /* Load vertices */ sl@0: glEnableClientState(GL_VERTEX_ARRAY); sl@0: glVertexPointer(3, GL_FIXED, 0, vert); sl@0: sl@0: /* Set up an identity modelview and projection */ sl@0: m3gPushScreenSpace(ctx, M3G_FALSE); sl@0: sl@0: /* Load indices -> draws the background */ sl@0: M3G_BEGIN_PROFILE(M3G_INTERFACE(ctx), M3G_PROFILE_NGL_DRAW); sl@0: glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); sl@0: M3G_END_PROFILE(M3G_INTERFACE(ctx), M3G_PROFILE_NGL_DRAW); sl@0: sl@0: m3gPopSpace(ctx); sl@0: m3gReleaseTextureImage(imagePow2); sl@0: } sl@0: } sl@0: } sl@0: sl@0: /*! sl@0: * \internal sl@0: * \brief Overloaded Object3D method. sl@0: * sl@0: * \param property animation property sl@0: * \retval M3G_TRUE property supported sl@0: * \retval M3G_FALSE property not supported sl@0: */ sl@0: static M3Gbool m3gBackgroundIsCompatible(M3Gint property) sl@0: { sl@0: switch (property) { sl@0: case M3G_ANIM_ALPHA: sl@0: case M3G_ANIM_COLOR: sl@0: case M3G_ANIM_CROP: sl@0: return M3G_TRUE; sl@0: default: sl@0: return m3gObjectIsCompatible(property); sl@0: } sl@0: } sl@0: sl@0: /*! sl@0: * \internal sl@0: * \brief Overloaded Object3D method. sl@0: * sl@0: * \param self Background object sl@0: * \param property animation property sl@0: * \param valueSize size of value array sl@0: * \param value value array sl@0: */ sl@0: static void m3gBackgroundUpdateProperty(Object *self, sl@0: M3Gint property, sl@0: M3Gint valueSize, sl@0: const M3Gfloat *value) sl@0: { sl@0: Background *background = (Background *)self; sl@0: M3G_VALIDATE_OBJECT(background); sl@0: M3G_ASSERT_PTR(value); sl@0: sl@0: switch (property) { sl@0: case M3G_ANIM_ALPHA: sl@0: M3G_ASSERT(valueSize >= 1); sl@0: background->color = m3gAlpha1f(value[0]) sl@0: & (background->color | M3G_ALPHA_MASK); sl@0: break; sl@0: case M3G_ANIM_COLOR: sl@0: M3G_ASSERT(valueSize >= 3); sl@0: background->color = m3gColor3f(value[0], value[1], value[2]) sl@0: & (background->color | M3G_RGB_MASK); sl@0: break; sl@0: case M3G_ANIM_CROP: sl@0: M3G_ASSERT(valueSize >= 2); sl@0: background->crop.x = m3gRoundToInt(value[0]); sl@0: background->crop.y = m3gRoundToInt(value[1]); sl@0: if (valueSize > 2) { sl@0: M3G_ASSERT(valueSize >= 4); sl@0: background->crop.width = sl@0: (value[2] < 0) ? 0 : m3gRoundToInt(value[2]); sl@0: background->crop.height = sl@0: (value[3] < 0) ? 0 : m3gRoundToInt(value[3]); sl@0: } sl@0: break; sl@0: default: sl@0: m3gObjectUpdateProperty(self, property, valueSize, value); sl@0: } sl@0: } sl@0: sl@0: /*! sl@0: * \internal sl@0: * \brief Overloaded Object3D method. sl@0: * sl@0: * \param self Background object sl@0: * \param references array of reference objects sl@0: * \return number of references sl@0: */ sl@0: static M3Gint m3gBackgroundDoGetReferences(Object *self, Object **references) sl@0: { sl@0: Background *bg = (Background *)self; sl@0: M3Gint num = m3gObjectDoGetReferences(self, references); sl@0: if (bg->image != NULL) { sl@0: if (references != NULL) sl@0: references[num] = (Object *)bg->image; sl@0: num++; sl@0: } sl@0: return num; sl@0: } sl@0: sl@0: /*! sl@0: * \internal sl@0: * \brief Overloaded Object3D method. sl@0: */ sl@0: static Object *m3gBackgroundFindID(Object *self, M3Gint userID) sl@0: { sl@0: Background *bg = (Background *)self; sl@0: Object *found = m3gObjectFindID(self, userID); sl@0: sl@0: if (!found && bg->image) { sl@0: found = m3gFindID((Object*) bg->image, userID); sl@0: } sl@0: return found; sl@0: } sl@0: sl@0: /*! sl@0: * \internal sl@0: * \brief Overloaded Object3D method. sl@0: * sl@0: * \param originalObj original Background object sl@0: * \param cloneObj pointer to cloned Background object sl@0: * \param pairs array for all object-duplicate pairs sl@0: * \param numPairs number of pairs sl@0: */ sl@0: static M3Gbool m3gBackgroundDuplicate(const Object *originalObj, sl@0: Object **cloneObj, sl@0: Object **pairs, sl@0: M3Gint *numPairs) sl@0: { sl@0: Background *original = (Background *)originalObj; sl@0: Background *clone = (Background *)m3gCreateBackground(originalObj->interface); sl@0: *cloneObj = (Object *)clone; sl@0: if (*cloneObj == NULL) { sl@0: return M3G_FALSE; sl@0: } sl@0: sl@0: if (m3gObjectDuplicate(originalObj, cloneObj, pairs, numPairs)) { sl@0: clone->color = original->color; sl@0: clone->modeX = original->modeX; sl@0: clone->modeY = original->modeY; sl@0: clone->crop = original->crop; sl@0: clone->colorClearEnable = original->colorClearEnable; sl@0: clone->depthClearEnable = original->depthClearEnable; sl@0: M3G_ASSIGN_REF(clone->image, original->image); sl@0: return M3G_TRUE; sl@0: } sl@0: else { sl@0: return M3G_FALSE; sl@0: } sl@0: } sl@0: sl@0: /*! sl@0: * \internal sl@0: * \brief Initializes a Background object. See specification sl@0: * for default values. sl@0: * sl@0: * \param m3g M3G interface sl@0: * \param background Background object sl@0: */ sl@0: static void m3gInitBackground(Interface *m3g, Background *background) sl@0: { sl@0: /* Background is derived from Object */ sl@0: m3gInitObject(&background->object, m3g, M3G_CLASS_BACKGROUND); sl@0: sl@0: background->modeX = M3G_BORDER; sl@0: background->modeY = M3G_BORDER; sl@0: background->colorClearEnable = M3G_TRUE; sl@0: background->depthClearEnable = M3G_TRUE; sl@0: } sl@0: sl@0: /*---------------------------------------------------------------------- sl@0: * Virtual function table sl@0: *--------------------------------------------------------------------*/ sl@0: sl@0: static const ObjectVFTable m3gvf_Background = { sl@0: m3gObjectApplyAnimation, sl@0: m3gBackgroundIsCompatible, sl@0: m3gBackgroundUpdateProperty, sl@0: m3gBackgroundDoGetReferences, sl@0: m3gBackgroundFindID, sl@0: m3gBackgroundDuplicate, sl@0: m3gDestroyBackground sl@0: }; sl@0: sl@0: sl@0: /*---------------------------------------------------------------------- sl@0: * Public API functions sl@0: *--------------------------------------------------------------------*/ sl@0: sl@0: /*! sl@0: * \brief Creates a Background object. sl@0: * sl@0: * \param interface M3G interface sl@0: * \retval Background new Background object sl@0: * \retval NULL Background creating failed sl@0: */ sl@0: sl@0: /*@access M3GInterface@*/ sl@0: /*@access M3Gobject@*/ sl@0: M3G_API M3GBackground m3gCreateBackground(M3GInterface interface) sl@0: { sl@0: Interface *m3g = (Interface *) interface; sl@0: M3G_VALIDATE_INTERFACE(m3g); sl@0: sl@0: { sl@0: Background *background = m3gAllocZ(m3g, sizeof(Background)); sl@0: sl@0: if (background != NULL) { sl@0: m3gInitBackground(m3g, background); sl@0: } sl@0: sl@0: return (M3GBackground) background; sl@0: } sl@0: } sl@0: sl@0: /*! sl@0: * \brief Sets background color. sl@0: * sl@0: * \param handle Background object sl@0: * \param ARGB background color as ARGB sl@0: */ sl@0: sl@0: /*@access M3Gobject@*/ sl@0: M3G_API void m3gSetBgColor(M3GBackground handle, M3Guint ARGB) sl@0: { sl@0: Background *background = (Background *) handle; sl@0: M3G_VALIDATE_OBJECT(background); sl@0: sl@0: background->color = ARGB; sl@0: } sl@0: sl@0: /*! sl@0: * \brief Sets background image x and y mode. sl@0: * sl@0: * \param handle Background object sl@0: * \param modeX Image X mode sl@0: * \param modeY Image Y mode sl@0: */ sl@0: sl@0: /*@access M3Gobject@*/ sl@0: M3G_API void m3gSetBgMode(M3GBackground handle, M3Gint modeX, M3Gint modeY) sl@0: { sl@0: Background *background = (Background *) handle; sl@0: M3G_VALIDATE_OBJECT(background); sl@0: sl@0: /* Check for errors */ sl@0: if (modeX < M3G_BORDER || modeX > M3G_REPEAT || sl@0: modeY < M3G_BORDER || modeY > M3G_REPEAT) { sl@0: m3gRaiseError(M3G_INTERFACE(background), M3G_INVALID_VALUE); sl@0: return; sl@0: } sl@0: sl@0: background->modeX = modeX; sl@0: background->modeY = modeY; sl@0: } sl@0: sl@0: /*! sl@0: * \brief Sets background image crop rectangle. sl@0: * sl@0: * \param handle Background object sl@0: * \param cropX crop upper left x sl@0: * \param cropY crop upper left y sl@0: * \param width crop width sl@0: * \param height crop height sl@0: */ sl@0: sl@0: /*@access M3Gobject@*/ sl@0: M3G_API void m3gSetBgCrop(M3GBackground handle, sl@0: M3Gint cropX, M3Gint cropY, sl@0: M3Gint width, M3Gint height) sl@0: { sl@0: Background *background = (Background *) handle; sl@0: M3G_VALIDATE_OBJECT(background); sl@0: sl@0: /* Check for errors */ sl@0: if (width < 0 || height < 0) { sl@0: m3gRaiseError(M3G_INTERFACE(background), M3G_INVALID_VALUE); sl@0: return; sl@0: } sl@0: sl@0: background->crop.x = cropX; sl@0: background->crop.y = cropY; sl@0: background->crop.width = width; sl@0: background->crop.height = height; sl@0: } sl@0: sl@0: /*! sl@0: * \brief Sets background image. sl@0: * sl@0: * \param handle Background object sl@0: * \param hImage Image2D object or NULL sl@0: */ sl@0: sl@0: /*@access M3Gobject@*/ sl@0: M3G_API void m3gSetBgImage(M3GBackground handle, M3GImage hImage) sl@0: { sl@0: Background *background = (Background *) handle; sl@0: Image *image = (Image *)hImage; sl@0: M3G_VALIDATE_OBJECT(background); sl@0: sl@0: if (image != NULL) { sl@0: /* Check allowed formats */ sl@0: if (m3gGetFormat(image) != M3G_RGB && sl@0: m3gGetFormat(image) != M3G_RGBA) { sl@0: m3gRaiseError(M3G_INTERFACE(background), M3G_INVALID_VALUE); sl@0: return; sl@0: } sl@0: sl@0: background->crop.x = 0; sl@0: background->crop.y = 0; sl@0: background->crop.width = m3gGetWidth(image); sl@0: background->crop.height = m3gGetHeight(image); sl@0: } sl@0: sl@0: M3G_ASSIGN_REF(background->image, image); sl@0: } sl@0: sl@0: /*! sl@0: * \brief Gets background image. sl@0: * sl@0: * \param handle Background object sl@0: * \return Image2D object or NULL sl@0: */ sl@0: sl@0: /*@access M3GObject@*/ sl@0: M3G_API M3GImage m3gGetBgImage(M3GBackground handle) sl@0: { sl@0: Background *bg = (Background *) handle; sl@0: M3G_VALIDATE_OBJECT(bg); sl@0: sl@0: return (M3GImage) bg->image; sl@0: } sl@0: sl@0: /*! sl@0: * \brief Gets background color as ARGB. sl@0: * sl@0: * \param handle Background object sl@0: * \return ARGB color sl@0: */ sl@0: sl@0: /*@access M3Gobject@*/ sl@0: M3G_API M3Guint m3gGetBgColor(M3GBackground handle) sl@0: { sl@0: Background *background = (Background *) handle; sl@0: M3G_VALIDATE_OBJECT(background); sl@0: sl@0: return background->color; sl@0: } sl@0: sl@0: /*! sl@0: * \brief Gets background image x or y mode. sl@0: * sl@0: * \param handle Background object sl@0: * \param which which mode to return sl@0: * \arg M3G_GET_MODEX sl@0: * \arg M3G_GET_MODEY sl@0: * \return image x or y mode sl@0: */ sl@0: sl@0: /*@access M3Gobject@*/ sl@0: M3G_API M3Gint m3gGetBgMode(M3GBackground handle, M3Gint which) sl@0: { sl@0: Background *background = (Background *) handle; sl@0: M3G_VALIDATE_OBJECT(background); sl@0: sl@0: switch(which) { sl@0: case M3G_GET_MODEX: sl@0: return background->modeX; sl@0: case M3G_GET_MODEY: sl@0: default: sl@0: return background->modeY; sl@0: } sl@0: } sl@0: sl@0: /*! sl@0: * \brief Gets background image crop parameter. sl@0: * sl@0: * \param handle Background object sl@0: * \param which which crop parameter to return sl@0: * \arg M3G_GET_CROPX sl@0: * \arg M3G_GET_CROPY sl@0: * \arg M3G_GET_CROPWIDTH sl@0: * \arg M3G_GET_CROPHEIGHT sl@0: * \return image crop parameter sl@0: */ sl@0: sl@0: /*@access M3Gobject@*/ sl@0: M3G_API M3Gint m3gGetBgCrop(M3GBackground handle, M3Gint which) sl@0: { sl@0: Background *background = (Background *) handle; sl@0: M3G_VALIDATE_OBJECT(background); sl@0: sl@0: switch(which) { sl@0: case M3G_GET_CROPX: sl@0: return background->crop.x; sl@0: case M3G_GET_CROPY: sl@0: return background->crop.y; sl@0: case M3G_GET_CROPWIDTH: sl@0: return background->crop.width; sl@0: case M3G_GET_CROPHEIGHT: sl@0: default: sl@0: return background->crop.height; sl@0: } sl@0: } sl@0: sl@0: /*! sl@0: * \brief Sets background color or depth clear enable. sl@0: * sl@0: * \param handle Background object sl@0: * \param which which clear to enable sl@0: * \arg M3G_SETGET_COLORCLEAR sl@0: * \arg M3G_SETGET_DEPTHCLEAR sl@0: * \param enable clear enable/disable sl@0: */ sl@0: sl@0: /*@access M3Gobject@*/ sl@0: M3G_API void m3gSetBgEnable(M3GBackground handle, M3Gint which, M3Gbool enable) sl@0: { sl@0: Background *background = (Background *) handle; sl@0: M3G_VALIDATE_OBJECT(background); sl@0: sl@0: switch(which) { sl@0: case M3G_SETGET_COLORCLEAR: sl@0: background->colorClearEnable = enable; sl@0: break; sl@0: case M3G_SETGET_DEPTHCLEAR: sl@0: default: sl@0: background->depthClearEnable = enable; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: /*! sl@0: * \brief Gets background color or depth clear enable. sl@0: * sl@0: * \param handle Background object sl@0: * \param which which clear to return sl@0: * \arg M3G_SETGET_COLORCLEAR sl@0: * \arg M3G_SETGET_DEPTHCLEAR sl@0: * \return clear enabled sl@0: */ sl@0: sl@0: /*@access M3Gobject@*/ sl@0: M3G_API M3Gbool m3gIsBgEnabled(M3GBackground handle, M3Gint which) sl@0: { sl@0: Background *background = (Background *) handle; sl@0: M3G_VALIDATE_OBJECT(background); sl@0: sl@0: switch(which) { sl@0: case M3G_SETGET_COLORCLEAR: sl@0: return background->colorClearEnable; sl@0: case M3G_SETGET_DEPTHCLEAR: sl@0: default: sl@0: return background->depthClearEnable; sl@0: } sl@0: } sl@0: