Getting DirectX or any other rendering API to update in real time in a widget...
-
OK, I know i prob asked this a million times but I can't get anything other then the OpenGL (which is native to Qt), to update in real time. For example, here is a screen shoot from my shader editor im trying to make.!http://i1069.photobucket.com/albums/u466/eggman3344/output.png(http://i1069.photobucket.com/albums/u466/eggman3344/output.png)!
as you can see, DirectX is created right and also the shader creation works pretty well the only reason there's an error was to show that the editor so far worked right just the pre-view window wont update as usually is with my luck sigh;
anyways here is the code for my render window.
RenderWindow.cpp
@
#include "RenderWindow.h"RenderWindow::RenderWindow(QWidget* parent /* = 0 */)
: QWidget(parent)
{
renderer = new Renderer(this->winId());
oldTimer = new QTimer(this,"Old Timer");
newTimer = new QTimer(this,"New Timer");
this->createViewport();
}RenderWindow::~RenderWindow()
{
delete renderer;
}bool RenderWindow::createViewport()
{
if(renderer->createRenderer(this->parentWidget()->width(),
this->parentWidget()->height()))
{
WId win = renderer->getWindowHandle();// this->create(win);
setAttribute(Qt::WA_PaintOnScreen,true);
setAttribute(Qt::WA_NoBackground,true);
return true;
}
else
{
return false;
}
}void RenderWindow::paintEvent(QPaintEvent *pE)
{
framesPerSec++;if (framesPerSec >= 60)
{
oldTimer->setInterval((int)framesPerSec);renderer->setClearColor(0,0,0,1);
renderer->_renderStart();this->update();
newTimer = oldTimer;
newTimer->setInterval((int)framesPerSec);
int newFrame = newTimer->interval();
newTimer += (int)framesPerSec;
oldTimer->setInterval(newFrame);
renderer->_renderEnd();
}
}void RenderWindow::resizeEvent(QResizeEvent *rE)
{
this->resize(this->parentWidget()->width(),
this->parentWidget()->height());renderer->setWidth(this->parentWidget()->width());
renderer->setHeight(this->parentWidget()->height());
renderer->reset();
}void RenderWindow::enterEvent(QEvent *Ee)
{
update();
}
@as you can see, it's kinda crap but as long as it creates Direct3D and compiles the shader, i don't care for now, i just want something that will allow me to be able to use as a way to update the widget in real time like in Unreal Ed and Ogitor (also since im trying to make my own Oger powered editor being able to update in real time will help tremendesly (probobably spelled that wrong).