opengl


What am I doing wrong, in regards to multi-texture(OpenGL)?


I am writing a bump mapping demo, so I need an image texture, and a normal texture which should be loaded into the fragment shader.
This is the texture part of my OpenGL code:
glActiveTexture(GL_TEXTURE0);
GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, brick);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint textureLocation = glGetUniformLocation(shader, "texture");
glUniform1i(textureLocation, 0);
glActiveTexture(GL_TEXTURE1);
GLuint normal_textureID;
glGenTextures(1, &normal_textureID);
glBindTexture(GL_TEXTURE_2D, normal_textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE,
brick_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint normalTextureLocation = glGetUniformLocation(shader, "normal_texture");
glUniform1i(normalTextureLocation, 1);
Here is the fragment shader:
uniform vec3 light;
uniform sampler2D texture;
uniform sampler2D normal_texture;
void main() {
vec3 tex = texture2D(normal_texture, gl_TexCoord[0].st).rgb;
gl_FragColor = vec4(tex, 1.0);
}
I am sure that the brick array contains the image texture, and the brick_texture array contains the normal texture; but it seems normal_texture and texture are both the image texture, not the normal texture. What am I doing wrong, in regards to multi-texture?

Related Links

Explenation of working principle of openGL
Why would you set a shader program inside a game loop?
glRotatef() - How to apply rotation in multiple axis?
OpenGL Light Scattering: FBO and Framebuffer blending
Set single constant buffer to multiple locations
OpenGL with GLUT: Solid objects are transperent
How to get focal length of virtual pinhole camera in opengl
Vertex Specification Best Practices using OpenGL (Windows)
optimization streaming vbo openg
opengl mixed perspective and ortographic projection
Does using column-major matrices in OpenGL cause striding on the GPU?
MSYS2: Setting up an Opengl development environment
How to set the colour of a vertex in shaders with OpenGL
Programmatically alpha fading a premultiplied texture in OpenGL 2.0
Cube with diffuse light always black
how to get original fragment color in fragment shader

Categories

HOME
php
rust
flask
orientdb
apple-push-notifications
xcode8.1
jms
d3.js
long-integer
couchdb
key
ews
visual-studio-2010
cypher
iptables
dji-sdk
jpa-criteria
erd
pm2
amazon-elb
synthesis
asciimath
scala-ide
significance
angular2-highcharts
altium-designer
websphere-portal
tortoisemerge
password-generator
ipa
bonita
laravel-4.2
boolean-logic
credit-card
netbios
cucumber-junit
quickcheck
listjs
advanced-filter
xmlunit
winrm
djcelery
installanywhere
rdp
opal-framework
pyttsx
raytracing
tinyioc
django-static-precompiler
amazon-elastic-beanstalk
extjs4.1
punctuation
pen
asp.net-web-api-routing
test-data
predicates
mechanicalturk
ltrace
portal
ndk-build
qpixmap
odp.net-managed
mathnet
django-redis
android-mapview
srv-record
mixins
bootstrap-wysiwyg
org-babel
com0com
text-align
uno
relationships
oracle-adf-mobile
pageviews
boolean-algebra
profiles
django-sites
django-settings
hyphen
mute
ember-table
proc-open
session-0-isolation
telerik-ajax
kobold2d
autosize
algol68
infopath-2007
datacontracts
server-variables
simile
3des
printqueue
uninstaller
ixmldomdocument
eventaggregator
accumulator
tso
twitter-feed

Resources

Encrypt Message