In fbgfx.bi we have these constants added:
Code: Select all
OGL_2D_NONE = 0
OGL_2D_MANUAL_SYNC = 1
OGL_2D_AUTO_SYNC = 2
SET_GL_2D_MODE = 150
SET_GL_SCALE = 151
Code: Select all
OGL_2D_NONE = 0
OGL_2D_MANUAL_SYNC = 1
OGL_2D_AUTO_SYNC = 2
SET_GL_2D_MODE = 150
SET_GL_SCALE = 151
[edit]
- ..........
..........- SET_GL_NUM_SAMPLES Sets the number of samples to be used for OpenGL multisampling
- [IN] param1 samples
- SET_GL_2D_MODE Sets OpenGL 2D render
- [IN] param1:
- OGL_2D_NONE No rendering
OGL_2D_MANUAL_SYNC Manual rendering (when Flip is called)
OGL_2D_AUTO_SYNC Automatic rendering- SET_GL_SCALE Apply a zoom factor of 2 on OpenGL 2D render (only allowed if OpenGL 2D render mode has yet been set via SET_GL_2D_MODE)
- [IN] param1:
- OGL_2D_NONE No rendering
OGL_2D_MANUAL_SYNC Manual rendering (when Flip is called)
OGL_2D_AUTO_SYNC Automatic rendering
But how to fix this for SET_GL_SCALE?Landeel wrote:The parameters for SET_GL_SCALE are wrong.
- ..........
..........- SET_GL_NUM_SAMPLES Sets the number of samples to be used for OpenGL multisampling
- [IN] param1 samples
- SET_GL_2D_MODE Sets OpenGL 2D render
- [IN] param1:
- OGL_2D_NONE No rendering
OGL_2D_MANUAL_SYNC Manual rendering (when Flip is called)
OGL_2D_AUTO_SYNC Automatic rendering- SET_GL_SCALE Apply a zoom factor of 2 on OpenGL 2D render (only allowed if OpenGL 2D render mode has yet been activated via SET_GL_2D_MODE)
- [IN] param1:
- OGL_2D_AUTO_SYNC Automatic rendering
(OGL_2D_NONE No more rendering)
Sorry but I did not play enough with it!Landeel wrote:It has nothing to do with sync. It's about scaling.
Either it should take a numeric value or we need new constants.
- ..........
..........- SET_GL_NUM_SAMPLES Sets the number of samples to be used for OpenGL multisampling
- [IN] param1 samples
- SET_GL_2D_MODE Sets OpenGL 2D render
- [IN] param1:
- OGL_2D_NONE No rendering
OGL_2D_MANUAL_SYNC Manual rendering (when Flip is called)
OGL_2D_AUTO_SYNC Automatic rendering- SET_GL_SCALE Apply a zoom factor on OpenGL 2D render (only allowed if OpenGL 2D render mode has yet been activated via SET_GL_2D_MODE)
- [IN] param1 Zoom factor (0: No rendering)
Sounds good to me.fxm wrote:Consistent with the 'ScreenRes' page, I propose to delete the values (in parentheses) of 'what' on the 'ScreenControl' page.
This comment seems important:coderJeff wrote:What can be or needs to be set-up before Screen/ScreenRes?
What can be changed after Screen/ScreenRes? To what effect?
fxm, thanks for testing and updating the manual.angros47 wrote:It is supposed to be a 1. Wait... in your test, you put ScreenControl after ScreenRes, you should put it BEFORE.
(ScreenControl is also used to set which driver will be used, so it has to be used before setting the graphic mode)
@angros47,fxm wrote:I tried on my PC. It works with a zoom factor from 1 to 14!
Code: Select all
#Include Once "GL/glu.bi"
#include once "fbgfx.bi"
using fb
screencontrol SET_GL_2D_MODE ,OGL_2D_MANUAL_SYNC
'screencontrol SET_GL_SCALE,1
Dim Shared As Integer xres,yres
Screenres 1024,512,32,,GFX_OPENGL
width 1024\8,512\16 'larger fonts
Screeninfo xres,yres
Function Regulate(Byval MyFps As long,Byref fps As long) As long
Static As Double timervalue,lastsleeptime,t3,frames
Dim As Double t=Timer
frames+=1
If (t-t3)>=1 Then t3=t:fps=frames:frames=0
Dim As long sleeptime=lastsleeptime+((1/myfps)-T+timervalue)*1000
If sleeptime<1 Then sleeptime=1
lastsleeptime=sleeptime
timervalue=T
Return sleeptime
End Function
Sub glsetup
glShadeModel(GL_SMOOTH) ' Enables Smooth Color Shading
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
glBlendFunc(GL_ONE,GL_ONE)
glEnable GL_ALPHA
glEnable GL_BLEND
glViewport(0, 0, xres, yres) ' Set the viewport
glMatrixMode(GL_PROJECTION) ' Change Matrix Mode to Projection
glLoadIdentity ' Reset View
gluPerspective(45.0, xres/yres, 1.0, 100.0)
glMatrixMode(GL_MODELVIEW) ' Return to the modelview matrix
glLoadIdentity ' Reset View
glclearcolor .2,0,0,1
End Sub
'Rotate and draw the cube with texturing on each face
Sub DrawGlCube(Byref rotangle As Single)
glLoadIdentity()
glTranslatef(0,0,-5)
glRotatef(rotangle,1,.5,.25) ' Rotate
glBegin(GL_QUADS)
glcolor3ub 255,0,0
glVertex3f( 1.0, 1.0,-1.0) ' Top right of the quad (top)
glVertex3f(-1.0, 1.0,-1.0) ' Top left of the quad (top)
glVertex3f(-1.0, 1.0, 1.0) ' Bottom left of the quad (top)
glVertex3f( 1.0, 1.0, 1.0) ' Bottom right of the quad (top)
glcolor3ub 255,100,0
glVertex3f( 1.0,-1.0, 1.0) ' Top right of the quad (bottom)
glVertex3f(-1.0,-1.0, 1.0) ' Top left of the quad (bottom)
glVertex3f(-1.0,-1.0,-1.0) ' Bottom left of the quad (bottom)
glVertex3f( 1.0,-1.0,-1.0) ' Bottom right of the quad (bottom)
glcolor3ub 255,0,255
glVertex3f( 1.0, 1.0, 1.0) ' Top right of the quad (front)
glVertex3f(-1.0, 1.0, 1.0) ' Top left of the quad (front)
glVertex3f(-1.0,-1.0, 1.0) ' Bottom left of the quad (front)
glVertex3f( 1.0,-1.0, 1.0) ' Bottom right of the quad (front)
glcolor3ub 0,0,200
glVertex3f( 1.0,-1.0,-1.0) ' Bottom left of the quad (back)
glVertex3f(-1.0,-1.0,-1.0) ' Bottom right of the quad (back)
glVertex3f(-1.0, 1.0,-1.0) ' Top right of the quad (back)
glVertex3f( 1.0, 1.0,-1.0) ' Top left of the quad (back)
glcolor3ub 0,255,0
glVertex3f(-1.0, 1.0, 1.0) ' Top right of the quad (left)
glVertex3f(-1.0, 1.0,-1.0) ' Top left of the quad (left)
glVertex3f(-1.0,-1.0,-1.0) ' Bottom left of the quad (left)
glVertex3f(-1.0,-1.0, 1.0) ' Bottom right of the quad (left)
glcolor3ub 255,0,100
glVertex3f( 1.0, 1.0,-1.0) ' Top right of the quad (right)
glVertex3f( 1.0, 1.0, 1.0) ' Top left of the quad (right)
glVertex3f( 1.0,-1.0, 1.0) ' Bottom left of the quad (right)
glVertex3f( 1.0,-1.0,-1.0)
glend
End Sub
'=============== for ball only =========
type pt
as long x=100,y=100
as single dx,dy
as long kx,ky
end type
sub ball()
static as pt b
static as long kx=1,ky=1
b.dx=8
b.dy=6.5
b.x+=b.dx*kx:b.y+=b.dy*ky
if b.x<50 or b.x>xres-50 then kx=-kx
if b.y<50 or b.y>yres-50 then ky=-ky
circle (b.x,b.y),50,rgb(0,100,255),,,,f
end sub
'===============
'NOW START OPENGL
glsetup
Dim As Single angle
dim as long fps
Do
angle=angle+1
glClear(GL_COLOR_BUFFER_BIT)
glEnable (GL_CULL_FACE)
DrawGlcube(angle)
gldisable (GL_CULL_FACE)
cls
glcolor3ub 255,255,255 'reset
ball()
draw string (20,20),"OpenGL cube with FreeBASIC ball and text",rgb(255,100,0)
draw string (30,50),"Frames per second = " &fps,rgb(255,255,255)
Flip
Sleep regulate(30,fps),1
Loop Until Inkey=Chr(27)