Archived

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

OpenGL opengl source way too slow 0-10 fps.

This topic is 5093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was very dissapointed with all the opengl samples I downloaded on Neon Helium. They were all very very slow! I am hoping that I can get gaming speed with directx. But I''d like to see an example program that has the fps drawing something semi-complex. If anyone knows of how to create fast opengl code, let me know, please. If not, an example of the speed of dx. I prefer opengl though.

Share this post


Link to post
Share on other sites
oh and what are the specs on ure comp?

also go update your video drivers.




[edited by - DerAngeD on February 7, 2004 8:51:44 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Google for: "How to as questions".

So, what are you system specs and are you sure your OpenGL drivers are up to date?

Share this post


Link to post
Share on other sites
If you ask me, you
a) have a machine that is a bit too slow (CPU and/or graphics card)
b) have really obsolete drivers
c) have an absolutely abysmal OpenGL driver implementation.

If you compiled them yourself, I suggest you also have a deep look at your compiler settings (optimizations, debug libraries, ...).

Using anything that is today normal, you won't have the massive speed boost you need by switching to Direct3D. Direct3D and OpenGL have slight speed differences (which one is faster in which circumstances is more like a religious war though), depending on card, driver and how you use it, but nothing like "0-10 fps" vs "game speed" (whatever you call that).

[edited by - BitMaster on February 7, 2004 8:55:49 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks for the quick and many replies! The thing is that all the games I have like doom, monkey island games - 2d and 3d, prince of persia 3d, delta force 2, command and conquer, indian jones 3d game ... all run great!

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Thanks for the quick and many replies! The thing is that all the games I have like doom, monkey island games - 2d and 3d, prince of persia 3d, delta force 2, command and conquer, indian jones 3d game ... all run great!


those are old games. old games will run great on a 286.


Share this post


Link to post
Share on other sites
That was me that just posted. I posted this same kind of thing here:
http://www.vbforums.com/showthread.php?s=&threadid=277226

Share this post


Link to post
Share on other sites
Ok. Have a look at this code. It just draws stars on the sceen coming at you and only runs at 10 fps on my hp pavilion 533 mgh celeron proc computer.

Is this code old or new implementation of opengl?

//stars.c
/*
* Spiraling Stars OpenGL demo,
* by Christohe Devine
* this program is licensed under the GPL.
*/

#ifdef WIN32
#include <windows.h>
#endif

#include <GL/gl.h>
#include <GL/glu.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <time.h>
#include <math.h>

#ifndef M_PI
#define M_PI 3.14159265358979f
#endif

/* application window title */

char *AppTitle = "Spiraling Stars";

/* external OS-dependant functions */

struct htime
{
unsigned char blob[16];
};

extern float timer( struct htime *t, int reset );

extern void move_mouse( int x, int y );

extern void hide_mouse( void );

/* global data */

int width, height;

int info;
int frames;
GLuint font;
GLfloat fps;
GLuint texture;
GLfloat spiral;
GLfloat **atoms;
struct htime tv;

/* particle engine constants */

#define NB_ATOMS 1024

#define CREATE_PARTICLE(p) \
{ \
p[0] = 20.0f * (GLfloat) rand() / RAND_MAX; \
p[1] = 0.2f - 0.4f * (GLfloat) rand() / RAND_MAX; \
p[2] = 0.2f - 0.4f * (GLfloat) rand() / RAND_MAX; \
p[3] = 0.5f + 1.0f * (GLfloat) rand() / RAND_MAX; \
p[4] = 90.0f * (GLfloat) rand() / RAND_MAX; \
do { \
p[5] = (GLfloat) rand() / RAND_MAX; \
p[6] = (GLfloat) rand() / RAND_MAX; \
p[7] = (GLfloat) rand() / RAND_MAX; \
} while( p[5] < 0.95f && p[6] < 0.95f && p[7] < 0.95f ); \
}

/* text drawing routine declaration */

void gl_printf( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha,
GLint x, GLint y, GLuint font, const char *format, ... );

/* data initialization function */

int gl_data( void )
{
int i;

info = 1;

spiral = 0.0f;

srand( (unsigned int) time( NULL ) );

atoms = (GLfloat **) malloc( NB_ATOMS * sizeof( GLfloat * ) );

if( atoms == NULL )
{
perror( "malloc" );
return( 1 );
}

for( i = 0; i < NB_ATOMS; i++)
{
atoms = (GLfloat *) malloc( 8 * sizeof( GLfloat ) );

if( atoms[i] == NULL )
{
perror( "malloc" );
return( 1 );
}

CREATE_PARTICLE( atoms[i] );
}

return( 0 );
}

/* gl initialization function */

int gl_init( void )
{
int i, j, k;
double dx, dy, alpha;
unsigned char *map, c;

if( ! ( map = (unsigned char *) malloc( 128 * 128 * 3 ) ) )
{
perror( "malloc" );
return( 1 );
}

glGenTextures( 1, &texture );

glBindTexture( GL_TEXTURE_2D, texture );

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

k = 0;

for( i = 0; i < 128; i++ )
{
dx = (double) ( i - 64 ) / 64.0;

for( j = 0; j < 128; j++ )
{
dy = (double) ( j - 64 ) / 64.0;
alpha = 0.6 * cos( M_PI - M_PI / ( 1.0 + fabs( dx + dy ) ) )
+ 0.6 * cos( M_PI - M_PI / ( 1.0 + fabs( dx - dy ) ) );
if( alpha < 0.0 ) alpha = 0.0;
if( alpha > 1.0 ) alpha = 1.0;
c = (unsigned char) ( alpha * 255.0 );
map[k++] = c;
map[k++] = c;
map[k++] = c;
}
}

glTexImage2D( GL_TEXTURE_2D, 0, 3, 128, 128, 0,
GL_RGB, GL_UNSIGNED_BYTE, map );

free( map );

glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE );

hide_mouse();

return( 0 );
}

