void CSqlOperator::Bind(const CString &oName, CMdbAccess * pAccess) { UnBind(); m_oName = oName; m_pAccess = pAccess; m_bError = false; }
bool Texture2D::LoadWithFile( const std::string &ImageName ) { //wczytanie obrazka ILuint image; ilGenImages( 1, &image ); ilBindImage( image ); ilLoadImage( ImageName.c_str() ); ILenum Error = ilGetError(); if( Error != IL_NO_ERROR ) { std::cerr << "ERROR: Wczytanie tekstury: "<< "nie powiodlo sie, plik: " << ImageName << " nie zostal wczytany" << std::endl; return false; } int width, height, depth; ILenum type, format; width = ilGetInteger(IL_IMAGE_WIDTH); height = ilGetInteger(IL_IMAGE_HEIGHT); depth = ilGetInteger( IL_IMAGE_DEPTH ); type = ilGetInteger( IL_IMAGE_TYPE ); format = ilGetInteger( IL_IMAGE_FORMAT ); ILubyte *pixmap = ilGetData(); glBindTexture( GL_TEXTURE_2D, m_BufferHandle ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, format, type, pixmap ); UnBind(); ilDeleteImage( image ); return true; }
void VBO::WriteData (void *data, int size) { Bind (); glBufferSubData (GL_ARRAY_BUFFER, 0, size, data); GLErrorCheck (); UnBind (); }
void FBO::CheckState() { Bind(); GLenum e = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER); switch (e) { case GL_FRAMEBUFFER_UNDEFINED: printf("FBO Undefined\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT : printf("FBO Incomplete Attachment\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : printf("FBO Missing Attachment\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER : printf("FBO Incomplete Draw Buffer\n"); break; case GL_FRAMEBUFFER_UNSUPPORTED : printf("FBO Unsupported\n"); break; case GL_FRAMEBUFFER_COMPLETE: printf("FBO OK\n"); break; default: printf("FBO Problem?\n"); } UnBind(); }
GPU2DMesh::~GPU2DMesh() { if ( IsOpened() ) Close(); if ( IsBound() ) UnBind(); }
// Set the OpenGL mode to use for texture addressing in // the S and T dimensions respectively. void STTexture::SetWrap(GLint wrapS, GLint wrapT) { Bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT); UnBind(); }
void PrelightPipeline::DrawQuad(const std::shared_ptr<Pass> &pass) { auto shader = m_CurrentShader; auto mesh = MeshUtil::Instance()->GetUnitQuad(); if (shader == nullptr) { LOGW << "Failed to draw full screen quad, shader not found!"; return; } shader->Bind(); shader->BindMesh(mesh); shader->BindCamera(m_CurrentCamera); for (unsigned int i = 0; i < pass->GetTextureCount(true); i++) { auto ptr = pass->GetTextureAt(i, true); shader->BindTexture(ptr->GetName(), ptr); } glDrawElements(GL_TRIANGLES, mesh->Indices.Data.size(), GL_UNSIGNED_INT, 0); shader->UnBind(); m_DrawCall++; }
LTBOOL CScreenConfigure::CheckMouseWheel (DeviceInput* pInput) { if (!g_pLTClient) return LTFALSE; if (pInput->m_DeviceType != DEVICETYPE_MOUSE || pInput->m_ControlType != CONTROLTYPE_ZAXIS) return LTFALSE; LTBOOL bWheelUp = ((int)pInput->m_InputValue > 0); char szCommand[64]; CLTGUIColumnCtrl *pCtrl=(CLTGUIColumnCtrl *)m_pList[m_nType]->GetSelectedControl(); int nCommand=pCtrl->GetParam1(); uint16 diCode = pInput->m_ControlCode; if (bWheelUp) strcpy(szCommand, "#U"); else strcpy(szCommand, "#D"); UnBind( 0, szCommand, pInput->m_DeviceType ); Bind(nCommand, pInput->m_nObjectId, 0, szCommand, pInput->m_DeviceType); pCtrl->SetString(SCREEN_COLUMN_EQUALS, ""); UpdateControlList(); return LTTRUE; }
void clConsole::UnbindAll() { for ( int i = 0; i != 255; ++i ) { UnBind( i ); } }
// Set the OpenGL texture-filtering mode to use for texture // magnification and minification respectively. void STTexture::SetFilter(GLint magFilter, GLint minFilter) { Bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); UnBind(); }
void FrameBuffer::AttachRBO(GLuint RB) { mRBID = RB; Bind(); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRBID); UnBind(); }
void VertexArray::RegisterToGPU() { glDeleteVertexArrays(1, &mVAO); glGenVertexArrays(1, &mVAO); mVBO.Init(); mVertexSize = VertexSize(); Bind(); { mVBO.Bind(); int offset = 0; for(const VertexAttribDef &attrib : mVertAttribs) { glEnableVertexAttribArray(attrib.index); glVertexAttribPointer( attrib.index, attrib.size, attrib.type, attrib.normalized, mVertexSize, (void*)offset); offset += attrib.SizeInBytes(); } } UnBind(); }
// Handle a keypress LTBOOL CScreenConfigure::HandleKeyDown(int key, int rep) { LTBOOL handled = LTFALSE; switch (key) { case VK_DELETE: { // Unassign the key if (!m_bWaitingForKey && !m_fInputPauseTimeLeft) { CLTGUICtrl *pCtrl = m_pList[m_nType]->GetSelectedControl(); int nCommand = pCtrl->GetParam1(); CBindingData* pData = m_pProfile->FindBinding(nCommand); UnBind( pData->nDeviceObjectId[0], NULL, DEVICETYPE_KEYBOARD); UnBind( 0, pData->strTriggerName[1], DEVICETYPE_MOUSE); if (g_pGameClientShell->HasGamepad()) UnBind( 0, pData->strTriggerName[2], DEVICETYPE_GAMEPAD); else if (g_pGameClientShell->HasJoystick()) UnBind(0, pData->strTriggerName[2], DEVICETYPE_JOYSTICK); else UnBind(0, pData->strTriggerName[2], DEVICETYPE_UNKNOWN); SetControlText(pCtrl); handled = LTTRUE; } break; } } // Check to see if the base class is handling this key if (m_bWaitingForKey || m_fInputPauseTimeLeft) return handled; if (!handled) { handled = CBaseScreen::HandleKeyDown(key, rep); } // Handled the key return handled; }
void VBO::Build () { glGenBuffers (1,&ID); GLErrorCheck (); Bind (); glBufferData (GL_ARRAY_BUFFER,static_cast <GLsizeiptr> (Size),nullptr, GL_DYNAMIC_DRAW); GLErrorCheck (); UnBind (); }
VOID CUnBindDeviceCMD::OnExecuteSql(SGDP::ISDDBConnection *poDBConn) { m_bSuccess = FALSE; PKT_CLIZS_UN_BIND_DEVICE_REQ* pstReq = (PKT_CLIZS_UN_BIND_DEVICE_REQ*)m_pUserData; if(NULL == pstReq) return; UnBind(poDBConn, pstReq); }
void FrameBuffer::Compile() const { Bind(); glDrawBuffers(mAttachments.size(), colorAttachments); UnBind(); // Check completeness Check(); }
void Texture2D::LoadFromFile(const String &imageFilepath) { Bind(); m_filepath = imageFilepath; unsigned char *loadedData = FileReader::ReadImage(imageFilepath, &m_width, &m_height); Fill(loadedData, m_width, m_height); UnBind(); }
void FrameBuffer::AddAttachment(GLenum internalFormat, GLenum format, GLenum type) { mAttachments.push_back(Texture2D()); Texture2D &attachement = mAttachments.back(); attachement.Init(internalFormat, ivec2(mWidth, mHeight), format, type); Bind(); glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[mAttachments.size() - 1], GL_TEXTURE_2D, attachement.ID(), 0); UnBind(); }
void Texture2D::CreateGPUTexture( const bool generateMipMaps /*= true*/) { if( !m_isLocalDataAvailable) BREAKPOINT(Local texture data is not available!); // generate texture ID glGenTextures( 1, &m_textureID); // send texture data to openGL Bind(); m_hasMipMaps = generateMipMaps; // set texture filters to bilinear if(generateMipMaps) glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); // TODO: make the next block better adjustable by external parameters to override auto select settings // select internal format GLenum type = GL_UNSIGNED_BYTE; GLint internalFormat = 0; switch(m_componentSizeInBytes) { case 1: // unsigned char buffer internalFormat = m_numComponents == 4 ? GL_RGBA8 : GL_RGB8; internalFormat = m_numComponents == 1 ? GL_R8 : internalFormat; type = GL_UNSIGNED_BYTE; break; case 2: // half float point buffer internalFormat = m_numComponents == 4 ? GL_RGBA16F : GL_RGB16F; internalFormat = m_numComponents == 1 ? GL_R16F : internalFormat; type = GL_FLOAT; break; case 4: // floating point buffer internalFormat = m_numComponents == 4 ? GL_RGBA32F : GL_RGB32F; internalFormat = m_numComponents == 1 ? GL_R32F : internalFormat; type = GL_FLOAT; break; } // select format from RGBA, RGB or RED GLenum format = m_numComponents == 4 ? GL_RGBA : GL_RGB; format = m_numComponents == 1 ? GL_RED : format; glTexImage2D( GL_TEXTURE_2D, 0, internalFormat, (GLsizei)m_width, (GLsizei)m_height, 0, format, type, (GLvoid*)m_textureData); UnBind(); m_isOnGPU = true; }
bool CKeyBindings::Command(const string& line) { const vector<string> words = SimpleParser::Tokenize(line, 2); if (words.size() <= 0) { return false; } const string command = StringToLower(words[0]); if (command == "keydebug") { if (words.size() == 1) { debug = (debug <= 0) ? 1 : 0; } else if (words.size() >= 2) { debug = atoi(words[1].c_str()); } } else if ((command == "fakemeta") && (words.size() > 1)) { if (!SetFakeMetaKey(words[1])) { return false; } } else if ((command == "keyset") && (words.size() > 2)) { if (!AddNamedKeySet(words[1], words[2])) { return false; } } else if ((command == "keysym") && (words.size() > 2)) { if (!AddKeySymbol(words[1], words[2])) { return false; } } else if ((command == "bind") && (words.size() > 2)) { if (!Bind(words[1], words[2])) { return false; } } else if ((command == "unbind") && (words.size() > 2)) { if (!UnBind(words[1], words[2])) { return false; } } else if ((command == "unbindaction") && (words.size() > 1)) { if (!UnBindAction(words[1])) { return false; } } else if ((command == "unbindkeyset") && (words.size() > 1)) { if (!UnBindKeyset(words[1])) { return false; } } else if (command == "unbindall") { bindings.clear(); keyCodes->Reset(); namedKeySets.clear(); typeBindings.clear(); Bind("enter", "chat"); // bare minimum } else { return false; } if (userCommand) { Sanitize(); } return false; }
void OGLRenderTexture2D_ARB::MakeCurrent() { if( IsBinded() ) UnBind(); if( !wglMakeCurrent( mPixelBuffer.mDC, mPixelBuffer.mRC ) ) { MessageBox(NULL,"Could not make the window's context current!", "ERROR",MB_OK|MB_ICONEXCLAMATION); exit(-1); } }
void Texture3D::LoadTexture(int width, int height, int depth, const char *data, Format format, int stride /*= -1*/) { GLint glFormat; GLint glInternalFormat; int elementSize = 0; switch (format) { case RGB: elementSize = 3; glFormat = GL_RGB; glInternalFormat = GL_RGB8; break; case RGBA: elementSize = 4; glFormat = GL_RGBA; glInternalFormat = GL_RGBA8; break; case Red: elementSize = 1; glFormat = GL_RED; glInternalFormat = GL_R8; break; case USHORT_5_5_5_1: elementSize = 2; glFormat = GL_UNSIGNED_SHORT_5_5_5_1; glInternalFormat = GL_RGBA8; break; case USHORT_1_5_5_5: elementSize = 2; glFormat = GL_UNSIGNED_SHORT_1_5_5_5_REV; glInternalFormat = GL_RGBA8; break; default: throw GraphicsException(GL_INVALID_ENUM, "Texture format not recognized"); break; } if (stride == -1) { stride = width * elementSize; } // Generate an texture GL_CHECKED(glGenTextures(1, &_id)); Bind(); GL_CHECKED(glPixelStorei(GL_UNPACK_ROW_LENGTH, stride)); //GL_CHECKED(glTexImage3D(_type, 0, glInternalFormat, width, height, depth, 0, glFormat, GL_UNSIGNED_BYTE, data)); GL_CHECKED(glTexStorage3D(_type, 1, glInternalFormat, width, height, depth)); if (data != nullptr) { GL_CHECKED(glTexSubImage3D(_type, 0, 0, 0, 0, width, height, depth, glFormat, GL_UNSIGNED_BYTE, data)); } GL_CHECKED(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0)); UnBind(); }
void STTexture::LoadShortData(const short* data, int width, int height) { Bind(); mWidth = width; mHeight = height; glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, width, height, 0, GL_RED, GL_SHORT, data); UnBind(); }
void DepthStencilBuffer::BuildBuffer (int width, int height, const DepthStencilFormat &format) { Bind (); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D (GL_TEXTURE_2D,0,format.Format (),width, height,0,0,0,nullptr); UnBind (); }
bool CKeyBindings::ExecuteCommand(const std::string& line) { const std::vector<std::string> words = CSimpleParser::Tokenize(line, 2); if (words.empty()) { return false; } const std::string command = StringToLower(words[0]); if (command == "keydebug") { if (words.size() == 1) { // toggle debugEnabled = !debugEnabled; } else if (words.size() >= 2) { // set debugEnabled = atoi(words[1].c_str()); } } else if ((command == "fakemeta") && (words.size() > 1)) { if (!SetFakeMetaKey(words[1])) { return false; } } else if ((command == "keysym") && (words.size() > 2)) { if (!AddKeySymbol(words[1], words[2])) { return false; } } else if ((command == "bind") && (words.size() > 2)) { if (!Bind(words[1], words[2])) { return false; } } else if ((command == "unbind") && (words.size() > 2)) { if (!UnBind(words[1], words[2])) { return false; } } else if ((command == "unbindaction") && (words.size() > 1)) { if (!UnBindAction(words[1])) { return false; } } else if ((command == "unbindkeyset") && (words.size() > 1)) { if (!UnBindKeyset(words[1])) { return false; } } else if (command == "unbindall") { bindings.clear(); keyCodes->Reset(); Bind("enter", "chat"); // bare minimum } else { return false; } if (buildHotkeyMap) { BuildHotkeyMap(); } return false; }
void VertexArray::SetIndices(const void *indices, int ctIndices, GLenum type) { mCtIndices = ctIndices; mIndexType = type; mIBO.Destroy(); mIBO.Init(); Bind(); mIBO.Bind(); UnBind(); mIBO.SetData(ctIndices * SizeOfGLType(type), indices); }
void Texture3D::SetData (TextureDataFormat format, void *data) { Bind (); cout << &glTexSubImage3D << endl; cout << hex << format.Format () << ", " << hex << format.DataType () << endl; glTexSubImage3D (GL_TEXTURE_3D,0,0,0,0,_Width, _Height,_Depth,format.Format (),format.DataType (),data); GLErrorCheck (); if (Filtering () != TextureFiltering::None) { glGenerateMipmap (GL_TEXTURE_3D); GLErrorCheck (); } UnBind (); }
// this binds to the interface , and assigns to the interface handle void __stdcall Bind(const char * NetworkAddress, const char * EndPoint, const char * protocolSequence) { // avoid leaking handles ? if (StringBinding) UnBind(); RpcStringBindingCompose(NULL, (unsigned char *) protocolSequence, (unsigned char *) NetworkAddress, (unsigned char *) EndPoint, NULL, &StringBinding); RpcBindingFromStringBinding(StringBinding, &winamp_IfHandle); }
void FrameBuffer::AttachRBO() { if(mRBID == 0) { // Init RBO glGenRenderbuffers(1, &mRBID); glBindRenderbuffer(GL_RENDERBUFFER, mRBID); glRenderbufferStorage(GL_RENDERBUFFER, mRBDepth, mWidth, mHeight); glBindRenderbuffer(GL_RENDERBUFFER, 0); // Attach RBO Bind(); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRBID); UnBind(); } }
void Texture2D::Fill(unsigned char *newData, int width, int height, bool genMipMaps) { if (m_data && m_data != newData) delete m_data; m_data = newData; // TODO: Copy (?) m_width = width; m_height = height; Bind(); glTexImage2D(GL_TEXTURE_2D, 0, m_glInternalFormat, width, height, 0, m_glFormat, m_glType, m_data); if (genMipMaps) { glGenerateMipmap(GL_TEXTURE_2D); } UnBind(); }