Jump to content

g.drawModel fails silently


Slick

Recommended Posts

Display d = new Display();

@Override
public void onPaint(Graphics2D g){
	log("aaaa");

	g.setColor(Color.RED);
	d.drawModel(g, myPlayer().getGridX(), myPlayer().getGridY(), myPlayer().getZ(), myPlayer().getModel());

	log("bbbb");
}

 

trying out the Display api and when I call drawModel it seems like it is throwing an exception silently as I never saw the second message being printed on the console

am I doing anything wrong here?

I am trying to draw the outline of entities and tiles on screen, searched for some older posts in the forum but no luck :(

 

EDIT: should be using getDisplay() rather than instantiating a new display class, all good now :D

Edited by Slick
Link to comment
Share on other sites

10 hours ago, Slick said:
Display d = new Display();

@Override
public void onPaint(Graphics2D g){
	log("aaaa");

	g.setColor(Color.RED);
	d.drawModel(g, myPlayer().getGridX(), myPlayer().getGridY(), myPlayer().getZ(), myPlayer().getModel());

	log("bbbb");
}

 

trying out the Display api and when I call drawModel it seems like it is throwing an exception silently as I never saw the second message being printed on the console

am I doing anything wrong here?

I am trying to draw the outline of entities and tiles on screen, searched for some older posts in the forum but no luck :(

 

EDIT: should be using getDisplay() rather than instantiating a new display class, all good now :D

Not sure what you are trying to do with this code, but you are trying to draw the display on top of your player :D

This draws the outline of a model :)
Same works for Npc,'s or whatever you are trying to draw.

public void onPaint(Graphics2D g){
RS2Object object = ....

  if(object != null && object.isVisible()){
     g.draw(object.getModel().getArea(object.getGridX(), object.getGridY(), object.getZ()));
  }
}

Retrieving a object in the onPaint method isn't a great example though, because this will result in FPS drops. The more things you load in the onPaint the harder your FPS drops :)
the best thing is to set the object inside the onLoop
 

RS2Object object;

public int onLoop(){
	object = ...;
}


public void onPaint(Graphics2D g){

  if(object != null && object.isVisible()){
     g.draw(object.getModel().getArea(object.getGridX(), object.getGridY(), object.getZ()));
  }
}

 

Edited by Khaleesi
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...