# Cast from PGraphics to GraphicsDevice?

**URL:** <https://discourse.processing.org/t/cast-from-pgraphics-to-graphicsdevice/2083>\
**Category:** Coding Questions\
**Created:** [July 25, 2018, 8:03pm UTC](https://discourse.processing.org/t/cast-from-pgraphics-to-graphicsdevice/2083 "2018-07-25T20:03:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MCCreeper8890](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mccreeper8890/32/751_2.png) [@MCCreeper8890](https://discourse.processing.org/u/MCCreeper8890)\
**Post date:** [July 25, 2018, 8:03pm UTC](https://discourse.processing.org/t/cast-from-pgraphics-to-graphicsdevice/2083/1 "2018-07-25T20:03:28Z")

</div>

I am trying to make a 3D game in Processing, and the problem I run into the most is the cursor going out of the window, and losing control of the camera. If only the cursor looped back around…  
Well, I used java.awt.Robot for that, and it can either use the current screen, or a GraphicsDevice element. So, is there any way to cast from a PGraphics object to a GraphicsDevice?

---

<div class="post-metadata">

**Author:** ![MCCreeper8890](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mccreeper8890/32/751_2.png) [@MCCreeper8890](https://discourse.processing.org/u/MCCreeper8890)\
**Post date:** [July 25, 2018, 8:10pm UTC](https://discourse.processing.org/t/cast-from-pgraphics-to-graphicsdevice/2083/2 "2018-07-25T20:10:26Z")

</div>

Also, I tried to use the empty constructor “Robot()”, and it constrained my cursor outside of the window. I get the feeling that this constructor would only work in fullscreen. And even then, it would fail…

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [July 25, 2018, 8:15pm UTC](https://discourse.processing.org/t/cast-from-pgraphics-to-graphicsdevice/2083/3 "2018-07-25T20:15:48Z")

</div>

By 3D I assume you’re using P3D? In which case check out GLWindow and this thread from earlier today [Problem with robot cursor](https://discourse.processing.org/t/problem-with-robot-cursor/2046)
