PUBLIC GLXWindow glXCreateWindow(Display * dpy, GLXFBConfig config, Window win, const int *attrib_list) { WARN_ONCE_GLX_1_3(dpy, __func__); #ifdef GLX_USE_APPLEGL XWindowAttributes xwattr; XVisualInfo *visinfo; (void) attrib_list; /*unused according to GLX 1.4 */ XGetWindowAttributes(dpy, win, &xwattr); visinfo = glXGetVisualFromFBConfig(dpy, config); if (NULL == visinfo) { __glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateWindow, false); return None; } if (visinfo->visualid != XVisualIDFromVisual(xwattr.visual)) { __glXSendError(dpy, BadMatch, 0, X_GLXCreateWindow, true); return None; } XFree(visinfo); return win; #else return CreateDrawable(dpy, (__GLcontextModes *) config, (Drawable) win, attrib_list, X_GLXCreateWindow); #endif }
// Create a frame for each player to display their current fleet in, // to be used when selecting the next ship to fight with. void BuildPickMeleeFrame (void) { STAMP s; CONTEXT OldContext = SetContext (OffScreenContext); if (PickMeleeFrame) DestroyDrawable (ReleaseDrawable (PickMeleeFrame)); PickMeleeFrame = CaptureDrawable (CreateDrawable ( WANT_PIXMAP, MELEE_WIDTH, MELEE_HEIGHT, 2)); s.origin.x = 0; s.origin.y = 0; s.frame = CaptureDrawable (LoadGraphic (MELEE_PICK_MASK_PMAP_ANIM)); SetContextFGFrame (PickMeleeFrame); DrawStamp (&s); s.frame = IncFrameIndex (s.frame); SetContextFGFrame (IncFrameIndex (PickMeleeFrame)); DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); SetContext (OldContext); }
PUBLIC GLXWindow GLX_PREFIX(glXCreateWindow)( Display *dpy, GLXFBConfig config, Window win, const int *attrib_list ) { return CreateDrawable( dpy, (__GLcontextModes *) config, (Drawable) win, attrib_list, X_GLXCreateWindow ); }
PUBLIC GLXPixmap GLX_PREFIX(glXCreatePixmap)( Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list ) { return CreateDrawable( dpy, (__GLcontextModes *) config, (Drawable) pixmap, attrib_list, X_GLXCreatePixmap ); }
PUBLIC GLXWindow glXCreateWindow(Display * dpy, GLXFBConfig config, Window win, const int *attrib_list) { WARN_ONCE_GLX_1_3(dpy, __func__); return CreateDrawable(dpy, (__GLcontextModes *) config, (Drawable) win, attrib_list, X_GLXCreateWindow); }
PUBLIC GLXPixmap glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list) { WARN_ONCE_GLX_1_3(dpy, __func__); return CreateDrawable(dpy, (__GLcontextModes *) config, (Drawable) pixmap, attrib_list, X_GLXCreatePixmap); }
PUBLIC GLXPixmap glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list) { WARN_ONCE_GLX_1_3(dpy, __func__); #ifdef GLX_USE_APPLEGL const __GLcontextModes *modes = (const __GLcontextModes *) config; if (apple_glx_pixmap_create(dpy, modes->screen, pixmap, modes)) return None; return pixmap; #else return CreateDrawable(dpy, (__GLcontextModes *) config, (Drawable) pixmap, attrib_list, X_GLXCreatePixmap); #endif }
// stretch_frame // create a new frame of size neww x newh, and blit a scaled version FramePtr // into it. // destroy the old frame if 'destroy' is 1 FRAME stretch_frame (FRAME FramePtr, int neww, int newh, int destroy) { FRAME NewFrame; CREATE_FLAGS flags; TFB_Image *tfbImg; TFB_Canvas src, dst; flags = GetFrameParentDrawable (FramePtr)->Flags; NewFrame = CaptureDrawable ( CreateDrawable (flags, (SIZE)neww, (SIZE)newh, 1)); tfbImg = FramePtr->image; LockMutex (tfbImg->mutex); src = tfbImg->NormalImg; dst = NewFrame->image->NormalImg; TFB_DrawCanvas_Rescale_Nearest (src, dst, -1, NULL, NULL, NULL); UnlockMutex (tfbImg->mutex); if (destroy) DestroyDrawable (ReleaseDrawable (FramePtr)); return (NewFrame); }
// Reads a piece of screen into a passed FRAME or a newly created one DRAWABLE LoadDisplayPixmap (const RECT *area, FRAME frame) { // TODO: This should just return a FRAME instead of DRAWABLE DRAWABLE buffer = GetFrameParentDrawable (frame); COUNT index; if (!buffer) { // asked to create a new DRAWABLE instead buffer = CreateDrawable (WANT_PIXMAP | MAPPED_TO_DISPLAY, area->extent.width, area->extent.height, 1); if (!buffer) return NULL; index = 0; } else { index = GetFrameIndex (frame); } frame = SetAbsFrameIndex (CaptureDrawable (buffer), index); if (_CurFramePtr->Type != SCREEN_DRAWABLE || frame->Type == SCREEN_DRAWABLE || !(GetFrameParentDrawable (frame)->Flags & MAPPED_TO_DISPLAY)) { log_add (log_Warning, "Unimplemented function activated: " "LoadDisplayPixmap()"); } else { TFB_Image *img = frame->image; TFB_DrawScreen_CopyToImage (img, area, TFB_SCREEN_MAIN); } ReleaseDrawable (frame); return buffer; }
void InitOscilloscope (FRAME scopeBg) { scope_frame = scopeBg; if (!scope_init) { EXTENT size = GetFrameBounds (scope_frame); POINT midPt = {size.width / 2, size.height / 2}; // mid-image pixel defines the color of scope lines scopeColor = GetFramePixel (scope_frame, midPt); scopeWork = CaptureDrawable (CreateDrawable ( WANT_PIXMAP | MAPPED_TO_DISPLAY, size.width, size.height, 1)); // assume and subtract the borders scopeSize.width = size.width - 2; scopeSize.height = size.height - 2; scope_init = 1; } }
void RenderingEngine::Initialize() { const unsigned int* faces[] = { Face0, Face1, Face2, Face3, Face4, Face5 }; // Load the background texture: glGenTextures(1, &m_textures.Metal); glBindTexture(GL_TEXTURE_2D, m_textures.Metal); { PVRTextureHeader* header = (PVRTextureHeader*) Metal; GLsizei w = header->Width; GLsizei h = header->Height; const unsigned int* texels = Metal + header->HeaderSize / 4; GLenum format = GL_RGB; GLenum type = GL_UNSIGNED_SHORT_5_6_5; glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, format, type, texels); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Load the cubemap texture: PVRTextureHeader* header = (PVRTextureHeader*) faces[0]; const unsigned int* faceData[] = { faces[0] + header->HeaderSize / 4, faces[1] + header->HeaderSize / 4, faces[2] + header->HeaderSize / 4, faces[3] + header->HeaderSize / 4, faces[4] + header->HeaderSize / 4, faces[5] + header->HeaderSize / 4 }; m_textures.Cubemap = CreateCubemap((void**) faceData, header->Width, GL_RGB, GL_UNSIGNED_SHORT_5_6_5); // Create some geometry: m_kleinBottle = CreateDrawable(KleinBottle(0.2), VertexFlagsNormals); //m_kleinBottle = CreateDrawable(Sphere(1), VertexFlagsNormals); m_quad = CreateDrawable(Quad(6, 9), VertexFlagsTexCoords); // Extract width and height from the color buffer: ivec2 screenSize; glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &screenSize.x); glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &screenSize.y); // Create the depth buffer: glGenRenderbuffers(1, &m_renderbuffers.Depth); glBindRenderbuffer(GL_RENDERBUFFER, m_renderbuffers.Depth); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, screenSize.x, screenSize.y); // Create the on-screen FBO: glGenFramebuffers(1, &m_framebuffers.Screen); glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffers.Screen); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_renderbuffers.Color); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_renderbuffers.Depth); glBindRenderbuffer(GL_RENDERBUFFER, m_renderbuffers.Color); // Create the GLSL programs: BuildProgram(SimpleVertexShader, SimpleFragmentShader, m_simple); BuildProgram(CubemapVertexShader, CubemapFragmentShader, m_cubemap); // Set up various GL state: glViewport(0, 0, screenSize.x, screenSize.y); glEnable(GL_DEPTH_TEST); // Set up the transforms: const float NearPlane = 5, FarPlane = 50; const float Scale = 0.004; const float HalfWidth = Scale * screenSize.x / 2; const float HalfHeight = Scale * screenSize.y / 2; mat4 projection = mat4::Frustum(-HalfWidth, HalfWidth, -HalfHeight, HalfHeight, NearPlane, FarPlane); glUseProgram(m_cubemap.Program); glUniformMatrix4fv(m_cubemap.Uniforms.Projection, 1, 0, projection.Pointer()); glUseProgram(m_simple.Program); glUniformMatrix4fv(m_simple.Uniforms.Projection, 1, 0, projection.Pointer()); }