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

ffmpeg and opengl
is it possible to render to framebuffer object outside of main render loop
Toxi and Processing?
Difficulties adjusting to OpenGL on the Mac
Fit 3d model inside a window
Texturing VBOs (Vertext Buffer Objects)
Any OCaml bindings for GtkGlExt? If not, how can I write them?
Should glEnable(GL_TEXTURE2D) be applied per texture unit
How to rotate model not camera in OpenGL?
Quaternion -> matrix[16] — ok, now what? (How to display object from quaternion?)
c++ graphical programming
Opengl VBO (with mixed index, tex coordinate array) does not work, help please
Does XNA support OpenGL
How to create OpenGL-enabled window with transparent background using xlib and glx
GLEW and Freeglut won't work together?
Mesh deformation and VBOs

Categories

HOME
openshift
xcode
clearcase
schema.org
paypal-ipn
histogram
jersey-2.0
header
firebase-database
buffer
responsivevoice
fullcalendar-scheduler
global-variables
vmware-workstation
pygobject
exchange-server-2010
software-packaging
python-appium
multi-dimensional-scaling
running-object-table
network-analysis
infopath2010
xcrun
kendo-listview
ms-media-foundation
image-optimization
transform
ejml
reverse-dns
libreoffice-writer
scala-breeze
test-data
ltrace
front-camera
instafeedjs
libharu
okio
livereload
nsrunloop
livecycle
meld
odp.net-managed
jeditable
mercurial-extension
flipclock
enunciate
servicestack-bsd
perceptron
netdatacontractserializer
apple
darwin
actionpack
ipod
azure-xplat-cli
comctl32
rubber
iplimage
tabris
webaii
wso2bam
jchartfx
hyphen
frontbase
sql-view
quickgraph
node.js-stream
void-pointers
chartfx
dynamic-rdlc-generation
spiral
oscilloscope
websphere-6.1
flymake
prototypal-inheritance
mkannotation
fbml
django-apps
expression-web
jquery-1.4
dip
libxslt
ccnet-config
j2mepolish
html-components
rtti

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App