Archived

This topic is now archived and is closed to further replies.

Basiror

Performance problem

Recommended Posts

ok i am new to this opengl things and i have some trouble with the render part the function underneath is thought to render 50000 small triangles but i get only 1 frame though vsync is disables are there any other things i should cares about ? i run it in windowed mode though static GLfloat vertices[]= { 0,2,0, -1,0,0, 1,0,1, 1,1,1, 2,0,0, -1,-1,-1 }; static GLfloat color[]= { 0,0,255, 0,0,255, 0,0,255, 255,0,0, 255,0,0, 255,0,0 }; static GLubyte indices[]= { 0,1,2,3,4,5 }; CRender::CRender() { } void CRender::SetPosition() { gluLookAt(0, 0, 80, 0, 0, 0, 1,10 , 1); } void CRender::Draw() { SetPosition(); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glColorPointer(3,GL_FLOAT,0,color); glVertexPointer(3,GL_FLOAT,0,vertices); //glDrawArrays(GL_TRIANGLES,0,6); glColor3f(255,0,0); for(int i=1;i<25000;i++) { glDrawElements(GL_TRIANGLES,6,GL_UNSIGNED_BYTE,indices); } }

Share this post


Link to post
Share on other sites
All your triangles are at the same position. The fillrate is probably not high enough.
If you''ve got a GeForce use the GL_VERTEX_ARRAY_RANGE extension instead of standard vertex arrays.

Share this post


Link to post
Share on other sites
why are you making a loop around you glDrawElement() function ?

it could be done just by one call

glDrawElements(GL_TRIANGLES,6,GL_UNSIGNED_BYTE,indices);

seems correct for all your rendering. so no loop.

or maybe i misunderstood your problem. so sorry


Share this post


Link to post
Share on other sites
GL_VERTEX_ARRAY_RANGE
where can i find this and how can i use it
and this CVA`s what is it and how to use it
you see i am damn knew to ogl


WGL_EXT_swap_control where can i find this extension and do i enable it like this glEnable(WGL_EXT_swap_control );??

[edited by - Basiror on March 21, 2002 12:57:01 PM]

Share this post


Link to post
Share on other sites
OK i did it your way thats really an performance increase
i manage 128000 polygons at 44 frames i think thats really good but i know you can get higher framerates so are you willing to help me further more?
the ways mention above sound interesting though i have no idea where to start
do i need an additional header from nVidia?






#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h>
#include "renderer.h"

static GLfloat vertices[]=
{
0,2,0,
-1,0,0,
1,0,1,

};
static GLfloat color[]=
{
0,0,255,
0,0,255,
0,0,255,
};

static GLubyte indices[128000];
GLuint list;
CRender::CRender()
{

}

void CRender::SetPosition()
{

}
void CRender::Draw()
{
//SetPosition();

gluLookAt(0, 0, 100, 0, 0, 0, 1,10 , 1);
glCallList(list);

glFlush();
}

void CRender::Init()
{
int a=0;
for(int i=0;i<128000;i++)
{

indices=a;
a++;
if(a>2)
a=0;
}
list=glGenLists(1);
glNewList(list,GL_COMPILE);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);

glColorPointer(3,GL_FLOAT,0,color);
glVertexPointer(3,GL_FLOAT,0,vertices);




glDrawElements(GL_TRIANGLES,128000,GL_UNSIGNED_BYTE,indices);

glEndList();



}

void CRender::LoadScene()
{
}

void CRender::LoadTextures()
{
}

Share this post


Link to post
Share on other sites
look at developer.nvidia.com, download their SDK. The full one is 140 meg, though, so you may want to pick out just the GL parts of it.

You need glext.h and wglext.h to use NV_vertex_array_range. Instructions on how to use it etc. are in the SDK documentation. If you haven''t used extensions before, look at NeHe''s tutorial 22. The functions aren''t exported by the DLL, so you need to use fn. pointers etc to use most extensions.

Share this post


Link to post
Share on other sites
char* text=(char*)malloc(strlen((char *)glGetString(GL_EXTENSIONS))+1); // Allocate Memory For Our Extension String
strcpy (text,(char *)glGetString(GL_EXTENSIONS));

token=strtok(text," "); // Parse ''text'' For Words, Seperated By " " (spaces)
while(token!=NULL) // While The Token Isn''t NULL
{
cnt++; // Increase The Counter
if (cnt>maxtokens) // Is ''maxtokens'' Less Than ''cnt''
{
maxtokens=cnt; // If So, Set ''maxtokens'' Equal To ''cnt''
}




this???????????????

Share this post


Link to post
Share on other sites