Example #1
0
        public static FloatBuffer getDirectBuffer(float[] values, int Length)
        {
            directFloatBuffer.clear();
            directFloatBuffer.limit(Length);
            directFloatBuffer.put(values, 0, Length);
            directFloatBuffer.rewind();

            return(directFloatBuffer);
        }
Example #2
0
        private void drawTexture(IRenderingEngine re, int x, int y, int projectionWidth, int projectionHeight, bool scaleToCanvas, bool redWriteEnabled, bool greenWriteEnabled, bool blueWriteEnabled, bool alphaWriteEnabled)
        {
            re.startDirectRendering(true, false, true, true, true, projectionWidth, projectionHeight);
            re.setColorMask(redWriteEnabled, greenWriteEnabled, blueWriteEnabled, alphaWriteEnabled);
            if (scaleToCanvas)
            {
                re.setViewport(0, 0, Modules.sceDisplayModule.CanvasWidth, Modules.sceDisplayModule.CanvasHeight);
            }
            else
            {
                re.setViewport(0, 0, projectionWidth, projectionHeight);
            }

            IREBufferManager bufferManager  = re.BufferManager;
            ByteBuffer       drawByteBuffer = bufferManager.getBuffer(drawBufferId);

            drawByteBuffer.clear();
            FloatBuffer drawFloatBuffer = drawByteBuffer.asFloatBuffer();

            drawFloatBuffer.clear();
            drawFloatBuffer.put(texS);
            drawFloatBuffer.put(texT);
            drawFloatBuffer.put(x + width);
            drawFloatBuffer.put(y + height);

            drawFloatBuffer.put(0.0f);
            drawFloatBuffer.put(texT);
            drawFloatBuffer.put(x);
            drawFloatBuffer.put(y + height);

            drawFloatBuffer.put(0.0f);
            drawFloatBuffer.put(0.0f);
            drawFloatBuffer.put(x);
            drawFloatBuffer.put(y);

            drawFloatBuffer.put(texS);
            drawFloatBuffer.put(0.0f);
            drawFloatBuffer.put(x + width);
            drawFloatBuffer.put(y);

            if (re.VertexArrayAvailable)
            {
                re.bindVertexArray(0);
            }
            re.setVertexInfo(null, false, false, true, -1);
            re.enableClientState(pspsharp.graphics.RE.IRenderingEngine_Fields.RE_TEXTURE);
            re.disableClientState(pspsharp.graphics.RE.IRenderingEngine_Fields.RE_COLOR);
            re.disableClientState(pspsharp.graphics.RE.IRenderingEngine_Fields.RE_NORMAL);
            re.enableClientState(pspsharp.graphics.RE.IRenderingEngine_Fields.RE_VERTEX);
            bufferManager.setTexCoordPointer(drawBufferId, 2, pspsharp.graphics.RE.IRenderingEngine_Fields.RE_FLOAT, 4 * SIZEOF_FLOAT, 0);
            bufferManager.setVertexPointer(drawBufferId, 2, pspsharp.graphics.RE.IRenderingEngine_Fields.RE_FLOAT, 4 * SIZEOF_FLOAT, 2 * SIZEOF_FLOAT);
            bufferManager.setBufferData(pspsharp.graphics.RE.IRenderingEngine_Fields.RE_ARRAY_BUFFER, drawBufferId, drawFloatBuffer.position() * SIZEOF_FLOAT, drawByteBuffer.rewind(), pspsharp.graphics.RE.IRenderingEngine_Fields.RE_DYNAMIC_DRAW);
            re.drawArrays(pspsharp.graphics.RE.IRenderingEngine_Fields.RE_QUADS, 0, 4);

            re.endDirectRendering();
        }