本文整理汇总了C++中IVideoDriver::getScreenSize方法的典型用法代码示例。如果您正苦于以下问题:C++ IVideoDriver::getScreenSize方法的具体用法?C++ IVideoDriver::getScreenSize怎么用?C++ IVideoDriver::getScreenSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVideoDriver
的用法示例。
在下文中一共展示了IVideoDriver::getScreenSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recreateCameras
void Editor::recreateCameras()
{
// Irrlicht
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
// Get screen sizes
int ResX = driver->getScreenSize().Width;
if (!state->settings->getBool("hide_sidebar"))
ResX -= 256;
int ResY = driver->getScreenSize().Height;
// reset matrix
matrix4 projMat;
irr::f32 orth_w = ResX / (irr::f32)ResY;
orth_w = 3 * orth_w;
projMat.buildProjectionMatrixOrthoLH(orth_w, 3, 1, 100);
// Loop through cameras
for (int i = 0; i < 4; i++) {
// Delete old camera
if (camera[i]) {
camera[i]->remove();
camera[i] = NULL;
}
ViewportType type = state->getViewportType((Viewport)i);
if (type == VIEWT_PERS) {
vector3df oldrot = pivot->getRotation();
pivot->setRotation(vector3df(0, 0, 0));
camera[i] = smgr->addCameraSceneNode(NULL, vector3df(0, 0, -2),
vector3df(0, 0, 0));
camera[i]->setParent(pivot);
camera[i]->setAspectRatio((float)ResX / (float)ResY);
pivot->setRotation(oldrot);
} else {
camera[i] = smgr->addCameraSceneNode(target);
switch(type) {
case VIEWT_TOP:
camera[i]->setPosition(vector3df(0, 2, -0.01f));
break;
case VIEWT_BOTTOM:
camera[i]->setPosition(vector3df(0, -2, -0.01f));
break;
case VIEWT_LEFT:
camera[i]->setPosition(vector3df(-5, 0, 0));
break;
case VIEWT_RIGHT:
camera[i]->setPosition(vector3df(5, 0, 0));
break;
case VIEWT_FRONT:
camera[i]->setPosition(vector3df(0, 0, -5));
break;
case VIEWT_BACK:
camera[i]->setPosition(vector3df(0, 0, 5));
break;
}
camera[i]->setProjectionMatrix(projMat, true);
}
applyCameraOffsets((Viewport)i);
}
}
示例2: viewportTick
void Editor::viewportTick(Viewport viewport, rect<s32> rect,
bool mousehit, bool middlehit)
{
// Init
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
IGUIEnvironment *guienv = device->getGUIEnvironment();
ViewportType type = state->getViewportType(viewport);
// Draw camera
smgr->setActiveCamera(camera[(int)viewport]);
driver->setViewPort(rect);
if (type == VIEWT_BOTTOM)
plane->setVisible(false);
smgr->drawAll();
if (type == VIEWT_BOTTOM)
plane->setVisible(true);
// Callbacks
if (state->Mode())
state->Mode()->viewportTick(viewport, driver, rect);
if (viewport_drag == viewport) {
vector2di delta = state->mouse_position;
delta -= viewport_drag_last;
viewport_drag_last = state->mouse_position;
viewport_offset[(int)viewport].X -= (f32)delta.X * 0.01f;
viewport_offset[(int)viewport].Y += (f32)delta.Y * 0.01f;
if (viewport_offset[(int)viewport].X > 0.5)
viewport_offset[(int)viewport].X = 0.5;
if (viewport_offset[(int)viewport].X < -0.5)
viewport_offset[(int)viewport].X = -0.5;
if (viewport_offset[(int)viewport].Y > 0.5)
viewport_offset[(int)viewport].Y = 0.5;
if (viewport_offset[(int)viewport].Y < -0.5)
viewport_offset[(int)viewport].Y = -0.5;
applyCameraOffsets(viewport);
}
if (middlehit && rect.isPointInside(state->mouse_position)
&& type != VIEWT_PERS) {
viewport_drag = viewport;
viewport_drag_last = state->mouse_position;
}
// Draw text
driver->setViewPort(rects32(0, 0, driver->getScreenSize().Width,
driver->getScreenSize().Height));
{
static const wchar_t* labels[7] = {L"Perspective", L"Front", L"Left",
L"Top", L"Back", L"Right", L"Bottom"};
// Handle clicking
position2d<s32> labelpos(rect.LowerRightCorner.X - 86,
rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?30:10));
rects32 backgroundrect(rect.LowerRightCorner.X - 96,
rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?25:5),
rect.LowerRightCorner.X - 5,
rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?185:165));
bool context_is_open = (viewport_contextmenu == viewport);
if (mousehit && !state->menu->dialog) {
if ((rects32(labelpos.X, labelpos.Y, labelpos.X + 90,
labelpos.Y + 25)).isPointInside(state->mouse_position)) {
viewport_contextmenu = viewport;
} else if (context_is_open) {
context_is_open = false;
viewport_contextmenu = VIEW_NONE;
if (backgroundrect.isPointInside(state->mouse_position)) {
int y = 0;
for (int i = 0; i < 7; i++) {
if (i != (int)type) {
int ty = rect.UpperLeftCorner.Y +
((rect.UpperLeftCorner.Y < 50)?56:36)
+ y * 20;
rects32 trect(rect.LowerRightCorner.X - 96,
ty,
rect.LowerRightCorner.X - 5, ty + 20);
y++;
if (trect.isPointInside(state->mouse_position)) {
viewport_offset[(int)viewport] = vector3df(0, 0, 0);
state->settings->set(viewportToSetting(viewport),
viewportTypeToSetting((ViewportType)i));
recreateCameras();
break;
}
}
}
}
}
}
// Context menu
if (context_is_open) {
// Context menu background
driver->draw2DRectangle(SColor(100, 32, 32, 32), backgroundrect);
s32 y2 = rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?52:32);
driver->draw2DLine(position2d<s32>(rect.LowerRightCorner.X - 96, y2),
position2d<s32>(rect.LowerRightCorner.X - 5, y2),
SColor(100, 255, 255, 255));
// Draw options
//.........这里部分代码省略.........
示例3: run
bool Editor::run(IrrlichtDevice* irr_device, Configuration* conf,
bool editor_is_installed)
{
// Do Irrlicht Stuff
device = irr_device;
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
IGUIEnvironment *guienv = device->getGUIEnvironment();
device->setEventReceiver(this);
device->setWindowCaption(L"Node Box Editor");
if (!conf->getBool("fullscreen")) {
device->setResizable(true);
}
// Project and state
Project *proj = new Project();
state = new EditorState(device, proj, conf);
state->isInstalled = editor_is_installed;
// Menu State
state->menu = new MenuState(state);
// Add editor modes
state->AddMode(new NBEditor(state));
state->AddMode(new NodeEditor(state));
state->AddMode(new TextureEditor(state));
// Set up project
proj->AddNode(state, true, false);
proj->media.debug();
// Load user interface
LoadScene();
state->SelectMode(0);
int LastX = driver->getScreenSize().Width;
if (!state->settings->getBool("hide_sidebar")) {
LastX -= 256;
}
int LastY = driver->getScreenSize().Height;
#ifdef _DEBUG
int lastFPS = -1;
#endif
bool dosleep = state->settings->getBool("use_sleep");
u32 last = std::clock();
double dtime = 0;
while (device->run()) {
if (state->NeedsClose()) {
device->closeDevice();
return true;
}
driver->beginScene(true, true, irr::video::SColor(255, 150, 150, 150));
int ResX = driver->getScreenSize().Width;
if (!state->settings->getBool("hide_sidebar"))
ResX -= 256;
int ResY = driver->getScreenSize().Height;
if (currentWindow == -1) {
bool newmoused = (state->mousedown && !click_handled);
viewportTick(VIEW_TL, rect<s32>(0, 0, ResX/2, ResY/2),
newmoused, !middle_click_handled);
viewportTick(VIEW_TR, rect<s32>(ResX/2, 0, ResX, ResY/2),
newmoused, !middle_click_handled);
viewportTick(VIEW_BL, rect<s32>(0, ResY/2, ResX/2, ResY ),
newmoused, !middle_click_handled);
viewportTick(VIEW_BR, rect<s32>(ResX/2, ResY/2, ResX, ResY ),
newmoused, !middle_click_handled);
// Draw separating lines
driver->setViewPort(rect<s32>(0, 0, driver->getScreenSize().Width,
driver->getScreenSize().Height));
driver->draw2DLine(vector2d<irr::s32>(0, ResY/2),
vector2d<irr::s32>(ResX, ResY/2), SColor(175,255,255,255));
driver->draw2DLine(vector2d<irr::s32>(0, ResY/2-1),
vector2d<irr::s32>(ResX, ResY/2-1), SColor(175,255,255,255));
driver->draw2DLine(vector2d<irr::s32>(ResX/2, 0),
vector2d<irr::s32>(ResX/2, ResY), SColor(175,255,255,255));
driver->draw2DLine(vector2d<irr::s32>(ResX/2+1, 0),
vector2d<irr::s32>(ResX/2+1, ResY), SColor(175,255,255,255));
} else if (camera[currentWindow]) {
viewportTick((Viewport)currentWindow, rect<s32>(0, 0, ResX, ResY),
(state->mousedown && !click_handled), !middle_click_handled);
}
if (state->menu) {
state->menu->draw(driver);
}
if (state->Mode()) {
state->Mode()->draw(driver);
}
if (state->project && state->project->GetCurrentNode()) {
vector3df pos = vector3df(
(f32)state->project->GetCurrentNode()->position.X,
//.........这里部分代码省略.........
示例4: OnEvent
bool Editor::OnEvent(const SEvent& event)
{
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT) {
if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) {
state->mousedown = false;
click_handled = true;
} else if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) {
state->mousedown = true;
click_handled = false;
} else if (event.MouseInput.Event == EMIE_MOUSE_MOVED) {
state->mouse_position.X = event.MouseInput.X;
state->mouse_position.Y = event.MouseInput.Y;
} else if (event.MouseInput.Event == EMIE_MMOUSE_LEFT_UP) {
viewport_drag = VIEW_NONE;
middle_click_handled = true;
} else if (event.MouseInput.Event == EMIE_MMOUSE_PRESSED_DOWN) {
middle_click_handled = false;
}
}
if (state->Mode()) {
if (state->Mode()->OnEvent(event)) {
return true;
}
}
if (state->menu) {
if (state->menu->OnEvent(event)) {
return true;
}
}
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key < NUMBER_OF_KEYS) {
if (event.KeyInput.PressedDown) {
state->keys[event.KeyInput.Key] = EKS_DOWN;
} else {
state->keys[event.KeyInput.Key] = EKS_UP;
}
if (event.KeyInput.PressedDown &&
event.KeyInput.Key == KEY_KEY_W &&
state->keys[164] == EKS_DOWN) {
if (currentWindow == -1) {
IVideoDriver *driver = state->device->getVideoDriver();
int ResX = driver->getScreenSize().Width;
if (!state->settings->getBool("hide_sidebar"))
ResX -= 256;
int ResY = driver->getScreenSize().Height;
if (state->mouse_position.X > ResX / 2)
if (state->mouse_position.Y > ResY / 2)
currentWindow = 3;
else
currentWindow = 1;
else
if (state->mouse_position.Y > ResY / 2)
currentWindow = 2;
else
currentWindow = 0;
} else
currentWindow = -1;
}
if (state->device->getGUIEnvironment()->getFocus() &&
state->device->getGUIEnvironment()->getFocus()->getType() == EGUIET_EDIT_BOX)
return false;
switch (event.KeyInput.Key) {
case KEY_KEY_S:
pivot->setRotation(vector3df(pivot->getRotation().X - 1,
pivot->getRotation().Y, pivot->getRotation().Z));
break;
case KEY_KEY_W:
pivot->setRotation(vector3df(pivot->getRotation().X + 1,
pivot->getRotation().Y, pivot->getRotation().Z));
break;
case KEY_KEY_A:
pivot->setRotation(vector3df(pivot->getRotation().X,
pivot->getRotation().Y + 1, pivot->getRotation().Z));
break;
case KEY_KEY_D:
pivot->setRotation(vector3df(pivot->getRotation().X,
pivot->getRotation().Y - 1, pivot->getRotation().Z));
break;
case KEY_KEY_B:
if (!event.KeyInput.PressedDown)
state->SelectMode(0);
break;
case KEY_KEY_N:
if (!event.KeyInput.PressedDown)
state->SelectMode(1);
break;
case KEY_KEY_T:
if (!event.KeyInput.PressedDown)
state->SelectMode(2);
break;
}
}
if (event.EventType == EET_GUI_EVENT) {
//.........这里部分代码省略.........
示例5: animateNode
void CSceneNodeAnimatorCameraFPS::animateNode(ISceneNode* node, UINT32 timeMs)
{
if (!node || node->getType() != ESNT_CAMERA)
return;
ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);
if (firstUpdate)
{
camera->updateAbsolutePosition();
if (CursorControl)
{
CursorControl->setPosition(0.5f, 0.5f);
CursorPos = CenterCursor = CursorControl->getRelativePosition();
}
LastAnimationTime = timeMs;
firstUpdate = false;
}
// If the camera isn't the active camera, and receiving input, then don't process it.
if (!camera->isInputReceiverEnabled())
{
firstInput = true;
return;
}
if (firstInput)
{
allKeysUp();
firstInput = false;
}
ISceneManager * smgr = camera->getSceneManager();
if (smgr && smgr->getActiveCamera() != camera)
return;
// get time
FLOAT32 timeDiff = (FLOAT32)(timeMs - LastAnimationTime);
LastAnimationTime = timeMs;
// update position
Vector3 pos = camera->getPosition();
// Update rotation
Vector3 target = (camera->getTarget() - camera->getAbsolutePosition());
Vector3 relativeRotation = target.getHorizontalAngle();
if (CursorControl)
{
if (CursorPos != CenterCursor)
{
relativeRotation.y -= (0.5f - CursorPos.x) * RotateSpeed;
relativeRotation.x -= (0.5f - CursorPos.y) * RotateSpeed * MouseYDirection;
// X < MaxVerticalAngle or X > 360-MaxVerticalAngle
if (relativeRotation.x > MaxVerticalAngle * 2 &&
relativeRotation.x < 360.0f - MaxVerticalAngle)
{
relativeRotation.x = 360.0f - MaxVerticalAngle;
}
else
if (relativeRotation.x > MaxVerticalAngle &&
relativeRotation.x < 360.0f - MaxVerticalAngle)
{
relativeRotation.x = MaxVerticalAngle;
}
// Do the fix as normal, special case below
// reset cursor position to the centre of the window.
CursorControl->setPosition(0.5f, 0.5f);
CenterCursor = CursorControl->getRelativePosition();
// needed to avoid problems when the event receiver is disabled
CursorPos = CenterCursor;
}
// Special case, mouse is whipped outside of window before it can update.
IVideoDriver* driver = smgr->getVideoDriver();
Vector2 mousepos(UINT32(CursorControl->getPosition().x), UINT32(CursorControl->getPosition().y));
rect<UINT32> screenRect(0, 0, driver->getScreenSize().Width, driver->getScreenSize().Height);
// Only if we are moving outside quickly.
bool reset = !screenRect.isPointInside(mousepos);
if (reset)
{
// Force a reset.
CursorControl->setPosition(0.5f, 0.5f);
CenterCursor = CursorControl->getRelativePosition();
CursorPos = CenterCursor;
}
}
// set target
target.set(0, 0, Math::_max<Real>(1.f, pos.length()));
Vector3 movedir = target;
//.........这里部分代码省略.........
示例6: run
bool Editor::run(IrrlichtDevice* irr_device,Configuration* conf)
{
// Do Irrlicht Stuff
device = irr_device;
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
IGUIEnvironment *guienv = device->getGUIEnvironment();
device->setEventReceiver(this);
device->setWindowCaption(L"Node Box Editor");
if (!conf->getBool("fullscreen")) {
device->setResizable(true);
}
// Project and state
Project *proj = new Project();
state = new EditorState(device, proj, conf);
// Menu State
state->menu = new MenuState(state);
// Add editor modes
state->AddMode(new NBEditor(state));
state->AddMode(new NodeEditor(state));
// Set up project
proj->AddNode(state, true, false);
// Load user interface
LoadScene();
state->SelectMode(0);
int LastX = driver->getScreenSize().Width;
if (!state->settings->getBool("hide_sidebar")) {
LastX -= 256;
}
int LastY = driver->getScreenSize().Height;
#ifdef _DEBUG
int lastFPS = -1;
#endif
bool dosleep = state->settings->getBool("use_sleep");
u32 last = std::clock();
double dtime = 0;
while (device->run()) {
if (state->NeedsClose()) {
device->closeDevice();
return true;
}
driver->beginScene(true, true, irr::video::SColor(255, 150, 150, 150));
int ResX = driver->getScreenSize().Width;
if (!state->settings->getBool("hide_sidebar"))
ResX -= 256;
int ResY = driver->getScreenSize().Height;
if (currentWindow == -1) {
// Draw Camera 0
if (camera[0]) {
smgr->setActiveCamera(camera[0]);
rect<s32> offset = rect<s32>(0, 0, ResX/2, ResY/2);
driver->setViewPort(offset);
smgr->drawAll();
if (state->Mode())
state->Mode()->viewportTick(VIEW_PERS, driver, offset);
}
// Draw Camera 1
if (camera[1]) {
smgr->setActiveCamera(camera[1]);
rect<s32> offset = rect<s32>(ResX/2, 0, ResX, ResY/2);
driver->setViewPort(offset);
smgr->drawAll();
if (state->Mode())
state->Mode()->viewportTick(VIEW_XZ, driver, offset);
}
// Draw Camera 2
if (camera[2]) {
smgr->setActiveCamera(camera[2]);
rect<s32> offset = rect<s32>(0, ResY/2, ResX/2, ResY);
driver->setViewPort(offset);
smgr->drawAll();
if (state->Mode())
state->Mode()->viewportTick(VIEW_XY, driver, offset);
}
// Draw Camera 3
if (camera[3]) {
smgr->setActiveCamera(camera[3]);
rect<s32> offset = rect<s32>(ResX/2, ResY/2, ResX, ResY);
driver->setViewPort(offset);
smgr->drawAll();
//.........这里部分代码省略.........
示例7: main
int main()
{
Input input;
IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9, dimension2d<u32>(800, 600), 16, false, true, false, &input);
device->setWindowCaption(L"Seas of Gold");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
E_DRIVER_TYPE driverType = driverChoiceConsole();
EffectHandler *effect = new EffectHandler(device, driver->getScreenSize(), false, true);
E_FILTER_TYPE filterType = (E_FILTER_TYPE)core::clamp<u32>((u32)3 - '1', 0, 4);
int skyR = 30, skyG = 30, skyB = 70;
int timer = 0;
SColor sky = SColor(255, skyR, skyG, skyB);
float plPos_x = 0.0f, plPos_y = 0.0f, plPos_z = 0.0f;
bool updateCam = true;
bool menu1 = false;
int state = Main;
LoadMap loadMap;
Player player;
Interface playerInterface(driver);
ITriangleSelector* selector = 0;
ISceneNodeAnimator* anim = 0;
// Load the map scene
//loadMap.Load(smgr, device, Map_Africa);
//loadMap.Load(smgr, device, Map_India);
//loadMap.Load(smgr, device, selector, plyrNode, anim, Map_England);
IAnimatedMeshSceneNode* plyrNode = player.loadPlayerNode(device, smgr);
//plyrNode->setDebugDataVisible((scene::E_DEBUG_SCENE_TYPE)(plyrNode->isDebugDataVisible() ^ scene::EDS_BBOX));
ICameraSceneNode* camera = smgr->addCameraSceneNode(0, plyrNode->getPosition() + vector3df(0, 2, 2), vector3df(0, 0, 100));
loadMap.Load(smgr, device, selector, plyrNode, anim, Map_England);
//loadMap.setCollisions(smgr, selector, plyrNode, anim);
if (loadMap.CollNode)
{
selector = smgr->createOctreeTriangleSelector(loadMap.CollNode->getMesh(), loadMap.CollNode, 32);
for (int i = 0; i < loadMap.CollNode->getMaterialCount(); i++)
{
loadMap.CollNode->getMaterial(i).NormalizeNormals = true;
}
loadMap.CollNode->setTriangleSelector(selector);
}
if (selector)
{
anim = smgr->createCollisionResponseAnimator(selector, plyrNode, vector3df(0.6f, 0.75f, 0.4f), core::vector3df(0.0f, -0.05f, 0.0f),
core::vector3df(0.0f, -0.725f, 0.0f));
plyrNode->addAnimator(anim);
}
ISceneCollisionManager* collMan = smgr->getSceneCollisionManager();
////////////// The Sun ////////////
ILightSceneNode *sun_node;
SLight sun_data;
ISceneNode *sun_billboard;
float sun_angle = 0;
video::SColorf Diffuse_Night = video::SColorf(0.0f, 0.0f, 0.0f, 1.0f);
video::SColorf Diffuse_Day = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
sun_node = smgr->addLightSceneNode();
sun_data.Direction = vector3df(0, 0, 0);
sun_data.Type = video::ELT_DIRECTIONAL;
sun_data.AmbientColor = video::SColorf(0.1f, 0.1f, 0.1f, 1);
sun_data.SpecularColor = video::SColorf(0, 0, 0, 0);
sun_data.DiffuseColor = Diffuse_Day;
sun_data.CastShadows = true;
sun_node->setLightData(sun_data);
sun_node->setPosition(vector3df(0, 0, 0));
sun_node->setRotation(vector3df(0, 0, 0));
sun_billboard = smgr->addBillboardSceneNode(sun_node, core::dimension2d<f32>(60, 60));
if (sun_billboard)
{
sun_billboard->setPosition(vector3df(0, 0, -100));
sun_billboard->setMaterialFlag(video::EMF_LIGHTING, false);
sun_billboard->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
sun_billboard->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
sun_billboard->setMaterialTexture(0, driver->getTexture("Assets/particlewhite.bmp"));
}
/////////// End ////////////
//------- candleLight -----//
ILightSceneNode *candleLight = smgr->addLightSceneNode();
SLight candleLight_data;
candleLight_data.Type = video::ELT_POINT;
candleLight_data.DiffuseColor = SColorf(1.0f, 0.546f, 0.016f, 1.0f);
candleLight_data.SpecularColor = video::SColorf(0, 0, 0, 0);
candleLight->setPosition(vector3df(2.43467f, 1.55795f, -3.94657));
candleLight_data.Radius = 1.5f;
candleLight->setLightData(candleLight_data);
//------- end -----//
//.........这里部分代码省略.........