1. I'm learning how to make my own interface addons now, and wouldn't you know it I get to a stumper on my first one!

    My question is about how WoW draws textures and sets their coordinates. Here's some sample code:

     for i = 0, 1679, 2 do
        local myLines = fAlign:CreateTexture(nil, 'BACKGROUND');
    
        myLines:SetTexture(0,0,0,0.5);
        myLines:SetPoint('TOPLEFT',fAlign,'TOPLEFT',i,0);
        myLines:SetPoint('BOTTOMRIGHT',fAlign,'BOTTOMLEFT',i+1,0);
     end
    

    fAlign is a frame with SetAllPoints(UIParent). This code should create 1 pixel vertical lines every other pixel across the width of my monitor (1680x1050). It draws the lines, but they're not perfect pixels. Here's what this looks like (enlarged 4x):

    Bad Pixels

    It's creating some sort of pattern. Why is it doing this? Why is it not drawing pixel perfectly? Is there any way I can draw pixel perfectly? My UI scale is turned off, fyi.

    Thanks in advance, Travis

    PS - The addon purpose was a custom temporary grid for precise UI customization. I know there are others out there, but I wanted to my own specific dimensions on everything. Can you tell I'm an engineer? lol

  2. After several hours more experimenting, investigating, and learning, I know why it's glitching, I just don't know how to fix it.

    Looking at the UIParent frame, it's showing a width of about 1365. Why is this not 1680... my monitor's width and the resolution I have in game?

    Looking at this link, it says the units are in pixels, but I don't see that.

    My "Use UI Scale" is unticked.

    I did push a UIParent:GetScale, and it's showing 0.9ish... but that would result in around 1517, and I don't see any parent for UIParent, so wouldn't understand how the scale would work anyways.

    I need to stop working on this before I run out of hair to pull out, lol.

    Just doesn't make ANY sense to me why I'm not using 1680x1050 when UI scaling is disabled...

  3. So... the scale for UIParent, when I use UI Scale, goes from 0.64ish to exactly 1. When I uncheck Use UI Scale, it actually sets the Scale to 0.9ish, not what I assumed as 1.

    But, at a UIParent scale of 1, the width is 1228, not my resolution setting of 1680...

    With some math and a UIParent:SetScale, I came up with this code:

    /run UIParent:SetScale((UIParent:GetWidth()*UIParent:GetScale())/1680)

    This sets the UIParent frame to be my desired width (1680) and the height changes with scale also. Ran my code from before, and got pixel perfect beautiful lines! Bad part is, the UIParent scale won't save itself unless I use the inaccurate slider in the settings...

    I also feel this is a hacky way to do this... what's UIParent referencing since it's parent object is nil? Why is this all not defaulting to my resolution? mmm, tasty unanswered questions.

  4. OOOOOOO KKKKKKKK, so sorry I keep replying to my own thread here.

    I've found that changing the CVAR uiscale to my calculation works, and it saves it across reloads (with "Use UI Scale" on).

    So my final question is...

    Is this the proper way to do it? Why does my screen report a smaller resolution than I have? (ie GetScreenWidth)

    I've seen others whose screen resolution was reported perfectly, but mine is not, just some wierd lower resolution.

    Any insight would be appreciated.

  5. OOOOOOO KKKKKKKK, so sorry I keep replying to my own thread here.

    I've found that changing the CVAR uiscale to my calculation works, and it saves it across reloads (with "Use UI Scale" on).

    You shouldn't be doing this. When the documentation says 'pixels', we explain in the book that this means game pixels, which are not the same thing. The short answer is that you are going to be incredibly hard pressed to get pixel-accurate anything in WoW, just because it isn't designed that way.

    Is this the proper way to do it? Why does my screen report a smaller resolution than I have? (ie GetScreenWidth)

    No, it's not. That function reports the size of the screen in game pixels, which is resolution independent. It changes depending on the aspect ratio (I believe normal is 1024 and I expect 1228 is what you're seeing on a wide-screen AR, but I'm not positive).

    I've seen others whose screen resolution was reported perfectly, but mine is not, just some wierd lower resolution.

    The functions are not designed to report the actual resolution of the screen. This is all independent of scaling, it's just the way that WoW is designed. An addon should NEVER set the UI Scale, and an addon should never rely on a specific resolution in order to work. Either of those is just asking for trouble.

  6. I wasn't really thinking about redistribution when I made this. I was just trying to create my own custom textures and load them in with pixel by pixel accuracy (which I am able to do now successfully, and strangely enough the uiscale that I calculated is very close to what I tend to use anyways).

    I completely agree an addon that will be given to others should not rely on resolution, nor set the cvars. This specific one is for my own user interface only.

    I see and understand about game pixels now. Thanks a ton for your information on this counterintuitive, but logical, design. Now on to my next project to be useful to others! :)