Perform transform of Translate and Rotate on RenderScript - Blog Android

Monday, 28 May 2012

Perform transform of Translate and Rotate on RenderScript

Perform transform of Translate and Rotate on RenderScript


Modify RenderScript.rs of last exercise "Program Renderscript on Android" to perform transform of Translate and Rotate - to rotate the rendered triangle.

RenderScript.rs
//declare RendorScript Version
#pragma version(1)

//declare package
#pragma rs java_package_name(com.exercise.AndroidRenderScript);

//include graphics library
#include "rs_graphics.rsh"

rs_mesh my_rs_mesh;

float rotation;

void init(){
rotation = 0.0f;
}

int root(){
//set background color
rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);

//Transform something
rs_matrix4x4 matrix;
rsMatrixLoadIdentity(&matrix);
rsMatrixTranslate(&matrix, 100.0f, 100.0f, 0.0f);
rsMatrixRotate(&matrix, rotation++, 0.0f, 0.0f, 1.0f);
rsgProgramVertexLoadModelMatrix(&matrix);

//draw something
rsgDrawMesh(my_rs_mesh);

//repeat 20ms
return 20;
}


Download the files.

Next:
- Draw square in Android RenderScript

Borneo08

About Borneo08

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :

More links

Related Posts Plugin for WordPress, Blogger...