TouchTextLayout::TouchTextLayout(vec2 startPoint, int width, int height, std::string text, std::string font, ColorA textColor, int fontSize) : startPoint(startPoint), width(width), height(height), text(text), font(font), textColor(textColor), fontSize(fontSize) { initializeTexture(); }
int main(int argc, char *argv[]) { SDL_Window *window; SDL_Renderer *renderer; Uint32 startFrame; Uint32 endFrame; Uint32 delay; int done; /* initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { fatalError("Could not initialize SDL"); } window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS); renderer = SDL_CreateRenderer(window, -1, 0); initializeTexture(renderer); initializeHappyFaces(); /* main loop */ done = 0; while (!done) { startFrame = SDL_GetTicks(); SDL_Event event; while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { done = 1; } } render(renderer); endFrame = SDL_GetTicks(); /* figure out how much time we have left, and then sleep */ delay = MILLESECONDS_PER_FRAME - (endFrame - startFrame); if (delay < 0) { delay = 0; } else if (delay > MILLESECONDS_PER_FRAME) { delay = MILLESECONDS_PER_FRAME; } SDL_Delay(delay); } /* cleanup */ SDL_DestroyTexture(texture); /* shutdown SDL */ SDL_Quit(); return 0; }
//================================================================================ //! メソッド名 CTEXTURE_BASE::コンストラクタ // // 機能 テクスチャをロードして初期化 // 引数 inDev Direct3Dデバイス // inName Xファイルの名称 // inSize サイズ // inColor 透明化される色 // inResource テクスチャフォルダ名 // 更新 2008/08/28 <新規> //================================================================================ CTEXTURE_BASE::CTEXTURE_BASE( CONST DEV inDev, CONST LPSTR inName, VEC2 inSize, DWORD inColor, CONST LPSTR inResource) { // 属性の初期化 startTextureInitialize(); // テクスチャの初期化 initializeTexture(inDev, inName, inSize, inColor, inResource); }
CTexture::CTexture(std::string const& a_texturePath, ETextureType const& a_textureType, pxBool const& a_willBeMultisampled) { STACK_TRACE; SDL_Surface *image = IMG_Load(a_texturePath.c_str()); if (image == nullptr) { STACK_TRACE; ERROR("Failed to load image: " + a_texturePath + " please check if it exists"); } initializeTexture(image->w, image->h, a_textureType, a_willBeMultisampled, image->pixels); SDL_FreeSurface(image); UNSTACK_TRACE; }
int main(int argc, char *argv[]) { int x, y, dx, dy; /* mouse location */ Uint8 state; /* mouse (touch) state */ SDL_Event event; SDL_Window *window; /* main window */ SDL_Renderer *renderer; int done; /* does user want to quit? */ /* initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { fatalError("Could not initialize SDL"); } /* create main window and renderer */ window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS); renderer = SDL_CreateRenderer(window, 0, 0); /*load brush texture */ initializeTexture(renderer); /* fill canvass initially with all black */ SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_RenderClear(renderer); SDL_RenderPresent(renderer); done = 0; while (!done && SDL_WaitEvent(&event)) { switch (event.type) { case SDL_QUIT: done = 1; break; case SDL_MOUSEMOTION: state = SDL_GetMouseState(&x, &y); /* get its location */ SDL_GetRelativeMouseState(&dx, &dy); /* find how much the mouse moved */ if (state & SDL_BUTTON_LMASK) { /* is the mouse (touch) down? */ drawLine(renderer, x - dx, y - dy, dx, dy); /* draw line segment */ SDL_RenderPresent(renderer); } break; } } /* cleanup */ SDL_DestroyTexture(brush); SDL_Quit(); return 0; }
void TextureUpdate::initializeTexture(const Measurement::ImageMeasurement& image) { if (!image) { return; } if (!m_bTextureInitialized) { GLuint tex_id; glGenTextures( 1, &(tex_id) ); m_bIsExternalTexture = false; initializeTexture(image, tex_id); } }
void XlGLDisplay::paintGL() { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (currentRenderMode == RENDER_IMAGE) { if ( !(this->textureGenerated)) { initializeTexture(); } drawImage(); } else if(currentRenderMode == RENDER_3D) { draw3D(); } }
bool OpenGLDisplay::changeRenderSize( int w, int h ) { if( (width != w) || (height != h) ) { if( texture != 0 ) { glDeleteTextures( 1, &texture ); texture = 0; } if( !initializeTexture( w, h ) ) { failed = true; return false; } } return true; }
int main(int argc, char *argv[]) { SDL_Window *window; /* main window */ SDL_GLContext context; //int w, h; Uint32 startFrame; /* time frame began to process */ Uint32 endFrame; /* time frame ended processing */ Uint32 delay; /* time to pause waiting to draw next frame */ int done; /* should we clean up and exit? */ /* initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { fatalError("Could not initialize SDL"); } /* seed the random number generator */ srand(time(NULL)); /* request some OpenGL parameters that may speed drawing */ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 0); SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); /* create main window and renderer */ window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS); context = SDL_GL_CreateContext(window); /* load the particle texture */ initializeTexture(); /* check if GL_POINT_SIZE_ARRAY_OES is supported this is used to give each particle its own size */ pointSizeExtensionSupported = SDL_GL_ExtensionSupported("GL_OES_point_size_array"); /* set up some OpenGL state */ glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); SDL_GetWindowSize(window, &screen_w, &screen_h); glViewport(0, 0, screen_w, screen_h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof((GLfloat) 0, (GLfloat) screen_w, (GLfloat) screen_h, (GLfloat) 0, 0.0, 1.0); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnable(GL_POINT_SPRITE_OES); glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, 1); if (pointSizeExtensionSupported) { /* we use this to set the sizes of all the particles */ glEnableClientState(GL_POINT_SIZE_ARRAY_OES); } else { /* if extension not available then all particles have size 10 */ glPointSize(10); } done = 0; /* enter main loop */ while (!done) { startFrame = SDL_GetTicks(); SDL_Event event; while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { done = 1; } if (event.type == SDL_MOUSEBUTTONDOWN) { int x, y; SDL_GetMouseState(&x, &y); spawnEmitterParticle(x, y); } } stepParticles(); drawParticles(); SDL_GL_SwapWindow(window); endFrame = SDL_GetTicks(); /* figure out how much time we have left, and then sleep */ delay = MILLESECONDS_PER_FRAME - (endFrame - startFrame); if (delay > MILLESECONDS_PER_FRAME) { delay = MILLESECONDS_PER_FRAME; } if (delay > 0) { SDL_Delay(delay); } } /* delete textures */ glDeleteTextures(1, &particleTextureID); /* shutdown SDL */ SDL_Quit(); return 0; }
Inventory::Inventory(Myst3Engine *vm) : _vm(vm), _texture(0) { initializeTexture(); }
CTexture::CTexture(pxUInt16 const& a_width, pxUInt16 const& a_height, ETextureType const& a_textureType, pxBool const& a_willBeMultisampled) { STACK_TRACE; initializeTexture(a_width, a_height, a_textureType, a_willBeMultisampled, nullptr); UNSTACK_TRACE; }