opengl in hardware mode

Started by
16 comments, last by ashtray 20 years, 8 months ago
I was wondering how you know if opengl is running in hardware mode or software mode. I made a surface with GL_QUADS that was 1 * 1 big, the did 2 for loops to draw that surface to be 200 * 200 (while using glTranslate...) and added a texture to it and if I don''t use the textures, I get about 60 fps and if I add the texture which is 96 pixels by 96 pixels, I get fps ranging from 21 to 18. I was just wondering if I might be running in software mode instead of hardware mode and this would be why my little program is sooo slow. thx for any help in advance.. ashtray.. ...
...
Advertisement
Make sure you don''t load the texture each frame, instead of loading it once at the beginning of your program. This would explain the huge fps decrease.
quote:Original post by ashtray
if I add the texture which is 96 pixels by 96 pixels, I get fps ranging from 21 to 18.


...



If your not using any new extension your texture must have dimensions of 2^x at each side..

2^x will never be 96 if x is an integer.. make it 64*64 or 128*128

and of course dont bind it for every single quad. also if you use immediate mode and a lot of glvertex calls then doing translate AND glvertex means twice more work then necessary.

and yes, using "odd" texture sizes might be possible by now, but its still slow.
f@dzhttp://festini.device-zero.de
quote:Original post by ashtray
I was wondering how you know if opengl is running in hardware mode or software mode.


In windows, glGet with GL_VENDOR and GL_RENDERER. If you see something like ''Generic microsoft'' you''re getting the software fallback. Typically you''ll see the name of the manufacturer of your video card.

But you could still be getting a non-accelerated display, most commonly if you request a funny/non-standard framebuffer format (nVidia cards tend to baulk at having high/mismatched depth and stencil bits on a 16bit desktop for example).

Hello,

I changed my texture to be of size 128 * 128

I what I meant by 96 * 96 was dots per inch (the resolution), does this need to be changed as well? or does my 128 pixels * 128 pixels new size good now keeping the same resolution?


I am also binding once, before my loops,

I think I''m doing something wrong because it''s still very slow...

Here''s my code...

in my render function I have this building my "ground or floor"

void render()
{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
int i, j;

glEnable(GL_TEXTURE_2D);

glBindTexture( GL_TEXTURE_2D, grassTexture );
for (i = 0; i <= 200; i++ ) {
for (j = 0; j <= 200; j++ ) { // largeur 3.1m
glPushMatrix();
glTranslatef( i, 0.0f, j );
glCallList(floor_display_list);
glPopMatrix();
}
}

glDisable(GL_TEXTURE_2D);

glFlush(); // Flush drawing commands
glutSwapBuffers();

}

and the display list function for creating my "floor" is

void drawFloor() {

glBegin(GL_QUADS);
glVertex3f( 0.0f, 0.0f, 0.0f);
glTexCoord2f( 0.0f, 0.0f);
glVertex3f( 1.0f, 0.0f, 0.0f);
glTexCoord2f( 1.0f, 0.0f);
glVertex3f( 1.0f, 0.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f);
glEnd();
}

This is the version info (and more) that I am using.

From what I understand, I am in hardware mode... right?

GL_VENDOR -> NVIDIA Corporation
GL_RENDERER -> GeForce4 MX 420 with AGP8X/AGP/3DNOW!
GL_VERSION -> 1.3.1
GL_EXTENSIONS -> GL_ARB_imaging GL_ARB_multitexture GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_transpose_matrix GL_S3_s3tc GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_clip_volume_hint GL_EXT_compiled_vertex_array GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_multi_draw_arrays GL_EXT_packed_pixels GL_EXT_paletted_texture GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shared_texture_palette GL_EXT_stencil_wrap GL_EXT_texture_compression_s3tc GL_EXT_texture_edge_clamp GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_cube_map GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_object GL_EXT_vertex_array GL_EXT_vertex_weighting GL_IBM_texture_mirrored_repeat GL_KTX_buffer_region GL_NV_blend_square GL_NV_evaluators GL_NV_fence GL_NV_fog_distance GL_NV_light_max_exponent GL_NV_packed_depth_stencil GL_NV_register_combiners GL_NV_texgen_emboss GL_NV_texgen_reflection GL_NV_texture_env_combine4 GL_NV_texture_rectangle GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_program GL_NV_vertex_program1_1 GL_SGIS_generate_mipmap GL_SGIS_multitexture GL_SGIS_texture
...
quote:
glBindTexture( GL_TEXTURE_2D, grassTexture );
for (i = 0; i <= 200; i++ ) {
for (j = 0; j <= 200; j++ ) { // largeur 3.1m
glPushMatrix();
glTranslatef( i, 0.0f, j );
glCallList(floor_display_list);
glPopMatrix();
}
}

There are two major performance sinks in this code, and a multitude of smaller ones.

The to big problems are the matrix stuff, and the display list call. You are basically performing more than 40000 matrix multiplication and display list calls per frame ! No wonder, that this is slow. Try this instead:

glBindTexture( GL_TEXTURE_2D, grassTexture );glBegin(GL_QUADS);for (i = 0; i <= 200; i++ ) {   for (j = 0; j <= 200; j++ ) { // largeur 3.1m      glTexCoord2f( 0.0f, 0.0f);      glVertex3f( i, 0.0f, j);      glTexCoord2f( 1.0f, 0.0f);      glVertex3f( i+1, 0.0f, j);      glTexCoord2f(1.0f, 1.0f);      glVertex3f( i+1, 0.0f, j+1);      glTexCoord2f(0.0f, 1.0f);      glVertex3f( i, 0.0f, j+1);   }}glEnd();


Oh, and there was a bug with the texture coordinates, btw: you have to set the vertex attributes (such as texcoords) before sending the vertex position (which will dispatch the vertex to the GPU).

This code above can of course still be tremendeously optimized: using triangle strips, for example. You''ll get the greatest performance boost by dropping immediate mode altogether, and using vertex arrays (or variants).
OK, thx for the tips.

I thought that using display list would increase my performance because the shape that I am drawing is already compiled. When should one use display lists? I though you did when you were repeating a patterns of something drawn.

Also, if I do use triangle strips, how would I go about adding a square texture onto the triangles. if I draw 2 triangles to make one square, how would I attach my texture to my new square.

I''ve looked for good tutorials on texturing but did not find anything that really suited my needs. How to attach it properly to the object, etc...

I also do not understand what you mean by "dropping immediate mode altogether, and using vertex arrays"

As you probably guessed, I''m new to opengl... what is "immediate mode"

I really appreciate you taking the time to answer my questions.

thx.


...
about immediate mode,
I knew what it was but forgot it was called immediate mode...
(command is executed as soon as the server receives it) but doesn''t having a display list give it all in one shot? so the transformations and drawing that I''m doing count at one command and not 4 because they are pre-compiled?

I changed my code yo use yours (trashed the display list and fixed the tex coord (thx)) and I only gained 5 fps. I''m looking into triangle stips now.
...

This topic is closed to new replies.

Advertisement