bmx-ng / sdl.mod

SDL backend for BlitzMax
7 stars 6 forks source link

[sdlgraphics.mod] Allow configurable window settings #21

Closed GWRon closed 1 year ago

GWRon commented 5 years ago

As default any SDL-Window is now created in the "center position". Also it uses default flags (so not borderless, not minimized, ...).

While other window creation methods might not provide these functionality I thought about adding some helpers to define "default flags" for the window creation.

TSDLWindow.SetDefaultWindowPosition() TSDLWindow.SetDefaultWindowFlags()

They set some global variables which are used then in

    Method SDLGraphicsCreateGraphics:TGraphicsContext(width:Int,height:Int,depth:Int,hertz:Int,flags:Int)
[...]
        context.window = TSDLWindow.Create(AppTitle, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, windowFlags)

Another question: ~There are constants like GRAPHICS_BACKBUFFER (value of "$2"). During creation of a SDL window you can pass flags too - but GRAPHICS_BACKBUFFER (and other BlitzMax) constants are not extracted into glFlags. It only extracts SDL_GRAPHICS_BACKBUFFER (value of "$00800000") and others $40000000. Maybe there should be an autoconversion for GRAPHICS_*** to SDL_GRAPHICS_*** ?~ For now it only does this with "SDL_GRAPHICS_NATIVE" ... got it.

Seems "SDL_GRAPHICS_ACCUMBUFFER" does not get evaluated in the glFlags:

            If glFlags Then
                If gFlags & SDL_GRAPHICS_BACKBUFFER Then SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1)
                If gFlags & SDL_GRAPHICS_ALPHABUFFER Then SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 1)
                If gFlags & SDL_GRAPHICS_DEPTHBUFFER Then SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24)
                If gFlags & SDL_GRAPHICS_STENCILBUFFER Then SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1)
            End If

SDL_GL_ACCUM_RED_SIZE the minimum number of bits for the red channel of the accumulation buffer; defaults to 0 SDL_GL_ACCUM_GREEN_SIZE the minimum number of bits for the green channel of the accumulation buffer; defaults to 0 SDL_GL_ACCUM_BLUE_SIZE the minimum number of bits for the blue channel of the accumulation buffer; defaults to 0 SDL_GL_ACCUM_ALPHA_SIZE the minimum number of bits for the alpha channel of the accumulation buffer; defaults to 0 https://wiki.libsdl.org/SDL_GL_SetAttribute

woollybah commented 5 years ago

It may be worth extending the main Graphics() related functions to include x,y somewhere.

GWRon commented 1 year ago

X and Y are now part of the Graphics()