mirror of
				https://github.com/aap/librw.git
				synced 2025-11-04 08:50:09 +00:00 
			
		
		
		
	vertex input stream functions
This commit is contained in:
		
							parent
							
								
									6116e51b24
								
							
						
					
					
						commit
						576d211cbd
					
				@ -87,7 +87,7 @@ but because librw is supposed to be able to
 | 
				
			|||||||
convert between all sorts of platform specific files,
 | 
					convert between all sorts of platform specific files,
 | 
				
			||||||
the code for that has to be available no matter
 | 
					the code for that has to be available no matter
 | 
				
			||||||
the render platform used.
 | 
					the render platform used.
 | 
				
			||||||
The common interface for all device-indepenent
 | 
					The common interface for all device-independent
 | 
				
			||||||
platform code is the `Driver` struct.
 | 
					platform code is the `Driver` struct.
 | 
				
			||||||
The `Engine` struct has an array with one for each platform.
 | 
					The `Engine` struct has an array with one for each platform.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -127,13 +127,7 @@ matfxRenderCB(Atomic *atomic, InstanceDataHeader *header)
 | 
				
			|||||||
	setWorldMatrix(atomic->getFrame()->getLTM());
 | 
						setWorldMatrix(atomic->getFrame()->getLTM());
 | 
				
			||||||
	lightingCB(atomic);
 | 
						lightingCB(atomic);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef RW_GL_USE_VAOS
 | 
						setupVertexInput(header);
 | 
				
			||||||
	glBindVertexArray(header->vao);
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, header->ibo);
 | 
					 | 
				
			||||||
	glBindBuffer(GL_ARRAY_BUFFER, header->vbo);
 | 
					 | 
				
			||||||
	setAttribPointers(header->attribDesc, header->numAttribs);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lastEnvFrame = nil;
 | 
						lastEnvFrame = nil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -155,9 +149,7 @@ matfxRenderCB(Atomic *atomic, InstanceDataHeader *header)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		inst++;
 | 
							inst++;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#ifndef RW_GL_USE_VAOS
 | 
						teardownVertexInput(header);
 | 
				
			||||||
	disableAttribPointers(header->attribDesc, header->numAttribs);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ObjPipeline*
 | 
					ObjPipeline*
 | 
				
			||||||
 | 
				
			|||||||
@ -90,6 +90,26 @@ disableAttribPointers(AttribDesc *attribDescs, int32 numAttribs)
 | 
				
			|||||||
		glDisableVertexAttribArray(a->index);
 | 
							glDisableVertexAttribArray(a->index);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					setupVertexInput(InstanceDataHeader *header)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef RW_GL_USE_VAOS
 | 
				
			||||||
 | 
						glBindVertexArray(header->vao);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
						glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, header->ibo);
 | 
				
			||||||
 | 
						glBindBuffer(GL_ARRAY_BUFFER, header->vbo);
 | 
				
			||||||
 | 
						setAttribPointers(header->attribDesc, header->numAttribs);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					teardownVertexInput(InstanceDataHeader *header)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifndef RW_GL_USE_VAOS
 | 
				
			||||||
 | 
						disableAttribPointers(header->attribDesc, header->numAttribs);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int32
 | 
					int32
 | 
				
			||||||
lightingCB(Atomic *atomic)
 | 
					lightingCB(Atomic *atomic)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -115,8 +135,6 @@ lightingCB(Atomic *atomic)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define U(i) currentShader->uniformLocations[i]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
 | 
					defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -126,13 +144,7 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
 | 
				
			|||||||
	setWorldMatrix(atomic->getFrame()->getLTM());
 | 
						setWorldMatrix(atomic->getFrame()->getLTM());
 | 
				
			||||||
	lightingCB(atomic);
 | 
						lightingCB(atomic);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef RW_GL_USE_VAOS
 | 
						setupVertexInput(header);
 | 
				
			||||||
	glBindVertexArray(header->vao);
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, header->ibo);
 | 
					 | 
				
			||||||
	glBindBuffer(GL_ARRAY_BUFFER, header->vbo);
 | 
					 | 
				
			||||||
	setAttribPointers(header->attribDesc, header->numAttribs);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	InstanceData *inst = header->inst;
 | 
						InstanceData *inst = header->inst;
 | 
				
			||||||
	int32 n = header->numMeshes;
 | 
						int32 n = header->numMeshes;
 | 
				
			||||||
@ -151,9 +163,7 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
 | 
				
			|||||||
		drawInst(header, inst);
 | 
							drawInst(header, inst);
 | 
				
			||||||
		inst++;
 | 
							inst++;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#ifndef RW_GL_USE_VAOS
 | 
						teardownVertexInput(header);
 | 
				
			||||||
	disableAttribPointers(header->attribDesc, header->numAttribs);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -259,13 +259,7 @@ skinRenderCB(Atomic *atomic, InstanceDataHeader *header)
 | 
				
			|||||||
	setWorldMatrix(atomic->getFrame()->getLTM());
 | 
						setWorldMatrix(atomic->getFrame()->getLTM());
 | 
				
			||||||
	lightingCB(atomic);
 | 
						lightingCB(atomic);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef RW_GL_USE_VAOS
 | 
						setupVertexInput(header);
 | 
				
			||||||
	glBindVertexArray(header->vao);
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, header->ibo);
 | 
					 | 
				
			||||||
	glBindBuffer(GL_ARRAY_BUFFER, header->vbo);
 | 
					 | 
				
			||||||
	setAttribPointers(header->attribDesc, header->numAttribs);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	InstanceData *inst = header->inst;
 | 
						InstanceData *inst = header->inst;
 | 
				
			||||||
	int32 n = header->numMeshes;
 | 
						int32 n = header->numMeshes;
 | 
				
			||||||
@ -286,9 +280,7 @@ skinRenderCB(Atomic *atomic, InstanceDataHeader *header)
 | 
				
			|||||||
		drawInst(header, inst);
 | 
							drawInst(header, inst);
 | 
				
			||||||
		inst++;
 | 
							inst++;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#ifndef RW_GL_USE_VAOS
 | 
						teardownVertexInput(header);
 | 
				
			||||||
	disableAttribPointers(header->attribDesc, header->numAttribs);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void*
 | 
					static void*
 | 
				
			||||||
 | 
				
			|||||||
@ -150,6 +150,8 @@ struct Im2DVertex
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void setAttribPointers(AttribDesc *attribDescs, int32 numAttribs);
 | 
					void setAttribPointers(AttribDesc *attribDescs, int32 numAttribs);
 | 
				
			||||||
void disableAttribPointers(AttribDesc *attribDescs, int32 numAttribs);
 | 
					void disableAttribPointers(AttribDesc *attribDescs, int32 numAttribs);
 | 
				
			||||||
 | 
					void setupVertexInput(InstanceDataHeader *header);
 | 
				
			||||||
 | 
					void teardownVertexInput(InstanceDataHeader *header);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Render state
 | 
					// Render state
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user