Re: [Plib-users] Re: Custom 'Looking' Widgets
Brought to you by:
sjbaker
|
From: <Rol...@t-...> - 2002-07-28 18:38:42
|
On Sunday 28 July 2002 19:37, Majel deMaya wrote:
> myButton->setRenderCallback(customCallback);
The render callback is the suggested way.
As I wanted to have textured buttons, I derived from puButton and replaced the
draw function. What I did there should also be possible in the render
callback.
puImageButton.h:
#include "puImageButton.h"
#include <iostream.h>
#ifndef INCL_PUIMAGEBUTTON_H
#define INCL_PUIMAGEBUTTON_H
#include <plib/pu.h>
#include <plib/ssg.h>
class puImageButton : public puButton
{
public:
puImageButton(int,int,int,int,const char *);
void draw(int dx,int dy);
protected:
ssgTexture *texture;
};
#endif
puImageButton.cpp:
puImageButton::puImageButton(int minx,int miny,int maxx,int maxy,const char
*image) : puButton(minx,miny,maxx,maxy)
{
texture=new ssgTexture(image);
//cerr << "texture handle : " << texture->getHandle() << endl;
}
void puImageButton::draw(int dx,int dy)
{
if (!visible || (window!=puGetWindow())) return;
puButton::draw(dx,dy);
int m=4;
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture->getHandle());
glColor4f(1.0,1.0,1.0,1.0);
glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0);
glVertex2i(dx+abox.min[0]+m,dy+abox.min[1]+m);
glTexCoord2f(0.0,1.0);
glVertex2i(dx+abox.min[0]+m,dy+abox.max[1]-m);
glTexCoord2f(1.0,1.0);
glVertex2i(dx+abox.max[0]-m,dy+abox.max[1]-m);
glTexCoord2f(1.0,0.0);
glVertex2i(dx+abox.max[0]-m,dy+abox.min[1]+m);
glEnd();
glDisable(GL_TEXTURE_2D);
}
Try to put something like that in the above draw function into your callback
(without the first two lines), it should work.
Rolf
--
Rolf Jakob at home (rj...@du...)
WWW : http://www.franken.de/users/duffy1/rjakob (KDE-Utils and CCS)
|