helloworld.rs revision e5f2f66f8c802d64ecf869081036ae13d4e9e19c
1// Copyright (C) 2011 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15#pragma version(1) 16 17// Tell which java package name the reflected files should belong to 18#pragma rs java_package_name(com.example.android.rs.helloworld) 19 20// Built-in header with graphics API's 21#include "rs_graphics.rsh" 22 23// gTouchX and gTouchY are variables that will be reflected for use 24// by the java API. We can use them to notify the script of touch events. 25int gTouchX; 26int gTouchY; 27 28// This is invoked automatically when the script is created 29void init() { 30 gTouchX = 50.0f; 31 gTouchY = 50.0f; 32} 33 34int root(void) { 35 36 // Clear the background color 37 rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f); 38 // Tell the runtime what the font color should be 39 rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f); 40 // Introuduce ourselves to the world by drawing a greeting 41 // at the position user touched on the screen 42 rsgDrawText("Hello World!", gTouchX, gTouchY); 43 44 // Return value tells RS roughly how often to redraw 45 // in this case 20 ms 46 return 20; 47} 48