Skip to content

Commit 6ba20e6

Browse files
committed
Merge branch 'release-0.20.0'
2 parents 3315131 + 7af1005 commit 6ba20e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2266
-265
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.10)
22

33
project(GF
4-
VERSION 0.19.0
4+
VERSION 0.20.0
55
LANGUAGES CXX C
66
)
77

ChangeLog.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# ChangeLog for gf
22

3+
## gf 0.20.0 (14 Apr 2021)
4+
5+
- Core (gf::core)
6+
- Add gf::Polygon::getPrevPoint() and gf::Polygon::getNextPoint()
7+
- Add gf::Rect::fromSize
8+
- Add gf::Polyline::getWinding() and gf::Polyline::contains()
9+
- Add gf::PointSequence::reverse()
10+
- Graphics (gf::graphics)
11+
- Add gf::Coordinates::getWindowSize()
12+
- Images are now uploaded correctly in textures
13+
- Make gf::RenderTarget::setActive() virtual
14+
- Fix SquareGrid rendering (thanks @NiiRoZz)
15+
- setTexture now takes a gf::RectF instead of a boolean (thanks @NiiRoZz)
16+
- Add area in texture loading functions (thanks @NiiRoZz)
17+
- Add gf::LightSystem and more light classes (early stage)
18+
- Network (gf::net)
19+
- Misc
20+
321
## gf 0.19.0 (14 Jan 2021)
422

523
- Core (gf::core)

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,4 @@ These screenshots are from games included in the repository.
121121

