Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Preformance With DrawImage!  (Read 1186 times)
0 Members and 1 Guest are viewing this topic.
Offline VIrtueeL
« Posted 2014-12-14 11:15:25 »

ok am drawing this on my screen // this is backround for the 2d platformer btw


but i don't want to draw it all i only want to draw what the screen can see

for example here i want to only draw whats inside that red rectangle


i got it working with tiles and stuff using a collision box but i have never done it with an full image

do i need to get the pixels that are colliding and so how do i do that?

i do devlogs and i do tutorials check em out
https://www.youtube.com/user/InidDevo
Offline matanui159

JGO Coder


Medals: 11
Projects: 1
Exp: 10-12 months


Aww... So cute...


« Reply #1 - Posted 2014-12-14 11:17:59 »

What are u using?
OpenGL: change the texture coords
Java2D: Graphics.setClip(x, y, width, height)
Thats all that I know

hope this helps! Cheesy

Is it sad that I still get a fright when the computer beeps at me...
Offline VIrtueeL
« Reply #2 - Posted 2014-12-14 11:31:30 »

Thanks so much! this is gonna make everything so much easier

so does it still load the pixels outside the clip?

i do devlogs and i do tutorials check em out
https://www.youtube.com/user/InidDevo
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lcass
« Reply #3 - Posted 2014-12-14 11:41:18 »

I would guess so , its a clip function not a modified load function , if you are going to do something like this take a look at buffered rendering.
Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #4 - Posted 2014-12-14 16:58:05 »

If you really care about performance move onto some framework that uses opengl.

But that does not really answer your question.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #5 - Posted 2014-12-14 21:50:19 »

Why use setClip when the drawImage method does it for you?

drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)


Offline VIrtueeL
« Reply #6 - Posted 2014-12-15 08:57:12 »

would you mind giving those varibles names, first time am doing this.. with and image!

i do devlogs and i do tutorials check em out
https://www.youtube.com/user/InidDevo
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #7 - Posted 2014-12-15 15:14:38 »

http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html#drawImage(java.awt.Image,%20int,%20int,%20int,%20int,%20int,%20int,%20int,%20int,%20java.awt.image.ImageObserver)
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (108 views)
2017-09-30 02:57:34

theagentd (135 views)
2017-09-26 18:23:31

cybrmynd (245 views)
2017-08-02 12:28:51

cybrmynd (240 views)
2017-08-02 12:19:43

cybrmynd (238 views)
2017-08-02 12:18:09

Sralse (252 views)
2017-07-25 17:13:48

Archive (864 views)
2017-04-27 17:45:51

buddyBro (1007 views)
2017-04-05 03:38:00

CopyableCougar4 (1566 views)
2017-03-24 15:39:42

theagentd (1373 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!