Jump to content

g.drawModel fails silently


Recommended Posts

Posted (edited)
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
Posted (edited)
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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