/* window drawing function */

void gl_draw( void )
{
int i;
GLfloat t, x, y, z;

glClear( GL_COLOR_BUFFER_BIT );

glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glRotatef( spiral, 0.0f, 0.0f, 1.0f );

if( fps )
{
spiral += 40.0f / fps;
}

glEnable( GL_TEXTURE_2D );

for( i = 0; i < NB_ATOMS; i++ )
{
t = atoms[i][0];

if( fps )
{
atoms[i][0] += 30.0f / fps;
}

x = t * atoms[i][1];
y = t * atoms[i][2];
z = t * atoms[i][3] - 100.0f;

glColor4f( atoms[i][5], atoms[i][6],
atoms[i][7], 1.0f + z / 80.0f );

glPushMatrix();

glRotatef( atoms[i][4], 0.0f, 0.0f, 1.0f );

glBegin( GL_QUADS );

glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 0.2f + x, 0.2f + y, z );
glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -0.2f + x, 0.2f + y, z );
glTexCoord2d( 0.0f, 0.0f ); glVertex3f( -0.2f + x, -0.2f + y, z );
glTexCoord2d( 1.0f, 0.0f ); glVertex3f( 0.2f + x, -0.2f + y, z );

glEnd();

glPopMatrix();

if( z >= 0.0f )
{
CREATE_PARTICLE( atoms[i] );
}
}

glDisable( GL_TEXTURE_2D );

if( fps && info )
{
gl_printf( 1.0f, 1.0f, 1.0f, 0.5f, width - 114, height - 40,
font, "%5.1f fps", fps );
}

glFinish();

frames++;

if( timer( &tv, 0 ) >= 0.2f )
{
fps = (GLfloat) frames / timer( &tv, 1 );
frames = 0;
}
}

/* window resizing function */

void gl_resize( void )
{
glViewport( 0, 0, width, height );

glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( 50.0, (GLdouble) width / height, 0.1, 100.0 );

fps = 0.0f;
frames = 0;
timer( &tv, 1 );
}

