Commit aabcae4e authored by Gerhard Stein's avatar Gerhard Stein

MOUSEWRAPPER define adaptations for the iPhone overlay

parent 8f793fb7
......@@ -31,6 +31,7 @@
</option>
<option id="gnu.cpp.compiler.option.preprocessor.def.1129603258" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
<listOptionValue builtIn="false" value="SDL"/>
<listOptionValue builtIn="false" value="MOUSEWRAPPER"/>
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="USE_OPENGL"/>
<listOptionValue builtIn="false" value="OGG"/>
......
......@@ -1024,7 +1024,7 @@ static TouchButton* getPhoneButtons(stInputCommand InputCommand[NUM_INPUTS][MAX_
return phoneButtons;
}
#if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)
#if defined(MOUSEWRAPPER)
static const int phoneButtonN = 11;
typedef std::set<int> MouseIndexSet;
......@@ -1032,6 +1032,8 @@ typedef std::set<int> MouseIndexSet;
static Uint32 phoneButtonLasttime[phoneButtonN] = {0,0,0,0,0,0,0,0,0,0,0};
static MouseIndexSet phoneButton_MouseIndex[phoneButtonN];
#endif
static TouchButton* getPhoneButton(int x, int y, TouchButton phoneButtons[]) {
for(int i = 0; i < phoneButtonN; ++i) {
......@@ -1076,12 +1078,15 @@ void CInput::processMouse() {
}
void CInput::processMouse(SDL_Event& ev) {
#if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)
SDL_Rect screenRect;
if(SDL_GetDisplayBounds(0, &screenRect) == 0) {
// transform mouse coordinates
// WARNING: I don't really understand that. It's probably somehow iPhoneRotateScreen + SDL stuff.
ev.button.y -= screenRect.h - 200;
}
#endif // iPhone
// NOTE: The ev.button.which / the multitouch support was removed in SDL 1.3 trunk
// with changeset 4465:3e69e077cb95 on May09. It is planned to add a real multitouch API
......@@ -1124,6 +1129,8 @@ void CInput::processMouse(int x, int y, bool down, int mouseindex) {
static void drawButton(TouchButton& button, bool down) {
// similar mysterious constant as in renderTexture/initGL
//glViewport(0,255,w,h);
float w = 512.0f, h = 256.0f;
int crop = 2;
......@@ -1139,8 +1146,7 @@ static void drawButton(TouchButton& button, bool down) {
x2, y2,
x1, y2,
};
//Render the vertices by pointing to the arrays.
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vertices);
......@@ -1155,11 +1161,11 @@ static void drawButton(TouchButton& button, bool down) {
//Finally draw the arrays.
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}
#endif
#endif // iPhone
void CInput::renderOverlay() {
#ifdef USE_OPENGL // only ogl supported yet (and probably worth)
......
......@@ -216,10 +216,9 @@ static void renderTexture(GLuint texture, bool withAlpha = false) {
glEnable(GL_BLEND);
if(withAlpha)
//glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA /*GL_SRC_COLOR*/);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
else
glBlendFunc(GL_ONE, GL_ZERO /*GL_SRC_COLOR*/);
glBlendFunc(GL_ONE, GL_ZERO );
glBindTexture (GL_TEXTURE_2D, texture);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
......@@ -292,7 +291,7 @@ void COpenGL::render()
reloadFX(mp_fgsurface);
renderTexture(m_texFG, true);
}
g_pInput->renderOverlay();
SDL_GL_SwapBuffers();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment