Author Topic: Window fullscreen problem.  (Read 9987 times)

0 Members and 1 Guest are viewing this topic.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Window fullscreen problem.
« Reply #20 on: January 28, 2008 »
yeah thats right,

and now i come to think of it as long as you stay away from freebasic commands altogether you could use jims tinyfy processes and get your exe's really small with this.
Challenge Trophies Won:

Offline stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
Re: Window fullscreen problem.
« Reply #21 on: January 28, 2008 »
why not writing everything from scratch by yourself? it's not that hard and you can really get low sizes if you do not link with all the Windows common lib-mess. Plus you will gain extra control on everything... and for sure less problems when learning.
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Window fullscreen problem.
« Reply #22 on: January 29, 2008 »
shockwave i hope you dont mind ive had a wee play around with your code.

i spotted a gdi ogl font sample on nehe and couldnt resist trying it out in freebasic the results are quite impressive i think it lets you convert any sytem font to an ogl 3d vector font and the final exe is only 3.5k bigger uncompressed.

here is the code.

Code: [Select]
      option explicit
        option static

'-------------------------------------
' Includes
'-------------------------------------

    #include "GL/gl.bi"
    #include "GL/glu.bi"
    #include "windows.bi"
    #include "crt.bi"
   
    DIM SHARED AS BYTE W_FULLSCREEN =1 : ' 1 = FULLSCREEN
    DIM SHARED AS INTEGER W_XO =40      : ' X pos of window
    DIM SHARED AS INTEGER W_YO =40      : ' Y pos of window   
    DIM SHARED AS INTEGER W_XW =1024    : ' Width.
    DIM SHARED AS INTEGER W_YH =768    : ' Height.

    DIM SHARED pfd as PIXELFORMATDESCRIPTOR
    DIM SHARED hdc as hDC
    DECLARE SUB InitOGL()


    DIM SHARED AS INTEGER STARS=500
    DIM SHARED AS DOUBLE VVX(STARS)
    DIM SHARED AS DOUBLE VVY(STARS)
    DIM SHARED AS DOUBLE VVZ(STARS)

    DECLARE SUB STARINIT()
    DECLARE SUB STARFIELD()



    STARINIT()

DIM SHARED XR AS SINGLE : ' X ROTATION
DIM SHARED YR AS SINGLE : ' Y ROTATION
DIM SHARED ZR AS SINGLE : ' Z ROTATION
   

DIM D AS INTEGER
DIM SHARED AS DOUBLE GX,GY,GZ,TW,ZRR,XRR,YRR,RRR,delta,mm,fr

'added gl list font variable
Dim shared FBase As GLuint
'added array to hold info about font charicters
Dim shared gmf( 0 To 256 ) As GLYPHMETRICSFLOAT
Dim shared rot As Single
Declare Sub glPrint(fmt as string)

mm=timer

InitOGL()
'===============================================================================
' MAIN LOOP
'===============================================================================
WHILE((GetAsyncKeyState(VK_ESCAPE)<>-32767))


    glClear(GL_DEPTH_BUFFER_BIT + GL_COLOR_BUFFER_BIT )
    glLoadIdentity()
    GlPushMatrix
glTranslatef(0.0f,0.0f,-3.0-cos(rot/20.0f))
glRotatef(rot,1.0f,0.0f,0.0f)
glRotatef(rot*1.5f,0.0f,1.0f,0.0f)
glRotatef(rot*1.4f,0.0f,0.0f,1.0f)
glColor3f(1.0f*cast( single , cos(rot/20.0f) ),1.0f*cast( single , sin(rot/25.0f) ),1.0f-0.5f*cast( single , cos(rot/17.0f) ) )
  glPrint("Hello EveryOne")
rot += 0.5f
    GlPopMatrix
    starfield()
    GLFLUSH()
   
        TW=TIMER
   
        fr=fr+1
        xr = xr +delta
yr = yr +delta
zr = zr +delta
       
if timer-mm>=.05 then
    delta=0.3/fr
    mm=timer
    fr=0
end if
SwapBuffers(hDC)
sleep 1


WEND

glDeleteLists(FBase, 256)
END



SUB STARFIELD
DIM A AS INTEGER

GLPUSHMATRIX
    glTranslatef(0, 0, -9)     
    glRotatef(XR, 1.0, 0.0, 0.0)
    glRotatef(YR, 0.0, 1.0, 0.0)
    glRotatef(ZR, 0.0, 0.0, 1.0)   
   
    glpointsize 1.5

    FOR A=0 TO STARS

    GLCOLOR3F 0.4,0.6,1.0
    GLBEGIN GL_POINTS
        GLVERTEX3F vvx(a),vvy(a),vvz(a)
    GLEND
   
    vvz(a)=vvz(a)+(delta*2)
    if vvz(a)>=20 then vvz(a)=vvz(a)-40
    NEXT