/* event handling function */

void gl_event( int event, int data, int xpos, int ypos )
{
if( event == 0 ) /* mouse button down */
{
}

if( event == 1 ) /* mouse button up */
{
}

if( event == 2 ) /* mouse move */
{
}

if( event == 3 ) /* key down */
{
}

if( event == 4 ) /* key up */
{
if( data == '' '' )
{
info ^= 1;
}
}
}

/* text drawing routine */

void gl_printf( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha,
GLint x, GLint y, GLuint font, const char *format, ... )
{
va_list argp;
char text[256];

va_start( argp, format );
vsprintf( text, format, argp );
va_end( argp );

glMatrixMode( GL_PROJECTION );
glPushMatrix();

glLoadIdentity();
gluOrtho2D( 0.0, (GLdouble) width,
0.0, (GLdouble) height );

glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

glColor4f( red, green, blue, alpha );
glRasterPos2i( x, y );
glListBase( font );
glCallLists( strlen( text ), GL_UNSIGNED_BYTE, text );

glMatrixMode( GL_PROJECTION );
glPopMatrix();
}















//winmain.c
/*
* Generic Win32 WGL basecode,
* by Christophe Devine
* this program is licensed under the GPL.
*/

#include <windows.h>
#include <stdio.h>
#include <gl/gl.h>

/* external gl data */

extern char *AppTitle;
extern int width, height, font;

/* external gl rountines */

extern int gl_data( void );
extern int gl_init( void );
extern void gl_draw( void );
extern void gl_resize( void );
extern void gl_event( int event, int data,
int xpos, int ypos );

/* perror port for Win32 */

void WinPerror( const char *title )
{
char buffer[64];

sprintf( buffer, "failure, error code = %ld\n", GetLastError() );
MessageBox( NULL, buffer, title, MB_OK | MB_ICONWARNING );
}

/* variables associated with the window */

HDC hDC;
HGLRC hRC;
HWND hWnd;

int modeswitch;
int active;
int run;

/* declaration of the window procedure function */

LRESULT CALLBACK WindowProc( HWND, UINT, WPARAM, LPARAM );

/* program entry point */

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
char ClassName[] = "opengl demo";
int fullscreen;
WNDCLASSEX wcx;
DWORD dwStyle;
MSG msg;

if( gl_data() )
{
WinPerror( "gl_data" );
return( 0 );
}

wcx.cbSize = sizeof( WNDCLASSEX );
wcx.style = 0;
wcx.lpfnWndProc = (WNDPROC) WindowProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = hInstance;
wcx.hIcon = NULL;
wcx.hCursor = LoadCursor( NULL, IDC_ARROW );
wcx.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
wcx.lpszMenuName = NULL;
wcx.lpszClassName = ClassName;
wcx.hIconSm = NULL;

if( ! RegisterClassEx( &wcx ) )
{
WinPerror( "RegisterClassEx" );
return( 0 );
}

fullscreen = 0;

do
{
modeswitch = 0;
fullscreen ^= 1;

if( fullscreen )
{
if( ! ( hDC = GetDC( NULL ) ) )
{
WinPerror( "GetDC" );
return( 0 );
}

width = GetDeviceCaps( hDC, HORZRES );
height = GetDeviceCaps( hDC, VERTRES );

ReleaseDC( NULL, hDC );

dwStyle = WS_POPUP;
}
else
{
width = 640;
height = 480;

dwStyle = WS_OVERLAPPEDWINDOW;
}

if( ! ( hWnd = CreateWindow( ClassName, AppTitle, dwStyle,
CW_USEDEFAULT, CW_USEDEFAULT, width, height,
NULL, NULL, hInstance, NULL ) ) )
{
WinPerror( "CreateWindowEx" );
return( 0 );
}

ShowWindow( hWnd, nCmdShow );

run = 1;

while( run )
{
if( active )
{
gl_draw();
SwapBuffers( hDC );
}
else
{
GetMessage( &msg, NULL, 0, 0 );
}

while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if( msg.message == WM_QUIT )
{
run = 0;
break;
}

TranslateMessage( &msg );
DispatchMessage( &msg );
}
}

