#include "SDL_ecore_ipc.h"
+#include <Ecore.h>
#if SDL_VIDEO_OPENGL
#include "SDL_opengl.h"
} GLES2_Context;
GLuint programObject;
+GLuint vIndex;
+GLuint cIndex;
+
+Uint32 _tizen_timer_callback_indicator(void *data)
+{
+ SDL_Log("[SDL} callbackck ckck clalall!\n");
+ SDL_VideoDevice *_this = SDL_GetVideoDevice();
+
+ drawIndicator(_this->windows);
+ SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) _this->windows->driverdata)->egl_surface);
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+int
+_tizen_indicator_event_filter()
+{
+ SDL_Window *window = SDL_GetVideoDevice()->windows;
+ SDL_WindowData *wind = window->driverdata;
+
+ if(window->indicator_show && wind->indicator_timer == NULL)
+ {
+ wind->indicator_timer = ecore_timer_add(0.02, _tizen_timer_callback_indicator, NULL);
+ }
+ else if(!window->indicator_show && wind->indicator_timer != NULL)
+ {
+ ecore_timer_del(wind ->indicator_timer);
+ wind->indicator_timer = NULL;
+ }
+
+ return 1;
+}
int
Tizen_GLES_LoadLibrary(_THIS, const char *path)
unsigned int textureID;
unsigned int indicator_vbo[4], indicator_ibo[4];
unsigned short indicator_index;
+ModelMatrix mMatrix;
extern void ModelMatrixLoadIdentity(ModelMatrix* matrix)
{
0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address);
}
- ModelMatrix mMatrix;
+void drawIndicator(SDL_Window *window)
+{
+ SDL_WindowData* wdata = (SDL_WindowData*)window->driverdata;
+ if (wdata->received_rotation == 1) {
+ ecore_wl_window_rotation_change_done_send(wdata->window);
+ wdata->received_rotation = 0;
+ }
+
+ if(window->last_indicator_showtime + 3000< SDL_GetTicks())
+ {
+ switch(window->indicator_type)
+ {
+ case 0://0
+ ModelMatrixTranslate(&mMatrix, 0.0f, 0.02f, 0.0f);
+ break;
+ case 1://90
+ ModelMatrixTranslate(&mMatrix, -0.02f, 0.0f, 0.0f);
+ break;
+ case 2://180
+ ModelMatrixTranslate(&mMatrix, 0.0f, -0.02f, 0.0f);
+ break;
+ case 3://270
+ ModelMatrixTranslate(&mMatrix, 0.02f, 0.0f, 0.0f);
+ break;
+ }
+ }
+
+ if(window->last_indicator_showtime + 3500 <SDL_GetTicks()) {
+ window->indicator_show = SDL_FALSE;
+ _tizen_indicator_event_filter();
+ }
+
+ if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS) && window->indicator_show)
+ {
+ GLES2_Context Mainctx;
+ LoadContext(&Mainctx);
+ Mainctx.glUseProgram(programObject);
+
+ Mainctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
+ Mainctx.glVertexAttribPointer(vIndex, 3, GL_FLOAT, GL_FALSE, 0, vVertices);
+ Mainctx.glVertexAttribPointer(cIndex, 2, GL_FLOAT, GL_FALSE, 0, vCoord);
+ Mainctx.glUniformMatrix4fv(Mainctx.glGetUniformLocation(programObject, "modelMatrix"), 1, GL_FALSE, mMatrix.m);
+
+ Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
+ if(fileInfo.ImageWidth!=0 && fileInfo.ImageHeight!=0)
+ Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fileInfo.ImageWidth, fileInfo.ImageHeight,0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address);
+
+ Mainctx.glEnableVertexAttribArray(vIndex);
+ Mainctx.glEnableVertexAttribArray(cIndex);
+
+ GLboolean isDepthTest = Mainctx.glIsEnabled(GL_DEPTH_TEST);
+ if(isDepthTest) Mainctx.glDisable(GL_DEPTH_TEST);
+ Mainctx.glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ if(isDepthTest) Mainctx.glEnable(GL_DEPTH_TEST);
+ Mainctx.glDisableVertexAttribArray(vIndex);
+ Mainctx.glDisableVertexAttribArray(cIndex);
+ }
+}
+
static int Indicator_GLES_Init(SDL_Window* window)
{
SDL_WindowData *wind = window->driverdata;
return 0;
}
-
Mainctx.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
Mainctx.glEnable(GL_DEPTH_TEST);
- /* Generate buffer object names */
- Mainctx.glGenBuffers(4, indicator_vbo);
- /* Bind a named buffer object */
- Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_vbo[0]);
- /* Ceates and initializes a buffer object's data store */
- Mainctx.glBufferData(GL_ARRAY_BUFFER, 18 * 4, vVertices, GL_STATIC_DRAW);
-
- /* Generate buffer object names */
- Mainctx.glGenBuffers(4, indicator_ibo);
- /* Bind a named buffer object */
- Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_ibo[0]);
- /* Ceates and initializes a buffer object's data store */
- Mainctx.glBufferData(GL_ARRAY_BUFFER, 12 * 4, vCoord, GL_STATIC_DRAW);
+ vIndex = Mainctx.glGetAttribLocation(programObject, "vVertices");
+ cIndex = Mainctx.glGetAttribLocation(programObject, "vCoord");
- Mainctx.glBindAttribLocation(programObject, 0, "vVertices");
- Mainctx.glBindAttribLocation(programObject, 1, "vCoord");
+ Mainctx.glBindAttribLocation(programObject, vIndex, "vVertices");
+ Mainctx.glBindAttribLocation(programObject, cIndex, "vCoord");
ModelMatrixLoadIdentity(&mMatrix);
Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fileInfo.ImageWidth, fileInfo.ImageHeight,0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address);
+
+ if(fileInfo.ImageWidth != 0 && fileInfo.ImageHeight != 0)
+ Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fileInfo.ImageWidth, fileInfo.ImageHeight,0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address);
window->indicator_show = SDL_TRUE;
window->last_indicator_showtime = SDL_GetTicks();
+
+ _tizen_indicator_event_filter();
+
return 1;
}
void
Tizen_GLES_SwapWindow(_THIS, SDL_Window *window)
{
- SDL_WindowData* wdata = (SDL_WindowData*)window->driverdata;
- if (wdata->received_rotation == 1) {
- ecore_wl_window_rotation_change_done_send(wdata->window);
- wdata->received_rotation = 0;
- }
-
- if(window->last_indicator_showtime + 3000 < SDL_GetTicks())
- {
- switch(window->indicator_type)
- {
- case 0://0
- ModelMatrixTranslate(&mMatrix, 0.0f, 0.02f, 0.0f);
- break;
- case 1://90
- ModelMatrixTranslate(&mMatrix, -0.02f, 0.0f, 0.0f);
- break;
- case 2://180
- ModelMatrixTranslate(&mMatrix, 0.0f, -0.02f, 0.0f);
- break;
- case 3://270
- ModelMatrixTranslate(&mMatrix, 0.02f, 0.0f, 0.0f);
- break;
- }
- }
-
- Uint32 time = window->last_indicator_showtime;
- Uint32 getTick = SDL_GetTicks();
- if(time + 3000> getTick && time + 4000 < getTick)
- {
- window->indicator_show = SDL_FALSE;
- }
-
- if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS) && window->indicator_show)
- {
- GLES2_Context Mainctx;
- LoadContext(&Mainctx);
- Mainctx.glUseProgram(programObject);
-
- Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_vbo[window->indicator_type]);
- Mainctx.glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
-
- Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_ibo[window->indicator_type]);
- Mainctx.glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0);
-
- Mainctx.glUniformMatrix4fv(Mainctx.glGetUniformLocation(programObject, "modelMatrix"), 1, GL_FALSE, mMatrix.m);
-
- Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fileInfo.ImageWidth, fileInfo.ImageHeight,0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address);
- Mainctx.glEnableVertexAttribArray(0);
- Mainctx.glEnableVertexAttribArray(1);
- Mainctx.glDrawArrays(GL_TRIANGLES, 0, 6);
+ if(!window->indicator_show) {
+ drawIndicator(window);
+ SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
}
-
- SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
}
-
int
Tizen_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
{
Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
- Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fileInfo.ImageWidth, fileInfo.ImageHeight,0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address);
+ if(fileInfo.ImageWidth != 0 && fileInfo.ImageHeight != 0)
+ Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fileInfo.ImageWidth, fileInfo.ImageHeight,0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address);
ModelMatrixLoadIdentity(&mMatrix);
window->indicator_show = SDL_TRUE;
window->last_indicator_showtime = SDL_GetTicks();
+
+ _tizen_indicator_event_filter();
+
}
}