Package com.ardor3d.renderer

Examples of com.ardor3d.renderer.RenderContext


        JoglRendererUtil.applyScissors(record);
    }

    public void setClipTestEnabled(final boolean enabled) {
        final RenderContext context = ContextManager.getCurrentContext();
        final RendererRecord record = context.getRendererRecord();

        JoglRendererUtil.setClippingEnabled(record, enabled);
    }
View Full Code Here


        if (texture == null) {
            return;
        }

        final GL gl = GLContext.getCurrentGL();
        final RenderContext context = ContextManager.getCurrentContext();
        if (context == null) {
            logger.warning("RenderContext is null for texture: " + texture);
            return;
        }

        final ContextCapabilities caps = context.getCapabilities();
        final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(StateType.Texture);

        // Check we are in the right unit
        if (record != null) {
            checkAndSetUnit(unit, record, caps);
        }

        // Create the texture...
        if (texture.getTextureKey() != null) {

            // Look for a texture in the cache just like ours
            final TextureKey texKey = texture.getTextureKey();
            final Texture cached = TextureManager.findCachedTexture(texKey);

            if (cached == null) {
                TextureManager.addToCache(texture);
            } else {
                final int textureId = cached.getTextureIdForContext(context.getGlContextRep());
                if (textureId != 0) {
                    doTextureBind(cached, unit, false);
                    return;
                }
            }
        }

        final IntBuffer id = BufferUtils.createIntBuffer(1);
        id.clear();
        gl.glGenTextures(id.limit(), id);
        final int textureId = id.get(0);

        // store the new id by our current gl context.
        texture.setTextureIdForContext(context.getGlContextRep(), textureId);

        update(texture, unit);
    }
View Full Code Here

    /**
     * bind texture and upload image data to card
     */
    public static void update(final Texture texture, final int unit) {
        final RenderContext context = ContextManager.getCurrentContext();
        final ContextCapabilities caps = context.getCapabilities();

        texture.getTextureKey().setClean(context.getGlContextRep());

        // our texture type:
        final Texture.Type type = texture.getType();

        final GL gl = GLContext.getCurrentGL();
View Full Code Here

    public static void compile(final Spatial scene, final Renderer renderer, final CompileOptions options) {
        // are we making a display list?
        if (options.isDisplayList()) {
            // grab our current context
            final RenderContext context = ContextManager.getCurrentContext();

            // handle camera...
            // save the current camera...
            final Camera originalCam = context.getCurrentCamera();
            // replace with a camera that will always pass frustum checks
            final Camera yesCam = new Camera(originalCam) {
                @Override
                public FrustumIntersect contains(final BoundingVolume bound) {
                    return FrustumIntersect.Inside;
                }
            };
            context.setCurrentCamera(yesCam);

            // setup for display list...
            // force all textures to load so their setup calls are not part of the displaylist
            scene.acceptVisitor(new TextureApplyVisitor(renderer), true);
            // invalidate any current opengl state information.
            context.invalidateStates();
            // generate a DL id by starting our list
            final int id = renderer.startDisplayList();
            // push our current buckets to back
            renderer.getQueue().pushBuckets();

            // render...
            // render our spatial
            scene.draw(renderer);
            // process buckets and then pop them
            renderer.renderBuckets();
            renderer.getQueue().popBuckets();

            // end list
            renderer.endDisplayList();

            // restore old camera
            context.setCurrentCamera(originalCam);

            // add a display list delegate to the given Spatial
            scene.setRenderDelegate(new DisplayListDelegate(id, context.getGlContextRep()), context.getGlContextRep());
        }
    }
View Full Code Here

        if (camera != Camera.getCurrentCamera()) {
            camera.update();
        }
        camera.apply(renderer);

        final RenderContext context = ContextManager.getCurrentContext();

        context.enforceStates(enforcedStates);

        if (spatial != null) {
            spatial.onDraw(renderer);
        } else {
            for (final Spatial spat : spatials) {
                spat.onDraw(renderer);
            }
        }

        renderer.renderBuckets();
        context.clearEnforcedStates();
    }
View Full Code Here

    /**
     * Check if we are keeping the size limits in terms of attribute locations on the card.
     */
    public void checkAttributeSizeLimits() {
        final RenderContext context = ContextManager.getCurrentContext();
        final ContextCapabilities caps = context.getCapabilities();
        if (_shaderAttributes.size() > caps.getMaxGLSLVertexAttributes()) {
            logger.severe("Too many shader attributes(standard+defined): " + _shaderAttributes.size() + " maximum: "
                    + caps.getMaxGLSLVertexAttributes());
        }
    }