wglMakeCurrent( NULL, NULL );
if( hDC ) ReleaseDC( hWnd, hDC );
if( hRC ) wglDeleteContext( hRC );
DestroyWindow( hWnd );
}
while( modeswitch );

return( msg.wParam );
}

/* the window procedure itself */

LRESULT CALLBACK WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam )
{
switch( uMsg )
{
case WM_CREATE:
{
PIXELFORMATDESCRIPTOR pfd =
{
sizeof( PIXELFORMATDESCRIPTOR ),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
16,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
int pixelformat, font;

hRC = NULL;

if( ! ( hDC = GetDC( hWnd ) ) )
{
WinPerror( "GetDC" );
PostQuitMessage( 0 );
break;
}

if( ! ( pixelformat = ChoosePixelFormat( hDC, &pfd ) ) )
{
WinPerror( "ChoosePixelFormat" );
PostQuitMessage( 0 );
break;
}

if( ! SetPixelFormat( hDC, pixelformat, &pfd ) )
{
WinPerror( "SetPixelFormat" );
PostQuitMessage( 0 );
break;
}

if( ! ( hRC = wglCreateContext( hDC ) ) )
{
WinPerror( "wglCreateContext" );
PostQuitMessage( 0 );
break;
}

if( ! wglMakeCurrent( hDC, hRC ) )
{
WinPerror( "wglMakeCurrent" );
PostQuitMessage( 0 );
break;
}

font = glGenLists( 255 );

{
HFONT courier = CreateFont( 20, 0, 0, 0, FW_MEDIUM, FALSE,
FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
FF_DONTCARE | DEFAULT_PITCH, "Courier New" );

SelectObject( hDC, courier );

if( ! wglUseFontBitmaps( hDC, 1, 255, font ) )
{
WinPerror( "wglUseFontBitmaps" );
PostQuitMessage( 0 );
}
}

if( gl_init() )
{
WinPerror( "gl_init" );
PostQuitMessage( 0 );
break;
}

gl_resize();
break;
}

case WM_LBUTTONDOWN:
{
gl_event( 0, 0, LOWORD(lParam), HIWORD(lParam) );
break;
}

case WM_RBUTTONDOWN:
{
gl_event( 0, 1, LOWORD(lParam), HIWORD(lParam) );
break;
}

case WM_LBUTTONUP:
{
gl_event( 1, 0, LOWORD(lParam), HIWORD(lParam) );
break;
}

case WM_RBUTTONUP:
{
gl_event( 1, 1, LOWORD(lParam), HIWORD(lParam) );
break;
}

case WM_MOUSEMOVE:
{
switch( wParam )
{
case MK_LBUTTON:

gl_event( 2, 0, LOWORD(lParam), HIWORD(lParam) );
break;

case MK_RBUTTON:

gl_event( 2, 1, LOWORD(lParam), HIWORD(lParam) );
break;

default:

gl_event( 2, -1, LOWORD(lParam), HIWORD(lParam) );
break;
}

break;
}

case WM_KEYDOWN:
{
break;
}

case WM_KEYUP:
{
switch( wParam )
{
case VK_TAB:

modeswitch = 1;

case VK_ESCAPE:

PostQuitMessage( 1 );
break;

default:

gl_event( 4, wParam, -1, -1 );
break;
}

break;
}

case WM_SIZE:
{
switch( wParam )
{
case SIZE_MINIMIZED: active = 0; break;
case SIZE_MAXIMIZED: active = 1; break;
case SIZE_RESTORED: active = 1; break;
}

width = LOWORD( lParam );
height = HIWORD( lParam );
gl_resize();
break;
}

case WM_CLOSE:
{
PostQuitMessage( 1 );
break;
}

case WM_SYSCOMMAND:
{
switch( wParam )
{
case SC_MONITORPOWER:
case SC_SCREENSAVE:

return 0;
}
}

default:

return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
}

return( 0 );
}

/* timer structure */

struct htime
{
LARGE_INTEGER start, hfreq;
};

/* timer query/reset routine */

float timer( struct htime *t, int reset )
{
float delta;
LARGE_INTEGER offset;

QueryPerformanceCounter( &offset );

if( t->hfreq.QuadPart )
{
delta = (float) ( offset.QuadPart - t->start.QuadPart ) /
(float) t->hfreq.QuadPart;
}

if( reset )
{
QueryPerformanceFrequency( &t->hfreq );
QueryPerformanceCounter( &t->start );
}

return( delta );
}

/* mouse handling routines */

void hide_mouse( void )
{
ShowCursor( FALSE );
}

void move_mouse( int x, int y )
{
POINT p;
p.x = x; p.y = y;
ClientToScreen( hWnd, &p );
SetCursorPos( p.x, p.y );
}

Share this post


Link to post
Share on other sites
quote:
Original post by aewarnick
on my hp pavilion 533 mgh


theres the problem. 533. most newer stuff needs atleast 1.4ghz

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
1. how do I turn off vsync?
2. is the code above old or new?
3. how do I use old code instead of new?

Share this post


Link to post
Share on other sites
533mhz is just fine for simple OpenGL apps. Could you tell us what kind of display adapter do you have?

Share this post


Link to post
Share on other sites
It has nothing to do with VSync, nobody has a 10hz refresh rate lol B-)

