Skip to content

Commit 85c9bd4

Browse files
committed
GLESv2 variant; fixes
1 parent 319aec1 commit 85c9bd4

7 files changed

Lines changed: 78 additions & 14 deletions

File tree

src/Makefile.linux-es2

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
CFLAGS = -O2 -Wall -Wextra -DDIR_OPENMRAC_DAT=/usr/share/openmrac/ -fno-exceptions -fPIC -std=c++20 -DNDEBUG -DUSE_GLESv2 -DDISABLE_ANISOTROPY
2+
LFLAGS = -lSDL2 -lGLESv2 -lopenal -ljpeg -lpng -lm -s
3+
4+
CXX = g++
5+
LINK = g++
6+
TARGET = openmrac
7+
OBJS := $(shell ls *.cpp | grep -v _win32.cpp | sed 's/.cpp/.o/g' | tr '\n' ' ')
8+
9+
.PHONY: all clean install uninstall deb
10+
11+
all: $(TARGET)
12+
13+
clean:
14+
rm -f *.o $(TARGET)
15+
16+
%.o: %.cpp *.h
17+
$(CXX) -c $(CFLAGS) $<
18+
19+
$(TARGET): $(OBJS)
20+
$(LINK) -o $(TARGET) $(OBJS) $(LFLAGS)
21+
22+
install: all uninstall
23+
sudo cp openmrac /usr/bin/openmrac
24+
sudo cp openmrac.ico /usr/share/pixmaps/openmrac.ico
25+
sudo cp openmrac.desktop /usr/share/applications/openmrac.desktop
26+
sudo update-desktop-database || true
27+
28+
uninstall:
29+
sudo rm -f /usr/bin/openmrac
30+
sudo rm -f /usr/share/pixmaps/openmrac.ico
31+
sudo rm -f /usr/share/applications/openmrac.desktop
32+
sudo update-desktop-database || true
33+
34+
deb: all
35+
rm -rf debian
36+
cd ../../OpenMRac-data ; make
37+
mkdir -p debian/openmrac/usr/bin
38+
cp openmrac debian/openmrac/usr/bin/openmrac
39+
mkdir -p debian/openmrac/usr/share/pixmaps
40+
cp openmrac.ico debian/openmrac/usr/share/pixmaps/openmrac.ico
41+
mkdir -p debian/openmrac/usr/share/applications
42+
cp openmrac.desktop debian/openmrac/usr/share/applications/openmrac.desktop
43+
mkdir -p debian/openmrac/usr/share/openmrac
44+
cp ../../OpenMRac-data/openmrac.dat debian/openmrac/usr/share/openmrac/openmrac.dat
45+
mkdir -p debian/openmrac/DEBIAN
46+
cp control debian/openmrac/DEBIAN/control
47+
cd debian ; dpkg-deb --build openmrac

src/OpenMRac-SDL2.pro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ QMAKE_CXXFLAGS += -DDIR_OPENMRAC_DAT=/usr/share/openmrac/
2121
QMAKE_CXXFLAGS += -DUSE_MINIAL
2222
#LIBS += -lopenal
2323

24-
LIBS += \
25-
-lSDL2 -lGL -ljpeg -lpng
24+
# libGL
25+
LIBS += -lSDL2 -lGL -ljpeg -lpng
26+
27+
# libGLESv2
28+
#QMAKE_CXXFLAGS += -DUSE_GLESv2 -DDISABLE_ANISOTROPY
29+
#LIBS += -lSDL2 -lGLESv2 -ljpeg -lpng
2630

2731
INCLUDEPATH += \
2832
/usr/include

src/gl1.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
#define PROFILE_ES2 1
66
#define PROFILE_CORE33 2
77

8+
#ifdef USE_GLESv2
9+
#define PROFILE_MIN PROFILE_ES2
10+
#define PROFILE_MAX PROFILE_ES2
11+
#else
812
#define PROFILE_MIN PROFILE_COMPAT
913
#define PROFILE_MAX PROFILE_CORE33
14+
#endif
1015

1116
#if defined(__WIN32__)
1217

@@ -51,10 +56,14 @@ extern int g_opengl_profile;
5156

5257
inline void glDepthRange1(float a, float b)
5358
{
59+
#ifdef USE_GLESv2
60+
glDepthRangef(a, b);
61+
#else
5462
if (g_opengl_profile == PROFILE_ES2)
5563
glDepthRangef(a, b);
5664
else
5765
glDepthRange(a, b);
66+
#endif
5867
}
5968

6069
#undef glDepthRangef

src/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,12 +1117,14 @@ int EnableOpenGL(bool fullscreen, bool vsync, int width, int height)
11171117
glDebugMessageCallback(GLDebugMessageCallback, 0);
11181118
#endif
11191119