View Full Code Here

    }

    @Override
    public void render(final Renderer renderer) {
        // Grab our render context - used to enforce renderstates
        final RenderContext context = ContextManager.getCurrentContext();

        // go through our bucket contents
        Spatial spatial;
        for (int i = 0; i < _currentListSize; i++) {
            spatial = _currentList[i];

            // make sure we have a real spatial
            if (spatial == null) {
                continue;
            }

            // we only care about altering the Mesh... perhaps could be altered later to some interface shared by Mesh
            // and other leaf nodes.
            if (spatial instanceof Mesh) {

                // get our transparency rendering type.
                final TransparencyType renderType = spatial.getSceneHints().getTransparencyType();

                // check for one of the two pass types...
                if (renderType != TransparencyType.OnePass) {

                    // get handle to Mesh
                    final Mesh mesh = (Mesh) spatial;

                    // check if we have a Cull state set or enforced. If one is explicitly set and is not Face.None,
                    // we'll not do two-pass transparency.
                    RenderState setState = context.hasEnforcedStates() ? context.getEnforcedState(StateType.Cull)
                            : null;
                    if (setState == null) {
                        setState = mesh.getWorldRenderState(RenderState.StateType.Cull);
                    }

                    // Do the described check.
                    if (setState == null || ((CullState) setState).getCullFace() == Face.None) {

                        // pull any currently enforced cull or zstate. We'll put them back afterwards
                        final RenderState oldCullState = context.getEnforcedState(StateType.Cull);
                        final RenderState oldZState = context.getEnforcedState(StateType.ZBuffer);

                        // enforce our cull and zstate. The zstate is setup to respect depth, but not write to it.
                        context.enforceState(_tranparentCull);
                        context.enforceState(_transparentZBuff);

                        // first render back-facing tris only
                        _tranparentCull.setCullFace(CullState.Face.Front);
                        mesh.draw(renderer);

                        // revert z state
                        context.clearEnforcedState(StateType.ZBuffer);
                        if (oldZState != null) {
                            context.enforceState(oldZState);
                        }

                        // render front-facing tris
                        _tranparentCull.setCullFace(CullState.Face.Back);
                        mesh.draw(renderer);

                        // revert cull state
                        if (oldCullState != null) {
                            context.enforceState(oldCullState);
                        } else {
                            context.clearEnforcedState(StateType.Cull);
                        }
                        continue;
                    }
                }
            }
View Full Code Here

     * @param renderer
     * @param shader
     * @return continue rendering or skip rendering all together
     */
    public boolean apply(final Mesh mesh, final Renderer renderer, final GLSLShaderObjectsState shader) {
        final RenderContext context = ContextManager.getCurrentContext();
        final ContextCapabilities caps = context.getCapabilities();

        if (!caps.isGeometryInstancingSupported()) {
            throw new Ardor3dException("Geometry instancing not supported for current graphics configuration");
        }

View Full Code Here

            glsl.setNeedsRefresh(true);
        }

        final InstancingManager instancing = glsl != null ? meshData.getInstancingManager() : null;

        final RenderContext context = ContextManager.getCurrentContext();
        final ContextCapabilities caps = context.getCapabilities();

        // Apply fixed function states before mesh transforms for proper function
        for (final StateType type : StateType.values) {
            if (type != StateType.GLSLShader && type != StateType.FragmentProgram && type != StateType.VertexProgram) {
                renderer.applyState(type, _states.get(type));
View Full Code Here

    public void draw(final Renderer r) {
        if (_children == null) {
            return;
        }

        final RenderContext context = ContextManager.getCurrentContext();
        r.getQueue().pushBuckets();
        for (final PassNodeState pass : _passNodeStates) {
            if (!pass.isEnabled()) {
                continue;
            }

            pass.applyPassNodeStates(context);

            Spatial child;
            for (int i = 0, cSize = _children.size(); i < cSize; i++) {
                child = _children.get(i);
                if (child != null) {
                    child.onDraw(r);
                }
            }
            r.renderBuckets();

            context.popEnforcedStates();
        }
        r.getQueue().popBuckets();
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.renderer.RenderContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.