The problem here is video adapter. My guess is that you guys are using onboard SiS chips, since they fail to give an adequate OpenGL implementation.

It looks like you are failing at a hardware device and rendering in software the whole time, hence the horrible fps.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
intel 82810.
Swift blocks starts then ends on the hp 533 mgh computer.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
"It looks like you are failing at a hardware device and rendering in software"

If that is true then why do the games I posted above run so fast? Are you familiar with prince of persia 3D, it''s a pretty advanced game.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Google for: "How to as questions".




Google for: "How to spell ''ask''".

Sorry, couldn''t help it...

cya,
Drag0n


-----------------------------
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning..." -- Rich Cook

My future web presence: Dave''s Programming Resources

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
"Why would you even think this should be in the DirectX forum?"

I started out this thread thinking that opengl speed was hopeless for me, so I WAS going to ask directx questions, but things turned. Thanks for moving it though

Share this post


Link to post
Share on other sites
Okay, trying to clarify this mess, since the poor guy obviously does not know what software mode means...

Those games you mention do not use OpenGL (which is a specific graphics library, there are others), thus their performance is not affected by the deplorable state of the OpenGL drivers on your computer. The code sample on the other hand, DOES use OpenGL, and does things that rely on the presence of and access to graphics hardware to run properly. Find out what graphics card you have, get the latest drivers, and pray they come with a good OpenGL implementation.

Share this post


Link to post
Share on other sites

CONGRATULATIONS!!! YOUR VIDEO CARD/DRIVERS AR SO OUT OF DATE YOU''RE RUNNING IN SOFTWARE!




Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Why do the games I mentioned above run fast?
How do I run in hardware mode?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ignore that post. I wasn''t viewing this second page when I posted it.

Share this post


Link to post
Share on other sites

