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

GL_POLYGON is not drawing a closed polygon for 3 points
Clipping triangles in screen space per pixel
Setup Orthographic projection correctly?
OpenGL Bindless Textures: Bind to uniform sampler2D array
OpenGL to Unity bridge/plugin
copying texture from GPU to CPU using pixel buffer objects
Isnt' it possible to run OpenGL 3.0 on Macbok Pro 2015 mid with glfw3?
texture3DLod in GLSL fragment shader
OpenGL when switch fron 2D to 3D
Comparing textures for matching pixel colours
GLSL - testing fragment world space coordinate intersection with geometry texture, and texture modification
OpenGL Orthographical Projection
imageStore in compute shader to depth texture
Fragment shader will overwrite the fragment color generated from rasterization?
How can I use normals from OBJ file for diffuse lighting?
Save world transform for the same model in multiple pass rendering

Categories

HOME
user-interface
mc
automapper
android-emulator
bing-search
dji-sdk
ag-grid
u-boot
swarm
amazon-emr
graphdb
feature-extraction
phonegap-build
user-defined-types
fosuserbundle
rpmbuild
google-sites
nullreferenceexception
adminlte
libgit2
data-type-conversion
ava
perfino
high-availability
acrobat
macromedia
php-5.3
javax.persistence
region
openbr
instructions
rspec-rails
directfb
bootstrap-sass
java-stream
jfxtras
nppexec
imgur
plane
data-uri
ejml
jqgrid-asp.net
asihttprequest
nuclio
xcode8.2
section508
windows-media-player
image-registration
libreoffice-writer
nonlinear-functions
cordova-ios
extjs4.1
nslayoutconstraint
deedle
glassfish-4.1
kendo-treeview
http4s
controllers
okio
seccomp
exists
gwt-syncproxy
wif4.5
in-app-billing
msgpack
mixins
search-form
libz
supersocket.net
karma-coverage
actionpack
r.java-file
tidyr
phonegap-facebook-plugin
n-tier-architecture
two.js
forceclose
nodeload
tabletools
jms-serializer
typesafe-stack
cloo
smips
quickgraph
ax
mongo-jackson-mapper
chefspec
session-0-isolation
dojo-1.9
gitx
story
cakeyframeanimation
trialware
kobold2d
firebird1.5
uploading
acpi
radscheduler
solandra
pinax
processors
efs
server-load

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