void RenderableObject::Init() { //setup vao and vbo stuff glGenVertexArrays(1, &vaoID); glGenBuffers(1, &vboVerticesID); glGenBuffers(1, &vboIndicesID); //get total vertices and indices totalVertices = GetTotalVertices(); totalIndices = GetTotalIndices(); primType = GetPrimitiveType(); //now allocate buffers glBindVertexArray(vaoID); glBindBuffer (GL_ARRAY_BUFFER, vboVerticesID); glBufferData (GL_ARRAY_BUFFER, totalVertices * sizeof(glm::vec3), 0, GL_STATIC_DRAW); GLfloat* pBuffer = static_cast<GLfloat*>(glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY)); FillVertexBuffer(pBuffer); glUnmapBuffer(GL_ARRAY_BUFFER); glEnableVertexAttribArray(shader["vVertex"]); glVertexAttribPointer(shader["vVertex"], 3, GL_FLOAT, GL_FALSE,0,0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID); glBufferData(GL_ELEMENT_ARRAY_BUFFER, totalIndices * sizeof(GLuint), 0, GL_STATIC_DRAW); GLuint* pIBuffer = static_cast<GLuint*>(glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY)); FillIndexBuffer(pIBuffer); glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); glBindVertexArray(0); }
bool D3D9VideoInfo::DrawSpriteFast(IDirect3DDevice9* pDevice, const Sprite::RECT_MODE mode) { const unsigned int polyCount = GetPolyCount(mode); const D3DPRIMITIVETYPE primType = GetPrimitiveType(mode); if (FAILED(pDevice->DrawPrimitive(primType, 0, polyCount))) return false; return true; }
bool D3D9VideoInfo::DrawSprite(IDirect3DDevice9 *pDevice, const Sprite::RECT_MODE mode) { IDirect3DVertexBuffer9* pSprite = GetVertexBuffer(mode); unsigned int polyCount = GetPolyCount(mode); D3DPRIMITIVETYPE primType = GetPrimitiveType(mode); if (FAILED(pDevice->SetStreamSource(0, pSprite, 0, sizeof(SPRITE_VERTEX)))) return false; pDevice->SetFVF(SPRITE_FVF); if (FAILED(pDevice->DrawPrimitive(primType, 0, polyCount))) return false; return true; }
String JSBHaxe::GetScriptType(JSBFunctionType* ftype) { String scriptType = "Dynamic"; if (ftype->type_->asPrimitiveType()) { JSBPrimitiveType* ptype = ftype->type_->asPrimitiveType(); scriptType = GetPrimitiveType(ptype); return scriptType; } if (ftype->type_->asStringHashType() || ftype->type_->asStringType()) scriptType = "String"; if (ftype->type_->asEnumType()) scriptType = ftype->type_->asEnumType()->enum_->GetName(); if (ftype->type_->asClassType()) { JSBClass* klass = ftype->type_->asClassType()->class_; scriptType = klass->GetName(); if (klass->GetPackage()->GetName() != package_->GetName()) { scriptType = klass->GetPackage()->GetName() + "." + klass->GetName(); } } if (ftype->type_->asVectorType()) { JSBVectorType* vectorType = ftype->type_->asVectorType(); scriptType = "Array<String>"; } return scriptType; }
void JSBHaxe::ExportModuleConstants(JSBModule* module) { HashMap<String, JSBModule::Constant>& constants = module->GetConstants(); const Vector<String>& constantsName = constants.Keys(); if (!constants.Size()) return; source_ += "\n"; for (unsigned i = 0; i < constantsName.Size(); i++) { const String& cname = constantsName.At(i); JSBModule::Constant& constant = constants[cname]; source_ += " public static var " + cname + ": " + GetPrimitiveType(constant.type) + ";\n"; } source_ += "\n"; }
void CMeshP3NT2::Draw(IRenderer3D &renderer) const { // Выполняем привязку vertex array, normal array, tex coord 2d array const size_t stride = sizeof(SVertexP3NT2); const size_t positionOffset = size_t(offsetof(SVertexP3NT2, position)); const size_t normalOffset = size_t(offsetof(SVertexP3NT2, normal)); const size_t texCoordOffset = size_t(offsetof(SVertexP3NT2, texCoord)); m_attributesBuffer.Bind(); m_indexesBuffer.Bind(); renderer.SetPosition3DOffset(positionOffset, stride); renderer.SetNormalOffset(normalOffset, stride); renderer.SetTexCoord2DOffset(texCoordOffset, stride); const GLenum primitive = GetPrimitiveType(m_meshType); const GLvoid *indexOffset = reinterpret_cast<const GLvoid *>(0); const GLuint minIndex = 0; const GLuint maxIndex = GLuint(m_verticiesCount); const GLsizei size = GLsizei(m_indiciesCount); glDrawRangeElements(primitive, minIndex, maxIndex, size, GL_UNSIGNED_INT, indexOffset); }
char * CQ931Pdu::ComposeJoyitApi(UINT16& len) { char * pPdu = NULL; char pdu[MAX_MSGLEN] = { 0 }; UINT8 pos = 0; UINT16 l; int i; UINT16 msgType = GetMessageType( ); UINT8 noIe = 2; // = NoIe( ); // Make up API header. memcpy(pdu, Header, sizeof(SInterApiHead)); pos += sizeof(SInterApiHead); // #### Add 2005-10-30, by Wujianjin. ### // Construct the FIX information element first. // UINT8 pt = GetProtocolType( ); // if ((MOD_TUPAPI == pt) // || (MOD_ISUPAPI == pt) // || (MOD_Q931API == pt)) // { // Construct the fix ie first. // Message index. CIeBase * pIe; pIe = GetIE(PSG_IE_MSGTYPE); if ((pIe != NULL) && (pIe->id != IE_NOT_EXIST)) { pdu[pos++] = pIe->id; pdu[pos++] = pIe->len; memcpy(pdu+pos, pIe->GetIeData(l), pIe->len); pos += pIe->len; } else { // Not exist, I will get it from mType. pdu[pos++] = PSG_IE_MSGTYPE; pdu[pos++] = 2; // memcpy(pdu+pos, &mType, 2); memcpy(pdu+pos, &msgType, 2); pos += 2; } if (pIe != NULL) { DelIE(PSG_IE_MSGTYPE); } // Circuit structure. pIe = GetIE(PSG_IE_CIR_STRUCT); if ((pIe != NULL) && (pIe->id != IE_NOT_EXIST)) { pdu[pos++] = pIe->id; pdu[pos++] = pIe->len; memcpy(pdu+pos, pIe->GetIeData(l), pIe->len); pos += pIe->len; } else { // Exception handle. // return pPdu; pdu[pos ++] = PSG_IE_CIR_STRUCT; pdu[pos ++] = sizeof(SCircuitStructIE); SCircuitStructIE chn; chn.pcmId = GetPri( ); chn.tsId = GetTs( ); memcpy(pdu+pos, &chn, sizeof(SCircuitStructIE)); pos += sizeof(SCircuitStructIE); } if (pIe != NULL) { DelIE(PSG_IE_CIR_STRUCT); } // Circuit group indicator. pIe = GetIE(PSG_IE_CG_IND); if ((pIe != NULL) && (pIe->id != IE_NOT_EXIST)) { pdu[pos++] = pIe->id; pdu[pos++] = pIe->len; memcpy(pdu+pos, pIe->GetIeData(l), pIe->len); pos += pIe->len; ++ noIe; } if (pIe != NULL) { DelIE(PSG_IE_CG_IND); } // } // ### End 2005-10-30 ### // Make up all other IEs. for (i=0; i<NoIe( ); ++i) { if ((PSG_IE_L3_SGM == IE[i].id) // || (PSG_IE_L3_SNDCMP == IE[i].id) // Delete 2005-11-21, by Wujianjin. || (PSG_IE_L3_MOREDATA == IE[i].id) || (PSG_IE_L3_CR == IE[i].id) || (PSG_IE_L3_PTLDCM == IE[i].id) || (PSG_IE_L3_CHNID == IE[i].id)) { // noIe --; continue; } pdu[pos++] = IE[i].id; pdu[pos++] = IE[i].len; noIe ++; if ((pos + IE[i].len) >= MAX_MSGLEN) { // Message too long. printf("Joyit API too long. mType:0x%04X\n", msgType); break; } memcpy(pdu+pos, IE[i].GetIeData(l), IE[i].len); pos += IE[i].len; } // Allocate memory for this PDU. // if (i == IeCounter) // { pPdu = new char[pos]; if (pPdu != NULL) { ((SInterApiHead *)pdu)->primType = GetPrimitiveType( ); // Modify 2005-10-27, by Wujianjin. ((SInterApiHead *)pdu)->noie = noIe;; // ((SJoyitApiHead *)pdu)->PktLength = pos; memcpy(pPdu, pdu, pos); len = pos; } else { // Out of memory. printf("Make up Joyit API out of memory. mType:0x%04X\n", msgType); } // } return pPdu; }