1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.example.android.rs.helloworld; 18 19import android.content.res.Resources; 20import android.renderscript.*; 21 22// This is the renderer for the HelloWorldView 23public class HelloWorldRS { 24 private Resources mRes; 25 private RenderScriptGL mRS; 26 27 private ScriptC_helloworld mScript; 28 29 public HelloWorldRS() { 30 } 31 32 // This provides us with the renderscript context and resources that 33 // allow us to create the script that does rendering 34 public void init(RenderScriptGL rs, Resources res) { 35 mRS = rs; 36 mRes = res; 37 initRS(); 38 } 39 40 public void onActionDown(int x, int y) { 41 mScript.set_gTouchX(x); 42 mScript.set_gTouchY(y); 43 } 44 45 private void initRS() { 46 mScript = new ScriptC_helloworld(mRS, mRes, R.raw.helloworld); 47 mRS.bindRootScript(mScript); 48 } 49} 50 51 52 53