2 Replies - 1453 Views - Last Post: 11 December 2012 - 05:13 AM Rate Topic: -----

#1 LittleGyros  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 14
  • Joined: 05-January 10

SDL&OpenGL - Simple colored triangle is pretty dark (C++)

Posted 10 December 2012 - 04:25 PM

Hi guys,

i started programming with SDL and OpenGL!
My first project was a simple rotating colored triangle. After that i tried a 2nd triangle, but this time textured!
After around 1 hour playing around with the byte-order (ARGB, RGBA etc.) it worked.
But now my 1st (still simple colored) triangle gets pretty dark.

i could figure out which functions causing this problem, but first my triangle code:
glRotatef(theta, 0.f, 0.f, 1.f);
glColor3f(1.f, 1.f, 1.f);
glBegin(GL_TRIANGLES);
glColor3f(1.f, 0.f, 0.f);
glVertex3f(0.f, 1.f, 0.5f);
glColor3f(0.f, 1.f, 0.f);
glVertex3f(0.87f, -0.5f, 0.5f);
glColor3f(0.f, 0.f, 1.f);
glVertex3f(-0.87f, -0.5f, 0.5f);
glEnd();



and these are the functions which cause the problem:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, surface->w, surface->h, 0, textureFormat, GL_UNSIGNED_BYTE, surface->pixels);



As soon as one of them gets commented out, my 1st simple triangle works again...
For simplicity i turned of the render part of the 2nd textured triangle...

How it should be:
Posted Image

How it actually is (barely visible):
Posted Image

So i'm asking you guys, what am i doing wrong? o_o

Is This A Good Question/Topic? 0
  • +

Replies To: SDL&OpenGL - Simple colored triangle is pretty dark (C++)

#2 LittleGyros  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 14
  • Joined: 05-January 10

Re: SDL&OpenGL - Simple colored triangle is pretty dark (C++)

Posted 11 December 2012 - 05:05 AM

I found another call which solves the problem:
glEnable(GL_TEXTURE_2D);



:( pretty confusing
Was This Post Helpful? 0
  • +
  • -

#3 LittleGyros  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 14
  • Joined: 05-January 10

Re: SDL&OpenGL - Simple colored triangle is pretty dark (C++)

Posted 11 December 2012 - 05:13 AM

ok, i just found out that i have to disable GL_TEXTURE_2D before drawing something "non-textured" and enable it as soon i use a texture or else it'll start multiplying the colors.

crazy stuff ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1