本文整理匯總了C++中GetContext函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetContext函數的具體用法?C++ GetContext怎麽用?C++ GetContext使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetContext函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: AddHWBP
/// <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;
}
示例2: PresContext
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;
}
示例3: GetContext
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;
}
示例4: mbstowcs
// --------------------------------------------------------------
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;
}
示例5: GetActiveOffset
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);
}
示例6: GetClientSize
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;
}
示例7: eglDestroyContext
// 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;
}
示例8: GetActiveOffset
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();
}
示例9:
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;
}
示例10: glGetIntegerv
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);
}
示例11: Sample2D
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();
}
示例12: Quartz_Polygon
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) );
}
示例13: GetContext
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);
}
示例14: WXUNUSED
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();
}
示例15: Encrypt
/*--------------------------------------------------------------------------------*/
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
}