This topic is 5093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.

  • Similar Content

    • By _OskaR
      Hi,
      I have an OpenGL application but without possibility to wite own shaders.
      I need to perform small VS modification - is possible to do it in an alternative way? Do we have apps or driver modifictions which will catch the shader sent to GPU and override it?
    • By xhcao
      Does sync be needed to read texture content after access texture image in compute shader?
      My simple code is as below,
      glUseProgram(program.get());
      glBindImageTexture(0, texture[0], 0, GL_FALSE, 3, GL_READ_ONLY, GL_R32UI);
      glBindImageTexture(1, texture[1], 0, GL_FALSE, 4, GL_WRITE_ONLY, GL_R32UI);
      glDispatchCompute(1, 1, 1);
      // Does sync be needed here?
      glUseProgram(0);
      glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
      glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                                     GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, texture[1], 0);
      glReadPixels(0, 0, kWidth, kHeight, GL_RED_INTEGER, GL_UNSIGNED_INT, outputValues);
       
      Compute shader is very simple, imageLoad content from texture[0], and imageStore content to texture[1]. Does need to sync after dispatchCompute?
    • By Jonathan2006
      My question: is it possible to transform multiple angular velocities so that they can be reinserted as one? My research is below:
      // This works quat quaternion1 = GEQuaternionFromAngleRadians(angleRadiansVector1); quat quaternion2 = GEMultiplyQuaternions(quaternion1, GEQuaternionFromAngleRadians(angleRadiansVector2)); quat quaternion3 = GEMultiplyQuaternions(quaternion2, GEQuaternionFromAngleRadians(angleRadiansVector3)); glMultMatrixf(GEMat4FromQuaternion(quaternion3).array); // The first two work fine but not the third. Why? quat quaternion1 = GEQuaternionFromAngleRadians(angleRadiansVector1); vec3 vector1 = GETransformQuaternionAndVector(quaternion1, angularVelocity1); quat quaternion2 = GEQuaternionFromAngleRadians(angleRadiansVector2); vec3 vector2 = GETransformQuaternionAndVector(quaternion2, angularVelocity2); // This doesn't work //quat quaternion3 = GEQuaternionFromAngleRadians(angleRadiansVector3); //vec3 vector3 = GETransformQuaternionAndVector(quaternion3, angularVelocity3); vec3 angleVelocity = GEAddVectors(vector1, vector2); // Does not work: vec3 angleVelocity = GEAddVectors(vector1, GEAddVectors(vector2, vector3)); static vec3 angleRadiansVector; vec3 angularAcceleration = GESetVector(0.0, 0.0, 0.0); // Sending it through one angular velocity later in my motion engine angleVelocity = GEAddVectors(angleVelocity, GEMultiplyVectorAndScalar(angularAcceleration, timeStep)); angleRadiansVector = GEAddVectors(angleRadiansVector, GEMultiplyVectorAndScalar(angleVelocity, timeStep)); glMultMatrixf(GEMat4FromEulerAngle(angleRadiansVector).array); Also how do I combine multiple angularAcceleration variables? Is there an easier way to transform the angular values?
    • By dpadam450
      I have this code below in both my vertex and fragment shader, however when I request glGetUniformLocation("Lights[0].diffuse") or "Lights[0].attenuation", it returns -1. It will only give me a valid uniform location if I actually use the diffuse/attenuation variables in the VERTEX shader. Because I use position in the vertex shader, it always returns a valid uniform location. I've read that I can share uniforms across both vertex and fragment, but I'm confused what this is even compiling to if this is the case.
       
      #define NUM_LIGHTS 2
      struct Light
      {
          vec3 position;
          vec3 diffuse;
          float attenuation;
      };
      uniform Light Lights[NUM_LIGHTS];
       
       
    • By pr033r
      Hello,
      I have a Bachelor project on topic "Implenet 3D Boid's algorithm in OpenGL". All OpenGL issues works fine for me, all rendering etc. But when I started implement the boid's algorithm it was getting worse and worse. I read article (http://natureofcode.com/book/chapter-6-autonomous-agents/) inspirate from another code (here: https://github.com/jyanar/Boids/tree/master/src) but it still doesn't work like in tutorials and videos. For example the main problem: when I apply Cohesion (one of three main laws of boids) it makes some "cycling knot". Second, when some flock touch to another it scary change the coordination or respawn in origin (x: 0, y:0. z:0). Just some streng things. 
      I followed many tutorials, change a try everything but it isn't so smooth, without lags like in another videos. I really need your help. 
      My code (optimalizing branch): https://github.com/pr033r/BachelorProject/tree/Optimalizing
      Exe file (if you want to look) and models folder (for those who will download the sources):
      http://leteckaposta.cz/367190436
      Thanks for any help...

  • Popular Now