bool RenderTexture::Create(unsigned int width, unsigned int height, bool depthBuffer) { // Create the texture if (!myTexture.Create(width, height)) { Err() << "Impossible to create render texture (failed to create the target texture)" << std::endl; return false; } // We disable smoothing by default for render textures SetSmooth(false); // Create the implementation delete myRenderTexture; if (priv::RenderTextureImplFBO::IsAvailable()) { // Use frame-buffer object (FBO) myRenderTexture = new priv::RenderTextureImplFBO; } else { // Use default implementation myRenderTexture = new priv::RenderTextureImplDefault; } // Initialize the render texture if (!myRenderTexture->Create(width, height, myTexture.myTexture, depthBuffer)) return false; // We can now initialize the render target part RenderTarget::Initialize(); return true; }
// Update data according to the setting in the UI void UC_PropertyPagePoint::Update(BOOL bToData) { const GR_DLAttribPtrVect& vAttrib = m_pDLPoint->GetAttribs(); for(GR_DLAttribPtrVect::const_iterator it = vAttrib.begin(); it != vAttrib.end(); it++) { GR_DLAttribColor* pDLAttribColor = dynamic_cast<GR_DLAttribColor*>((*it).GetTarget()); GR_DLAttribPointSize* pDLAttribPointSize = dynamic_cast<GR_DLAttribPointSize*>((*it).GetTarget()); GR_DLAttribPointSmooth* pDLAttribPointSmooth = dynamic_cast<GR_DLAttribPointSmooth*>((*it).GetTarget()); if(pDLAttribColor) bToData ? pDLAttribColor->SetColor(GetColor()) : SetColor(pDLAttribColor->GetColor()); else if(pDLAttribPointSize) bToData ? pDLAttribPointSize->SetSize(GetSize()) : SetSize(pDLAttribPointSize->GetSize()); else if(pDLAttribPointSmooth) bToData ? pDLAttribPointSmooth->SetSmooth(GetSmooth()) : SetSmooth(pDLAttribPointSmooth->GetSmooth()); } }
void Contour2D::SetInput( vtkImageData* imagedata, double dContourValue, double dSliceLocation, int active_frame ) { vtkSmartPointer<vtkImageExtractComponents> extract = vtkSmartPointer<vtkImageExtractComponents>::New(); if ( imagedata->GetNumberOfScalarComponents() > 1 ) { extract->SetInput( imagedata ); extract->SetComponents( active_frame ); extract->Update(); m_imageInput = extract->GetOutput(); } else m_imageInput = imagedata; m_filterThreshold->SetInput( m_imageInput ); SetContourValue( dContourValue ); // create two masks and initialize them. m_imageMaskAdd = vtkSmartPointer<vtkImageData>::New(); m_imageMaskAdd->DeepCopy( m_filterThreshold->GetOutput() ); m_imageMaskRemove = vtkSmartPointer<vtkImageData>::New(); m_imageMaskRemove->DeepCopy( m_imageMaskAdd ); int* dim = m_imageMaskAdd->GetDimensions(); int size = dim[0]*dim[1]*dim[2]; memset( m_imageMaskAdd->GetScalarPointer(), 0, size ); unsigned char* ptr = (unsigned char*)m_imageMaskRemove->GetScalarPointer(); for ( int i = 0; i < size; i++ ) ptr[i] = 1; m_filterLogic->SetInput1( m_filterThreshold->GetOutput() ); m_filterLogic->SetInput2( m_imageMaskAdd ); m_filterMask->SetInputConnection( m_filterLogic->GetOutputPort() ); m_filterMask->SetMaskInput( m_imageMaskRemove ); m_filterResample->SetInputConnection( m_filterMask->GetOutputPort() ); m_filterEdge->SetInputConnection( m_filterResample->GetOutputPort() ); m_colormap->SetInputConnection( m_filterEdge->GetOutputPort() ); m_actorContour->SetInput( m_colormap->GetOutput() ); SetSmooth( m_bSmooth ); UpdateSliceLocation( dSliceLocation ); }
//================================================================= // Texture3D::CreateFromData //--------------------------------------- void Texture3D::CreateFromData( UInt32 width, UInt32 height, UInt32 depth, void *data) { const GLsizei NUMBER_OF_TEXTURES = 1; const GLint BORDER_SIZE_0 = 0; // Reset our texture Destroy(); PFNGLTEXIMAGE3DPROC glTexImage3D = GetTex3DFunction(); if( glTexImage3D ) { glGenTextures(NUMBER_OF_TEXTURES, &mTextureID); SetSmooth( true ); SetWrapFunction( GL_REPEAT ); glTexImage3D( GL_TEXTURE_3D, MIP_MAP_LEVEL_0, GL_RGBA8, width, height, depth, BORDER_SIZE_0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) data ); } else { throw GraphicsHardwareException( "Unable to obtain glTexImage3D." ); } }
void Init() override { m_rigidBody = parent->GetComponent<uth::Rigidbody>(); //m_rigidBody->SetKinematic(true); m_rigidBody->SetPhysicsGroup(3); m_direction = uth::Randomizer::GetInt(0, 10); if (m_direction < 6) { m_direction = 1; m_startX = -m_startX; } else { m_direction = -1; } auto bombTex = uthRS.LoadTexture("Enemies/Projectiles/boulder.png"); bombTex->SetSmooth(true); auto AtomBomb = new uth::Sprite(bombTex); pAtomBomb->AddComponent(AtomBomb); pAtomBomb->transform.SetOrigin(6); pAtomBomb->transform.SetPosition(m_rigidBody->GetPosition()); m_layer->AddChild(pAtomBomb); uth::Texture* ropeTex = uthRS.LoadTexture("Enemies/Projectiles/rope.png"); ropeTex->SetSmooth(true); auto Rope = new uth::Sprite(ropeTex); pRope->AddComponent(Rope); pRope->transform.SetOrigin(9); pRope->transform.SetPosition(m_rigidBody->GetPosition()); m_layer->AddChild(pRope); isInited = true; }
//////////////////////////////////////////////////////////// /// Enable or disable image smooth filter //////////////////////////////////////////////////////////// void sfImage_SetSmooth(sfImage* Image, sfBool Smooth) { CSFML_CALL(Image, SetSmooth(Smooth == sfTrue)); }
void sfRenderTexture_SetSmooth(sfRenderTexture* renderTexture, sfBool smooth) { CSFML_CALL(renderTexture, SetSmooth(smooth == sfTrue)); }
int32_t PS3Graphics::PSGLInit() { glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_FOG); glDisable(GL_DITHER); glShadeModel(GL_FLAT); glEnable(GL_VSYNC_SCE); glEnable(GL_TEXTURE_2D); /* //glEnable(GL_BLEND); //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); //glBlendColor(0, 0, 0, 0); //glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); */ context_width = SCREEN_RENDER_TEXTURE_WIDTH; context_height = SCREEN_RENDER_TEXTURE_HEIGHT; InitCg(); SetViewports(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glGenBuffers(2, vbo); glBindBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE, vbo[0]); glBufferData(GL_TEXTURE_REFERENCE_BUFFER_SCE, SCREEN_RENDER_TEXTURE_HEIGHT * SCREEN_RENDER_TEXTURE_PITCH, NULL, GL_STREAM_DRAW); glTextureReferenceSCE(GL_TEXTURE_2D, 1, SCREEN_RENDER_TEXTURE_WIDTH, SCREEN_RENDER_TEXTURE_HEIGHT, 0, GL_RGB5_A1, SCREEN_RENDER_TEXTURE_PITCH, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); SetSmooth(m_smooth); // PSGL doesn't clear the screen on startup, so let's do that here. glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glColor4f(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); psglSwap(); // Use some initial values for the screen quad. GLfloat vertexes[] = { 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1 }; GLfloat vertex_buf[128]; __builtin_memcpy(vertex_buf, vertexes, 12 * sizeof(GLfloat)); __builtin_memcpy(vertex_buf + 32, vertexes + 12, 8 * sizeof(GLfloat)); __builtin_memcpy(vertex_buf + 32 * 3, vertexes + 12, 8 * sizeof(GLfloat)); glBindBuffer(GL_ARRAY_BUFFER, vbo[1]); glBufferData(GL_ARRAY_BUFFER, 256, vertex_buf, GL_STATIC_DRAW); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, 0, 0); glTexCoordPointer(2, GL_FLOAT, 0, (void*)128); return CELL_OK; }
void sfTexture_SetSmooth(sfTexture* texture, sfBool smooth) { CSFML_CALL_PTR(texture, SetSmooth(smooth == sfTrue)); }
int32_t FceuGraphics::PSGLInit() { glDisable(GL_DEPTH_TEST); ToggleVSync(m_vsync); uint32_t ret = InitCg(); if (ret != CELL_OK) { LOG_DBG("Failed to InitCg: %d\n", __LINE__); } //FIXME: Change to SetViewports? set_aspect(); vertex_buf = (uint8_t*)memalign(128, 256); assert(vertex_buf); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glColor4f(1.0, 1.0, 1.0, 1.0); Clear(); Swap(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glGenBuffers(1, &pbo); glGenBuffers(1, &vbo); // Vertexes GLfloat vertexes[] = { 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1 }; memcpy(vertex_buf, vertexes, 12 * sizeof(GLfloat)); memcpy(vertex_buf + 128, vertexes + 12, 8 * sizeof(GLfloat)); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, 256, vertex_buf, GL_STATIC_DRAW); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, 0, 0); glTexCoordPointer(2, GL_FLOAT, 0, (void*)128); glEnable(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbo); SetSmooth(m_smooth); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glColor4f(1.0, 1.0, 1.0, 1.0); Clear(); Swap(); return CELL_OK; }