It is currently Wed Jul 08, 2020 1:12 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Multiple ViewPorts in the same OpenGL window
PostPosted: Wed Feb 26, 2020 2:13 pm 
Offline
Addict
Addict

Joined: Sun Jun 25, 2006 7:28 pm
Posts: 1404
and every viewport have its own color
the gluOrtho2D_(-10, 10, -10, 10) projects the tiny real values to a viewport, here the coordinates will look as Cartesian coordinates (the 0,0 is at the center)
gluOrtho2D_(0, 10, 0, 10) here the (0,0) will be at the bottom Left of every viewport
Image
using GL Lists:
Code:
OpenWindow(0, 0, 0, 300, 300, "several ViewPorts with glViewPort", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

Global glist.l
Declare BuildScene(xrng.f, yrng.f)

glWin = OpenGLGadget(#PB_Any , 0, 0, 300, 300)
Global xrng.f = 10.0 , yrng.f = 10.0
gluOrtho2D_(-xrng, xrng, -yrng, yrng)
;glMatrixMode_ (#GL_MODELVIEW)
;glMatrixMode_ (#GL_PROJECTION)

BuildScene(xrng, yrng)   
  Repeat
    Repeat
    EventID = WindowEvent()
    Select EventID
      Case #PB_Event_Gadget
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
  Until EventID = 0
 
  glEnable_(#GL_SCISSOR_TEST);; look descr in line 25
  glViewport_(0,0,150,150)
  glScissor_(0,0,150,150) ; cut part from the viewPort so clear color can be effective localy and not to the whole gl screen    ;
  glClearColor_(0.98, 0.59, 0.69, 0)
  glClear_(#GL_COLOR_BUFFER_BIT)
  glCallList_(glist)
     
  glViewport_(150,0,150,150)
  glScissor_(150,0,150,150)    ;
  glClearColor_(0.3, 0.6, 0.6, 0)
  glClear_(#GL_COLOR_BUFFER_BIT)
  glCallList_(glist)
   
  glViewport_(150,150,150,150)
  glScissor_(150,150,150,150)    ;
  glClearColor_(0.2, 0.6, 0.9, 0)
  glClear_(#GL_COLOR_BUFFER_BIT)
  glCallList_(glist)
   
  glViewport_(0,150,150,150)
  glScissor_(0,150,150,150)   ;
  glClearColor_(0.7, 0.6, 0.6, 0)
  glClear_(#GL_COLOR_BUFFER_BIT)
  glCallList_(glist)
           
  SetGadgetAttribute(glWin, #PB_OpenGL_FlipBuffers, #True)
  ;glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  glDisable_(#GL_SCISSOR_TEST) 
   
 Until Quit = #True
 
 End
       
 Procedure BuildScene(xrng.f, yrng.f)
   Protected.f x, y, z
  ;make the glist
  glist = glGenLists_(1)
  glNewList_(glist, #GL_COMPILE_AND_EXECUTE)
 
 glColor3f_(0, 0, 1)
 glBegin_(#GL_LINES) ; plot the horizontal line
   glVertex2f_(-xrng, 0)
   glVertex2f_(xrng, 0)
   glEnd_()
glBegin_(#GL_LINES) ; plot the vertical line
   glVertex2f_(0, -yrng)
   glVertex2f_(0, yrng)
 glEnd_()   
x.f = -10
 While x <= 10 ; plot the function y = x^2
    y  = Pow(x,2);try also Pow(2,x) or Pow(x,2)
    glColor3f_(1, 1, 1)
    glBegin_(#GL_POINTS)
       glVertex2f_(x, y)
    glEnd_()
    x + 0.01
     
  Wend
 
 glEndList_()
 
 glFinish_()
             
EndProcedure             


-------------------------------------------------------------------------
Image

using glDrawArray
and every viewport show the same curve but with different constants (usefull to compare several plots in one shot)
economic but slower than using glDrawArray with a fixed array
Code:
Declare FillCurveData(k, s.f, s2.f)
Declare DrawCurve()

Structure Point3D
  ;position
  x.f
  y.f
  z.f
  ;color
  r.f
  g.f
  b.f
EndStructure


Global Dim vertex.Point3D(0)
Global.f maxX, minX, maxY, minY ; ranges to provide it to gluOrtho2D()


OpenWindow(0, 0, 0, 300, 300, "Curves ", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenGLGadget(0, 0, 0, 300, 300)
   
FillCurveData(0, 0, 0) ; just to find minX, maxX, minY, maxY

;Debug minX: Debug maxX ;calculated from the procedure
s.f = 0.5; make small margin
gluOrtho2D_(minX-s, maxX+s, minY-s, maxY+s)

glEnable_(#GL_POINT_SMOOTH)
glEnable_(#GL_LINE_SMOOTH) ; will make the line a little thick
;glLineWidth_(2)
;Debug ArraySize(vertex())

Repeat
 
DrawCurve()     

Repeat
    event = WindowEvent()
    If event = #PB_Event_CloseWindow
      quit = #True
    EndIf
  Until event = 0 Or quit = #True

Until quit = #True
 
End


Procedure FillCurveData(k, s.f, s2.f)
  b = 0
  Protected.f x,y, inc, t
  ;k = 3: s =  1/19: s2 = 1/6 ; toon triangle
  ;k=3: s =  0:  s2 = 1/3 ; concave triangle
  ;k=6: s = 0: s2 = 1/19 ; hexagon
  ;k=3: s = 0: s2 = 1/19 ; not perfect circle
  ;k=0: s = 0: s2 = 0; circle
   
  inc = 2*#PI/2000
 
     While t <= 2*#PI 
       
       x = -s2 *Sin(t - k*t) - s* Cos((k + 1)* t) + Cos(t)
       y = -s* Sin((k + 1)* t) + s2* Cos(t - k* t) + Sin(t)
             
       vertex(b)\r = 1 :vertex(b)\g = 0 :vertex(b)\b = 0
       
       vertex(b)\x = x
       vertex(b)\y = y
       vertex(b)\z = 0
       
 
       t + inc
       b + 1
       ReDim vertex(b)
       
     Wend

     SetWindowTitle(0, Str(b)+" vertices")
     ;**********************************************
     ;find the min and max values to provide them to gluOrtho2D_(,,,) function
     For i = 1 To b
      If minX > vertex(i)\x
         minX = vertex(i)\x
      EndIf
      If maxX < vertex(i)\x
         maxX = vertex(i)\x
       EndIf
    Next

    For i = 1 To b
      If minY > vertex(i)\y
         minY = vertex(i)\y
      EndIf
      If maxY < vertex(i)\y
         maxY = vertex(i)\y
      EndIf
    Next
 
     ;Debug b
   
  EndProcedure
 
 
  Procedure DrawCurve()
  SetGadgetAttribute(0, #PB_OpenGL_SetContext, #True)
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  glClearColor_(0.1, 0.2, 0.1, 1.0) ; background color
 
      glEnableClientState_(#GL_VERTEX_ARRAY)
      glEnableClientState_(#GL_COLOR_ARRAY)
      glVertexPointer_(3, #GL_FLOAT, SizeOf(Point3D), @vertex(0))
      glColorPointer_(3, #GL_FLOAT, SizeOf(Point3D), @vertex(0)\r)
     
      glEnable_(#GL_SCISSOR_TEST);
      glViewport_(0,0,150,150)
      glScissor_(0,0,150,150) ; cut part from the viewPort so clear color can be effective localy and not to the whole screen    ;
      glClearColor_(1.0, 0.7, 0.8, 0)
      glClear_(#GL_COLOR_BUFFER_BIT)
      FillCurveData(3, 1/19, 1/6)
      glDrawArrays_(#GL_LINE_STRIP, 0, ArraySize(vertex()))
     
      glViewport_(150,0,150,150)
      glScissor_(150,0,150,150)    ;
      glClearColor_(0.62, 0.81, 0.81, 0)
      glClear_(#GL_COLOR_BUFFER_BIT)
      FillCurveData(3, 0, 1/3)
      glDrawArrays_(#GL_LINE_STRIP, 0, ArraySize(vertex()))
     
      glViewport_(150,150,150,150)
      glScissor_(150,150,150,150)    ;
      glClearColor_(0.6, 0.8, 0.95, 0)
      glClear_(#GL_COLOR_BUFFER_BIT)
      FillCurveData(6, 0, 1/19)
      glDrawArrays_(#GL_LINE_STRIP, 0, ArraySize(vertex()))
      ;glDrawArrays_(#GL_LINES, 0, ArraySize(vertex()))
      ;glDrawArrays_(#GL_POINTS, 0, ArraySize(vertex()))
       
      glViewport_(0,150,150,150)
      glScissor_(0,150,150,150)   ;
      glClearColor_(0.86, 0.82, 0.82, 0)
      glClear_(#GL_COLOR_BUFFER_BIT)
      FillCurveData(0, 0, 0)
      glDrawArrays_(#GL_LINE_STRIP, 0, ArraySize(vertex()))
           
      glDisableClientState_(#GL_COLOR_ARRAY)
      glDisableClientState_(#GL_VERTEX_ARRAY)
   
  SetGadgetAttribute(0, #PB_OpenGL_FlipBuffers, #True)
EndProcedure





Note:: to let every viewport have its own specific gluOrtho2D(...)
use somthing like this:
Code:
glLoadIdentity_()
  gluOrtho2D_(0, xrng, 0, yrng)
  glViewport_(0,150,150,150)

for every viewport


Top
 Profile  
Reply with quote  
 Post subject: Re: Multiple ViewPorts in the same OpenGL window
PostPosted: Thu Feb 27, 2020 10:01 am 
Offline
Addict
Addict

Joined: Sun Jun 25, 2006 7:28 pm
Posts: 1404
i have searched for how to pass a structured arrays to a procedure and find this solution:
https://www.purebasic.fr/english/viewtopic.php?f=13&t=46687#p355058
so the following is a better solution when using glDrawArray to display 4 viewports
we prepare 4 vertex arrays
Code:
Global Dim vertex.Point3D(0) ; we will redim it later
Global Dim vertex2.Point3D(0)
...

and we declare the procedure:
Code:
Declare FillCurveData(Array pass.Point3D(1), k, s.f, s2.f)

and then we call it 4 times with different arrays, and constants
Code:
FillCurveData(vertex(),3, 1/19, 1/6)
FillCurveData(vertex2(),3, 0, 1/3)
...


Code:
Structure Point3D
  ;position
  x.f
  y.f
  z.f
  ;color
  r.f
  g.f
  b.f
EndStructure

Declare FillCurveData(Array pass.Point3D(1), k, s.f, s2.f)
Declare DrawCurve()

Global Dim vertex.Point3D(0)
Global Dim vertex2.Point3D(0)
Global Dim vertex3.Point3D(0)
Global Dim vertex4.Point3D(0)

Global.f maxX, minX, maxY, minY


OpenWindow(0, 0, 0, 300, 300, "Curves ", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenGLGadget(0, 0, 0, 300, 300)
   
FillCurveData(vertex(),3, 1/19, 1/6) ; also it finds the minX, maxX, minY, maxY needed by gluOrtho2D at the end of the procedure
FillCurveData(vertex2(),3, 0, 1/3)
FillCurveData(vertex3(),6, 0, 1/19)
FillCurveData(vertex4(),0, 0, 0)


;Debug minX: Debug maxX ;calculated from the procedure
s.f = 0.5; increasing the opengl windows range a little so the curve is not exactly fit the window
gluOrtho2D_(minX-s, maxX+s, minY-s, maxY+s)

glEnable_(#GL_POINT_SMOOTH)
glEnable_(#GL_LINE_SMOOTH) ; will make the line a little thick
;glLineWidth_(2)
;Debug ArraySize(vertex())

Repeat
 
DrawCurve()     

Repeat
    event = WindowEvent()
    If event = #PB_Event_CloseWindow
      quit = #True
    EndIf
  Until event = 0 Or quit = #True

Until quit = #True
 
End


Procedure FillCurveData(Array pass.Point3D(1),k, s.f, s2.f)
  b = 0
  Protected.f x,y, inc, t
  ;k = 3: s =  1/19: s2 = 1/6 ; toon triangle
  ;k=3: s =  0:  s2 = 1/3 ; concave triangle
  ;k=6: s = 0: s2 = 1/19 ; hexagon
  ;k=3: s = 0: s2 = 1/19 ; not perfect circle
  ;k=0: s = 0: s2 = 0; circle
   
  inc = 2*#PI/2000
 
     While t <= 2*#PI 
       
       x = -s2 *Sin(t - k*t) - s* Cos((k + 1)* t) + Cos(t)
       y = -s* Sin((k + 1)* t) + s2* Cos(t - k* t) + Sin(t)
             
       pass(b)\r = 1 :pass(b)\g = 0 :pass(b)\b = 0
       
       pass(b)\x = x
       pass(b)\y = y
       pass(b)\z = 0
       
 
       t + inc
       b + 1
       ReDim pass(b)
       
     Wend

     SetWindowTitle(0, Str(b)+" vertices")
     ;**********************************************
     ;find the min and max values to provide them to gluOrtho2D_(,,,) function
     For i = 1 To b
      If minX > pass(i)\x
         minX = pass(i)\x
      EndIf
      If maxX < pass(i)\x
         maxX = pass(i)\x
       EndIf
    Next

    For i = 1 To b
      If minY > pass(i)\y
         minY = pass(i)\y
      EndIf
      If maxY < pass(i)\y
         maxY = pass(i)\y
      EndIf
    Next
 
     ;Debug b
   
  EndProcedure

 
  Procedure DrawCurve()
  SetGadgetAttribute(0, #PB_OpenGL_SetContext, #True)
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  glClearColor_(0.1, 0.2, 0.1, 1.0) ; background color
 
      glEnableClientState_(#GL_VERTEX_ARRAY)
      glEnableClientState_(#GL_COLOR_ARRAY)
     
      rot.f + 1
      glRotatef_(rot, 0,0,1)
      glEnable_(#GL_SCISSOR_TEST);
      glViewport_(0,0,150,150)
      glScissor_(0,0,150,150) ; cut part from the viewPort so clear color can be effective localy and not to the whole screen    ;
      glClearColor_(1.0, 0.7, 0.8, 0)
      glClear_(#GL_COLOR_BUFFER_BIT)
      glVertexPointer_(3, #GL_FLOAT, SizeOf(Point3D), @vertex(0)\x)
      glColorPointer_(3, #GL_FLOAT, SizeOf(Point3D), @vertex(0)\r)
      glDrawArrays_(#GL_LINE_STRIP, 0, ArraySize(vertex()))
     
      glViewport_(150,0,150,150)
      glScissor_(150,0,150,150)    ;
      glClearColor_(0.62, 0.81, 0.81, 0)
      glClear_(#GL_COLOR_BUFFER_BIT)
      glVertexPointer_(3, #GL_FLOAT, SizeOf(Point3D), @vertex2(0)\x)
      glColorPointer_(3, #GL_FLOAT, SizeOf(Point3D), @vertex2(0)\r)
      glDrawArrays_(#GL_LINE_STRIP, 0, ArraySize(vertex2()))
     
      glViewport_(150,150,150,150)
      glScissor_(150,150,150,150)    ;
      glClearColor_(0.6, 0.8, 0.95, 0)
      glClear_(#GL_COLOR_BUFFER_BIT)
      glVertexPointer_(3, #GL_FLOAT, SizeOf(Point3D), @vertex3(0)\x)
      glColorPointer_(3, #GL_FLOAT, SizeOf(Point3D), @vertex3(0)\r)
      glDrawArrays_(#GL_LINE_STRIP, 0, ArraySize(vertex3()))
      ;glDrawArrays_(#GL_LINES, 0, ArraySize(vertex()))
      ;glDrawArrays_(#GL_POINTS, 0, ArraySize(vertex()))
       
      glViewport_(0,150,150,150)
      glScissor_(0,150,150,150)   ;
      glClearColor_(0.86, 0.82, 0.82, 0)
      glClear_(#GL_COLOR_BUFFER_BIT)
      glVertexPointer_(3, #GL_FLOAT, SizeOf(Point3D), @vertex4(0)\x)
      glColorPointer_(3, #GL_FLOAT, SizeOf(Point3D), @vertex4(0)\r)
      glDrawArrays_(#GL_LINE_STRIP, 0, ArraySize(vertex4()))
           
      glDisableClientState_(#GL_COLOR_ARRAY)
      glDisableClientState_(#GL_VERTEX_ARRAY)
   
  SetGadgetAttribute(0, #PB_OpenGL_FlipBuffers, #True)
EndProcedure





Top
 Profile  
Reply with quote  
 Post subject: Re: Multiple ViewPorts in the same OpenGL window
PostPosted: Tue Mar 10, 2020 4:15 pm 
Offline
Addict
Addict

Joined: Sun Jun 25, 2006 7:28 pm
Posts: 1404
i want to try the Multiple ViewPorts with PB Ogre
adapted from Camera.pb example, all the 4 cameras here are showing the same scene, ie the Robot and the Barrel,
but is it possible to draw different scene with every camera such as the camera 1: robot only
camera 2 the barrel only ...etc
Code:
InitEngine3D()
InitSprite()
InitKeyboard()

OpenWindow(0, 0, 0, 800, 600, " scene", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)

Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Models", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Scripts", #PB_3DArchive_FileSystem)
Parse3DScripts()

AmbientColor(RGB(0, 200, 0))  ; Green 'HUD' like color
 
    CreateMaterial(0, LoadTexture(0, "r2skin.jpg"))
    CreateMaterial(1, LoadTexture(1, "RustyBarrel.png"))
    CreateEntity(0, LoadMesh(0, "robot.mesh"), MaterialID(0))
    StartEntityAnimation(0, "Walk")
    ;----------------------------------------------
    CreateCamera(1, 0, 0, 50, 50)  ; First camera
    MoveCamera(1, 0, 0, 250, #PB_Absolute)
    CameraBackColor(1, RGB(255, 0, 0))
   
    CreateCamera(2, 50, 0, 50, 50)  ; second camera
    MoveCamera(2, 0, 0, 250, #PB_Absolute)
    CameraBackColor(2, RGB(55, 250, 0))
   
    CreateCamera(3, 0, 50, 50, 50) ; third camera
    MoveCamera(3, 0, 0, 250, #PB_Absolute)
    CameraBackColor(3, RGB(20, 25, 255))
   
    CreateCamera(4, 50, 50, 50, 50) ; fourth camera
    MoveCamera(4, 0, 0, 250, #PB_Absolute)
    CameraBackColor(4, RGB(255, 255, 0))
    CreateEntity(1, LoadMesh(1, "Barrel.mesh"), MaterialID(1), 60,0,0)
    ScaleEntity(1,10,10,10)   
    CameraRenderMode(4, #PB_Camera_Wireframe)  ; Wireframe for this camera
       
Repeat
   Repeat
    EventID = WindowEvent()
    Select EventID
      Case #PB_Event_Gadget
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
  Until EventID = 0
 
  RotateEntity(1,1,1,0, #PB_Relative)
 
  RenderWorld()
 
  FlipBuffers()
 
  ExamineKeyboard()
 
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1


i have tried using glViewPort with Ogre code compiled as Opengl subsystem(1)
i can't draw but one graphics for all viewPorts
Code:
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  CompilerIf Subsystem("OpenGL") = #False
    MessageRequester("Error", "Please set the subsystem to OpenGL")
    End
  CompilerEndIf
CompilerEndIf

InitEngine3D()
InitSprite()
InitKeyboard()

OpenWindow(0, 0, 0, 800, 600, "#PB_Camera_Orthographic ... with glViewport", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
;OpenWindowedScreen(WindowID(0), 0, 0, 800/2, 600/2)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)

Define.f KeyX, KeyY, MouseX, MouseY
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
CreateMaterial(0, LoadTexture(0, "White.jpg"))
DisableMaterialLighting(0, #True)
   
    ;- Mesh
    CreateMesh(0, #PB_Mesh_LineStrip, #PB_Mesh_Static)
    Define.f x, y, z, t
   
    k=6 ;20
    While t <= 2*#PI
      x.f = Cos(t) - Cos(k* t)/2 + Sin(14* t)/3
      y.f = Cos(14* t)/3 + Sin(t)- Sin(k* t)/2
      z.f = 0
           
      MeshVertexPosition(x, y, z)
      MeshVertexColor(RGB(255,0,0))

      t + 0.001
     
    Wend
       
    FinishMesh(#False)
   
    SetMeshMaterial(0, MaterialID(0))
    Plane = CreateNode(#PB_Any)
    AttachNodeObject(Plane, MeshID(0))
   
    ;-Camera
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0, 0, 0, 1, #PB_Absolute)
    CameraLookAt(0,0,0,0)
   
    CameraBackColor(0, RGB(50, 250, 50))
    Width.f = 2*#PI ; width of the plotting x range
    Height.f = (600/800)*Width ; 800 is the windowed Screen width
    CameraProjectionMode(0, #PB_Camera_Orthographic, 1*Width, 1*Height)
    glLineWidth_(2) ;thick lines only For opengl subsystem
   
    Repeat
     
 
  glClearColor_(0.7, 0.7, 0.5, 0) ; background color
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  Repeat
    event = WindowEvent()
    Select Event
      Case #PB_Event_CloseWindow
        quit = 1
     EndSelect
  Until event = 0
 
 RotateNode(Plane, 0, 0, 0.5, #PB_Relative)
 
 glViewport_(0,100,140,140)
 glLoadIdentity_()
 CameraBackColor(0, RGB(255, 250, 50))
 RenderWorld()
 glViewport_(150,100,350,350)
 glLoadIdentity_()
 CameraBackColor(0, RGB(25, 250, 50))
 RenderWorld()
 glViewport_(700,500,100,100)
 glLoadIdentity_()
 CameraBackColor(0, RGB(100, 25, 50))
 RenderWorld()
 
 FlipBuffers()
 
  ExamineKeyboard()
 
Until KeyboardPushed(#PB_Key_Escape) Or quit = 1


(1) Compiler -> Compiler Options -> Library subsystem: opengl


Top
 Profile  
Reply with quote  
 Post subject: Re: Multiple ViewPorts in the same OpenGL window
PostPosted: Wed Mar 11, 2020 10:46 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 853
Location: Denmark
@applePi
Something is broken in the 5.7x concerning the visibilitymask parameter. I can't get it to work.
It works in as expected in PB 5.62.

Code:
InitEngine3D()
InitSprite()
InitKeyboard()

#OBJ1 = 1<<1
#OBJ2 = 1<<2

OpenWindow(0, 0, 0, 800, 600, " scene", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)

Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Models", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Scripts", #PB_3DArchive_FileSystem)
Parse3DScripts()

AmbientColor(RGB(0, 200, 0))  ; Green 'HUD' like color
 
    ;----------------------------------------------
    CreateCamera(1, 0, 0, 50, 50, #OBJ1)  ; First camera
    MoveCamera(1, 0, 0, 250, #PB_Absolute)
    CameraBackColor(1, RGB(255, 0, 0))
   
    CreateCamera(2, 50, 0, 50, 50, #OBJ2)  ; second camera
    MoveCamera(2, 0, 0, 250, #PB_Absolute)
    CameraBackColor(2, RGB(55, 250, 0))
   
    CreateCamera(3, 0, 50, 50, 50, #OBJ1) ; third camera
    MoveCamera(3, 0, 0, 250, #PB_Absolute)
    CameraBackColor(3, RGB(20, 25, 255))
   
    CreateCamera(4, 50, 50, 50, 50) ; fourth camera
    MoveCamera(4, 0, 0, 250, #PB_Absolute)
    CameraBackColor(4, RGB(255, 255, 0))
   
    CreateMaterial(0, LoadTexture(0, "r2skin.jpg"))
    CreateMaterial(1, LoadTexture(1, "RustyBarrel.png"))
    CreateEntity(0, LoadMesh(0, "robot.mesh"), MaterialID(0), 0,0,0, 0,#OBJ2)
    StartEntityAnimation(0, "Walk")
   
    CreateEntity(1, LoadMesh(1, "Barrel.mesh"), MaterialID(1), 60,0,0, 0, #OBJ1)
    ScaleEntity(1,10,10,10)   
    CameraRenderMode(4, #PB_Camera_Wireframe)  ; Wireframe for this camera
       
Repeat
   Repeat
    EventID = WindowEvent()
    Select EventID
      Case #PB_Event_Gadget
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
  Until EventID = 0
 
  RotateEntity(1,1,1,0, #PB_Relative)
 
  RenderWorld()
 
  FlipBuffers()
 
  ExamineKeyboard()
 
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 10, Intel 6800K, GeForce Gtx 1060, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: Multiple ViewPorts in the same OpenGL window
PostPosted: Wed Mar 11, 2020 10:50 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14065
Location: France
Don't hesitate to fill a bug, so we can investigate


Top
 Profile  
Reply with quote  
 Post subject: Re: Multiple ViewPorts in the same OpenGL window
PostPosted: Wed Mar 11, 2020 11:49 am 
Offline
Addict
Addict

Joined: Sun Jun 25, 2006 7:28 pm
Posts: 1404
Thanks DK_PETER and Fred
this is a nice and short solution, it works fine in v5.62 and v5.46 .
Edit: works also with v5.70 LTS, but not 5.71 and up


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye