aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/ogl/CompressedGeometryRetained.c
blob: 36ca16444cbb9c1a9ea2b7d92c8ff379ab035d3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * $RCSfile$
 *
 * Copyright (c) 2004 Sun Microsystems, Inc. All rights reserved.
 *
 * Use is subject to license terms.
 *
 * $Revision$
 * $Date$
 * $State$
 */

#include <stdio.h>
#include <jni.h>
#include "gldefs.h"

#ifdef SOLARIS
#pragma weak glDrawCompressedGeomSUNX

#else
static void glDrawCompressedGeomSUNX(GLint size, GLubyte *data) {
    fprintf(stderr, "Warning: glDrawCompressedGeomSUNX() not supported\n") ;
}
#endif /* SOLARIS */


JNIEXPORT
void JNICALL Java_javax_media_j3d_CompressedGeometryRetained_execute
    (JNIEnv *env, jobject obj, jlong ctxInfo, jint version, jint bufferType,
     jint bufferContents, jint renderFlags, jint offset, jint size,
     jbyteArray geometry)
{
    GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; 
    jlong ctx = ctxProperties->context;

    jbyte *cg = (*env)->GetPrimitiveArrayCritical(env, geometry, 0) ;

    /* ignore offset and pass header at 0 along with cg data */
    if(ctxProperties->geometry_compression_sunx)
	glDrawCompressedGeomSUNX((GLint)(size + 48), (GLubyte *)cg) ;
    
    (*env)->ReleasePrimitiveArrayCritical(env, geometry, cg, 0) ;
}


JNIEXPORT
jboolean JNICALL Java_javax_media_j3d_CompressedGeometryRetained_decompressByRef
    (JNIEnv *env, jobject obj, jlong ctxInfo)
{
    return JNI_FALSE ;
}

JNIEXPORT
jboolean JNICALL Java_javax_media_j3d_CompressedGeometryRetained_decompressHW
    (JNIEnv *env, jobject obj, jlong ctxInfo, jint majorVersion, jint minorVersion)
{
    /*
     * Return true if hardware decompression is supported for the given
     * version number of the compressed geometry.
     */

    GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; 
    jlong ctx = ctxProperties->context;

    return
	(ctxProperties->geometry_compression_accelerated == 1) &&
	((majorVersion < ctxProperties->geometry_compression_accelerated_major_version) ||
	 ((majorVersion == ctxProperties->geometry_compression_accelerated_major_version) &&
	  (minorVersion <= ctxProperties->geometry_compression_accelerated_minor_version))) ;
}