/// <summary> /// Add hardware breakpoint to thread /// </summary> /// <param name="addr">Breakpoint address</param> /// <param name="type">Breakpoint type(read/write/execute)</param> /// <param name="length">Number of bytes to include into breakpoint</param> /// <returns>Index of used breakpoint; -1 if failed</returns> int Thread::AddHWBP( ptr_t addr, HWBPType type, HWBPLength length ) { _CONTEXT64 context; // CONTEXT_DEBUG_REGISTERS can be operated without thread suspension if (!GetContext( context, CONTEXT64_DEBUG_REGISTERS, true )) return -1; auto getFree = []( ptr_t regval ) { if (!(regval & 1)) return 0; else if (!(regval & 4)) return 1; else if (!(regval & 16)) return 2; else if (!(regval & 64)) return 3; return -1; }; // Get free DR int freeIdx = getFree( context.Dr7 ); // If all 4 registers are occupied - error if (freeIdx < 0) return -1; // Enable corresponding HWBP and local BP flag context.Dr7 |= (1 << (2 * freeIdx)) | ((int)type << (16 + 4 * freeIdx)) | ((int)length << (18 + 4 * freeIdx)) | 0x100; *(&context.Dr0 + freeIdx) = addr; // Write values to registers if (!SetContext( context, true )) return -1; return freeIdx; }
already_AddRefed<nsStyleContext> nsStyleSet::ResolveStyleForNonElement(nsStyleContext* aParentContext) { nsStyleContext* result = nsnull; nsPresContext *presContext = PresContext(); if (presContext) { if (mRuleProcessors[eAgentSheet] || mRuleProcessors[ePresHintSheet] || mRuleProcessors[eUserSheet] || mRuleProcessors[eHTMLPresHintSheet] || mRuleProcessors[eDocSheet] || mRuleProcessors[eStyleAttrSheet] || mRuleProcessors[eOverrideSheet]) { result = GetContext(presContext, aParentContext, nsCSSAnonBoxes::mozNonElement).get(); NS_ASSERTION(mRuleWalker->AtRoot(), "rule walker must be at root"); } } return result; }
void CRenderingContext::UseProgram(class CShader* pShader) { CRenderContext& oContext = GetContext(); oContext.m_pShader = m_pShader = pShader; if (!m_pShader) { oContext.m_szProgram[0] = '\0'; m_iProgram = 0; glUseProgram(0); return; } tstrncpy(oContext.m_szProgram, PROGRAM_LEN, pShader->m_sName.c_str(), PROGRAM_LEN); m_iProgram = m_pShader->m_iProgram; glUseProgram((GLuint)m_pShader->m_iProgram); oContext.m_bProjectionUpdated = false; oContext.m_bViewUpdated = false; }
// -------------------------------------------------------------- void GFontWin32GDIPlus::GetExtent( unsigned char c, float * outWidth, float * outHeight, VGDevice * context ) const { WCHAR wstr [] = L"0"; mbstowcs(wstr, (const char*)&c, 1); Graphics* gdiContext = (Graphics*) GetContext( context ); /* -- known Gdi+ issue: We must use the following way to determine correct font extent because typical Graphics::MeasureString() method doesn't work properly (return values are incorrect due to antialiasing) */ Font* dgiFont = GetNativeFont(); // Layout rectangles used for drawing strings RectF layoutRect_A(0.0f, 0.0f, 1300.0f, 1300.0f); // 1 range of character positions within the string CharacterRange charRange(0, 1); // String format used to apply to string when drawing StringFormat strFormat; // Set three ranges of character positions. strFormat.SetMeasurableCharacterRanges(1, &charRange); Region *pCharRangeRegions = new Region(); // Get the regions that correspond to the ranges within the string when // layout rectangle A is used. gdiContext->MeasureCharacterRanges( wstr, 1, dgiFont, layoutRect_A, &strFormat, 1, pCharRangeRegions); RectF boundRect; pCharRangeRegions->GetBounds( &boundRect, gdiContext); *outHeight = boundRect.Height; *outWidth = boundRect.Width; // in some cases (when some symbols must be forced into char map), extent needs to be fixed if (c == 139) *outWidth = 6.0; }
void Image::Draw() { const Point &offset = GetActiveOffset(); const Point &area = GetActiveArea(); const float x = offset.x; const float y = offset.y; const float sx = area.x; const float sy = area.y; const vector2f texSize = m_texture->GetDescriptor().texSize; Graphics::VertexArray va(Graphics::ATTRIB_POSITION | Graphics::ATTRIB_UV0); va.Add(vector3f(x, y, 0.0f), vector2f(0.0f, 0.0f)); va.Add(vector3f(x, y+sy, 0.0f), vector2f(0.0f, texSize.y)); va.Add(vector3f(x+sx, y, 0.0f), vector2f(texSize.x, 0.0f)); va.Add(vector3f(x+sx, y+sy, 0.0f), vector2f(texSize.x, texSize.y)); Graphics::Renderer *r = GetContext()->GetRenderer(); r->SetBlendMode(Graphics::BLEND_ALPHA); r->DrawTriangles(&va, m_material.Get(), Graphics::TRIANGLE_STRIP); }
void tui::LayoutCanvas::OnresizeGL(wxSizeEvent& event) { // this is also necessary to update the context on some platforms wxGLCanvas::OnSize(event); // set GL viewport (not called by wxGLCanvas::OnSize on all platforms...) int w, h; GetClientSize(&w, &h); #ifndef __WXMOTIF__ if (GetContext()) #endif { SetCurrent(); glViewport( 0, 0, (GLint)w, (GLint)h ); } lp_BL = TP(0,0) * _LayCTM; lp_TR = TP(w, h) * _LayCTM; // glMatrixMode( GL_PROJECTION ); // glLoadIdentity(); // glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 15.0 ); glMatrixMode( GL_MODELVIEW ); glClear(GL_ACCUM_BUFFER_BIT); invalid_window = true; }
// Destroy the specified rendering context. EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { EGL_API_ENTRY("%p, %p", dpy, ctx); EglDisplayImpl* display = EglDisplayImpl::GetDisplay(dpy); if (display == NULL || display->IsInitialized() == false) { SetError(EGL_BAD_DISPLAY); return EGL_FALSE; } ContextPtr context = display->GetContexts().Get(ctx); if (context == NULL) { return EGL_BAD_CONTEXT; } if (GetContext() == context) { display->MakeCurrent(EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE); } context->Release(); display->GetContexts().Unregister(ctx); return EGL_TRUE; }
void Gradient::Draw() { const Point &offset = GetActiveOffset(); const Point &area = GetActiveArea(); const float x = offset.x; const float y = offset.y; const float sx = area.x; const float sy = area.y; Graphics::VertexArray va(Graphics::ATTRIB_POSITION | Graphics::ATTRIB_DIFFUSE); va.Add(vector3f(x, y, 0.0f), m_beginColor); va.Add(vector3f(x, y+sy, 0.0f), m_direction == HORIZONTAL ? m_beginColor : m_endColor); va.Add(vector3f(x+sx, y, 0.0f), m_direction == HORIZONTAL ? m_endColor : m_beginColor); va.Add(vector3f(x+sx, y+sy, 0.0f), m_endColor); Graphics::Renderer *r = GetContext()->GetRenderer(); r->SetBlendMode(Graphics::BLEND_ALPHA); r->DrawTriangles(&va, m_material.Get(), Graphics::TRIANGLE_STRIP); Container::Draw(); }
Sink& BufferSink::MapEntry(Term& key, Term& value) { Term& t = *(terms.back()); Term& newmap = t.MapPutValue(GetContext(), key, value); if (&newmap != &t) { terms.pop_back(); if (terms.empty()) term = &newmap; else { subIndex.pop_back(); int subindex = subIndex.back(); Term& parent = *(terms.back()); parent.SetSub(subindex - 1, newmap); subIndex.push_back(0); } terms.push_back(&newmap); } return *this; }
void DisplayWindow::SetupView(int picking, int x, int y) { GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); int w,h; GetClientSize(&w, &h); if (!GetContext()) return; SetCurrent(); float aspect = (float)w/h; glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (picking) gluPickMatrix(x,viewport[3] - y,5.0,5.0,viewport); glFrustum(-0.5, 0.5, -0.5/aspect, 0.5/aspect, 0.5, 10.0 ); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef( 0.0, 0.0, zoom); glRotatef(yrot,0.0,1.0,0.0); glRotatef(xrot,1.0,0.0,0.0); }
void Urho2DPlatformer::Start() { // Execute base class startup Sample::Start(); sample2D_ = new Sample2D(context_); // Set filename for load/save functions sample2D_->demoFilename_ = "Platformer2D"; // Create the scene content CreateScene(); // Create the UI content sample2D_->CreateUIContent("PLATFORMER 2D DEMO", character2D_->remainingLifes_, character2D_->remainingCoins_); auto* ui = GetContext()->m_UISystem.get(); Button* playButton = static_cast<Button*>(ui->GetRoot()->GetChild("PlayButton", true)); playButton->released.Connect(this,&Urho2DPlatformer::HandlePlayButton); // Hook up to the frame update events SubscribeToEvents(); }
static void Quartz_Polygon(int n, double *x, double *y, R_GE_gcontext *gc, NewDevDesc *dd) { int i; QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific; CGPoint *lines; CGContextSaveGState( GetContext(xd) ); CGContextBeginPath( GetContext(xd) ); /* Quartz_SetLineProperties(gc, dd); */ lines = (CGPoint *)malloc(sizeof(CGPoint)*(n+1)); if(lines == NULL) return; for (i = 0; i < n; i++) { lines[i].x = (float)x[i]; lines[i].y = (float)y[i]; } lines[n].x = (float)x[0]; lines[n].y = (float)y[0]; CGContextAddLines( GetContext(xd), &lines[0], n+1 ); Quartz_SetLineProperties(gc, dd); Quartz_SetFill( gc->fill, gc->gamma, dd); CGContextFillPath( GetContext(xd) ); CGContextAddLines( GetContext(xd), &lines[0], n+1 ); Quartz_SetStroke( gc->col, gc->gamma, dd); CGContextStrokePath( GetContext(xd) ); CGContextRestoreGState( GetContext(xd) ); }
void Slider::HandleMouseMove(const MouseMotionEvent &event) { const Skin &skin = GetContext()->GetSkin(); if (m_buttonDown && IsMouseActive()) { float travel; if (m_orient == SLIDER_HORIZONTAL) { const Skin::EdgedRectElement &gutterRect = skin.SliderHorizontalGutter(); const Skin::RectElement &buttonRect = skin.SliderHorizontalButtonNormal(); const int effectiveLength = GetActiveArea().x - gutterRect.edgeWidth*2 - buttonRect.size.x; const int pos = Clamp(event.pos.x - int(gutterRect.edgeWidth) - buttonRect.size.x/2 - GetActiveOffset().x, 0, effectiveLength); travel = float(pos) / effectiveLength; } else { const Skin::EdgedRectElement &gutterRect = skin.SliderVerticalGutter(); const Skin::RectElement &buttonRect = skin.SliderVerticalButtonNormal(); const int effectiveLength = GetActiveArea().y - gutterRect.edgeWidth*2 - buttonRect.size.y; const int pos = Clamp(event.pos.y - int(gutterRect.edgeWidth) - buttonRect.size.y/2 - GetActiveOffset().y, 0, effectiveLength); travel = float(pos) / effectiveLength; } SetValue(travel); } else { m_lastMousePosition = event.pos; m_mouseOverButton = PointInsideButton(event.pos); } Widget::HandleMouseMove(event); }
void TestGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) ) { // must always be here wxPaintDC dc(this); #ifndef __WXMOTIF__ if (!GetContext()) return; #endif SetCurrent(); // Initialize OpenGL if (!m_gldata.initialized) { InitGL(); ResetProjectionMode(); m_gldata.initialized = true; } // Clear glClearColor( 0.3f, 0.4f, 0.6f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Transformations glLoadIdentity(); glTranslatef( 0.0f, 0.0f, -20.0f ); GLfloat m[4][4]; build_rotmatrix( m, m_gldata.quat ); glMultMatrixf( &m[0][0] ); m_renderer.Render(); // Flush glFlush(); // Swap SwapBuffers(); }
/*--------------------------------------------------------------------------------*/ void ABlowfish::Encrypt(const uint8_t *src, uint8_t *dst, uint32_t& iv1, uint32_t& iv2) { BLOWFISH_CTX *ctx = (BLOWFISH_CTX *)GetContext(); uint32_t l, r; // copy bytes into 2 32-bit variables memcpy(&l, src, sizeof(l)); src += sizeof(l); memcpy(&r, src, sizeof(r)); // for little endian machines, swap bytes to make all data big-endian if (!MachineIsBigEndian()) { l = SwapBytes(l); r = SwapBytes(r); } // XOR in initialisation vectors (for CBC mode) l ^= iv1; r ^= iv2; // encrypt data Blowfish_Encrypt(ctx, &l, &r); // return new initialisation vectors (for CBC mode) iv1 = l; iv2 = r; // for little endian machines, swap bytes back to make all data little-endian if (!MachineIsBigEndian()) { l = SwapBytes(l); r = SwapBytes(r); } // copy bytes to destination memcpy(dst, &l, sizeof(l)); dst += sizeof(l); memcpy(dst, &r, sizeof(r)); l = r = 0; // clear local variables to prevent security leaks }
// Create a reusable EGL sync object. EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint* attrib_list) { EGL_API_ENTRY("%p, 0x%x, %p", dpy, type, attrib_list); EglDisplayImpl* display = EglDisplayImpl::GetDisplay(dpy); if (display == NULL) { SetError(EGL_BAD_DISPLAY); return EGL_NO_SYNC_KHR; } if (type != EGL_SYNC_FENCE_KHR || (attrib_list != NULL && attrib_list[0] != EGL_NONE)) { SetError(EGL_BAD_ATTRIBUTE); return EGL_NO_SYNC_KHR; } ContextPtr context = GetContext(); if (context == NULL) { SetError(EGL_BAD_MATCH); return EGL_NO_SYNC_KHR; } glFinish(); return kFenceSyncHandle; }
void LoadScriptL(CLocaLogic* cl, const TDesC& aScriptName) { TFileName fn=_L("c:\\system\\data\\context\\scripts\\"); fn.Append(aScriptName); RAFile f; f.OpenLA(GetContext()->Fs(), fn, EFileRead|EFileShareAny); TBuf8<256> buf8; TBuf<256> buf; _LIT(KScript, "script"); auto_ptr<CBBString> ss(CBBString::NewL(KScript)); while (f.Read(buf8)==KErrNone && buf8.Length()>0) { buf.Copy(buf8); ss->Append(buf); } if (aScriptName[0]=='_') { TPtrC script=aScriptName.Left(aScriptName.Length()-3); cl->NewScriptL(script, ss.get()); } else { TPtrC tp=aScriptName.Mid(4); TPtrC script=tp.Left(tp.Length()-3); cl->NewScriptL(script, ss.get()); } }
void SwrSync(HANDLE hContext, PFN_CALLBACK_FUNC pfnFunc, uint64_t userData, uint64_t userData2) { RDTSC_START(APISync); SWR_CONTEXT *pContext = GetContext(hContext); DRAW_CONTEXT* pDC = GetDrawContext(pContext); pDC->inUse = true; pDC->FeWork.type = SYNC; pDC->FeWork.pfnWork = ProcessSync; pDC->FeWork.desc.sync.pfnCallbackFunc = pfnFunc; pDC->FeWork.desc.sync.userData = userData; pDC->FeWork.desc.sync.userData2 = userData2; // cannot execute until all previous draws have completed pDC->dependency = pDC->drawId - 1; //enqueue QueueDraw(pContext); RDTSC_STOP(APISync, 1, 0); }
HANDLE LogStartAny(TInt aOp) { CApp_context *c=(CApp_context *)GetContext(); if (!c) return INVALID_HANDLE_VALUE; HANDLE logfile=c->iHookData; if (!logfile) { TBuf<100> filen=_L("c:\\"); filen.Append(c->Name()); filen.Append(_L("-alloctrace.dat")); logfile=CreateFile( filen.PtrZ(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 ); c->iHookData=logfile; } if (logfile==INVALID_HANDLE_VALUE) return logfile; DWORD written; BOOL ret; DWORD err; ret=WriteFile(logfile, &aOp, sizeof(aOp), &written, 0); if (!ret) err=GetLastError(); const TDesC8& stack=c->FullCallStackBuffer(); TInt len=stack.Length(); ret=WriteFile(logfile, &len, sizeof(len), &written, 0); ret=WriteFile(logfile, stack.Ptr(), stack.Length(), &written, 0); return logfile; }
size_t TerminalDisplay::WriteWrapped(Range::EPromptUpdate PromptUpdate, bool hidden, size_t Offset, size_t Requested /* = -1*/) { Attach(); const Text& Prompt = GetContext()->GetPrompt(); size_t PromptLen = GetContext()->GetPrompt().length(); const Text& EditPrompt = GetContext()->GetEditor()->GetEditorPrompt(); size_t EditorPromptLen = EditPrompt.length(); if (!IsTTY()) { PromptLen = 0; EditorPromptLen = 0; PromptUpdate = Range::kNoPromptUpdate; } if (PromptUpdate & Range::kUpdatePrompt) { // Writing from front means we write the prompt, too Move(Pos()); WriteWrappedElement(Prompt, 0, 0, PromptLen); } if (PromptUpdate != Range::kNoPromptUpdate) { // Any prompt update means we'll have to re-write the editor prompt Move(IndexToPos(PromptLen)); if (EditorPromptLen) { WriteWrappedElement(EditPrompt, 0, PromptLen, EditorPromptLen); } // Any prompt update means we'll have to re-write the text Offset = 0; Requested = (size_t) -1; } Move(IndexToPos(PromptLen + EditorPromptLen + Offset)); size_t avail = 0; if (hidden) { Text hide(std::string(GetContext()->GetLine().length(), '*'), 0); avail = WriteWrappedElement(hide, Offset, PromptLen + EditorPromptLen, Requested); } else { avail = WriteWrappedElement(GetContext()->GetLine(), Offset, PromptLen + EditorPromptLen, Requested); } fWriteLen = PromptLen + EditorPromptLen + GetContext()->GetLine().length(); return avail; }
void Button::Layout() { Widget *innerWidget = GetInnerWidget(); if (!innerWidget) { SetActiveArea(Point(GetContext()->GetSkin().ButtonMinInnerSize()) + Point(GetContext()->GetSkin().ButtonNormal().borderWidth*2)); return; } const Point innerSize = GetSize() - Point(GetContext()->GetSkin().ButtonNormal().borderWidth*2); SetWidgetDimensions(innerWidget, Point(GetContext()->GetSkin().ButtonNormal().borderWidth), CalcSize(innerWidget, innerSize)); innerWidget->Layout(); Point innerActiveArea(innerWidget->GetActiveArea()); growToMinimum(innerActiveArea, GetContext()->GetSkin().ButtonMinInnerSize()); SetActiveArea(innerActiveArea + Point(GetContext()->GetSkin().ButtonNormal().borderWidth*2)); }
void CheckBox::Draw() { if (m_checked) { if (IsDisabled()) GetContext()->GetSkin().DrawCheckBoxCheckedDisabled(GetActiveOffset(), GetActiveArea()); else if (IsMouseOver()) GetContext()->GetSkin().DrawCheckBoxCheckedHover(GetActiveOffset(), GetActiveArea()); else GetContext()->GetSkin().DrawCheckBoxCheckedNormal(GetActiveOffset(), GetActiveArea()); } else { if (IsDisabled()) GetContext()->GetSkin().DrawCheckBoxDisabled(GetActiveOffset(), GetActiveArea()); else if (IsMouseOver()) GetContext()->GetSkin().DrawCheckBoxHover(GetActiveOffset(), GetActiveArea()); else GetContext()->GetSkin().DrawCheckBoxNormal(GetActiveOffset(), GetActiveArea()); } }
void Slider::Draw() { const Skin &skin = GetContext()->GetSkin(); if (m_orient == SLIDER_HORIZONTAL) { skin.DrawSliderHorizontalGutter(m_gutterPos, m_gutterSize); if (m_buttonDown && IsMouseActive()) skin.DrawSliderHorizontalButtonActive(m_buttonPos, m_buttonSize); else if (m_mouseOverButton) skin.DrawSliderHorizontalButtonHover(m_buttonPos, m_buttonSize); else skin.DrawSliderHorizontalButtonNormal(m_buttonPos, m_buttonSize); } else { skin.DrawSliderVerticalGutter(m_gutterPos, m_gutterSize); if (m_buttonDown && IsMouseActive()) skin.DrawSliderVerticalButtonActive(m_buttonPos, m_buttonSize); else if (m_mouseOverButton) skin.DrawSliderVerticalButtonHover(m_buttonPos, m_buttonSize); else skin.DrawSliderVerticalButtonNormal(m_buttonPos, m_buttonSize); } }
// Creates a new element context. Context* CreateContext(const String& name, const Vector2i& dimensions, RenderInterface* custom_render_interface) { if (!initialised) return NULL; if (custom_render_interface == NULL && render_interface == NULL) Log::Message(Log::LT_WARNING, "Failed to create context '%s', no render interface specified and no default render interface exists.", name.CString()); if (GetContext(name) != NULL) { Log::Message(Log::LT_WARNING, "Failed to create context '%s', context already exists.", name.CString()); return NULL; } Context* new_context = Factory::Instance()->InstanceContext(name); if (new_context == NULL) { Log::Message(Log::LT_WARNING, "Failed to instance context '%s', instancer returned NULL.", name.CString()); return NULL; } // Set the render interface on the context, and add a reference onto it. if (custom_render_interface) new_context->render_interface = custom_render_interface; else new_context->render_interface = render_interface; new_context->render_interface->AddReference(); new_context->SetDimensions(dimensions); contexts[name] = new_context; PluginRegistry::Instance()->NotifyContextCreate(new_context); return new_context; }
void SwrSetLinkage( HANDLE hContext, uint32_t mask, const uint8_t* pMap) { API_STATE* pState = GetDrawState(GetContext(hContext)); static const uint8_t IDENTITY_MAP[] = { 0, 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, }; static_assert(sizeof(IDENTITY_MAP) == sizeof(pState->linkageMap), "Update for new value of MAX_ATTRIBUTES"); pState->linkageMask = mask; pState->linkageCount = _mm_popcnt_u32(mask); if (!pMap) { pMap = IDENTITY_MAP; } memcpy(pState->linkageMap, pMap, pState->linkageCount); }
void CRenderingContext::EndRenderVertexArrayIndexed(size_t iBuffer, size_t iVertices) { CRenderContext& oContext = GetContext(); if (!oContext.m_bProjectionUpdated) SetUniform("mProjection", oContext.m_mProjection); if (!oContext.m_bViewUpdated) SetUniform("mView", oContext.m_mView); if (!oContext.m_bTransformUpdated) SetUniform("mGlobal", oContext.m_mTransformations); oContext.m_bProjectionUpdated = oContext.m_bViewUpdated = oContext.m_bTransformUpdated = true; glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iBuffer); glDrawElements(r_wireframe.GetBool()?GL_LINES:GL_TRIANGLES, iVertices, GL_UNSIGNED_INT, nullptr); glDisableVertexAttribArray(m_pShader->m_iPositionAttribute); for (size_t i = 0; i < MAX_TEXTURE_CHANNELS; i++) { if (m_pShader->m_aiTexCoordAttributes[i] != ~0) glDisableVertexAttribArray(m_pShader->m_aiTexCoordAttributes[i]); } if (m_pShader->m_iNormalAttribute != ~0) glDisableVertexAttribArray(m_pShader->m_iNormalAttribute); if (m_pShader->m_iTangentAttribute != ~0) glDisableVertexAttribArray(m_pShader->m_iTangentAttribute); if (m_pShader->m_iBitangentAttribute != ~0) glDisableVertexAttribArray(m_pShader->m_iBitangentAttribute); if (m_pShader->m_iColorAttribute != ~0) glDisableVertexAttribArray(m_pShader->m_iColorAttribute); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); }
SAnchor& CEmbodiedEntity::AddAnchor(const std::string& str_id, const CVector3& c_offset_position, const CQuaternion& c_offset_orientation) { /* Make sure the anchor id is unique */ if(m_mapAnchors.count(str_id) > 0 ) { THROW_ARGOSEXCEPTION("Embodied entity \"" << GetContext() + GetId() << "\" already has an anchor with id " << str_id); } /* Calculate anchor position */ CVector3 cPos = c_offset_position; cPos.Rotate(m_psOriginAnchor->Orientation); cPos += m_psOriginAnchor->Position; /* Calculate anchor orientation */ CQuaternion cOrient = m_psOriginAnchor->Orientation * c_offset_orientation; /* Create anchor */ SAnchor* psAnchor = new SAnchor(str_id, m_mapAnchors.size(), c_offset_position, c_offset_orientation, cPos, cOrient); /* Add anchor to map */ m_mapAnchors[str_id] = psAnchor; return *psAnchor; }
BOOL CSSLContext::Initialize(EnSSLSessionMode enSessionMode, int iVerifyMode, LPCTSTR lpszPemCertFile, LPCTSTR lpszPemKeyFile, LPCTSTR lpszKeyPasswod, LPCTSTR lpszCAPemCertFileOrPath, HP_Fn_SNI_ServerNameCallback fnServerNameCallback) { ASSERT(!IsValid()); if(IsValid()) { ::SetLastError(ERROR_INVALID_STATE); return FALSE; } m_enSessionMode = enSessionMode; if(AddContext(iVerifyMode, lpszPemCertFile, lpszPemKeyFile, lpszKeyPasswod, lpszCAPemCertFileOrPath) == 0) m_sslCtx = GetContext(0); else { Cleanup(); return FALSE; } SetServerNameCallback(fnServerNameCallback); return TRUE; }
void wxCoreGLCanvas::ResizeGL(void) { // set GL viewport (not called by wxGLCanvas::OnSize on all platforms...) wxInt32 w, h; GetClientSize(&w, &h); if (GetContext()) { SetCurrent(); glViewport(0, 0, (GLint) w, (GLint) h); //select the projection matrix and reset it glMatrixMode(GL_PROJECTION); glLoadIdentity(); //calculate the aspect ratio GLfloat dAspect; dAspect = (GLfloat) w / (GLfloat) h; gluPerspective(45.0f, dAspect, 0.1, 250.); //reset the modelview matrix glMatrixMode(GL_MODELVIEW); } }
void Slider::UpdateButton() { const Skin &skin = GetContext()->GetSkin(); const Point activeArea(GetActiveArea()); if (m_orient == SLIDER_HORIZONTAL) { const Skin::EdgedRectElement &gutterRect = skin.SliderHorizontalGutter(); const Skin::RectElement &buttonRect = skin.SliderHorizontalButtonNormal(); m_buttonSize = Point(buttonRect.size.x, buttonRect.size.y); m_buttonPos = Point(((activeArea.x-gutterRect.edgeWidth*2-buttonRect.size.x)*m_value)+gutterRect.edgeWidth, (activeArea.y-buttonRect.size.y)/2); } else { const Skin::EdgedRectElement &gutterRect = skin.SliderVerticalGutter(); const Skin::RectElement &buttonRect = skin.SliderVerticalButtonNormal(); m_buttonSize = Point(buttonRect.size.x, buttonRect.size.y); m_buttonPos = Point((activeArea.x-buttonRect.size.x)/2, ((activeArea.y-gutterRect.edgeWidth*2-buttonRect.size.y)*m_value)+gutterRect.edgeWidth); } m_mouseOverButton = IsMouseOver() && PointInsideButton(m_lastMousePosition); }