summaryrefslogtreecommitdiff
path: root/src/graphics.h
AgeCommit message (Collapse)AuthorFilesLines
2025-04-25Simplified ImageRect handlingThorbjørn Lindeijer1-30/+27
We don't need to keep an array of SubImage instances, but can just remember the top, left, right and bottom margins and use those when rendering the scaled ImageRect. Graphics::drawRescaledImagePattern had to be extended to allow specifying the source rectangle.
2025-03-31GUI: Apply clipping only where necessaryThorbjørn Lindeijer1-0/+8
Clipping has been disabled globally by taking it out of Graphics::pushClipArea. Now its name is a little confusing, but it can't just be changed since it is part of Guichan. Widgets that do need to clip their children use the new Graphics::pushClipRect, which pushes a clipping rectangle without affecting the local coordinates. These are: * ScrollArea * TextField * TabbedArea (scrolling tabs) * MiniMap While it might count as a small optimization, I'm actually disabling clipping because it is not always desired. For example it gets in the way of rendering the complete ResizeGrip in the Jewelry theme because that's a child widget.
2025-03-24Added fill mode parameter to ImageRectThorbjørn Lindeijer1-1/+14
ImageRect now stretches the sides and center images by default because this is more efficient these days. FilMode::Repeat can be specified when repetition is desired. Added 'fill' attribute to allow the fill mode to be specified for the GUI theme images.
2025-03-24Define the GUI theme in XMLThorbjørn Lindeijer1-0/+2
Now all images used by the various UI widgets are defined in a `theme.xml`, removing hardcoded requirements on the size of images, borders and sub-images and their locations. The `colors.xml` file was merged into this new file as well. The `<img>` element defines either a plain image, or a 9-scale that is automatically rendered at the size of the widget when any of the `left`, `right`, `top` or `bottom` attributes are given. The `x`, `y`, `width` and `height` attributes determine the sub-rectangle within the image referenced by `src`. `x` and `y` default to 0 and `width` and `height` default to the imge size. The `<state>` element defines in which state its images are used by setting its `selected`, `disabled`, `hovered` or `focused` attributes to either `true` or `false`. Only the first matching state is rendered. The `Text` and `SpeechBubble` classes now use the same skin to draw the bubble, as well as using a newly introduced `BUBBLE_TEXT` color from the theme palette.
2025-03-17Have ImageRect automatically initialize and clean upThorbjørn Lindeijer1-0/+8
2025-01-21Replaced include guards with #pragma onceThorbjørn Lindeijer1-4/+1
Thanks to https://github.com/cgmb/guardonce and a follow-up replace to remove duplicated newlines at end of file: find src -type f -name '*.h' -exec \ sed --in-place -e :a -e '/^\n*$/{$d;N;};/\n$/ba' {} \; Source: https://unix.stackexchange.com/questions/81685/how-to-remove-multiple-newlines-at-eof Fixes compile on macOS, which appears to have been due to the EVENT_H include guard.
2024-10-18Take only const pointers to images in GraphicsThorbjørn Lindeijer1-13/+13
Helps making sure we're not modifying the images in the rendering code. Re-applies 4eea727b7649726670d8963d11ab4fd429624b3e (and reverts 363f71157a8107190b3bd2ba656faf0a0e63ab36).
2024-03-26Added support for HiDPI fontsThorbjørn Lindeijer1-0/+6
* TrueTypeFont class now takes into account the graphics scale, in order to render an appropriate higher-resolution texture. * Removed TrueTypeFont::fontCounter, since TTF_Init/TTF_Quit already keep a counter. * Avoid copying the rendered string needlessly, when it already exists in the cache. Avoid another copy, when inserting a new chunk into the cache.
2024-03-26Added functions to draw images at sub-pixel positionsThorbjørn Lindeijer1-0/+29
This can be used for smoother mouse cursor movement when rendering our own mouse cursor (already changed in this commit) and is also necessary for implementing support for HiDPI font rendering. Also dropped some almost duplicated OpenGL code.
2024-03-22Added support for scaling the outputThorbjørn Lindeijer1-5/+18
* Added "Scale" user option, which can either by "Auto" or an explicit scaling factor. Its maximum value depends on the current resolution. The "Auto" factor is based on keeping the logical resolution on at least 800x600, wheres the maximum scale is based on keeping the logical resolution on at least 640x480. * Enabled support for High DPI. This means the rendering target can now have a different resolution than the window size, which can happen on macOS, Windows and Wayland. The resulting scale is multiplied by the above user-controlled scale. Currently, this looks ugly for non-integer scales, which are not used on macOS and can only be configured on some Wayland compositors. Has not been tested on Windows. * Simplified OpenGL initialization (moved out of _beginDraw). * Made sure _beginDraw/_endDraw sets a clip area also for SDLGraphics.
2024-02-27Added VSync and windowed fullscreen optionsThorbjørn Lindeijer1-87/+27
The configuration and setup UI were adjusted to the new options. This also fixes issues in applying new video settings. Default resolution was changed from 800x600 to 1280x720. VSync is enabled by default while FPS limit was disabled. Display aspect ratio for the resolution options. I had to work around some macOS issues: * Don't change window size when it appears to be "maximized", since it just changes the rendering area while leaving the window maximized. * Unset fullscreen display mode temporarily to allow changing resolutions, otherwise the rendering area no longer matches the screen and mouse input is also off. * Removed SDL_WINDOW_ALLOW_HIGHDPI for now because it causes issues on macOS, since we're not actually handling the scaling factor. A Video class and an SDLGraphics subclass were split off from Graphics. This setup has Less duplication and leaves the OpenGLGraphics and SDLGraphics better separated. Fixes #57 Fixes #58
2024-01-29Apply C++11 fixitsThorbjørn Lindeijer1-0/+2
modernize-loop-convert modernize-deprecated-headers
2024-01-26Apply C++11 fixitsThorbjørn Lindeijer1-11/+11
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
2024-01-25Ported to SDL2Thorbjørn Lindeijer1-37/+62
2012-08-12Removed ImageLoader and ProxyImage classesThorbjørn Lindeijer1-6/+0
They allowed using gcn::Image, which in turns allows using gcn::Icon and gcn::ImageFont, but none of this is actually used anymore. Reviewed-by: Erik Schilling
2012-08-05Revert "Graphics: take only const pointers to images."Thorbjørn Lindeijer1-3/+3
This reverts commit 4eea727b7649726670d8963d11ab4fd429624b3e. It broke the overrides of the virtual functions and leaves the Graphics API in inconsistent state with some Image* being const and others not.
2012-08-05Graphics: take only const pointers to images.Stefan Beller1-3/+3
Acked-by: Erik Schilling
2012-02-09Allow changing fullscreen resolution without restartThorbjørn Lindeijer1-8/+21
Unified Graphics:setFullscreen and Graphics:resize into a single Graphics:changeVideoMode function that tries to restore the existing mode when changing to the new mode didn't work, and exists with an error when that also fails. Split up handling of SDL_VIDEORESIZE and the adapting to new resolution in the Client class, so that the second part could also be called when changing resolution fullscreen mode. The Video tab in the Setup window now also filters out any modes smaller than 640x480 since the game won't properly adapt to that resolution anyway. Reviewed-by: Yohann Ferreira
2012-01-26Updated copyrights to 2012Thorbjørn Lindeijer1-1/+1
2012-01-26Removed 'inline' keyword where it's not of any valueThorbjørn Lindeijer1-2/+2
Members that are implemented inline are already inline, there is no need to mark them as such. Made two inline members of OpenGLGraphics private since because they are marked as inline, they can't be used from other classes. Reviewed-by: Erik Schilling
2012-01-22Allow resizing of the game in windowed modeThorbjørn Lindeijer1-0/+5
Window positions are semi-smartly corrected as a result of the resize. Not supported when using OpenGL on Windows for now. Reviewed-by: Yohann Ferreira
2011-04-09Removed a lot of useless "documentation"Thorbjørn Lindeijer1-6/+0
I have to admit I contributed a large part of these. Sorry for that. Less empty space, more attention to the code. Acked-by: Jared Adams
2010-05-20Buffer layered sprites under SDLJared Adams1-0/+12
This improves framerate and allows transparent overlay for complex sprites. Two copies of the buffer are kept, one at full opacity, one with variable opactiy, to reduce calls to setAlpha. Reviewed-by: Bertram
2010-02-22Modify copyright headersFreeyorp1-1/+2
2010-02-20License header update for The Mana ClientThorbjørn Lindeijer1-4/+3
2010-02-14Removed a redundant SDL_Surface pointerTametomo1-1/+0
Signed-off-by: Tametomo <irarice@gmail.com>
2010-02-10Improve look and utility of the SkillDialogJared Adams1-0/+10
2010-02-09Got rid of non-sensical Vector operator overloadsThorbjørn Lindeijer1-1/+1
Just because something is the kind of calculation that seems to be required does not mean it makes sense in general. Let's try to keep things understandable.
2010-02-08Fix finding width of bold textJared Adams1-0/+2
2010-02-07Updated Copyright year to 2010!Bertram1-1/+1
Also added the update copyright tool from the Wormux Team. ( And not forgetting credit's due. :P )
2010-01-26Fixed crash when failing to switch to fullscreen/windowedThorbjørn Lindeijer1-1/+5
The setup page tries to restore the previous video mode by calling setFullscreen again after it has failed. However, the setFullscreen function assumed a valid mode was set (it referenced mScreen). This would then crash. Worked around by remembering the parameters passed to setVideoMode, and using those in setFullscreen. Besides fixing a potential crash, this also fixes switching between fullscreen and windowed on Maemo 5. Probably trying to keep the color depth the same was what made it fail (which is not necessary anyway).
2009-07-27Added the ability to ask a ambient layer to keep its ratio when the ↵Bertram1-0/+10
resolution isn't the default. You'll have to add this in map properties, for instance if you're want to keep ratio on overlay 0: <map version="1.0" orientation="orthogonal" width="128" height="128" tilewidth="32" tileheight="32"> <properties> ... <property name="overlay0keepratio" value="true"/> ... </properties> </map>
2009-07-24Made the wallpaper be rescaled when necessary under SDL and OpenGL.Bertram1-0/+22
The SDL methods to rescale the wallpaper has been optimized to permit rescaling at load time while OpenGL draws directly rescaled. Does someone know how to smooth the rescaled image under OpenGL?
2009-04-14Put the remaining unnamespaced handlers in a namespaceBjørn Lindeijer1-5/+5
Also fixed some initialization order warnings when compiling with tmwserv support and made two getters const.
2009-03-25A host of code style fixesBjørn Lindeijer1-1/+1
Mostly putting & and * in the right place and making some getters const.
2009-03-23Merge branch 'aethyra/master'Bjørn Lindeijer1-0/+13
Conflicts: Many files.
2009-03-10Extended window layout to take relative positions, as well as offsets toIra Rice1-0/+13
that position. This makes it so that when resolutions are changed, the default locations stay relative to the window's position, and not the 800x600 screen resolution. Signed-off-by: Ira Rice <irarice@gmail.com>
2009-02-10Fixed header files, as well as removed the unused buddy list class (notIra Rice1-2/+3
useful since buddy lists are tracked through the player relation interface instead) Signed-off-by: Ira Rice <irarice@gmail.com>
2009-02-07Some more include cleanups.Ira Rice1-2/+6
Signed-off-by: Ira Rice <irarice@gmail.com>
2009-01-23Removed unnecessary references to The Mana World in code headersBjørn Lindeijer1-4/+4
This dates back to the old days of TMW, but the usage instructions of GPLv2 don't mention this being necessary. Since it doesn't add anything, avoid the branding in these sections.
2009-01-15Style cleanups throughout most of the code. Splitting function type fromIra Rice1-11/+9
the function names should no longer be around. Signed-off-by: Ira Rice <irarice@gmail.com>
2008-11-18Pedantic fixes to the client, where I alphabetized all of the include Ira Rice1-2/+0
statements, as well as removing the new skill dialog, which we do not, nor will we use (if we do, it'd be a new one that we'd make). WARNING!!! This, and all other previous builds have a linker error for the Gnome libraries version 4.3.2 on my setup. It's assumed that this is also the case for other users of this library as well. I'm currently assuming that there's a bug in the compiler itself, and will look into reporting this, but in the mean time, it doesn't build for these users, unfortunately. Sorry about this.
2008-07-18Import of client treeLloyd Bryant1-1/+1
2007-10-18Merged removal of dependency on Guichan OpenGL from trunk to 0.0 branch, Bjørn Lindeijer1-1/+8
including optimization of OpenGL memory usage on modern OpenGL drivers. Patches by Guillaume Melquiond.
2007-09-20Merged a bunch of small changes from trunk to 0.0 and set svn:eol-style Bjørn Lindeijer1-1/+1
to native for some files that were still missing this property. This is a feeble attempt to reduce the amount of conflicts for future merges.
2007-06-03Fixed image loading in software mode to not check for alpha layer with imagesBjørn Lindeijer1-8/+0
aren't 32-bit and removed drawImageTransparent from Graphics class, should be set on image.
2007-05-04Merged particle engine into main eAthena branch.Philipp Sehmisch1-0/+8
2006-12-12Merged r2829 from trunk (Merged the definition of ImageRect into graphics.h)Bjørn Lindeijer1-0/+21
2006-01-31Various small cleanups.Björn Steinbrink1-2/+0
2005-09-19Mostly code cleanups related to commits in past two days.Bjørn Lindeijer1-2/+2
* Replaced custom function FIND_PATH with AC_PATH_PROG, used for finding sdl-config. * Removed -lphysfs from Makefile.am which should be added automatically already. * Actually show the overweight message, and only show it once for each time weight goes above half the max weight. * Surfaces passed to SDL_BlitSurface shouldn't be locked according to the manual. * Minimal fps limit is now 10 fps. * Reverted change by Bertram that hardcoded the updatehost value.