//-------------------------------------------------------------- void ofApp::update(){ fbo.begin(); mClient.draw(0, 0); fbo.end(); fbo.readToPixels(pixels); fboTour.begin(); tClient.draw(0, 0); fboTour.end(); fboTour.readToPixels(pixTour); while(receiver.hasWaitingMessages()){ // get the next message ofxOscMessage m; receiver.getNextMessage(m); if(m.getAddress() == "/b"){ //ofLog() << "b" << m.getArgAsInt32(0); for (int i=0; i<3; i++){ setBrightness(i, m.getArgAsInt32(0)); } } else if(m.getAddress() == "/t"){ //ofLog() << "t" << m.getArgAsInt32(0); setBrightness(3, m.getArgAsInt32(0)); } else if(m.getAddress() == "/d"){ for (int i=0; i<3; i++){ setDither(i, m.getArgAsInt32(0)); } //ofLog() << "d" << m.getArgAsInt32(0); } else if(m.getAddress() == "/dt"){ setDither(3, m.getArgAsInt32(0)); //ofLog() << "d" << m.getArgAsInt32(0); } } for (int i=0; i<4; i++) { sendLine(i); } }
void State::setEnableFeature(GLenum feature, bool enabled) { switch (feature) { case GL_CULL_FACE: setCullFace(enabled); break; case GL_POLYGON_OFFSET_FILL: setPolygonOffsetFill(enabled); break; case GL_SAMPLE_ALPHA_TO_COVERAGE: setSampleAlphaToCoverage(enabled); break; case GL_SAMPLE_COVERAGE: setSampleCoverage(enabled); break; case GL_SCISSOR_TEST: setScissorTest(enabled); break; case GL_STENCIL_TEST: setStencilTest(enabled); break; case GL_DEPTH_TEST: setDepthTest(enabled); break; case GL_BLEND: setBlend(enabled); break; case GL_DITHER: setDither(enabled); break; case GL_PRIMITIVE_RESTART_FIXED_INDEX: UNIMPLEMENTED(); break; case GL_RASTERIZER_DISCARD: setRasterizerDiscard(enabled); break; default: UNREACHABLE(); } }
gl::Error StateManager9::setBlendDepthRasterStates(const gl::State &glState, unsigned int sampleMask) { const gl::Framebuffer *framebuffer = glState.getDrawFramebuffer(); const gl::BlendState &blendState = glState.getBlendState(); const gl::ColorF &blendColor = glState.getBlendColor(); const gl::RasterizerState &rasterState = glState.getRasterizerState(); const auto &depthStencilState = glState.getDepthStencilState(); bool frontFaceCCW = (glState.getRasterizerState().frontFace == GL_CCW); unsigned int maxStencil = (1 << mCurStencilSize) - 1; // All the depth stencil states depends on the front face ccw variable if (frontFaceCCW != mCurFrontFaceCCW) { forceSetDepthStencilState(); mCurFrontFaceCCW = frontFaceCCW; } for (auto dirtyBit : angle::IterateBitSet(mDirtyBits)) { switch (dirtyBit) { case DIRTY_BIT_BLEND_ENABLED: setBlendEnabled(blendState.blend); break; case DIRTY_BIT_BLEND_COLOR: setBlendColor(blendState, blendColor); break; case DIRTY_BIT_BLEND_FUNCS_EQUATIONS: setBlendFuncsEquations(blendState); break; case DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE: setSampleAlphaToCoverage(blendState.sampleAlphaToCoverage); break; case DIRTY_BIT_COLOR_MASK: setColorMask(framebuffer, blendState.colorMaskRed, blendState.colorMaskBlue, blendState.colorMaskGreen, blendState.colorMaskAlpha); break; case DIRTY_BIT_DITHER: setDither(blendState.dither); break; case DIRTY_BIT_CULL_MODE: setCullMode(rasterState.cullFace, rasterState.cullMode, rasterState.frontFace); break; case DIRTY_BIT_DEPTH_BIAS: setDepthBias(rasterState.polygonOffsetFill, rasterState.polygonOffsetFactor, rasterState.polygonOffsetUnits); break; case DIRTY_BIT_STENCIL_DEPTH_MASK: setDepthMask(depthStencilState.depthMask); break; case DIRTY_BIT_STENCIL_DEPTH_FUNC: setDepthFunc(depthStencilState.depthTest, depthStencilState.depthFunc); break; case DIRTY_BIT_STENCIL_TEST_ENABLED: setStencilTestEnabled(depthStencilState.stencilTest); break; case DIRTY_BIT_STENCIL_FUNCS_FRONT: setStencilFuncsFront(depthStencilState.stencilFunc, depthStencilState.stencilMask, glState.getStencilRef(), frontFaceCCW, maxStencil); break; case DIRTY_BIT_STENCIL_FUNCS_BACK: setStencilFuncsBack(depthStencilState.stencilBackFunc, depthStencilState.stencilBackMask, glState.getStencilBackRef(), frontFaceCCW, maxStencil); break; case DIRTY_BIT_STENCIL_WRITEMASK_FRONT: setStencilWriteMask(depthStencilState.stencilWritemask, frontFaceCCW); break; case DIRTY_BIT_STENCIL_WRITEMASK_BACK: setStencilBackWriteMask(depthStencilState.stencilBackWritemask, frontFaceCCW); break; case DIRTY_BIT_STENCIL_OPS_FRONT: setStencilOpsFront(depthStencilState.stencilFail, depthStencilState.stencilPassDepthFail, depthStencilState.stencilPassDepthPass, frontFaceCCW); break; case DIRTY_BIT_STENCIL_OPS_BACK: setStencilOpsBack(depthStencilState.stencilBackFail, depthStencilState.stencilBackPassDepthFail, depthStencilState.stencilBackPassDepthPass, frontFaceCCW); break; default: break; } } if (sampleMask != mCurSampleMask) { setSampleMask(sampleMask); } return gl::Error(GL_NO_ERROR); }
gxScene::gxScene( gxGraphics *g,gxCanvas *t ): graphics(g),target(t),dir3dDev( g->dir3dDev ), n_texs(0),tris_drawn(0){ memset( d3d_rs,0x55,sizeof(d3d_rs) ); memset( d3d_tss,0x55,sizeof(d3d_tss) ); //nomalize normals setRS( D3DRENDERSTATE_NORMALIZENORMALS,TRUE ); //vertex coloring setRS( D3DRENDERSTATE_COLORVERTEX,FALSE ); setRS( D3DRENDERSTATE_DIFFUSEMATERIALSOURCE,D3DMCS_COLOR1 ); setRS( D3DRENDERSTATE_AMBIENTMATERIALSOURCE,D3DMCS_COLOR1 ); setRS( D3DRENDERSTATE_EMISSIVEMATERIALSOURCE,D3DMCS_MATERIAL ); setRS( D3DRENDERSTATE_SPECULARMATERIALSOURCE,D3DMCS_MATERIAL ); //Alpha test setRS( D3DRENDERSTATE_ALPHATESTENABLE,false ); setRS( D3DRENDERSTATE_ALPHAFUNC,D3DCMP_GREATER ); setRS( D3DRENDERSTATE_ALPHAREF,128 ); //source/dest blending modes setRS( D3DRENDERSTATE_SRCBLEND,D3DBLEND_SRCALPHA ); setRS( D3DRENDERSTATE_DESTBLEND,D3DBLEND_INVSRCALPHA ); //suss out caps can_wb=false; hw_tex_stages=1; D3DDEVICEDESC7 devDesc={0}; if( dir3dDev->GetCaps( &devDesc )>=0 ){ DWORD caps=devDesc.dpcTriCaps.dwRasterCaps; //texture stages hw_tex_stages=devDesc.wMaxSimultaneousTextures; //depth buffer mode if( (caps & D3DPRASTERCAPS_WBUFFER) && graphics->zbuffFmt.dwRGBBitCount==16 ) can_wb=true; //fog mode if( (caps&D3DPRASTERCAPS_FOGTABLE)&&(caps&D3DPRASTERCAPS_WFOG) ){ setRS( D3DRENDERSTATE_FOGVERTEXMODE,D3DFOG_NONE ); setRS( D3DRENDERSTATE_FOGTABLEMODE,D3DFOG_LINEAR ); }else{ setRS( D3DRENDERSTATE_FOGTABLEMODE,D3DFOG_NONE ); setRS( D3DRENDERSTATE_FOGVERTEXMODE,D3DFOG_LINEAR ); } } tex_stages=hw_tex_stages; caps_level=100; if( devDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_CUBEMAP ){ caps_level=110; } //default texture states for( int n=0;n<hw_tex_stages;++n ){ setTSS( n,D3DTSS_COLORARG1,D3DTA_TEXTURE ); setTSS( n,D3DTSS_COLORARG2,D3DTA_CURRENT ); setTSS( n,D3DTSS_ALPHAARG1,D3DTA_TEXTURE ); setTSS( n,D3DTSS_ALPHAARG2,D3DTA_CURRENT ); setTSS( n,D3DTSS_MINFILTER,D3DTFN_LINEAR ); setTSS( n,D3DTSS_MAGFILTER,D3DTFG_LINEAR ); setTSS( n,D3DTSS_MIPFILTER,D3DTFP_LINEAR ); } setHWMultiTex( true ); //ATI lighting hack dir3dDev->LightEnable( 0,true ); dir3dDev->LightEnable( 0,false ); //globals sphere_mat._11=.5f;sphere_mat._22=-.5f;sphere_mat._33=.5f; sphere_mat._41=.5f;sphere_mat._42=.5f;sphere_mat._43=.5f; nullmatrix._11=nullmatrix._22=nullmatrix._33=nullmatrix._44=1; //set null renderstate memset(&material,0,sizeof(material)); shininess=0;blend=BLEND_REPLACE;fx=0; for( int k=0;k<MAX_TEXTURES;++k ) memset( &texstate[k],0,sizeof(texstate[k]) ); wbuffer=can_wb; dither=false;setDither( true ); antialias=true;setAntialias( false ); wireframe=true;setWireframe( false ); flipped=true;setFlippedTris( false ); ambient=~0;setAmbient( GRAY ); ambient2=~0;setAmbient2( BLACK ); fogcolor=~0;setFogColor( BLACK ); fogrange_nr=fogrange_fr=0;setFogRange( 1,1000 ); fogmode=FOG_LINEAR;setFogMode( FOG_NONE ); zmode=-1;setZMode( ZMODE_NORMAL ); memset(&projmatrix,0,sizeof(projmatrix)); ortho_proj=true;frustum_nr=frustum_fr=frustum_w=frustum_h=0;setPerspProj( 1,1000,1,1 ); memset(&viewport,0,sizeof(viewport));viewport.dvMaxZ=1;setViewport( 0,0,target->getWidth(),target->getHeight() ); viewmatrix=nullmatrix;setViewMatrix( 0 ); worldmatrix=nullmatrix;setWorldMatrix( 0 ); //set default renderstate blend=fx=~0;shininess=1; RenderState state;memset(&state,0,sizeof(state)); state.color[0]=state.color[1]=state.color[2]=state.alpha=1; state.blend=BLEND_REPLACE; setRenderState( state ); }