V wrote on Apr 18th, 2009, 8:15am:shaderlib
technical:
tested in windows xp 32bit
compiled for j1.5 ( so it should work for macs )
Seems to be working on Mac too (at least on mine ;-) ) , OSX 10.5.6, Processing 1.0.3) although i'm experiencing issues with one of the examples (that crashes upon launch) and strange behaviours (aka black screen) when doing slight modifications of the examples that work (but it might be my fault).
More specifically, out of the 5 examples, all work OK but for the "glsl_simple" sketch which crashes with:
Code:
loading texture: dark3.jpg with id= 1
(ShaderGLSL) Info Log of Shader Object ID: 1
(ShaderGLSL) --------------------------
(ShaderGLSL) Shader was compiled sucessfully!
(ShaderGLSL) --------------------------
(ShaderGLSL) Error occured with object parameter: 0
Invalid memory access of location 00000000 eip=60db31a3
Otherwise, as mentioned above, i've tried some modification to the sketch "cgfx_texture" to try and combine it with a video feed to test performance in anticipation of trying to mix and match GLSL and Cg shaders in a chain. The simple test i made is as follows:
Quote:import processing.opengl.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import com.sun.opengl.cg.*;
import com.sun.opengl.util.*;
import vitamin.math.*;
import vitamin.shaderlib.*;
import processing.video.*;
GL _gl;
GLU _glu;
Capture video;
VTexture tex;
int shaderID;
ShaderManager shaderMan;
void setup()
{
// Added to circumvent issue between OpenGL and video libs on mac
try {
quicktime.QTSession.open();
} catch (quicktime.QTException qte) {
qte.printStackTrace();
}
size( 800, 600, OPENGL );
video = new Capture(this, width, height, 25);
_gl = ((PGraphicsOpenGL)g).gl;
_glu = ((PGraphicsOpenGL)g).glu;
//tex = new VTexture("dark3.jpg");
shaderMan = new ShaderManager( _gl );
shaderID = shaderMan.addEffect( "simple", dataPath("simple_texture.cgfx") );
}
void draw() {
if (video.available()) {
tex = new VTexture(video);
_gl = ((PGraphicsOpenGL)g).beginGL();
_gl.glClearColor( 0, 0, 0, 1 );
_gl.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
vperspective( 45, 1.3333, 1, 5000 );
vcamera( 0, 0, 100, 0, 0, 0, 0, 1, 0 );
_gl.glRotatef( frameCount, 0, 1, 0 );
_gl.glDisable( GL.GL_TEXTURE_2D );
Matrix matWorld = new Matrix();
matWorld.identity();
matWorld.rotateY( frameCount );
matWorld.transpose();
shaderMan.enable( shaderID );
shaderMan.setTextureParameter( "ColorSampler", tex.getId() );
shaderMan.setMatrixParameterSemantic( "WORLDVIEWPROJECTION", ShaderSemantics.WORLDVIEWPROJECTION_MATRIX, ShaderSemantics.IDENTITY_MATRIX );
shaderMan.setMatrixParameterSemantic( "MODELVIEWMATRIX", ShaderSemantics.VIEW_MATRIX, ShaderSemantics.IDENTITY_MATRIX );
shaderMan.setMatrixParameterSemantic( "WORLDMATRIX", matWorld.getArray() );
((ShaderCGFX)shaderMan.getActiveShader()).setTechnique( "Technique_SimpleDiffuseTexture" );
((ShaderCGFX)shaderMan.getActiveShader()).setPass();
vrect( 0, 0, 0, 20, 20 );
((ShaderCGFX)shaderMan.getActiveShader()).resetPass();
shaderMan.disable();
((PGraphicsOpenGL)g).endGL();
}
}
void stop()
{
super.stop();
}
Note that i've also added a new Constructor "VTexture( PImage pimg )":
Quote: VTexture( PImage pimg )
{
_tex = null;
_buffer = null;
_img = null;
isLoaded = false;
loadPImageFromMemory( pimg );
}
so that the VTexture is updated with the video frame whenever a new frame is available.
What seems odd (to me) is that the resulting screen is pitch black with no error reported. Any idea as to what might be going wrong?