mirror of https://github.com/aap/librw.git
subraster rendering on gl
This commit is contained in:
parent
ee2a32e142
commit
5e5a624681
|
@ -52,6 +52,7 @@ struct GlGlobals
|
|||
GLFWwindow **pWindow;
|
||||
#endif
|
||||
int presentWidth, presentHeight;
|
||||
int presentOffX, presentOffY;
|
||||
|
||||
// for opening the window
|
||||
int winWidth, winHeight;
|
||||
|
@ -1036,8 +1037,8 @@ flushCache(void)
|
|||
static void
|
||||
setFrameBuffer(Camera *cam)
|
||||
{
|
||||
Raster *fbuf = cam->frameBuffer;
|
||||
Raster *zbuf = cam->zBuffer;
|
||||
Raster *fbuf = cam->frameBuffer->parent;
|
||||
Raster *zbuf = cam->zBuffer->parent;
|
||||
assert(fbuf);
|
||||
|
||||
Gl3Raster *natfb = PLUGINOFFSET(Gl3Raster, fbuf, nativeRasterOffset);
|
||||
|
@ -1151,24 +1152,45 @@ beginUpdate(Camera *cam)
|
|||
setFrameBuffer(cam);
|
||||
|
||||
int w, h;
|
||||
if(cam->frameBuffer->type == Raster::CAMERA){
|
||||
int x, y;
|
||||
Raster *fb = cam->frameBuffer->parent;
|
||||
if(fb->type == Raster::CAMERA){
|
||||
#ifdef LIBRW_SDL2
|
||||
SDL_GetWindowSize(glGlobals.window, &w, &h);
|
||||
#else
|
||||
glfwGetWindowSize(glGlobals.window, &w, &h);
|
||||
#endif
|
||||
}else{
|
||||
w = fb->width;
|
||||
h = fb->height;
|
||||
}
|
||||
x = 0;
|
||||
y = 0;
|
||||
|
||||
// Got a subraster
|
||||
if(cam->frameBuffer != fb){
|
||||
x = cam->frameBuffer->offsetX;
|
||||
// GL y offset is from bottom
|
||||
y = h - cam->frameBuffer->height - cam->frameBuffer->offsetY;
|
||||
w = cam->frameBuffer->width;
|
||||
h = cam->frameBuffer->height;
|
||||
}
|
||||
|
||||
if(w != glGlobals.presentWidth || h != glGlobals.presentHeight){
|
||||
glViewport(0, 0, w, h);
|
||||
if(w != glGlobals.presentWidth || h != glGlobals.presentHeight ||
|
||||
x != glGlobals.presentOffX || y != glGlobals.presentOffY){
|
||||
glViewport(x, y, w, h);
|
||||
glGlobals.presentWidth = w;
|
||||
glGlobals.presentHeight = h;
|
||||
glGlobals.presentOffX = x;
|
||||
glGlobals.presentOffY = y;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
endUpdate(Camera *cam)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
clearCamera(Camera *cam, RGBA *col, uint32 mode)
|
||||
{
|
||||
|
@ -1442,6 +1464,8 @@ printf("version %s\n", glGetString(GL_VERSION));
|
|||
*glGlobals.pWindow = win;
|
||||
glGlobals.presentWidth = 0;
|
||||
glGlobals.presentHeight = 0;
|
||||
glGlobals.presentOffX = 0;
|
||||
glGlobals.presentOffY = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1656,7 +1680,7 @@ deviceSystemGLFW(DeviceReq req, void *arg, int32 n)
|
|||
Device renderdevice = {
|
||||
-1.0f, 1.0f,
|
||||
gl3::beginUpdate,
|
||||
null::endUpdate,
|
||||
gl3::endUpdate,
|
||||
gl3::clearCamera,
|
||||
gl3::showRaster,
|
||||
gl3::rasterRenderFast,
|
||||
|
|
|
@ -387,8 +387,8 @@ struct Line
|
|||
|
||||
struct Rect
|
||||
{
|
||||
int32 h, w;
|
||||
int32 x, y;
|
||||
int32 w, h;
|
||||
};
|
||||
|
||||
struct Sphere
|
||||
|
|
Loading…
Reference in New Issue