int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int nCmdShow) { MSG msg; game = new Game(&backHDC, &frontHDC, &bitmapHDC, &screenRect, &CONTROLS); RegisterMyWindow(hInstance); if (!InitialiseMyWindow(hInstance, nCmdShow)) return FALSE; setBuffers(); while (TRUE) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if (msg.message==WM_QUIT) break; TranslateMessage (&msg); DispatchMessage (&msg); } else { if(WaitFor(10)) game->play(); } } releaseResources(); return msg.wParam ; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ sf::SoundBuffer soundBuffers[NUM_COL][MAX_PER_COL]; sf::Sound sounds[NUM_COL][MAX_PER_COL]; sf::Image buttons[NUM_COL][MAX_PER_COL]; sf::Sprite btns[NUM_COL][MAX_PER_COL]; sf::RenderWindow mainWin(sf::VideoMode(W_WIDTH, W_HEIGHT, 32), "Soundboard - by eyeosk", sf::Style::Close); sf::Image background; sf::Image header; sf::Sprite bg; sf::Sprite hd; hd.SetY(0); hd.SetX(W_WIDTH/4); bg.SetX(0); bg.SetY(0); background.LoadFromFile("background.png"); header.LoadFromFile("header.png"); bg.SetImage(background); hd.SetImage(header); int numInCol[NUM_COL]; for(int i = 0; i < NUM_COL; i++){ loadBuffers(soundBuffers[i], i); numInCol[i] = loadImages(buttons[i], i); setSprites(buttons[i], btns[i], numInCol[i]); setBuffers(soundBuffers[i], sounds[i], numInCol[i]); setSpritesPos(btns[i], i, numInCol[i]); } mainWin.SetFramerateLimit(360); while(mainWin.IsOpened()){ sf::Event mainEvent; while(mainWin.GetEvent(mainEvent)){ if(mainEvent.Type == sf::Event::Closed || (mainEvent.Type == sf::Event::KeyPressed && mainEvent.Key.Code == sf::Key::Escape)){ mainWin.Close(); } if(mainEvent.Type == sf::Event::MouseButtonPressed){ for(int i = 0; i < NUM_COL; i++){ for(int j = 0; j < numInCol[i]; j++){ if(checktangle(i, j, mainEvent.MouseButton.X, mainEvent.MouseButton.Y)){ sounds[i][j].Play(); } } } } } mainWin.Clear(); mainWin.Draw(bg); mainWin.Draw(hd); for(int i =0; i < NUM_COL; i++){ for(int j = 0; j < numInCol[i]; j++){ mainWin.Draw(btns[i][j]); } } mainWin.Display(); } return 0; }
std::shared_ptr<LabelVectorShape> VectorLayerEditor::_getLabel(const std::string &key, bool &newLabel) { auto label_it = _labels.find(key); if(label_it==_labels.end()) { auto label = std::make_shared<LabelVectorShape>(); auto bufferData = std::make_shared<BufferDataCollection>(); label->setBuffers( bufferData ); label->setStateSet( _labelStateSet ); _labels[key] = label; newLabel = true; return label; } newLabel = false; return (*label_it).second; }
status_t BnStreamSource::onTransact( uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { switch (code) { case SET_LISTENER: { CHECK_INTERFACE(IStreamSource, data, reply); setListener( interface_cast<IStreamListener>(data.readStrongBinder())); break; } case SET_BUFFERS: { CHECK_INTERFACE(IStreamSource, data, reply); size_t n = static_cast<size_t>(data.readInt32()); Vector<sp<IMemory> > buffers; for (size_t i = 0; i < n; ++i) { sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder()); buffers.push(mem); } setBuffers(buffers); break; } case ON_BUFFER_AVAILABLE: { CHECK_INTERFACE(IStreamSource, data, reply); onBufferAvailable(static_cast<size_t>(data.readInt32())); break; } case FLAGS: { CHECK_INTERFACE(IStreamSource, data, reply); reply->writeInt32(this->flags()); break; } default: return BBinder::onTransact(code, data, reply, flags); } return OK; }
status_t StreamBuffer_Server::onTransact( uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { switch (code) { case SET_USER: { CHECK_INTERFACE(IStreamBuffer, data, reply); AGILE_LOGD("SET_USER: enter!"); setUser(interface_cast<IStreamBufferUser>(data.readStrongBinder())); AGILE_LOGD("SET_USER: exit!"); break; } case SET_BUFFERS: { CHECK_INTERFACE(IStreamBuffer, data, reply); AGILE_LOGD("SET_BUFFERS: enter!"); _size_t n = static_cast<_size_t>(data.readInt32()); List_t *bufHead = (List_t *)mag_mallocz(sizeof(List_t)); BufferNode_t *p; INIT_LIST(bufHead); for (_size_t i = 0; i < n; ++i) { p = (BufferNode_t *)mag_mallocz(sizeof(BufferNode_t)); p->buffer = interface_cast<IMemory>(data.readStrongBinder()); p->pts = data.readInt64(); p->flag = data.readInt32(); INIT_LIST(&p->node); list_add_tail(&p->node, bufHead); } setBuffers(bufHead); AGILE_LOGD("SET_BUFFERS: exit!"); break; } case ON_BUFFER_EMPTY: { CHECK_INTERFACE(IStreamBuffer, data, reply); onBufferEmpty(static_cast<_size_t>(data.readInt32()), static_cast<_size_t>(data.readInt32())); break; } case GET_TYPE: { CHECK_INTERFACE(IStreamBuffer, data, reply); reply->writeInt32(static_cast<i32>(getType())); break; } case RESET: { CHECK_INTERFACE(IStreamBuffer, data, reply); reset(); break; } default: return BBinder::onTransact(code, data, reply, flags); } return OK; }
void GrGpuGLFixed::setupGeometry(int* startVertex, int* startIndex, int vertexCount, int indexCount) { int newColorOffset; int newTexCoordOffsets[kNumStages]; GrGLsizei newStride = VertexSizeAndOffsetsByStage(fGeometrySrc.fVertexLayout, newTexCoordOffsets, &newColorOffset); int oldColorOffset; int oldTexCoordOffsets[kNumStages]; GrGLsizei oldStride = VertexSizeAndOffsetsByStage(fHWGeometryState.fVertexLayout, oldTexCoordOffsets, &oldColorOffset); bool indexed = NULL != startIndex; int extraVertexOffset; int extraIndexOffset; setBuffers(indexed, &extraVertexOffset, &extraIndexOffset); GrGLenum scalarType; if (fGeometrySrc.fVertexLayout & kTextFormat_VertexLayoutBit) { scalarType = GrGLTextType; } else { scalarType = GrGLType; } size_t vertexOffset = (*startVertex + extraVertexOffset) * newStride; *startVertex = 0; if (indexed) { *startIndex += extraIndexOffset; } // all the Pointers must be set if any of these are true bool allOffsetsChange = fHWGeometryState.fArrayPtrsDirty || vertexOffset != fHWGeometryState.fVertexOffset || newStride != oldStride; // position and tex coord offsets change if above conditions are true // or the type changed based on text vs nontext type coords. bool posAndTexChange = allOffsetsChange || ((GrGLTextType != GrGLType) && (kTextFormat_VertexLayoutBit & (fHWGeometryState.fVertexLayout ^ fGeometrySrc.fVertexLayout))); if (posAndTexChange) { GR_GL(VertexPointer(2, scalarType, newStride, (GrGLvoid*)vertexOffset)); fHWGeometryState.fVertexOffset = vertexOffset; } for (int s = 0; s < kNumStages; ++s) { // need to enable array if tex coord offset is 0 // (using positions as coords) if (newTexCoordOffsets[s] >= 0) { GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset + newTexCoordOffsets[s]); if (oldTexCoordOffsets[s] < 0) { GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s)); GR_GL(EnableClientState(GR_GL_TEXTURE_COORD_ARRAY)); GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset)); } else if (posAndTexChange || newTexCoordOffsets[s] != oldTexCoordOffsets[s]) { GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s)); GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset)); } } else if (oldTexCoordOffsets[s] >= 0) { GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s)); GR_GL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY)); } } if (newColorOffset > 0) { GrGLvoid* colorOffset = (GrGLvoid*)(vertexOffset + newColorOffset); if (oldColorOffset <= 0) { GR_GL(EnableClientState(GR_GL_COLOR_ARRAY)); GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset)); } else if (allOffsetsChange || newColorOffset != oldColorOffset) { GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset)); } } else if (oldColorOffset > 0) { GR_GL(DisableClientState(GR_GL_COLOR_ARRAY)); } fHWGeometryState.fVertexLayout = fGeometrySrc.fVertexLayout; fHWGeometryState.fArrayPtrsDirty = false; }
void GrGpuGLShaders::setupGeometry(int* startVertex, int* startIndex, int vertexCount, int indexCount) { int newColorOffset; int newTexCoordOffsets[kMaxTexCoords]; GrGLsizei newStride = VertexSizeAndOffsetsByIdx(fGeometrySrc.fVertexLayout, newTexCoordOffsets, &newColorOffset); int oldColorOffset; int oldTexCoordOffsets[kMaxTexCoords]; GrGLsizei oldStride = VertexSizeAndOffsetsByIdx(fHWGeometryState.fVertexLayout, oldTexCoordOffsets, &oldColorOffset); bool indexed = NULL != startIndex; int extraVertexOffset; int extraIndexOffset; setBuffers(indexed, &extraVertexOffset, &extraIndexOffset); GrGLenum scalarType; bool texCoordNorm; if (fGeometrySrc.fVertexLayout & kTextFormat_VertexLayoutBit) { scalarType = GrGLTextType; texCoordNorm = GR_GL_TEXT_TEXTURE_NORMALIZED; } else { scalarType = GrGLType; texCoordNorm = false; } size_t vertexOffset = (*startVertex + extraVertexOffset) * newStride; *startVertex = 0; if (indexed) { *startIndex += extraIndexOffset; } // all the Pointers must be set if any of these are true bool allOffsetsChange = fHWGeometryState.fArrayPtrsDirty || vertexOffset != fHWGeometryState.fVertexOffset || newStride != oldStride; // position and tex coord offsets change if above conditions are true // or the type/normalization changed based on text vs nontext type coords. bool posAndTexChange = allOffsetsChange || (((GrGLTextType != GrGLType) || GR_GL_TEXT_TEXTURE_NORMALIZED) && (kTextFormat_VertexLayoutBit & (fHWGeometryState.fVertexLayout ^ fGeometrySrc.fVertexLayout))); if (posAndTexChange) { GR_GL(VertexAttribPointer(POS_ATTR_LOCATION, 2, scalarType, false, newStride, (GrGLvoid*)vertexOffset)); fHWGeometryState.fVertexOffset = vertexOffset; } for (int t = 0; t < kMaxTexCoords; ++t) { if (newTexCoordOffsets[t] > 0) { GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset + newTexCoordOffsets[t]); if (oldTexCoordOffsets[t] <= 0) { GR_GL(EnableVertexAttribArray(TEX_ATTR_LOCATION(t))); GR_GL(VertexAttribPointer(TEX_ATTR_LOCATION(t), 2, scalarType, texCoordNorm, newStride, texCoordOffset)); } else if (posAndTexChange || newTexCoordOffsets[t] != oldTexCoordOffsets[t]) { GR_GL(VertexAttribPointer(TEX_ATTR_LOCATION(t), 2, scalarType, texCoordNorm, newStride, texCoordOffset)); } } else if (oldTexCoordOffsets[t] > 0) { GR_GL(DisableVertexAttribArray(TEX_ATTR_LOCATION(t))); } } if (newColorOffset > 0) { GrGLvoid* colorOffset = (int8_t*)(vertexOffset + newColorOffset); if (oldColorOffset <= 0) { GR_GL(EnableVertexAttribArray(COL_ATTR_LOCATION)); GR_GL(VertexAttribPointer(COL_ATTR_LOCATION, 4, GR_GL_UNSIGNED_BYTE, true, newStride, colorOffset)); } else if (allOffsetsChange || newColorOffset != oldColorOffset) { GR_GL(VertexAttribPointer(COL_ATTR_LOCATION, 4, GR_GL_UNSIGNED_BYTE, true, newStride, colorOffset)); } } else if (oldColorOffset > 0) { GR_GL(DisableVertexAttribArray(COL_ATTR_LOCATION)); } fHWGeometryState.fVertexLayout = fGeometrySrc.fVertexLayout; fHWGeometryState.fArrayPtrsDirty = false; }
FrameData::FrameData() : _frameNumber(0) { setBuffers(fabric::Frame::Buffer::undefined); }