GLPOPMATRIX

GLPUSHMATRIX
        glTranslatef(0, 0, -12)

glbegin gl_lines
        GLCOLOR3F 0.6,0.6,1.0
        GLVERTEX3F -17.4,-9.8,0
        GLCOLOR3F 0.9,0.8,1.0
        GLVERTEX3F  17.4,-9.8,0

        GLVERTEX3F -17.4,9.8,0
        GLCOLOR3F 0.6,0.6,1.0
        GLVERTEX3F  17.4,9.8,0

glend

GLPOPMATRIX


END SUB


SUB STARINIT()

DIM A AS INTEGER

FOR A=0 TO STARS
    VVX(A)=(RND(1)*40)-20
    VVY(A)=(RND(1)*40)-20
    VVZ(A)=(RND(1)*40)-20
NEXT

END SUB


'===============================================================================
' Initialise OpenGL
'===============================================================================
sub InitOGL()

pfd.cColorBits = 32
    pfd.cDepthBits = 32
pfd.dwFlags    = PFD_SUPPORT_OPENGL + PFD_DOUBLEBUFFER
    IF W_FULLSCREEN=1 THEN hDC = GetDC(CreateWindow( "Edit", "BLAH!", WS_POPUP+WS_VISIBLE+WS_MAXIMIZE, 0 , 0 , 0 , 0, 0, 0, 0, 0))
    IF W_FULLSCREEN<>1 THEN hDC = GetDC(CreateWindow("Edit", "BLAH!", WS_POPUP+WS_VISIBLE+WS_BORDER,W_XO, W_YO, W_XW , W_YH, 0, 0, 0, 0))   
SetPixelFormat ( hDC, ChoosePixelFormat ( hDC, @pfd) , @pfd )
wglMakeCurrent ( hDC, wglCreateContext(hDC) )
    ShowCursor(FALSE)
   

    GLVIEWPORT 0, 0, W_XW, W_YH                          '' Reset The Current Viewport
GLMATRIXMODE GL_PROJECTION                          '' Select The Projection Matrix
GLLOADIDENTITY
   
    GLUPERSPECTIVE 90.0, W_XW / W_YH, 0.1, 100.0       '' Calculate The Aspect Ratio Of The Window
   
GLMATRIXMODE GL_MODELVIEW                           '' Select The Modelview Matrix
GLLOADIDENTITY                                      '' Reset The Modelview Matrix

GLSHADEMODEL GL_SMOOTH                              '' Enable Smooth Shading
GLCLEARCOLOR 0.0, 0.0, 0.0,0
GLCLEARDEPTH 1.0                                    '' Depth Buffer Setup
GLENABLE GL_DEPTH_TEST                              '' Enables Depth Testing
GLDEPTHFUNC GL_LEQUAL                               '' The Type Of Depth Testing To Do
GLHINT GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST    '' Really Nice Perspective Calculations


    GLHINT(GL_FOG_HINT,GL_NICEST)
    GLFOGF(GL_FOG_DENSITY,0.05)
    GLFOGF(GL_FOG_START,    13.0)
    GLFOGF(GL_FOG_END,     15.0)
    GLFOGI(GL_FOG_MODE,GL_EXP2)   
    GLENABLE (GL_FOG)
   
    'tiny ogl font init
    dim Font as HFONT
FBase = glGenLists(256)
Font = CreateFont( -12, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE or DEFAULT_PITCH, "Comic Sans MS")
SelectObject(hDC, Font)
wglUseFontOutlines( hDC, 0, 255, FBase, 0.0f, 0.2f, WGL_FONT_POLYGONS, @gmf(0))

end sub

Sub glPrint(fmt As String)

        Dim As Single length = 0
        Dim text As ZString Ptr
        text = Allocate( 256 + 1 )

        *text = fmt
        Dim as integer MLoop
        for MLoop = 0 to strlen(text)
length += gmf(text[MLoop]).gmfCellIncX
        Next

glTranslatef(-Length/2,0.0f,0.0f)

glPushAttrib(GL_LIST_BIT)
glListBase(FBase)
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text)
glPopAttrib()

End Sub

have a play around and see what you think try changing WGL_FONT_POLYGONS to WGL_FONT_LINES
« Last Edit: January 29, 2008 by ninogenio »
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Window fullscreen problem.
« Reply #23 on: January 29, 2008 »
Hi Nino, that's a nice useful example :)

Thank you for posting it and have some good Karma. Loading truetype fonts was going to be one of my next projects, you must have read my mind!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Window fullscreen problem.
« Reply #24 on: January 29, 2008 »
no problem mate.

if you need any info on controlling the fonts you create this is a good read.

http://functionx.com/visualc/gdi/fonts.htm

im glad the example is of some use and thanks for the karma!
Challenge Trophies Won: