All light source objects.
This commit is contained in:
@@ -85,6 +85,7 @@ LOCAL_SRC_FILES:= \
|
||||
rsContext.cpp \
|
||||
rsDevice.cpp \
|
||||
rsElement.cpp \
|
||||
rsLight.cpp \
|
||||
rsLocklessFifo.cpp \
|
||||
rsObjectBase.cpp \
|
||||
rsMatrix.cpp \
|
||||
|
||||
@@ -38,6 +38,7 @@ typedef void * RsScript;
|
||||
typedef void * RsScriptBasicTemp;
|
||||
typedef void * RsTriangleMesh;
|
||||
typedef void * RsType;
|
||||
typedef void * RsLight;
|
||||
|
||||
typedef void * RsProgramVertex;
|
||||
typedef void * RsProgramFragment;
|
||||
|
||||
@@ -14,6 +14,7 @@ typedef void * RsTriangleMesh;
|
||||
typedef void * RsType;
|
||||
typedef void * RsProgramFragment;
|
||||
typedef void * RsProgramFragmentStore;
|
||||
typedef void * RsLight;
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -85,6 +85,7 @@ public class FilmRS {
|
||||
private RenderScript.Allocation mAllocState;
|
||||
private RenderScript.Allocation mAllocPV;
|
||||
private RenderScript.TriangleMesh mMesh;
|
||||
private RenderScript.Light mLight;
|
||||
|
||||
private float[] mBufferPos;
|
||||
private float[] mBufferPV;
|
||||
@@ -144,6 +145,10 @@ public class FilmRS {
|
||||
mPV = mRS.programVertexCreate();
|
||||
mPV.setName("PV");
|
||||
|
||||
mRS.lightBegin();
|
||||
mLight = mRS.lightCreate();
|
||||
mLight.setPosition(0, -0.5f, -1.0f);
|
||||
|
||||
Log.e("rs", "Done loading named");
|
||||
}
|
||||
|
||||
|
||||
@@ -157,6 +157,14 @@ public class RenderScript {
|
||||
native private void nProgramVertexSetTextureMatrixEnable(boolean enable);
|
||||
native private int nProgramVertexCreate();
|
||||
|
||||
native private void nLightBegin();
|
||||
native private void nLightSetIsMono(boolean isMono);
|
||||
native private void nLightSetIsLocal(boolean isLocal);
|
||||
native private int nLightCreate();
|
||||
native private void nLightDestroy(int l);
|
||||
native private void nLightSetColor(int l, float r, float g, float b);
|
||||
native private void nLightSetPosition(int l, float x, float y, float z);
|
||||
|
||||
|
||||
private int mDev;
|
||||
private int mContext;
|
||||
@@ -869,6 +877,44 @@ public class RenderScript {
|
||||
return new Sampler(id);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Light
|
||||
|
||||
public class Light extends BaseObj {
|
||||
Light(int id) {
|
||||
mID = id;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
nLightDestroy(mID);
|
||||
mID = 0;
|
||||
}
|
||||
|
||||
public void setColor(float r, float g, float b) {
|
||||
nLightSetColor(mID, r, g, b);
|
||||
}
|
||||
|
||||
public void setPosition(float x, float y, float z) {
|
||||
nLightSetPosition(mID, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public void lightBegin() {
|
||||
nLightBegin();
|
||||
}
|
||||
|
||||
public void lightSetIsMono(boolean isMono) {
|
||||
nLightSetIsMono(isMono);
|
||||
}
|
||||
|
||||
public void lightSetIsLocal(boolean isLocal) {
|
||||
nLightSetIsLocal(isLocal);
|
||||
}
|
||||
|
||||
public Light lightCreate() {
|
||||
int id = nLightCreate();
|
||||
return new Light(id);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Root state
|
||||
|
||||
@@ -881,10 +881,67 @@ static jint
|
||||
nSamplerCreate(JNIEnv *_env, jobject _this)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nSamplerCreate, con(%p), script(%p)", con, (RsScript)script);
|
||||
LOG_API("nSamplerCreate, con(%p)", con);
|
||||
return (jint)rsSamplerCreate();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
nLightBegin(JNIEnv *_env, jobject _this)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nLightBegin, con(%p)", con);
|
||||
rsLightBegin();
|
||||
}
|
||||
|
||||
static void
|
||||
nLightSetIsMono(JNIEnv *_env, jobject _this, jboolean isMono)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nLightSetIsMono, con(%p), isMono(%i)", con, isMono);
|
||||
rsLightSetMonochromatic(isMono);
|
||||
}
|
||||
|
||||
static void
|
||||
nLightSetIsLocal(JNIEnv *_env, jobject _this, jboolean isLocal)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nLightSetIsLocal, con(%p), isLocal(%i)", con, isLocal);
|
||||
rsLightSetLocal(isLocal);
|
||||
}
|
||||
|
||||
static jint
|
||||
nLightCreate(JNIEnv *_env, jobject _this)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nLightCreate, con(%p)", con);
|
||||
return (jint)rsLightCreate();
|
||||
}
|
||||
|
||||
static void
|
||||
nLightDestroy(JNIEnv *_env, jobject _this, jint light)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nLightDestroy, con(%p), light(%p)", con, (RsLight)light);
|
||||
rsLightDestroy((RsLight)light);
|
||||
}
|
||||
|
||||
static void
|
||||
nLightSetColor(JNIEnv *_env, jobject _this, jint light, float r, float g, float b)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nLightSetColor, con(%p), light(%p), r(%f), g(%f), b(%f)", con, (RsLight)light, r, g, b);
|
||||
rsLightSetColor((RsLight)light, r, g, b);
|
||||
}
|
||||
|
||||
static void
|
||||
nLightSetPosition(JNIEnv *_env, jobject _this, jint light, float x, float y, float z)
|
||||
{
|
||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||
LOG_API("nLightSetPosition, con(%p), light(%p), x(%f), y(%f), z(%f)", con, (RsLight)light, x, y, z);
|
||||
rsLightSetPosition((RsLight)light, x, y, z);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -979,6 +1036,14 @@ static JNINativeMethod methods[] = {
|
||||
{"nProgramVertexSetTextureMatrixEnable", "(Z)V", (void*)nProgramVertexSetTextureMatrixEnable },
|
||||
{"nProgramVertexCreate", "()I", (void*)nProgramVertexCreate },
|
||||
|
||||
{"nLightBegin", "()V", (void*)nLightBegin },
|
||||
{"nLightSetIsMono", "(Z)V", (void*)nLightSetIsMono },
|
||||
{"nLightSetIsLocal", "(Z)V", (void*)nLightSetIsLocal },
|
||||
{"nLightCreate", "()I", (void*)nLightCreate },
|
||||
{"nLightDestroy", "(I)V", (void*)nLightDestroy },
|
||||
{"nLightSetColor", "(IFFF)V", (void*)nLightSetColor },
|
||||
{"nLightSetPosition", "(IFFF)V", (void*)nLightSetPosition },
|
||||
|
||||
{"nContextBindRootScript", "(I)V", (void*)nContextBindRootScript },
|
||||
{"nContextBindProgramFragmentStore","(I)V", (void*)nContextBindProgramFragmentStore },
|
||||
{"nContextBindProgramFragment", "(I)V", (void*)nContextBindProgramFragment },
|
||||
|
||||
@@ -403,3 +403,36 @@ ProgramVertexSetTextureMatrixEnable {
|
||||
param bool enable
|
||||
}
|
||||
|
||||
LightBegin {
|
||||
}
|
||||
|
||||
LightSetLocal {
|
||||
param bool isLocal
|
||||
}
|
||||
|
||||
LightSetMonochromatic {
|
||||
param bool isMono
|
||||
}
|
||||
|
||||
LightCreate {
|
||||
ret RsLight light
|
||||
}
|
||||
|
||||
LightDestroy {
|
||||
param RsLight light
|
||||
}
|
||||
|
||||
LightSetPosition {
|
||||
param RsLight light
|
||||
param float x
|
||||
param float y
|
||||
param float z
|
||||
}
|
||||
|
||||
LightSetColor {
|
||||
param RsLight light
|
||||
param float r
|
||||
param float g
|
||||
param float b
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "rsProgramFragment.h"
|
||||
#include "rsProgramFragmentStore.h"
|
||||
#include "rsProgramVertex.h"
|
||||
#include "rsLight.h"
|
||||
|
||||
#include "rsgApiStructs.h"
|
||||
#include "rsLocklessFifo.h"
|
||||
@@ -62,6 +63,7 @@ public:
|
||||
ProgramFragmentState mStateFragment;
|
||||
ProgramFragmentStoreState mStateFragmentStore;
|
||||
ProgramVertexState mStateVertex;
|
||||
LightState mStateLight;
|
||||
|
||||
TriangleMeshContext mStateTriangleMesh;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user