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

Page 1 of 1

## 2 Replies - 2673 Views - Last Post: 11 December 2012 - 05:13 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=303492&amp;s=9b6d542720e2da77dff9bb1a8ae09fd1&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 LittleGyros

Reputation: 3
• 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:

How it actually is (barely visible):

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

Reputation: 3
• 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

### #3 LittleGyros

Reputation: 3
• 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