1120-
if (PROFILE_CORE33)
1120+
#ifndef USE_GLESv2
1121+
if (g_opengl_profile == PROFILE_CORE33)
11211122
{
11221123
GLuint vao;
11231124
glGenVertexArrays(1, &vao);
11241125
glBindVertexArray(vao);
11251126
}
1127+
#endif
11261128
glViewport(0, 0, actualWidth, actualHeight); checkGL();
11271129
return 0;
11281130
}

src/settingsdialog.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,14 @@ SettingsDialog::SettingsDialog(
101101
m_items.push_back(GuiItem(GuiItem::LABEL, m_horLay.getCellPS(2, 1), m_verLay.getCellPS(4, 1), "Renderer"));
102102

103103
std::vector<std::string> renderers;
104-
renderers.push_back("OpenGL Compat. profile");
105-
renderers.push_back("OpenGL ES 2");
106-
renderers.push_back("OpenGL 3.3 Core profile");
104+
const char* strProfiles[3] = {"OpenGL Compat. profile", "OpenGL ES 2", "OpenGL 3.3 Core profile"};
105+
for (int i = PROFILE_MIN; i <= PROFILE_MAX; ++i)
106+
{
107+
renderers.push_back(strProfiles[i]);
108+
}
107109

108110
m_rendererComboIndex = m_items.size();
109-
m_items.push_back(GuiItem(GuiItem::COMBO, m_horLay.getCellPS(3, 3), m_verLay.getCellPS(4, 1), renderers, renderer, 20, 6));
111+
m_items.push_back(GuiItem(GuiItem::COMBO, m_horLay.getCellPS(3, 3), m_verLay.getCellPS(4, 1), renderers, renderer - PROFILE_MIN, 20, 6));
110112

111113
m_items.push_back(GuiItem(GuiItem::LABEL, m_horLay.getCellPS(2, 1), m_verLay.getCellPS(6, 1), "Mode"));
112114
m_resolutionsComboIndex = m_items.size();
@@ -285,7 +287,7 @@ void SettingsDialog::onKeyUp(SDL_Keycode k)
285287
int SettingsDialog::getRenderer()
286288
{
287289
const GuiItem& item = m_items[m_rendererComboIndex];
288-
return item.currentItem;
290+
return item.currentItem + PROFILE_MIN;
289291
}
290292

291293
int SettingsDialog::getSelectedScreenMode() const

src/shadermng.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ inline const char* strShaderUniTex(int a)
8585

8686
ShaderMng::ShaderMng() : ints()
8787
{
88-
currentShader = ShaderId::None;
88+
currentShader = ShaderId::NoShader;
8989
}
9090

9191
static GLuint loadShader(GLenum type, const char *shaderSrc, const char* shaderName = nullptr)
@@ -293,7 +293,7 @@ void ShaderMng::use(ShaderId id)
293293
glUseProgram(0);
294294
currentShader = id;
295295
GLint loc;
296-
if (id != ShaderId::None)
296+
if (id != ShaderId::NoShader)
297297
{
298298
glUseProgram(shaders[(int)id].program);
299299
for (int i = 0; i != (int)ShaderUniMat4::Count; ++i)
@@ -349,7 +349,7 @@ void ShaderMng::set(ShaderUniMat4 id, glm::mat4 m)
349349
mat4pmv = m * mat4s[(int)ShaderUniMat4::ModelViewMat];
350350
updatedPmv = true;
351351
}*/
352-
if (currentShader != ShaderId::None)
352+
if (currentShader != ShaderId::NoShader)
353353
{
354354
glUseProgram(shaders[(int)currentShader].program);
355355
GLint loc = shaders[(int)currentShader].mat4locs[(int)id];
@@ -379,7 +379,7 @@ void ShaderMng::set(ShaderUniMat4 id, glm::mat4 m)
379379
void ShaderMng::set(ShaderUniVec4 id, glm::vec4 v)
380380
{
381381
vec4s[(int)id] = v;
382-
if (currentShader != ShaderId::None)
382+
if (currentShader != ShaderId::NoShader)
383383
{
384384
GLint loc = shaders[(int)currentShader].vec4locs[(int)id];
385385
if (loc != -1)
@@ -392,7 +392,7 @@ void ShaderMng::set(ShaderUniVec4 id, glm::vec4 v)
392392
void ShaderMng::set(ShaderUniInt id, GLint i)
393393
{
394394
ints[(int)id] = i;
395-
if (currentShader != ShaderId::None)
395+
if (currentShader != ShaderId::NoShader)
396396
{
397397
GLint loc = shaders[(int)currentShader].intlocs[(int)id];
398398
if (loc != -1)

src/shadermng.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "glm1.h"
66

77
enum class ShaderId {
8-
None = -1,
8+
NoShader = -1,
99
Color = 0,
1010
Tex,
1111
ColorTex, // uses AlphaDiscard

0 commit comments

Comments
 (0)