Search Results

Search found 261 results on 11 pages for 'redraw'.

Page 4/11 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11  | Next Page >

  • Constant game speed independent of variable FPS in OpenGL with GLUT?

    - by Nazgulled
    I've been reading Koen Witters detailed article about different game loop solutions but I'm having some problems implementing the last one with GLUT, which is the recommended one. After reading a couple of articles, tutorials and code from other people on how to achieve a constant game speed, I think that what I currently have implemented (I'll post the code below) is what Koen Witters called Game Speed dependent on Variable FPS, the second on his article. First, through my searching experience, there's a couple of people that probably have the knowledge to help out on this but don't know what GLUT is and I'm going to try and explain (feel free to correct me) the relevant functions for my problem of this OpenGL toolkit. Skip this section if you know what GLUT is and how to play with it. GLUT Toolkit: GLUT is an OpenGL toolkit and helps with common tasks in OpenGL. The glutDisplayFunc(renderScene) takes a pointer to a renderScene() function callback, which will be responsible for rendering everything. The renderScene() function will only be called once after the callback registration. The glutTimerFunc(TIMER_MILLISECONDS, processAnimationTimer, 0) takes the number of milliseconds to pass before calling the callback processAnimationTimer(). The last argument is just a value to pass to the timer callback. The processAnimationTimer() will not be called each TIMER_MILLISECONDS but just once. The glutPostRedisplay() function requests GLUT to render a new frame so we need call this every time we change something in the scene. The glutIdleFunc(renderScene) could be used to register a callback to renderScene() (this does not make glutDisplayFunc() irrelevant) but this function should be avoided because the idle callback is continuously called when events are not being received, increasing the CPU load. The glutGet(GLUT_ELAPSED_TIME) function returns the number of milliseconds since glutInit was called (or first call to glutGet(GLUT_ELAPSED_TIME)). That's the timer we have with GLUT. I know there are better alternatives for high resolution timers, but let's keep with this one for now. I think this is enough information on how GLUT renders frames so people that didn't know about it could also pitch in this question to try and help if they fell like it. Current Implementation: Now, I'm not sure I have correctly implemented the second solution proposed by Koen, Game Speed dependent on Variable FPS. The relevant code for that goes like this: #define TICKS_PER_SECOND 30 #define MOVEMENT_SPEED 2.0f const int TIMER_MILLISECONDS = 1000 / TICKS_PER_SECOND; int previousTime; int currentTime; int elapsedTime; void renderScene(void) { (...) // Setup the camera position and looking point SceneCamera.LookAt(); // Do all drawing below... (...) } void processAnimationTimer(int value) { // setups the timer to be called again glutTimerFunc(TIMER_MILLISECONDS, processAnimationTimer, 0); // Get the time when the previous frame was rendered previousTime = currentTime; // Get the current time (in milliseconds) and calculate the elapsed time currentTime = glutGet(GLUT_ELAPSED_TIME); elapsedTime = currentTime - previousTime; /* Multiply the camera direction vector by constant speed then by the elapsed time (in seconds) and then move the camera */ SceneCamera.Move(cameraDirection * MOVEMENT_SPEED * (elapsedTime / 1000.0f)); // Requests to render a new frame (this will call my renderScene() once) glutPostRedisplay(); } void main(int argc, char **argv) { glutInit(&argc, argv); (...) glutDisplayFunc(renderScene); (...) // Setup the timer to be called one first time glutTimerFunc(TIMER_MILLISECONDS, processAnimationTimer, 0); // Read the current time since glutInit was called currentTime = glutGet(GLUT_ELAPSED_TIME); glutMainLoop(); } This implementation doesn't fell right. It works in the sense that helps the game speed to be constant dependent on the FPS. So that moving from point A to point B takes the same time no matter the high/low framerate. However, I believe I'm limiting the game framerate with this approach. Each frame will only be rendered when the time callback is called, that means the framerate will be roughly around TICKS_PER_SECOND frames per second. This doesn't feel right, you shouldn't limit your powerful hardware, it's wrong. It's my understanding though, that I still need to calculate the elapsedTime. Just because I'm telling GLUT to call the timer callback every TIMER_MILLISECONDS, it doesn't mean it will always do that on time. I'm not sure how can I fix this and to be completely honest, I have no idea what is the game loop in GLUT, you know, the while( game_is_running ) loop in Koen's article. But it's my understanding that GLUT is event-driven and that game loop starts when I call glutMainLoop() (which never returns), yes? I thought I could register an idle callback with glutIdleFunc() and use that as replacement of glutTimerFunc(), only rendering when necessary (instead of all the time as usual) but when I tested this with an empty callback (like void gameLoop() {}) and it was basically doing nothing, only a black screen, the CPU spiked to 25% and remained there until I killed the game and it went back to normal. So I don't think that's the path to follow. Using glutTimerFunc() is definitely not a good approach to perform all movements/animations based on that, as I'm limiting my game to a constant FPS, not cool. Or maybe I'm using it wrong and my implementation is not right? How exactly can I have a constant game speed with variable FPS? More exactly, how do I correctly implement Koen's Constant Game Speed with Maximum FPS solution (the fourth one on his article) with GLUT? Maybe this is not possible at all with GLUT? If not, what are my alternatives? What is the best approach to this problem (constant game speed) with GLUT? I originally posted this question on Stack Overflow before being pointed out about this site. The following is a different approach I tried after creating the question in SO, so I'm posting it here too. Another Approach: I've been experimenting and here's what I was able to achieve now. Instead of calculating the elapsed time on a timed function (which limits my game's framerate) I'm now doing it in renderScene(). Whenever changes to the scene happen I call glutPostRedisplay() (ie: camera moving, some object animation, etc...) which will make a call to renderScene(). I can use the elapsed time in this function to move my camera for instance. My code has now turned into this: int previousTime; int currentTime; int elapsedTime; void renderScene(void) { (...) // Setup the camera position and looking point SceneCamera.LookAt(); // Do all drawing below... (...) } void renderScene(void) { (...) // Get the time when the previous frame was rendered previousTime = currentTime; // Get the current time (in milliseconds) and calculate the elapsed time currentTime = glutGet(GLUT_ELAPSED_TIME); elapsedTime = currentTime - previousTime; /* Multiply the camera direction vector by constant speed then by the elapsed time (in seconds) and then move the camera */ SceneCamera.Move(cameraDirection * MOVEMENT_SPEED * (elapsedTime / 1000.0f)); // Setup the camera position and looking point SceneCamera.LookAt(); // All drawing code goes inside this function drawCompleteScene(); glutSwapBuffers(); /* Redraw the frame ONLY if the user is moving the camera (similar code will be needed to redraw the frame for other events) */ if(!IsTupleEmpty(cameraDirection)) { glutPostRedisplay(); } } void main(int argc, char **argv) { glutInit(&argc, argv); (...) glutDisplayFunc(renderScene); (...) currentTime = glutGet(GLUT_ELAPSED_TIME); glutMainLoop(); } Conclusion, it's working, or so it seems. If I don't move the camera, the CPU usage is low, nothing is being rendered (for testing purposes I only have a grid extending for 4000.0f, while zFar is set to 1000.0f). When I start moving the camera the scene starts redrawing itself. If I keep pressing the move keys, the CPU usage will increase; this is normal behavior. It drops back when I stop moving. Unless I'm missing something, it seems like a good approach for now. I did find this interesting article on iDevGames and this implementation is probably affected by the problem described on that article. What's your thoughts on that? Please note that I'm just doing this for fun, I have no intentions of creating some game to distribute or something like that, not in the near future at least. If I did, I would probably go with something else besides GLUT. But since I'm using GLUT, and other than the problem described on iDevGames, do you think this latest implementation is sufficient for GLUT? The only real issue I can think of right now is that I'll need to keep calling glutPostRedisplay() every time the scene changes something and keep calling it until there's nothing new to redraw. A little complexity added to the code for a better cause, I think. What do you think?

    Read the article

  • How to use caching to increase render performance?

    - by Christian Ivicevic
    First of all I am going to cover the basic design of my 2d tile-based engine written with SDL in C++, then I will point out what I am up to and where I need some hints. Concept of my engine My engine uses the concept of GameScreens which are stored on a stack in the main game class. The main methods of a screen are usually LoadContent, Render, Update and InitMultithreading. (I use the last one because I am using v8 as a JavaScript bridge to the engine. The main game loop then renders the top screen on the stack (if there is one; otherwise, it exits the game) - actually it calls the render methods, but stores all items to be rendered in a list. After gathering all this information the methods like SDL_BlitSurface are called by my GameUIRenderer which draws the enqueued content and then draws some overlay. The code looks like this: while(Game is running) { Handle input if(Screens on stack == 0) exit Update timer etc. Clear the screen Peek the screen on the stack and collect information on what to render Actually render the enqueue screen stuff and some overlay etc. Flip the screen } The GameUIRenderer uses as hinted a std::vector<std::shared_ptr<ImageToRender>> to hold all necessary information described by this class: class ImageToRender { private: SDL_Surface* image; int x, y, w, h, xOffset, yOffset; }; This bunch of attributes is usually needed if I have a texture atlas with all tiles in one SDL_Surface and then the engine should crop one specific area and draw this to the screen. The GameUIRenderer::Render() method then just iterates over all elements and renders them something like this: std::for_each( this->m_vImageVector.begin(), this->m_vImageVector.end(), [this](std::shared_ptr<ImageToRender> pCurrentImage) { SDL_Rect rc = { pCurrentImage->x, pCurrentImage->y, 0, 0 }; // For the sake of simplicity ignore offsets... SDL_Rect srcRect = { 0, 0, pCurrentImage->w, pCurrentImage->h }; SDL_BlitSurface(pCurrentImage->pImage, &srcRect, g_pFramework->GetScreen(), &rc); } ); this->m_vImageVector.clear(); Current ideas which need to be reviewed The specified approach works really good and IMHO it is really has a good structure, however the performance could be definitely increased. I would like to know what do you suggest, how to implement efficient caching of surfaces etc so that there is no need to redraw the same scene over and over again? The map itself would be almost static, only when the player moves, we would need to move the map. Furthermore animated entities would either require updates of the whole map or updates of only the specific areas the entities are currently moving in. My first approaches were to include a flag IsTainted which should be used by the GameUIRenderer to decide whether to redraw everything or use cached version (or to not render anything so that we do not have to Clear the screen and let the last frame persist). However this seems to be quite messy if I have to manually handle in my Render method of the screen class if something has changed or not.

    Read the article

  • SmartGWT - Update ListGridRecord dynamically

    - by Haylwood
    I am using SmartGWT and I have a ListGrid populated with an array of ListGridRecords using the setData() call. I am trying to update a progress property of a single record (on a timer for testing) and have it update in the browser. I have tried various combinations of draw(), redraw(), markForRedraw() etc. to no avail. I also tried overriding the updateRecordComponent() method in my table class, but it only gets called when the records are first created (after createRecordComponent()). I should note that I do NOT want to accomplish this by binding to a DataSource. I just want to be able to update the attribute on the client-side. ArrayList<SegmentSortRecord> mRecords; mRecords.add(new SegmentSortRecord("03312010_M001_S004")); mRecords.add(new SegmentSortRecord("03312010_M001_S005")); mRecords.add(new SegmentSortRecord("03312010_M001_S006")); mRecords.add(new SegmentSortRecord("03312010_M001_S007")); SegmentSortRecord[] records = new SegmentSortRecord[mRecords.size()]; mRecords.toArray(records); mSortProgressTable.setData(records); . . . mTestTimer = new Timer() { public void run() { mTestPercent += 5; if (mTestPercent <= 100) { mSortProgressTable.getRecord(2).setAttribute(Constants.PROGRESS_COL_NAME, mTestPercent); //mSortProgressTable.markForRedraw(); //mSortProgressTable.redraw(); } else { mTestPercent = 0; } } }; ... @Override protected Canvas createRecordComponent(final ListGridRecord aRecord, Integer aColumn) { String fieldName = getFieldName(aColumn); // Want to override the behavior for rendering the "progress" field if (fieldName.equals(Constants.PROGRESS_COL_NAME)) { Progressbar bar = new Progressbar(); bar.setBreadth(10); bar.setLength(100); // The JavaScript record object contains attributes that we can // access via 'getAttribute' functions. bar.setPercentDone(aRecord.getAttributeAsInt(Constants.PROGRESS_COL_NAME)); return bar; } Thanks in advance for any help.

    Read the article

  • matplotlib.pyplot/pylab not updating figure while isinteractive(), using ipython -pylab

    - by NumberOverZero
    There are a lot of questions about matplotlib, pylab, pyplot, ipython, so I'm sorry if you're sick of seeing this asked. I'll try to be as specific as I can, because I've been looking through people's questions and looking at documentation for pyplot and pylab, and I still am not sure what I'm doing wrong. On with the code: Goal: plot a figure every .5 seconds, and update the figure as soon as the plot command is called. My attempt at coding this follows (running on ipython -pylab): import time ion() x=linspace(-1,1,51) plot(sin(x)) for i in range(10): plot([sin(i+j) for j in x]) #see ** print i time.sleep(1) print 'Done' It correctly plots each line, but not until it has exited the for loop. I have tried forcing a redraw by putting draw() where ** is, but that doesn't seem to work either. Ideally, I'd like to have it simply add each line, instead of doing a full redraw. If redrawing is required however, that's fine. Additional attempts at solving: just after ion(), tried adding hold(True) to no avail. for kicks tried show() for ** The closest answer I've found to what I'm trying to do was at http://stackoverflow.com/questions/2310851/plotting-lines-without-blocking-execution, but show() isn't doing anything. I apologize if this is a straightforward request, and I'm looking past something so obvious. For what it's worth, this came up while I was trying to convert matlab code from class to some python for my own use. The original matlab (initializations removed) which I have been trying to convert follows: for i=1:time plot(u) hold on pause(.01) for j=2:n-1 v(j)=u(j)-2*u(j-1) end v(1)= pi u=v end Any help, even if it's just "look up this_method" would be excellent, so I can at least narrow my efforts to figuring out how to use that method. If there's any more information that would be useful, let me know.

    Read the article

  • Treeview does not refresh to show childnode moved from one parent node to another

    - by mike
    I am using the Windows Forms TreeView class which contains a set of TreeNodes. The TreeNodes can have child nodes. I have a root node with 2 sub nodes (Node1 and Node2) Node1 has 2 subnodes (child1 and child2) I have a function that will allow a user to select any node and move it to another node: TreeNode SelectNode = this.TreeView1.SelectedNode; TreeNode DestNode = SelectedNewNode(); //function to select a new node SelectedNode.Remove(); DestNode.Nodes.Add(SelectedNode); this.TreeView1.Refresh(); When this executes, the current selected node (child2) is removed from its current parent (Node1) and added to Node2. However, the Refresh() method of the TreeView control does not show that child2 is under Node2. If I debug it and look at the Nodes collection in the TreeView i do see that child2 is under Node2. Can anyone tell me why the Refresh() method does not redraw the new parent to child mapping? Is there a way to tell the TreeView to redraw with the new mappings?

    Read the article

  • How to invalidate layout of listbox from custom children

    - by Stephen Price
    I have a custom panel for a listbox <ItemsPanelTemplate x:Key="FloatPanelTemplate"> <Controls:FloatPanel x:Name="CardPanel" /> </ItemsPanelTemplate> The panel lays out its children using its X and Y dependency properties. This all works nicely when the FloatPanel is used by itself - I'm using FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure on the dependency properties of the child items to tell the FloatPanel to redraw its layout. When I use it in a Listbox (code above) then it draws fine the first time, but when I drag the children (which modifies the item's X and Y) it is not notifying the Listbox that it needs to redraw the FloatPanel's children. I think the issue is related to the fact that each item in the bound collection is wrapped with a ListBoxItem. Hopefully I've described what i'm doing well enough that someone can tell me how to make the panel (or its children) tell it needs to do the Layout routines again. As I said it works once (initial draw) but then dragging items doesn't work (Listbox isnt aware that its children have changed and needs to relayout.) If I drag an item and then resize the window, the listbox does a layout and the items are drawn in their new locations. How do I notify the ListBox (or more importantly the FloatPanel in the ItemsPanelTemplate) that it needs to do a Layout pass?

    Read the article

  • redrawing on ncurses

    - by John C
    I'm trying to redraw the content of a simple loop. So far it prints out to the stdscr 100 lines, and then by using scrl to scroll n lines I get n blank rows. What I want is to keep with the sequence. However, I'm not sure how to redraw the stdscr with the n extra lines. Any ideas will be appreciate it! #include <ncurses.h> int main(void) { initscr(); int maxy,maxx,y; getmaxyx(stdscr,maxy,maxx); scrollok(stdscr,TRUE); for(y=0;y<=100;y++) mvprintw(y,0,"This is some text written to line %d.",y); refresh(); getch(); scrl(5); refresh(); getch(); endwin(); return(0); }

    Read the article

  • Form not updating usercontrol

    - by user328259
    From the post "Growing user control not updating"... Using C#, .Net 2.0 in a Windows environment. UserControl1 - draws cells to a bitmap buffer dependent upon NumberOfCells property UserControl2 - panel contains UserControl1 which displays vertical scroll when necessary; also contains NumberOfCells which sets UserControl1's NumberOfCells. Formf1 - contains NumericUpDown controls (just increments) which updates the UserControl2 - suppose to! When I increment the control on the form by say 20, UserControl1 adds the necessary cells, UserControl2 displays the vertical scroll bar accordingly, BUT the form does not 'redraw' to the updated/correct image!! Meaning, after I increment by 20, cells are added, vertical scrool bar added... but the image shown is just everything else expanding. I reset the control to scoll to the very TOP and the scrolling works, but the image is still staic... UNTIL I resize my form, more specifically, when I change it from maximize to window or vice versa!!! What can I do to 'reset/redraw' the correct image???? Thank you in advance. Lawrence

    Read the article

  • array loop not complete

    - by user217582
    Whenever the cursor move over the note, it would call getCollision() function to store the name of the sprite. Can store more than one sprite in array but the normalNote() function failed to work correctly? When I click a button which called normalNote(), it would only loop once (one note was redraw) before the pop. After the pop, it should have continue to loop until the rest of the notes from getChildbyname is redraw. Wonder if there any missing code? private function getCollision(x:int, pt:int):void { for(var i:int=pt;i<tickArray.length;i++) { if(typeArray[i]=="eighth") { var getCurrentNote:String = "note"+i; var child:Sprite = c.getChildByName(getCurrentNote) as Sprite; drawEighthUp(child,"-","-",0xff0000); tempNote.push(getCurrentNote); } } } private function normalNote():void { for(var iii:int=0;iii<tempNote.length;iii++) { var child:Sprite = c.getChildByName(tempNote[iii]) as Sprite; trace("tt",tempNote.length); trace("iii",iii); var asd:String = tempNote[iii].toString(); var idx:int = int(asd.substr(4)); if(typeArray[idx]=="eighth") { drawEighthUp(child,"-","-",0x000000); tempNote.pop(); } } }

    Read the article

  • OpenLayers eraseFeatures doesn't erase features from map screen.

    - by Jenny
    I'm using OpenLayers, and have a layer for my Map, and a single Vector Layer. In this vector layer, I am using the DrawFeature control to draw a square. I have a listener waiting for a feature to be added, and then deleting any existing features (I only want one square at a time), like so: polygonLayer.events.register("beforefeatureadded", feature, function(evt){ console.log("Clearing existing polygons"); console.log(polygonLayer.features.length); polygonLayer.destroyFeatures(); polygonLayer.redraw(); });//end attempt at events registration When I check my layer.features.size, I can see that it's always 1, just like I expect, but the squares on the screen are still displayed. Even when I call .redraw() on the layer, the squares are still there. Is there some extra step I'm missing? Edit: You can find my code here: http://pastie.org/909644 Edit: Just realized: If I draw a square from previously existing coordinates, I can clear it just fine. It seems to be just the squares drawn from the controller that are an issue?

    Read the article

  • another question about OpenGL ES rendering to texture

    - by ensoreus
    Hello, pros and gurus! Here is another question about rendering to texture. The whole stuff is all about saving texture between passing image into different filters. Maybe all iPhone developers knows about Apple's sample code with OpenGL processing where they used GL filters(functions), but pass into them the same source image. I need to edit an image by passing it sequentelly with saving the state of the image to edit. I am very noob in OpenGL, so I spent increadibly a lot of to solve the issue. So, I desided to create 2 FBO's and attach source image and temporary image as a textures to render in. Here is my init routine: glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnable(GL_TEXTURE_2D); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, (GLint *)&SystemFBO); glImage = [self loadTexture:preparedImage]; //source image for (int i = 0; i < 4; i++) { fullquad[i].s *= glImage->s; fullquad[i].t *= glImage->t; flipquad[i].s *= glImage->s; flipquad[i].t *= glImage->t; } tmpImage = [self loadEmptyTexture]; //editing image glGenFramebuffersOES(1, &tmpImageFBO); glBindFramebufferOES(GL_FRAMEBUFFER_OES, tmpImageFBO); glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, tmpImage->texID, 0); GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES); if(status != GL_FRAMEBUFFER_COMPLETE_OES) { NSLog(@"failed to make complete tmp framebuffer object %x", status); } glBindTexture(GL_TEXTURE_2D, 0); glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); glGenRenderbuffersOES(1, &glImageFBO); glBindFramebufferOES(GL_FRAMEBUFFER_OES, glImageFBO); glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, glImage->texID, 0); status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) ; if(status != GL_FRAMEBUFFER_COMPLETE_OES) { NSLog(@"failed to make complete cur framebuffer object %x", status); } glBindTexture(GL_TEXTURE_2D, 0); glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); When user drag the slider, this routine invokes to apply changes -(void)setContrast:(CGFloat)value{ contrast = value; if(flag!=mfContrast){ NSLog(@"contrast: dumped"); flag = mfContrast; glBindFramebufferOES(GL_FRAMEBUFFER_OES, glImageFBO); glClearColor(1,1,1,1); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(0, 512, 0, 512, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glScalef(512, 512, 1); glBindTexture(GL_TEXTURE_2D, tmpImage->texID); glViewport(0, 0, 512, 512); glVertexPointer(2, GL_FLOAT, sizeof(V2fT2f), &fullquad[0].x); glTexCoordPointer(2, GL_FLOAT, sizeof(V2fT2f), &fullquad[0].s); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); } glBindFramebufferOES(GL_FRAMEBUFFER_OES,tmpImageFBO); glClearColor(0,0,0,1); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(0, 512, 0, 512, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glScalef(512, 512, 1); glBindTexture(GL_TEXTURE_2D, glImage->texID); glViewport(0, 0, 512, 512); [self contrastProc:fullquad value:contrast]; glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); [self redraw]; } Here are two cases: if it is the same filter(edit mode) to use, I bind tmpFBO to draw into tmpImage texture and edit glImage texture. contrastProc is a pure routine from Apples's sample. If it is another mode, than I save edited image by drawing tmpImage texture in source texture glImage, binded with glImageFBO. After that I call redraw: glBindFramebufferOES(GL_FRAMEBUFFER_OES, SystemFBO); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(0, kTexWidth, 0, kTexHeight, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glScalef(kTexWidth, kTexHeight, 1); glBindTexture(GL_TEXTURE_2D, glImage->texID); glViewport(0, 0, kTexWidth, kTexHeight); glVertexPointer(2, GL_FLOAT, sizeof(V2fT2f), &flipquad[0].x); glTexCoordPointer(2, GL_FLOAT, sizeof(V2fT2f), &flipquad[0].s); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); And here it binds visual framebuffer and dispose glImage texture. So, the result is VERY aggresive filtering. Increasing contrast volume by just 0.2 brings image to state that comparable with 0.9 contrast volume in Apple's sample code project. I miss something obvious, I guess. Interesting, if I disabple line glBindTexture(GL_TEXTURE_2D, glImage->texID); in setContrast routine it brings no effect. At all. If I replace tmpImageFBO with SystemFBO to draw glImage directly on display(and disabling redraw invoking line), all works fine. Please, HELP ME!!! :(

    Read the article

  • No wireless and display issues on Dell Inspiron 1210 (Mini 12)

    - by Bryan M.
    I recently upgraded a friend's Dell Mini 12 (Inspiron 1210) from Ubuntu 8.10 to 10.04 netbook edition. After installing, and performing the available updates, I'm unable to detect any wireless networks (it knows it has a wireless card, but won't list any active networks). There also seems to be an issue with the display drivers: when scrolling, resizing, or drawing any windows there is a noticeable lag as I watch the screen redraw. As if there are no compatible display drivers installed. All these problems go away the moment I boot up a version of 8.10. But I'd like to keep 10.04 if possible. Are these common problems? Everything I've read suggest this is laptop should be compatible. Any suggestions? Thanks.

    Read the article

  • Fade out Label / Button / Status Bar with GTK

    - by wolfv
    What is the easiest way to fade out and fade in elements in Python / GTK 3? Coming from webdevelopment, my initial take on this problem was to call c = widget.get_style_context(), c.remove_class('visible'), c.add_class('invisible') but that didn't work out (Do I have to call something like "redraw"?) I also added a transition to the GTK CSS. Thanks, Wolf EDIT: I might specify what I would like to achieve: I have this "statusbar" which is just a vertical container on my app (like in the screenshot on top of this page http://uberwriter.wolfvollprecht.de/). If the mouse is not moving, I want to fade all that stuff out (also to preserve computing power // no recalculation of word- and char count) and to minimize "distraction"). I already found the appropriate event to listen to (motion-notify-event), so now I only need to add a simple fade out and a timeout. If someone can point me to a solution, be it with clutter or cairo, I would be very happy.

    Read the article

  • What collision detection approach for top down car game?

    - by nathan
    I have a quite advanced top down car game and i use masks to detect collisions. I have the actual designed track (what the player see) with fancy graphics etc. and two other pictures i use as mask for my detection collisions. Each mask has only two colors, white and black and i check each frame if a pixel of the car collide with a black pixel of the masks. This approach works of course but it's not really flexible. Whenever i want to change the look of a track, i have to redraw the mask and it's a real pain. What is the general approach for this kind of game? How can i improve the flexibility of such a mask based approach?

    Read the article

  • c++, win 32 , Erase text using TextOut or DrawText [on hold]

    - by XXXXX
    How to erase the inputted character on the window and to write the another one on its place??? Say, for example, d d d d was inputted, I want to redraw it to d j j f I'm trying to do this in the following way: TextOut(hdc,rect.right,rect.top,(LPCWSTR)" ",2); DrawText( hdc, (LPCWSTR)str, -1, &rect, DT_SINGLELINE | DT_NOCLIP ) ; or DrawText( hdc, (LPCWSTR)" ", -1, &rect, DT_SINGLELINE | DT_NOCLIP ) ; DrawText( hdc, (LPCWSTR)str, -1, &rect, DT_SINGLELINE | DT_NOCLIP ) ; Anyway, some characters are redrawn, and in some cases(f, j,i characters) the junks are seen(one character is just drawn on another). I haven't set the SetBkMode to transparent. What to do? Thanks much in advance!!!

    Read the article

  • What are the pros and cons of a non-fixed-interval update loop?

    - by akonsu
    I am studying various approaches to implementing a game loop and I have found this article. In the article the author implements a loop which, if the processing falls behind in time, skips frame renderings and just updates the game in a loop (the last variant called "Constant Game Speed independent of Variable FPS"). I do not understand why it is acceptable to call update_game() in a loop without making sure the update function is called at a particular interval. I do not see any value in doing this. I would think that in my game I want to be sure the game is updated periodically with a known period. So maybe it is worthwhile to have two threads, one would call update periodically, and the other one would redraw the game, also periodically? Would this be a good and practical approach? Of course I would need to synchronise the threads.

    Read the article

  • How long till HTML5 canvas becomes a viable game development platform?

    - by Shouvik
    So I have been working on web application. So invariably what it boils down to is making simple games which were previously based on flash or openGL. Now I know apple was moving away from flash because its proprietary unlike their stance that its got "pathetic performance"! Not true, try playing a canvas game, I can assure you at any point of time (including when its idle) it will use up a fair bit of processing power just to redraw the UI. Now I do understand that this is my fault because when the game is not active I should not be redrawing the canvas, but honestly its a lot of work and I suppose there should be libraries which should be able to assist me with that! So, how much will it be before I see a decent canvas library which handles these "tiny" issues for me? I can't honestly expect Steve Jobs to be doing anything more for HTML5! I someone knows of a good library, I am all ears...! :) PS: I use mootools and am presently using Mootools Canvas Library.

    Read the article

  • Is it possible to make the desktop background transparent or otherwise hidden?

    - by EndangeredMassa
    I'm running Ubuntu in a virtual machine via VirtualBox. I have the seamless mode turned on, which is pretty cool. However, if I move an Ubuntu window around quickly, I can see the redraw of the ubuntu background quickly before it's hidden by VirtualBox again. This isn't a huge deal, but I'd like to fix it, if possible. I see two possible options that don't involve changing VirtualBox code: 1. Make the Ubuntu desktop transparent 2. Make the Ubuntu desktop hidden entirely Is it possible to do either? I know that Compiz Fusion has/had a feature to do this for their cube effects, but I don't think that I can run this on the VM. And, even if I could, I don't want to run those services for this one small feature.

    Read the article

  • Drawing Transparency in XNA 4.0

    - by dpaz
    Using C# (VS2010) with XNA 4.0, I have a terrain layer (RenderTarget2D) in a 2D side-scroller. My visual system tracks updates to redraw individual tiles, but I am having trouble finding a way to clear out the rectangle where the tile will be drawn, which I must do because A) there may no longer be a tile or B) the tile may itself contain transparency. How can I draw a rectangle of transparency onto an existing RenderTarget2D? I essentially want to clear just that rectangular portion of it. My Google searches have not yielded anything relevant.

    Read the article

  • Triple Monitor Setup with Nvidia and Compiz

    - by AndrewX192
    I have a triple monitor setup with two video cards on Ubuntu 10.04. I have the monitors and graphics cards currently setup as follows: Nvidia Geforce 210 #1 - 1920x1080 Monitor (Twinview) [Center - Monitor #1] - 1920x1080 Monitor (Twinview) [Right - Monitor #2] Nvidia Geforce 210 #2 - 1920x1080 Monitor (Separate X Screen) [Left - Monitor #3] This works fine, except when I open a program, it shows up in between monitor #1 and #2 - meaning I have to drag it to one screen before I can use the window. Gnome2's gnome-panel also does not work on the twinview setup; it spans between both monitors, but it does not redraw (ex: the clock never changes). In addition, when I maximize an application, it spans both monitors, which is not acceptable. When I enable Xinerama for my setup, gnome-panel no longer spans two monitors, and applications maximize as expected, but compiz does not work, as X11 compositing is not available. The lack of desktop compositing causes problems with dragging windows between screens (redraws take forever). Is there anything I can do to fix these issues without opting for different graphics cards?

    Read the article

  • How to display consistent background image

    - by Tofu_Craving_Redish_BlueDragon
    Drawing a large background is relatively slow in PyGame. In order to avoid drawing BG every frame, you could draw it once, then do nothing. However, if something is overdrawn onto the surface and keeps moving, you will need to redraw the background in order to "erase" the color pixels left by moving object; otherwise, you will have "traces" of the moving object. I have a moving object in my PyGame. However, I do not want to "clear the color buffer" by redrawing the background image. Redrawing the background image every frame is slow. My solution : I will "clear" only required portions (where the "traces" of moving object are left) of the "buffer" by redrawing portions of background. Is there any other better way to have a consistent background?

    Read the article

  • No background/wallpaper in Ubuntu 12.04 - what to do?

    - by magnesus
    This is how my desktop looks like after moving Firefox window arround: The background just doesn't redraw, there is no wallpaper. It is like that since update to 12.04 - it was the same in 11.10 but I had special intel drivers then that fixed this problem. Doesn't seem to be fixed in 12.04 even with the ppa I was using then. What can I do? I couldn't find anything about it on Google because results were unrelated. :( I have Samsung RF-511 notebook with Nvidia card turned off - so it's using only Intel from i7.

    Read the article

  • How to persistently export an environment variable before starting compiz

    - by Dykam
    A few months ago compiz suddenly stopped working. That is, it got to a refreshrate where the redrawing is more than noticeable. It took 5 seconds to redraw a chat window. Ever since I've been using metacity instead, but I've found myself missing some plugins badly. I found the following solution: export __GL_YIELD="NOTHING"; compiz --replace This works fine, everything is fast again with compiz. But how to make sure this variable is always set whenever I run compiz? I'm using standard nVidia drivers, failed to get the open source ones working.

    Read the article

  • Sprite.js surface background

    - by user1086671
    I'm making a tile-based game using Sprite.js. It is not easy to redraw every tile each frame, so I tried to make a scrolling surface background. There is an example here http://batiste.dosimple.ch/sprite.js/tests/test_scrolling.html The example works, but it seems like ScrollingSurface.update is buggy or there is something I'm missing. What I tried to do is to draw 5x5 tiles and after 5 seconds draw another 5x5 tiles near the first ones. But it draws only the first ones. And surface.update() only updates the position of surface. Here is my code https://github.com/Sektoid/sprite.js/blob/master/tests/test_scrolling.html (You need also to set this.divider = 1.0 in scrolling.js to avoid drawing the same tiles 4 times.) There aren't any sprite.js-forums like with the other sprite- and game-engines have, so I'm asking here.

    Read the article

  • How to refresh an Android RelativeLayout when orientation changes without restarting the Activity?

    - by johnrock
    I have an Android Activity with a RelativeLayout and I have implemented the following method to prevent the activity from being recreated on change of Orientation: @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); } I am obviously not doing anything in this method, but it worked perfect when using a LinearLayout. Now however, using RelativeLayout, my layout is all messed up when changing to landscape orientation. What is the most efficient way to have the screen redraw correctly without having the activity restarted again with a call to onCreate?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11  | Next Page >