122122
- LGTM: [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/GamedevFramework/gf.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/GamedevFramework/gf/context:cpp)
123123
- CodeFactor: [![CodeFactor](https://www.codefactor.io/repository/github/gamedevframework/gf/badge)](https://www.codefactor.io/repository/github/gamedevframework/gf)
124-
- Codacy: [![Codacy Badge](https://api.codacy.com/project/badge/Grade/991cd949d3d74b3a9052be89d7b42541)](https://www.codacy.com/app/jube/gf?utm_source=github.com&utm_medium=referral&utm_content=GamedevFramework/gf&utm_campaign=Badge_Grade)
125-
124+
- Codacy: [![Codacy Badge](https://app.codacy.com/project/badge/Grade/8199bae5ed3b4f7fb50ad23bbe1867fc)](https://www.codacy.com/gh/GamedevFramework/gf/dashboard?utm_source=github.com&utm_medium=referral&utm_content=GamedevFramework/gf&utm_campaign=Badge_Grade)

TODO.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ This file is a list of ideas for gf. Some of them will eventually be in gf. Othe
1616

1717
- (font) use Signed Distance Field for big size fonts
1818
- (window/events) add a flag in `pollEvent`/`waitEvent` (`EventFlag::TouchAsMouse`, `EventFlag::NoWindowFilter`)
19-
- (texture) add area in loading functions
20-
- (texture) `setTexture(const Texture& texture, const RectF& textureRect = RectF(0, 0, 1, 1))` instead of `bool resetRect`
2119
- (curve/shape) add anti-aliasing to `Curve` and `Shape`
2220
- ideas: [vaserenderer](https://github.com/tyt2y3/vaserenderer),
2321
- ideas: [a forum thread](https://forum.libcinder.org/topic/smooth-thick-lines-using-geometry-shader#23286000001269127)

docs/index.dox

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ target_link_libraries(mygame
166166
@ingroup graphics
167167
@brief Tiles and tilelayers
168168

169+
@defgroup graphics_light Lights
170+
@ingroup graphics
171+
@brief Lights
172+
169173
@defgroup graphics_particles Particles
170174
@ingroup graphics
171175
@brief Particles

docs/snippets/doc_class_sprite.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ void dummySpriteUsage(gf::RenderTarget& renderer) {
2929

3030
// Create a sprite
3131
gf::Sprite sprite;
32-
sprite.setTexture(texture);
33-
sprite.setTextureRect(gf::RectF::fromPositionSize({ 0.1f, 0.1f }, { 0.5f, 0.3f }));
32+
sprite.setTexture(texture, gf::RectF::fromPositionSize({ 0.1f, 0.1f }, { 0.5f, 0.3f }));
3433
sprite.setColor({ 1.0f, 1.0f, 1.0f, 0.8f });
3534
sprite.setPosition({ 100.0f, 25.0f });
3635

examples/14_spritebatch.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ int main() {
4949
std::size_t i = k % 4;
5050
std::size_t j = k / 4;
5151

52-
sprite.setTexture(texture);
53-
sprite.setTextureRect(gf::RectF::fromPositionSize({ i * 0.25f, j * 0.5f }, { 0.25f, 0.5f }));
52+
sprite.setTexture(texture, gf::RectF::fromPositionSize({ i * 0.25f, j * 0.5f }, { 0.25f, 0.5f }));
5453
sprite.setScale(0.5f);
5554
sprite.setOrigin({ 128.0f, 128.0f });
5655
}

examples/15_atlas.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ int main() {
4343
atlas.setTexture(texture);
4444

4545
gf::Sprite brickRed06;
46-
brickRed06.setTexture(atlas.getTexture());
47-
brickRed06.setTextureRect(atlas.getTextureRect("brickRed06.png"));
46+
brickRed06.setTexture(atlas.getTexture(), atlas.getTextureRect("brickRed06.png"));
4847
brickRed06.setPosition({ 200.0f, 200.0f });
4948

5049
gf::Sprite brickBlack01;
51-
brickBlack01.setTexture(atlas.getTexture());
52-
brickBlack01.setTextureRect(atlas.getTextureRect("brickBlack01.png"));
50+
brickBlack01.setTexture(atlas.getTexture(), atlas.getTextureRect("brickBlack01.png"));
5351
brickBlack01.setPosition({ 200.0f, 176.0f });
5452

5553
std::cout << "Gamedev Framework (gf) example #15: Texture atlas\n";

examples/35_squaregrid.cc

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
* Gamedev Framework (gf)
3+
* Copyright (C) 2016-2021 Julien Bernard
4+
*
5+
* This software is provided 'as-is', without any express or implied
6+
* warranty. In no event will the authors be held liable for any damages
7+
* arising from the use of this software.
8+
*
9+
* Permission is granted to anyone to use this software for any purpose,
10+
* including commercial applications, and to alter it and redistribute it
11+
* freely, subject to the following restrictions:
12+
*
13+
* 1. The origin of this software must not be misrepresented; you must not
14+
* claim that you wrote the original software. If you use this software
15+
* in a product, an acknowledgment in the product documentation would be
16+
* appreciated but is not required.
17+
* 2. Altered source versions must be plainly marked as such, and must not be
18+
* misrepresented as being the original software.
19+
* 3. This notice may not be removed or altered from any source distribution.
20+
*/
21+
#include <cstdlib>
22+
#include <cstdio>
23+
24+
#include <iostream>
25+
26+
#include <gf/Clock.h>
27+
#include <gf/Color.h>
28+
#include <gf/Coordinates.h>
29+
#include <gf/Event.h>
30+
#include <gf/Grid.h>
31+
#include <gf/RenderWindow.h>
32+
#include <gf/Shapes.h>
33+
#include <gf/ViewContainer.h>
34+
#include <gf/Views.h>
35+
#include <gf/Window.h>
36+
37+
int main() {
38+
static constexpr gf::Vector2i ScreenSize(640, 480);
39+
constexpr gf::Vector2i GridSize = { 7, 7 };
40+
constexpr gf::Vector2f CellSize = { 64.0f, 64.0f };
41+
constexpr float IncreaseDecreaseFactor = 1.0f;
42+
43+
gf::Window window("35_squaregrid", ScreenSize, ~gf::WindowHints::Resizable);
44+
gf::RenderWindow renderer(window);
45+
46+
gf::ViewContainer views;
47+
48+
gf::ScreenView screenView;
49+
views.addView(screenView);
50+
views.setInitialFramebufferSize(ScreenSize);
51+
52+
float lineWidth = 1.0f;
53+
gf::SquareGrid squareGrid(GridSize, CellSize, gf::Color::Black, lineWidth);
54+
squareGrid.setAnchor(gf::Anchor::Center);
55+
56+
std::cout << "Gamedev Framework (gf) example #35: SquareGrid\n";
57+
std::cout << "This example prints a square grid.\n";
58+
std::cout << "How to use:\n";
59+
std::cout << "\t1: Increase line width\n";
60+
std::cout << "\t2: Decrease line width\n";
61+
std::cout << "\t3: Switch to red color\n";
62+
std::cout << "\t4: Switch to green color\n";
63+
std::cout << "\t5: Switch to blue color\n";
64+
std::cout << "\t6: Switch to black color\n";
65+
66+
renderer.clear(gf::Color::White);
67+
renderer.setView(screenView);
68+
69+
while (window.isOpen()) {
70+
gf::Event event;
71+
72+
while (window.pollEvent(event)) {
73+
switch (event.type) {
74+
case gf::EventType::Closed:
75+
window.close();
76+
break;
77+
78+
case gf::EventType::KeyPressed:
79+
switch (event.key.scancode) {
80+
case gf::Scancode::Num1:
81+
lineWidth += IncreaseDecreaseFactor;
82+
squareGrid.setLineWidth(lineWidth);
83+
84+
std::cout << "Increased line width to " << lineWidth << "\n";
85+
break;
86+
87+
case gf::Scancode::Num2:
88+
lineWidth -= IncreaseDecreaseFactor;
89+
squareGrid.setLineWidth(lineWidth);
90+
91+
std::cout << "Decreased line width to " << lineWidth << "\n";
92+
break;
93+
94+
case gf::Scancode::Num3:
95+
std::cout << "Switched to red color\n";
96+
squareGrid.setColor(gf::Color::Red);
97+
break;
98+
99+
case gf::Scancode::Num4:
100+
std::cout << "Switched to green color\n";
101+
squareGrid.setColor(gf::Color::Green);
102+
break;
103+
104+
case gf::Scancode::Num5:
105+
std::cout << "Switched to blue color\n";
106+
squareGrid.setColor(gf::Color::Blue);
107+
break;
108+
109+
case gf::Scancode::Num6:
110+
std::cout << "Switched to black color\n";
111+
squareGrid.setColor(gf::Color::Black);
112+
break;
113+
114+
case gf::Scancode::Escape:
115+
window.close();
116+
break;
117+
118+
default:
119+
break;
120+
}
121+
break;
122+
123+
default:
124+
break;
125+
}
126+
127+
views.processEvent(event);
128+
}
129+
130+
gf::Coordinates coordinates(renderer);
131+
squareGrid.setPosition(coordinates.getCenter());
132+
133+
renderer.clear();
134+
renderer.draw(squareGrid);
135+
renderer.display();
136+
}
137+
138+
return 0;
139+
}

examples/45_lights.cc

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/*
2+
* Gamedev Framework (gf)
3+
* Copyright (C) 2016-2021 Julien Bernard
4+
*
5+
* This software is provided 'as-is', without any express or implied
6+
* warranty. In no event will the authors be held liable for any damages
7+
* arising from the use of this software.
8+
*
9+
* Permission is granted to anyone to use this software for any purpose,
10+
* including commercial applications, and to alter it and redistribute it
11+
* freely, subject to the following restrictions:
12+
*
13+
* 1. The origin of this software must not be misrepresented; you must not
14+
* claim that you wrote the original software. If you use this software
15+
* in a product, an acknowledgment in the product documentation would be
16+
* appreciated but is not required.
17+
* 2. Altered source versions must be plainly marked as such, and must not be
18+
* misrepresented as being the original software.
19+
* 3. This notice may not be removed or altered from any source distribution.
20+
*/
21+
#include <cstdlib>
22+
#include <iostream>
23+
24+
#include <gf/Color.h>
25+
#include <gf/Event.h>
26+
#include <gf/LightSystem.h>
27+
#include <gf/LightTextures.h>
28+
#include <gf/RenderWindow.h>
29+
#include <gf/Views.h>
30+
#include <gf/ViewContainer.h>
31+
#include <gf/Window.h>
32+
33+
int main() {
34+
static constexpr gf::Vector2i ScreenSize(640, 480);
35+
36+
gf::Window window("45_lights", ScreenSize);
37+
gf::RenderWindow renderer(window);
38+
39+
gf::ViewContainer views;
40+
41+
gf::ExtendView view;
42+
view.setCenter({ 0.0f, 0.0f });
43+
view.setSize({ 1000.0f, 1000.0f });
44+
views.addView(view);
45+
46+
views.setInitialFramebufferSize(ScreenSize);
47+
48+
gf::LightSystem lights(ScreenSize);
49+
50+
std::cout << "Gamedev Framework (gf) example #45: Lights\n";
51+
52+
gf::RectF red = gf::RectF::fromPositionSize({ 0.0f, 0.0f }, { 128.0f, 128.0f });
53+
gf::RectF green = gf::RectF::fromPositionSize({ 128.0f, 0.0f }, { 128.0f, 128.0f });
54+
gf::CircF blue({ -200, -200 }, 32);
55+
gf::Vector2f pos0 = { 0.0f, -200.0f };
56+
gf::Vector2f pos1 = { 250.0f, 250.0f };
57+
58+
static constexpr int Size = 1024;
59+
60+
gf::Texture texture = gf::LightTextures::createRealisticLight(Size, 1.0f, Size / 40);
61+
62+
gf::LightPointEmission light0(texture);
63+
light0.setPosition(pos0);
64+
light0.setAnchor(gf::Anchor::Center);
65+
light0.setSourceRadius(Size * 0.05f);
66+
light0.setShadowOverExtendMultiplier(1.5f);
67+
light0.setLocaleCastCenter({ 0.0f, 0.0f }); // gf::vec(Size * 0.5f, Size * 0.5f));
68+
lights.addLightPoint(light0);
69+
70+
gf::LightPointEmission light1(texture);
71+
light1.setPosition(pos1);
72+
light1.setAnchor(gf::Anchor::Center);
73+
light1.setSourceRadius(Size * 0.01f);
74+
light1.setShadowOverExtendMultiplier(20.0f);
75+
light1.setLocaleCastCenter({ 0.0f, 0.0f }); // gf::vec(Size * 0.5f, Size * 0.5f));
76+
lights.addLightPoint(light1);
77+
78+
gf::CircleShape circle(light0.getSourceRadius());
79+
circle.setColor(gf::Color::Transparent);
80+
circle.setOutlineColor(gf::Color::Red);
81+
circle.setOutlineThickness(2.0f);
82+
circle.setPosition(pos0);
83+
circle.setAnchor(gf::Anchor::Center);
84+
85+
86+
gf::LightShape occluder0(red);
87+
lights.addLightShape(occluder0);
88+
89+
gf::RectangleShape shape0(red);
90+
shape0.setColor(gf::Color::Red);
91+
92+
gf::LightShape occluder1(blue);
93+
lights.addLightShape(occluder1);
94+
95+
gf::CircleShape shape1(blue);
96+
shape1.setColor(gf::Color::Blue);
97+
98+
gf::LightShape occluder2(green);
99+
lights.addLightShape(occluder2);
100+
101+
gf::RectangleShape shape2(green);
102+
shape2.setColor(gf::Color::Green);
103+
104+
105+
renderer.clear(gf::Color::Chartreuse);
106+
107+
bool change = false;
108+
109+
while (window.isOpen()) {
110+
gf::Event event;
111+
112+
while (window.pollEvent(event)) {
113+
switch (event.type) {
114+
case gf::EventType::Closed:
115+
window.close();
116+
break;
117+
118+
case gf::EventType::KeyPressed:
119+
if (event.key.keycode == gf::Keycode::F1) {
120+
lights.dump();
121+
}
122+
break;
123+
124+
case gf::EventType::MouseButtonPressed:
125+
change = true;
126+
pos0 = renderer.mapPixelToCoords(event.mouseButton.coords);
127+
light0.setPosition(pos0);
128+
circle.setPosition(pos0);
129+
break;
130+
131+
case gf::EventType::MouseButtonReleased:
132+
change = false;
133+
break;
134+
135+
case gf::EventType::MouseMoved:
136+
if (change) {
137+
pos0 = renderer.mapPixelToCoords(event.mouseCursor.coords);
138+
light0.setPosition(pos0);
139+
circle.setPosition(pos0);
140+
}
141+
break;
142+
143+
default:
144+
break;
145+
}
146+
147+
views.processEvent(event);
148+
}
149+
150+
renderer.setView(view);
151+
renderer.clear();
152+
renderer.draw(shape0);
153+
renderer.draw(shape1);
154+
renderer.draw(shape2);
155+
renderer.draw(lights);
156+
renderer.draw(circle);
157+
renderer.display();
158+
}
159+
160+
return 0;
161+
}

0 commit comments

Comments
 (0)