本文整理汇总了C++中CommonInit函数的典型用法代码示例。如果您正苦于以下问题:C++ CommonInit函数的具体用法?C++ CommonInit怎么用?C++ CommonInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CommonInit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main(int argc, char *argv[])
{
int fsaa, accel;
int value;
int i, done;
SDL_DisplayMode mode;
SDL_Event event;
Uint32 then, now, frames;
int status;
/* Initialize parameters */
fsaa = 0;
accel = 0;
/* Initialize test framework */
state = CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {
return 1;
}
for (i = 1; i < argc;) {
int consumed;
consumed = CommonArg(state, i);
if (consumed == 0) {
if (SDL_strcasecmp(argv[i], "--fsaa") == 0) {
++fsaa;
consumed = 1;
} else if (SDL_strcasecmp(argv[i], "--accel") == 0) {
++accel;
consumed = 1;
} else {
consumed = -1;
}
}
if (consumed < 0) {
fprintf(stderr, "Usage: %s %s [--fsaa] [--accel]\n", argv[0],
CommonUsage(state));
quit(1);
}
i += consumed;
}
/* Set OpenGL parameters */
state->window_flags |= SDL_WINDOW_OPENGL;
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
if (fsaa) {
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
}
if (accel) {
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
}
if (!CommonInit(state)) {
quit(2);
}
context=SDL_calloc(state->num_windows, sizeof(SDL_GLContext));
if (context==NULL)
{
fprintf(stderr, "Out of memory!\n");
quit(2);
}
/* Create OpenGL ES contexts */
for (i=0; i<state->num_windows; i++)
{
context[i] = SDL_GL_CreateContext(state->windows[i]);
if (!context[i]) {
fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
quit(2);
}
}
if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) {
SDL_GL_SetSwapInterval(1);
} else {
SDL_GL_SetSwapInterval(0);
}
SDL_GetCurrentDisplayMode(&mode);
printf("Screen BPP: %d\n", SDL_BITSPERPIXEL(mode.format));
printf("\n");
printf("Vendor : %s\n", glGetString(GL_VENDOR));
printf("Renderer : %s\n", glGetString(GL_RENDERER));
printf("Version : %s\n", glGetString(GL_VERSION));
printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
printf("\n");
status=SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
if (!status) {
printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
} else {
fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
}
status=SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
if (!status) {
//.........这里部分代码省略.........
示例2: Open
/**
* It creates a Direct3D vout display.
*/
static int Open(vlc_object_t *object)
{
vout_display_t *vd = (vout_display_t *)object;
vout_display_sys_t *sys;
/* Allocate structure */
vd->sys = sys = calloc(1, sizeof(vout_display_sys_t));
if (!sys)
return VLC_ENOMEM;
if (Direct3DCreate(vd)) {
msg_Err(vd, "Direct3D could not be initialized");
Direct3DDestroy(vd);
free(sys);
return VLC_EGENERIC;
}
sys->use_desktop = var_CreateGetBool(vd, "video-wallpaper");
sys->reset_device = false;
sys->reset_device = false;
sys->allow_hw_yuv = var_CreateGetBool(vd, "directx-hw-yuv");
sys->desktop_save.is_fullscreen = vd->cfg->is_fullscreen;
sys->desktop_save.is_on_top = false;
sys->desktop_save.win.left = var_InheritInteger(vd, "video-x");
sys->desktop_save.win.right = vd->cfg->display.width;
sys->desktop_save.win.top = var_InheritInteger(vd, "video-y");
sys->desktop_save.win.bottom = vd->cfg->display.height;
if (CommonInit(vd))
goto error;
/* */
video_format_t fmt;
if (Direct3DOpen(vd, &fmt)) {
msg_Err(vd, "Direct3D could not be opened");
goto error;
}
/* */
vout_display_info_t info = vd->info;
info.is_slow = true;
info.has_double_click = true;
info.has_hide_mouse = false;
info.has_pictures_invalid = true;
info.has_event_thread = true;
if (var_InheritBool(vd, "direct3d-hw-blending") &&
sys->d3dregion_format != D3DFMT_UNKNOWN &&
(sys->d3dcaps.SrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) &&
(sys->d3dcaps.DestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) &&
(sys->d3dcaps.TextureCaps & D3DPTEXTURECAPS_ALPHA) &&
(sys->d3dcaps.TextureOpCaps & D3DTEXOPCAPS_SELECTARG1) &&
(sys->d3dcaps.TextureOpCaps & D3DTEXOPCAPS_MODULATE))
info.subpicture_chromas = d3d_subpicture_chromas;
else
info.subpicture_chromas = NULL;
/* Interaction */
vlc_mutex_init(&sys->lock);
sys->ch_desktop = false;
sys->desktop_requested = sys->use_desktop;
vlc_value_t val;
val.psz_string = _("Desktop");
var_Change(vd, "video-wallpaper", VLC_VAR_SETTEXT, &val, NULL);
var_AddCallback(vd, "video-wallpaper", DesktopCallback, NULL);
/* Setup vout_display now that everything is fine */
vd->fmt = fmt;
vd->info = info;
vd->pool = Pool;
vd->prepare = Prepare;
vd->display = Display;
vd->control = Control;
vd->manage = Manage;
/* Fix state in case of desktop mode */
if (sys->use_desktop && vd->cfg->is_fullscreen)
vout_display_SendEventFullscreen(vd, false);
return VLC_SUCCESS;
error:
Direct3DClose(vd);
CommonClean(vd);
Direct3DDestroy(vd);
free(vd->sys);
return VLC_EGENERIC;
}
示例3: idWindow
idFieldWindow::idFieldWindow( idUserInterfaceLocal *g ) : idWindow( g )
{
gui = g;
CommonInit();
}
示例4: CommonInit
ImageDrawingArea::ImageDrawingArea()
{
CommonInit();
}
示例5: m_Impl
CBCGPropertySheet::CBCGPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage),
m_Impl (*this)
{
CommonInit ();
}
示例6: Open
static int Open(vlc_object_t *object)
{
vout_display_t *vd = (vout_display_t *)object;
vout_display_sys_t *sys;
vd->sys = sys = calloc(1, sizeof(*sys));
if (!sys)
return VLC_ENOMEM;
#ifdef MODULE_NAME_IS_wingapi
/* Load GAPI */
sys->gapi_dll = LoadLibrary(_T("GX.DLL"));
if (!sys->gapi_dll) {
msg_Warn(vd, "failed loading gx.dll");
free(sys);
return VLC_EGENERIC;
}
GXOpenDisplay = (void *)GetProcAddress(sys->gapi_dll,
_T("[email protected]@[email protected]@[email protected]"));
GXCloseDisplay = (void *)GetProcAddress(sys->gapi_dll,
_T("[email protected]@YAHXZ"));
GXBeginDraw = (void *)GetProcAddress(sys->gapi_dll,
_T("[email protected]@YAPAXXZ"));
GXEndDraw = (void *)GetProcAddress(sys->gapi_dll,
_T("[email protected]@YAHXZ"));
GXGetDisplayProperties = (void *)GetProcAddress(sys->gapi_dll,
_T("[email protected]@[email protected]@XZ"));
GXSuspend = (void *)GetProcAddress(sys->gapi_dll,
_T("[email protected]@YAHXZ"));
GXResume = GetProcAddress(sys->gapi_dll,
_T("[email protected]@YAHXZ"));
if (!GXOpenDisplay || !GXCloseDisplay ||
!GXBeginDraw || !GXEndDraw ||
!GXGetDisplayProperties || !GXSuspend || !GXResume) {
msg_Err(vd, "failed GetProcAddress on gapi.dll");
free(sys);
return VLC_EGENERIC;
}
msg_Dbg(vd, "GAPI DLL loaded");
#endif
if (CommonInit(vd))
goto error;
/* */
video_format_t fmt = vd->fmt;
if (Init(vd, &fmt, fmt.i_width, fmt.i_height))
goto error;
vout_display_info_t info = vd->info;
info.is_slow = false;
info.has_double_click = true;
info.has_hide_mouse = false;
info.has_pictures_invalid = true;
/* */
vd->fmt = fmt;
vd->info = info;
vd->pool = Pool;
vd->prepare = NULL;
vd->display = Display;
vd->manage = Manage;
vd->control = Control;
return VLC_SUCCESS;
error:
Close(VLC_OBJECT(vd));
return VLC_EGENERIC;
}
示例7: spMsgOut
HRESULT CTestClientLogic::TestBehaviorAndFiltering(bool fBehaviorTest, NatBehavior behavior, bool fFilteringTest, NatFiltering filtering)
{
HRESULT hr = S_OK;
StunClientLogicConfig config;
HRESULT hrRet;
uint32_t time = 0;
CRefCountedBuffer spMsgOut(new CBuffer(MAX_STUN_MESSAGE_SIZE));
CRefCountedBuffer spMsgResponse(new CBuffer(MAX_STUN_MESSAGE_SIZE));
SocketRole outputRole;
CSocketAddress addrDummy;
StunMessageIn stunmsgIn;
StunMessageOut stunmsgOut;
CSocketAddress addrDest;
CSocketAddress addrMapped;
CSocketAddress addrServerResponse; // what address the fake server responded back on
StunClientResults results;
StunTransactionId transid= {};
//std::string strAddr;
ChkA(CommonInit(behavior, filtering));
config.addrServer = _addrServerPP;
config.fBehaviorTest = fBehaviorTest;
config.fFilteringTest = fFilteringTest;
config.timeoutSeconds = 5;
config.uMaxAttempts = 10;
ChkA(_spClientLogic->Initialize(config));
while (true)
{
CStunMessageReader reader;
bool fDropMessage = false;
time += 1000;
hrRet = _spClientLogic->GetNextMessage(spMsgOut, &addrDest, time);
if (hrRet == E_STUNCLIENT_STILL_WAITING)
{
//printf("GetNextMessage returned 'still waiting'\n");
continue;
}
if (hrRet == E_STUNCLIENT_RESULTS_READY)
{
//printf("GetNextMessage returned 'results ready'\n");
break;
}
//addrDest.ToString(&strAddr);
//printf("Client is sending stun packet to %s\n", strAddr.c_str());
ChkA(GetMappedAddressForDestinationAddress(addrDest, &addrMapped));
//addrMapped.ToString(&strAddr);
//printf("Server is receiving stun packet from %s\n", strAddr.c_str());
ChkA(ValidateBindingRequest(spMsgOut, &transid));
// --------------------------------------------------
reader.AddBytes(spMsgOut->GetData(), spMsgOut->GetSize());
ChkIfA(reader.GetState() != CStunMessageReader::BodyValidated, E_UNEXPECTED);
// Simulate sending the binding request and getting a response back
stunmsgIn.socketrole = GetSocketRoleForDestinationAddress(addrDest);
stunmsgIn.addrLocal = addrDest;
stunmsgIn.addrRemote = addrMapped;
stunmsgIn.fConnectionOriented = false;
stunmsgIn.pReader = &reader;
stunmsgOut.socketrole = (SocketRole)-1; // intentionally setting it wrong
stunmsgOut.addrDest = addrDummy; // we don't care what address the server sent back to
stunmsgOut.spBufferOut = spMsgResponse;
spMsgResponse->SetSize(0);
ChkA(::CStunRequestHandler::ProcessRequest(stunmsgIn, stunmsgOut, &_tsa, NULL));
// simulate the message coming back
// make sure we got something!
outputRole = stunmsgOut.socketrole;
ChkIfA(::IsValidSocketRole(outputRole)==false, E_FAIL);
ChkIfA(spMsgResponse->GetSize() == 0, E_FAIL);
addrServerResponse = _tsa.set[stunmsgOut.socketrole].addr;
// --------------------------------------------------
//addrServerResponse.ToString(&strAddr);
//printf("Server is sending back from %s\n", strAddr.c_str());
//.........这里部分代码省略.........
示例8: main
int
main(int argc, char *argv[])
{
int i, done;
SDL_Event event;
Uint32 then, now, frames;
/* Initialize parameters */
num_sprites = NUM_SPRITES;
/* Initialize test framework */
state = CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {
return 1;
}
for (i = 1; i < argc;) {
int consumed;
consumed = CommonArg(state, i);
if (consumed == 0) {
consumed = -1;
if (SDL_strcasecmp(argv[i], "--blend") == 0) {
if (argv[i + 1]) {
if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
blendMode = SDL_BLENDMODE_NONE;
consumed = 2;
} else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
blendMode = SDL_BLENDMODE_MASK;
consumed = 2;
} else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
blendMode = SDL_BLENDMODE_BLEND;
consumed = 2;
} else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
blendMode = SDL_BLENDMODE_ADD;
consumed = 2;
} else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
blendMode = SDL_BLENDMODE_MOD;
consumed = 2;
}
}
} else if (SDL_strcasecmp(argv[i], "--scale") == 0) {
if (argv[i + 1]) {
if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
scaleMode = SDL_TEXTURESCALEMODE_NONE;
consumed = 2;
} else if (SDL_strcasecmp(argv[i + 1], "fast") == 0) {
scaleMode = SDL_TEXTURESCALEMODE_FAST;
consumed = 2;
} else if (SDL_strcasecmp(argv[i + 1], "slow") == 0) {
scaleMode = SDL_TEXTURESCALEMODE_SLOW;
consumed = 2;
} else if (SDL_strcasecmp(argv[i + 1], "best") == 0) {
scaleMode = SDL_TEXTURESCALEMODE_BEST;
consumed = 2;
}
}
} else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) {
cycle_color = SDL_TRUE;
consumed = 1;
} else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) {
cycle_alpha = SDL_TRUE;
consumed = 1;
} else if (SDL_isdigit(*argv[i])) {
num_sprites = SDL_atoi(argv[i]);
consumed = 1;
}
}
if (consumed < 0) {
fprintf(stderr,
"Usage: %s %s [--blend none|mask|blend|add|mod] [--scale none|fast|slow|best] [--cyclecolor] [--cyclealpha]\n",
argv[0], CommonUsage(state));
quit(1);
}
i += consumed;
}
if (!CommonInit(state)) {
quit(2);
}
/* Create the windows, initialize the renderers, and load the textures */
sprites =
(SDL_TextureID *) SDL_malloc(state->num_windows * sizeof(*sprites));
if (!sprites) {
fprintf(stderr, "Out of memory!\n");
quit(2);
}
for (i = 0; i < state->num_windows; ++i) {
SDL_SelectRenderer(state->windows[i]);
SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
SDL_RenderRect(NULL);
}
if (LoadSprite("icon.bmp") < 0) {
quit(2);
}
/* Allocate memory for the sprite info */
positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
if (!positions || !velocities) {
fprintf(stderr, "Out of memory!\n");
//.........这里部分代码省略.........
示例9: CommonInit
// ----------------------------------------------------------------------------
void vHavokChainConstraintChainRenderer::OnVariableValueChanged(
VisVariable_cl *pVar, const char * value)
{
CommonInit();
}
示例10: CommonInit
CBCGPControlRendererParams::CBCGPControlRendererParams (const CBCGPControlRendererParams& rSrc)
{
CommonInit ();
(*this) = rSrc;
}
示例11: CommonInit
wxRibbonButtonBar::wxRibbonButtonBar()
{
m_layouts_valid = false;
CommonInit (0);
}
示例12: Open
/**
* Initialises Direct2D vout module
*/
static int Open(vlc_object_t *object)
{
vout_display_t *vd = (vout_display_t *)object;
vout_display_sys_t *sys;
vd->sys = sys = (vout_display_sys_t *)calloc(1, sizeof(*sys)); // sunqueen modify
if (!sys)
return VLC_ENOMEM;
sys->d2_render_target = NULL;
sys->d2_dll = LoadLibrary(TEXT("D2D1.DLL"));
if (!sys->d2_dll) {
if (object->b_force)
msg_Err(vd, "Cannot load D2D1.DLL, aborting");
goto error;
}
D2D1_FACTORY_OPTIONS fo = {
D2D1_DEBUG_LEVEL_NONE
};
HRESULT (WINAPI *D2D1CreateFactory)(D2D1_FACTORY_TYPE, REFIID,
const D2D1_FACTORY_OPTIONS *,
void **);
D2D1CreateFactory = (HRESULT (__stdcall *)(D2D1_FACTORY_TYPE,const IID &,const D2D1_FACTORY_OPTIONS *,void **))GetProcAddress(sys->d2_dll, // sunqueen modify
"D2D1CreateFactory");
if (!D2D1CreateFactory) {
msg_Err(vd,
"Cannot locate reference to a D2D1CreateFactory ABI in D2D1.DLL");
goto error;
}
#ifndef NDEBUG
msg_Dbg(vd, "D2D1.DLL loaded");
#endif
HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
(REFIID)IID_ID2D1Factory, // sunqueen modify
&fo,
(void **)&sys->d2_factory);
if (hr != S_OK) {
msg_Err(vd, "Cannot create Direct2D factory (hr = 0x%x)!",
(unsigned)hr);
goto error;
}
if (CommonInit(vd))
goto error;
if (D2D_CreateRenderTarget(vd) != VLC_SUCCESS)
goto error;
vout_display_info_t info = vd->info;
info.is_slow = false;
info.has_double_click = true;
info.has_hide_mouse = false;
info.has_pictures_invalid = false;
vd->info = info;
vd->fmt.i_chroma = VLC_CODEC_RGB32; /* masks change this to BGR32 for ID2D1Bitmap */
vd->fmt.i_rmask = 0x0000ff00;
vd->fmt.i_gmask = 0x00ff0000;
vd->fmt.i_bmask = 0xff000000;
vd->pool = Pool;
vd->prepare = Prepare;
vd->display = Display;
vd->manage = Manage;
vd->control = Control;
EventThreadUpdateTitle(sys->event, VOUT_TITLE " (Direct2D output)");
#ifndef NDEBUG
msg_Dbg(vd, "Ready");
#endif
return VLC_SUCCESS;
error:
Close(VLC_OBJECT(vd));
return VLC_EGENERIC;
}
示例13: CommonInit
CBCGPRibbonQuickStepsButton::CBCGPRibbonQuickStepsButton()
{
CommonInit();
}
示例14: CommonInit
// ----------------------------------------------------------------------------
void vHavokChainAnimation::OnVariableValueChanged(VisVariable_cl *pVar, const char * value)
{
// Re-Init
CommonInit();
}
示例15: CommonInit
void VCablePathRenderer::OnVariableValueChanged(VisVariable_cl* pVar, const char* value)
{
CommonInit();
}