Example #1
0
void DepthTexture::Generate()
{


    int nWidth=0;
    int nHeight=0;
    if(GetSizeType() == TEX_TYPE_DEVICE)
    {
        nWidth = GetRender()->GetDeviceWidth();
        nHeight = GetRender()->GetDeviceHeight();
    }
    else
    {
        nWidth = GetWidth();
        nHeight = GetHeight();
    }

    uint32 id = GetID();
    if (GetID())
    {
        glDeleteTextures(1, &id);
    }

    glGenTextures(1, &id);
    SetID(id);

    // make active and bind
    glBindTexture(GL_TEXTURE_2D, id);

    // turn off filtering and wrap models
    //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    GLenum internalFormat = GL_DEPTH_COMPONENT;
    GLenum textureFormat = GL_DEPTH_COMPONENT;

    // egl EGL_DEPTH_SIZE 24 use GL_UNSIGNED_INT, 16 use GL_UNSIGNED_SHORT
    //GLenum type = GL_UNSIGNED_INT;
    GLenum type = GL_FLOAT;

    switch(GetFormat())
    {
    case TEX_FORMAT_DEPTH_DEFAULT:
        {
            internalFormat = GL_DEPTH_COMPONENT;
            textureFormat = GL_DEPTH_COMPONENT;
            type = GL_FLOAT;
        }
        break;
    default:
        break;
    }

	// android test
	//type = GL_UNSIGNED_SHORT;

    glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, nWidth, nHeight, 0, textureFormat, type, NULL);
    glBindTexture(GL_TEXTURE_2D, 0);
}
Example #2
0
void ColorTexture::Generate()
{
    int nWidth=0;
    int nHeight=0;
    if(GetSizeType() == TEX_TYPE_DEVICE)
    {
        nWidth = GetRender()->GetDeviceWidth();
        nHeight = GetRender()->GetDeviceHeight();
    }
    else
    {
        nWidth = GetWidth();
        nHeight = GetHeight();
    }

    uint32 id = GetID();
    if (GetID())
    {
        glDeleteTextures(1, &id);
    }

    glGenTextures(1, &id);
    SetID(id);

    // make active and bind
    glBindTexture(GL_TEXTURE_2D, id);

    // turn off filtering and wrap models
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);


	// changed on android
    //GLenum internalFormat = GL_RGB;
    //GLenum textureFormat = GL_RGB;
    //GLenum type = GL_UNSIGNED_SHORT_5_6_5;

	GLenum internalFormat = GL_RGBA;
	GLenum textureFormat = GL_RGBA;
	GLenum type = GL_UNSIGNED_BYTE;

	switch (GetFormat())
	{
	case TEX_FORMAT_rgb_alpha:
	{
		internalFormat = GL_RGBA;
		textureFormat = GL_RGBA;
		type = GL_UNSIGNED_BYTE;
	}
	break;
	case TEX_FORMAT_rgb:
	{
		internalFormat = GL_RGB;
		textureFormat = GL_RGB;
		type = GL_UNSIGNED_BYTE;
	}
	break;
	default:
		break;
	}
    glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, nWidth, nHeight, 0, textureFormat, type, NULL);
    glBindTexture(GL_TEXTURE_2D, 0);
}
Example #3
0
    void VirtualMachine::LoadRuntimeClasses()
    {
        // Load only once.
        if(objectClass)
            return;

        // The first loaded module must be the runtime.
        runtimeModule = loadedModules[0];
        runtimeModule->SetRuntimeFlag(true);

        // Get basic classes.
        typeClass = GetClass(runtimeModule, "Chela.Lang.Type");
        objectClass = GetClass(runtimeModule, "Chela.Lang.Object");
        stringClass = GetClass(runtimeModule, "Chela.Lang.String");
        closureClass = GetClass(runtimeModule, "Chela.Lang.Closure");
        arrayClass = GetClass(runtimeModule, "Chela.Lang.Array");
        valueTypeClass = GetClass(runtimeModule, "Chela.Lang.ValueType");
        enumClass = GetClass(runtimeModule, "Chela.Lang.Enum");
        delegateClass = GetClass(runtimeModule, "Chela.Lang.Delegate");

        // Special attributes.
        threadStaticAttribute = GetClass(runtimeModule, "Chela.Lang.ThreadStaticAttribute");
        chelaIntrinsicAttribute = GetClass(runtimeModule, "Chela.Runtime.Core.ChelaIntrinsicAttribute");

        // Get the kernel data holding classes.
        streamHolderClass = GetTemplateClass(runtimeModule, "Chela.Compute.StreamHolder");
        streamHolder1DClass = GetTemplateClass(runtimeModule, "Chela.Compute.StreamHolder1D");
        streamHolder2DClass = GetTemplateClass(runtimeModule, "Chela.Compute.StreamHolder2D");
        streamHolder3DClass = GetTemplateClass(runtimeModule, "Chela.Compute.StreamHolder3D");
        uniformHolderClass = GetTemplateClass(runtimeModule, "Chela.Compute.UniformHolder");

        // Get the reflection classes.
        assemblyClass = GetClass(runtimeModule, "Chela.Reflection.Assembly");
        constructorInfoClass = GetClass(runtimeModule, "Chela.Reflection.ConstructorInfo");
        eventInfoClass = GetClass(runtimeModule, "Chela.Reflection.EventInfo");
        fieldInfoClass = GetClass(runtimeModule, "Chela.Reflection.FieldInfo");
        memberInfoClass = GetClass(runtimeModule, "Chela.Reflection.MemberInfo");
        methodInfoClass = GetClass(runtimeModule, "Chela.Reflection.MethodInfo");
        parameterInfoClass = GetClass(runtimeModule, "Chela.Reflection.ParameterInfo");
        propertyInfoClass = GetClass(runtimeModule, "Chela.Reflection.PropertyInfo");

        // Register associated types.
        RegisterPrimStruct(GetBoolType(), "Chela.Lang.Boolean");
        RegisterPrimStruct(GetCharType(), "Chela.Lang.Char");
        RegisterPrimStruct(GetSByteType(), "Chela.Lang.SByte");
        RegisterPrimStruct(GetByteType(), "Chela.Lang.Byte");
        RegisterPrimStruct(GetShortType(), "Chela.Lang.Int16");
        RegisterPrimStruct(GetUShortType(), "Chela.Lang.UInt16");
        RegisterPrimStruct(GetIntType(), "Chela.Lang.Int32");
        RegisterPrimStruct(GetUIntType(), "Chela.Lang.UInt32");
        RegisterPrimStruct(GetLongType(), "Chela.Lang.Int64");
        RegisterPrimStruct(GetULongType(), "Chela.Lang.UInt64");
        RegisterPrimStruct(GetSizeType(), "Chela.Lang.UIntPtr");
        RegisterPrimStruct(GetPtrDiffType(), "Chela.Lang.IntPtr");
        RegisterPrimStruct(GetFloatType(), "Chela.Lang.Single");
        RegisterPrimStruct(GetDoubleType(), "Chela.Lang.Double");
        RegisterPrimStruct(GetVoidType(), "Chela.Lang.Void");

        // Register vector associated types.
        RegisterPrimStruct(GetFloatVectorTy(this, 2), "Chela.Lang.Single2");
        RegisterPrimStruct(GetFloatVectorTy(this, 3), "Chela.Lang.Single3");
        RegisterPrimStruct(GetFloatVectorTy(this, 4), "Chela.Lang.Single4");
        RegisterPrimStruct(GetDoubleVectorTy(this, 2), "Chela.Lang.Double2");
        RegisterPrimStruct(GetDoubleVectorTy(this, 3), "Chela.Lang.Double3");
        RegisterPrimStruct(GetDoubleVectorTy(this, 4), "Chela.Lang.Double4");
        RegisterPrimStruct(GetIntVectorTy(this, 2), "Chela.Lang.Int32x2");
        RegisterPrimStruct(GetIntVectorTy(this, 3), "Chela.Lang.Int32x3");
        RegisterPrimStruct(GetIntVectorTy(this, 4), "Chela.Lang.Int32x4");
        RegisterPrimStruct(GetBoolVectorTy(this, 2), "Chela.Lang.Boolean2");
        RegisterPrimStruct(GetBoolVectorTy(this, 3), "Chela.Lang.Boolean3");
        RegisterPrimStruct(GetBoolVectorTy(this, 4), "Chela.Lang.Boolean4");

        // Register matrix associated types.
        RegisterPrimStruct(GetFloatMatrixTy(this, 3,3), "Chela.Lang.Single3x3");
        RegisterPrimStruct(GetFloatMatrixTy(this, 4,4), "Chela.Lang.Single4x4");

        // Declare them.
        typeClass->DeclarePass();
        objectClass->DeclarePass();
        stringClass->DeclarePass();
        closureClass->DeclarePass();
        arrayClass->DeclarePass();
        valueTypeClass->DeclarePass();
        enumClass->DeclarePass();
        delegateClass->DeclarePass();
        streamHolderClass->DeclarePass();
        streamHolder1DClass->DeclarePass();
        streamHolder2DClass->DeclarePass();
        streamHolder3DClass->DeclarePass();
        uniformHolderClass->DeclarePass();

        assemblyClass->DeclarePass();
        constructorInfoClass->DeclarePass();
        eventInfoClass->DeclarePass();
        fieldInfoClass->DeclarePass();
        memberInfoClass->DeclarePass();
        methodInfoClass->DeclarePass();
        parameterInfoClass->DeclarePass();
        propertyInfoClass->DeclarePass();
    }