summaryrefslogtreecommitdiff
path: root/src/openglgraphics.cpp
AgeCommit message (Collapse)AuthorFilesLines
6 daysFixed clipping issue when using legacy OpenGL rendererThorbjørn Lindeijer1-2/+0
Fixes regression in 80f76c3aae438f7b9a7c1359c3f37aac460f934b. The scissor is no longer always enabled, but since it was enabled on startup there was visible clipping when resizing the window right after startup.
6 daysWork around issue with minimizing maximized windowsThorbjørn Lindeijer1-1/+0
Only call `SDL_ShowWindow` once, since it seems old SDL versions (like 2.30.0, shipping with Ubuntu 24.04) do not allow a maximized window to be minimized when `SDL_ShowWindow` is called each frame.
2025-07-04Added logging priorities and use SDLs logging facilitiesThorbjørn Lindeijer1-2/+2
By using SDL logging, we can rely on SDL to filter the log messages by their priority before they get sent to our custom output function. For example, we now no longer get entries for created and destroyed Window instances by default, since these have only "debug" priority whereas the default priority for the "app" category is "info". We can also get log messages raised by SDL itself in our log now. Log levels can be controlled per category through the "SDL_LOGGING" environment variable. Many existing log messages have been assigned a category based on their existing prefix.
2025-07-02Delay showing of the window to avoid startup flickerThorbjørn Lindeijer1-0/+1
Otherwise, at least on X11, the window is (visibly) re-created once the SDL renderer is created. Also the window icon can be seen changing on startup. Showing the window only after all related setup has been completed avoids this. On X11 this appears to have the added benefit of putting a "windowed fullscreen" window on the active screen (in terms of where the mouse is) rather than always using the primary screen. On Windows, showing the window only after the initial paint avoids the window initially appearing with its contents entirely black. The window is still immediately shown in the following cases: * In exclusive fullscreen mode, because on Windows this caused the initial show of a fullscreen window to take much longer and on X11 it could cause the resolution of the primary screen to be changed while maximizing the Mana window on the active screen. * In "windowed fullscreen" mode when the legacy OpenGL renderer is used, where it was causing an additional flicker on Windows.
2025-04-25Simplified ImageRect handlingThorbjørn Lindeijer1-39/+39
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-19/+19
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-01-25snap: Updated to core24Thorbjørn Lindeijer1-0/+2
2024-10-18Take only const pointers to images in GraphicsThorbjørn Lindeijer1-9/+9
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-5/+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-106/+20
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-41/+72
* 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-03-02General code cleanupsThorbjørn Lindeijer1-4/+2
* Don't needlessly store or return raw pointers in BeingInfo * Less copying, more moving * Less else after return * Make AddDEF a template instead of a macro * Removed some unused includes * Use range-based for loops
2024-02-27Added VSync and windowed fullscreen optionsThorbjørn Lindeijer1-97/+36
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-26Apply C++11 fixitsThorbjørn Lindeijer1-5/+5
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
2024-01-25Ported to SDL2Thorbjørn Lindeijer1-21/+54
2012-08-12Removed manual calling of glFlush and made glFinish optionalThorbjørn Lindeijer1-3/+20
Actually neither glFlush nor glFinish need to be called manually [1]. However, the rendering pipeline is then free to queue up future frames which can cause a lag which is especially noticable with mouse movement. To avoid this lag, we call glFinish after SDL_GL_SwapBuffers. This makes sure processing of the next frame does not start before the current frame is being displayed. [1] http://www.opengl.org/wiki/Common_Mistakes#glFinish_and_glFlush Reviewed-by: Yohann Ferreira Sounded-fine-to: Erik Schilling
2012-08-05Added support for ARB_texture_non_power_of_two extensionThorbjørn Lindeijer1-1/+4
If the graphics driver supports this, there is no need to create textures with power-of-two dimensions. It is then also preferred to use regular textures than relying on the older GL_ARB_texture_rectangle extension. Reviewed-by: Erik Schilling
2012-08-05Some cleanups in OpenGL codeThorbjørn Lindeijer1-37/+0
* Removed empty and unused function `setTargetPlane` * Removed duplicated enabling of `GL_VERTEX_ARRAY` * Removed strange smoothing code from `drawRescaledImage` Reviewed-by: Erik Schilling
2012-08-05Fixed mixup of parameter types in OpenGL codeThorbjørn Lindeijer1-4/+4
Textures were not rendering correctly on cards that did not support the GL_ARB_texture_rectangle extension, since the alternative code path was passing ints as floats and floats as ints to OpenGL. Reviewed-by: Erik Schilling
2012-01-26Updated copyrights to 2012Thorbjørn Lindeijer1-1/+1
2012-01-22Allow resizing of the game in windowed modeThorbjørn Lindeijer1-0/+11
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
2012-01-16Restore GL_PACK_ALIGNMENT after creating screenshots in OpenGL modeAndrei Karas1-0/+4
Reviewed-by: Thorbjørn Lindeijer Reviewed-by: Yohann Ferreira
2011-09-13Fixed OpenGLGraphics::drawRescaledImagePatternThorbjørn Lindeijer1-32/+45
This fixes overlay effects that are meant to scale with screen resolution. The problem was that the texture coordinates were not calculated correctly. They were adjusted to the scaled size of the image, and when scaling both the vertex and the texture coordinates, the image will simply not appear scaled at all. Now the texture coordinates are calculated based on the visible part of the original texture. There was also a problem with the vertex coordinates, which were not taking into account the visible part of the image. TMW-Mantis-issue: 1047
2010-12-06Removed superfluous #includes taken from checkheaders list.Yohann Ferreira1-2/+0
Resolves: Mana-Mantis #265. Trivial fix.
2010-07-27Improve OpenGL speed.Andrei Karas1-107/+395
Use batch commands and not selecting already selected texture. Signed-off-by: Jared Adams <jaxad0127@gmail.com>
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-7/+7
Signed-off-by: Tametomo <irarice@gmail.com>
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-27Copy height/width/bpp cache setting from Graphics::setVideoMode to ↵Daniel Bradshaw1-0/+3
OpenGLGraphics::setVideoMode to stop Graphics::getWidth and getHeight returning 0
2010-01-12Standardize header orderJared Adams1-2/+2
Also remove some extra new lines and fix eAthena's PartyTab define guards.
2009-10-09Made the smooth effect quadratic.Bertram1-0/+5
2009-10-09IAS (I am stupid (TM) ;D...Bertram1-4/+6
2009-10-09Final fix (or I hope so) to smooth effect in OpenGL.Bertram1-2/+3
2009-10-07Fixed wallpaper blur by only using resized image drawing when it is necessaryPhilipp Sehmisch1-0/+6
2009-09-23Added a basic smooth effect to rescaled wallpapers in OpenGL.Bertram1-0/+23
The current login wallpaper (as any streched ones) will look a bit less ugly...
2009-07-27Added the ability to ask a ambient layer to keep its ratio when the ↵Bertram1-0/+43
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/+67
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-14Unduplicated the code that draws a quadBjørn Lindeijer1-58/+36
Shouldn't affect performance.
2009-03-23Merge branch 'aethyra/master'Bjørn Lindeijer1-20/+93
Conflicts: Many files.
2009-03-18Fixed a broken Mac include for SDL_ttfBjørn Lindeijer1-2/+2
Reviewed-by: trapdoor
2009-03-17Added an image merge feature loosely based on a merge function found inIra Rice1-1/+0
the open source project Wormux. To improve SDL performance, the number of layers that are pushed out to the hardware or software buffers should be reduced, which is where this function comes into play, as it combines two surfaces together so that the number of blit operations is reduced. This function is currently not used, but will be used once a good way to link each of the target systems is determined so that it only initiates when SDL is enabled, as well as making sure that each hook that uses this function is benefiting from it sufficiently. At the moment, it's suspected that the particle engine will likely be the most likely to benefit from this function, followed by tile drawing, then sprite drawing. Signed-off-by: Ira Rice <irarice@gmail.com>
2009-03-16Applied a similar optimization as in commitIra Rice1-17/+36
d654758ef63f6515d678ceaf77d63a2693e08fb7, but for SDL instead. This currently doesn't buy too much, but it's a little better than it used to be. TODO: Find out why SDL is bottlenecked, and try to bring its performance up to OpenGL levels, if possible. Signed-off-by: Ira Rice <irarice@gmail.com>
2009-03-16Optimising OpenGLGraphics::drawImagePatternSteve Cotton1-0/+53
2009-03-10Extended window layout to take relative positions, as well as offsets toIra Rice1-20/+22
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-5/+0
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-05Made an option around the syncing, but no way to change it for now.Bjørn Lindeijer1-3/+1
(cherry picked from mainline commit f6f8b2f885145d4cacf7a6c42d88b6a39f71b366) Conflicts: src/openglgraphics.cpp
2008-12-02Made an option around the syncing, but no way to change it for now.Bjørn Lindeijer1-1/+11